using System.Collections.Generic;
using System.Linq;
using System.Windows.Documents;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
//----------------------------------------------------------------
//Module Name: $safeprojectname$
//Purpose:
//CopyRight: Muchinfo
//History:
//----------------------------------------------------------------
//DateTime 2015/11/12 13:46:09
//Author ouyang.hongbin
//Description Create
//----------------------------------------------------------------
using System.Windows;
using GalaSoft.MvvmLight.Ioc;
using Muchinfo.MTPClient.Data;
using Muchinfo.MTPClient.Data.Enums;
using Muchinfo.MTPClient.Data.Model;
using Muchinfo.MTPClient.Infrastructure.Helpers;
using Muchinfo.MTPClient.Infrastructure.Utilities;
using Muchinfo.MTPClient.IService;
using Muchinfo.MTPClient.Resources;
using Muchinfo.MTPClient.Infrastructure.Cache;
namespace Muchinfo.MTPClient.UI.ViewModels
{
public class RateNoticeViewModel : ViewModelBase
{
private ILoginService loginService;
private const string c_paramId = "226";
private bool _isNotice=true;
///
/// 是否提示
///
public bool IsNotice
{
get { return _isNotice; }
set { Set(() => IsNotice, ref _isNotice, value); }
}
private bool _isBusy;
public bool IsBusy
{
get { return _isBusy; }
set { Set(() => IsBusy, ref _isBusy, value); }
}
private string _noticeText;
///
/// 显示内容
///
public string NoticeText
{
get { return _noticeText; }
set { Set(() => NoticeText, ref _noticeText, value); }
}
///
/// 是否显示
///
public bool IsShowCheckedBox
{
get
{
return ApplicationParameter.IsShowRateTips == 2;
}
}
///
/// 同意
///
public RelayCommand AgreeCommand
{
get
{
return new RelayCommand((view) =>
{
loginService.SystemRateComfrim(UserManager.CurrentTradeAccount.AccountId, ComfrimType.AgreeAndComfrim, RateComfrimSuccess, RateComfrimError);
view.DialogResult = true;
});
}
}
///
/// 不同意
///
public RelayCommand RefuseCommond
{
get
{
return new RelayCommand((view) =>
{
view.DialogResult = false;
});
}
}
///
/// 加载风险提示内容
///
public void LoadNotices()
{
IsBusy = true;
loginService = SimpleIoc.Default.GetInstance();
//loginService.SystemClientParamterConfigByID(c_paramId, RateNoticeContent, QueryNoticeError);
ulong lastUpdateTimeUTC = CacheManager.GetLastUpdateTimeBy(Muchinfo.MTPClient.Data.Enums.LastUpdateTimeType.RiskMsgUTime);
loginService.RiskTipQuerySearch(lastUpdateTimeUTC, RateNoticeContent, QueryNoticeError);
}
private void RateComfrimSuccess(bool rateComfrim)
{
}
private void RateComfrimError(ErrorEntity errorEntity)
{
var format = "风险提示确认" + string.Format(ErrorManager.FormatErrorMsg(errorEntity));
NoticeText = Client_Resource.RateNotice_Content;
LogInfoHelper.WriteInfo(format);
}
///
/// 显示内容
///
///
private void RateNoticeContent(RiskTipQueryRspModel parameter,ulong risktipStamp=0)
{
IsBusy = false;
if (parameter != null)
{
if (string.IsNullOrWhiteSpace(parameter.TipMsg))
{
NoticeText = Client_Resource.RateNotice_Content;
}
else
{
NoticeText = parameter.TipMsg;
}
}
else
{
NoticeText = Client_Resource.RateNotice_Content;
}
}
///
/// 风险提示出错
///
///
private void QueryNoticeError(ErrorEntity errorEntity)
{
IsBusy = false;
var format = "查询:" + string.Format(ErrorManager.FormatErrorMsg(errorEntity));
LogInfoHelper.WriteInfo(format);
}
}
}