RateNoticeViewModel.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Windows.Documents;
  4. using GalaSoft.MvvmLight;
  5. using GalaSoft.MvvmLight.Command;
  6. //----------------------------------------------------------------
  7. //Module Name: $safeprojectname$
  8. //Purpose:
  9. //CopyRight: Muchinfo
  10. //History:
  11. //----------------------------------------------------------------
  12. //DateTime 2015/11/12 13:46:09
  13. //Author ouyang.hongbin
  14. //Description Create
  15. //----------------------------------------------------------------
  16. using System.Windows;
  17. using GalaSoft.MvvmLight.Ioc;
  18. using Muchinfo.MTPClient.Data;
  19. using Muchinfo.MTPClient.Data.Enums;
  20. using Muchinfo.MTPClient.Data.Model;
  21. using Muchinfo.MTPClient.Infrastructure.Helpers;
  22. using Muchinfo.MTPClient.Infrastructure.Utilities;
  23. using Muchinfo.MTPClient.IService;
  24. using Muchinfo.MTPClient.Resources;
  25. using Muchinfo.MTPClient.Infrastructure.Cache;
  26. namespace Muchinfo.MTPClient.UI.ViewModels
  27. {
  28. public class RateNoticeViewModel : ViewModelBase
  29. {
  30. private ILoginService loginService;
  31. private const string c_paramId = "226";
  32. private bool _isNotice=true;
  33. /// <summary>
  34. /// 是否提示
  35. /// </summary>
  36. public bool IsNotice
  37. {
  38. get { return _isNotice; }
  39. set { Set(() => IsNotice, ref _isNotice, value); }
  40. }
  41. private bool _isBusy;
  42. public bool IsBusy
  43. {
  44. get { return _isBusy; }
  45. set { Set(() => IsBusy, ref _isBusy, value); }
  46. }
  47. private string _noticeText;
  48. /// <summary>
  49. /// 显示内容
  50. /// </summary>
  51. public string NoticeText
  52. {
  53. get { return _noticeText; }
  54. set { Set(() => NoticeText, ref _noticeText, value); }
  55. }
  56. /// <summary>
  57. /// 是否显示
  58. /// </summary>
  59. public bool IsShowCheckedBox
  60. {
  61. get
  62. {
  63. return ApplicationParameter.IsShowRateTips == 2;
  64. }
  65. }
  66. /// <summary>
  67. /// 同意
  68. /// </summary>
  69. public RelayCommand<Window> AgreeCommand
  70. {
  71. get
  72. {
  73. return new RelayCommand<Window>((view) =>
  74. {
  75. loginService.SystemRateComfrim(UserManager.CurrentTradeAccount.AccountId, ComfrimType.AgreeAndComfrim, RateComfrimSuccess, RateComfrimError);
  76. view.DialogResult = true;
  77. });
  78. }
  79. }
  80. /// <summary>
  81. /// 不同意
  82. /// </summary>
  83. public RelayCommand<Window> RefuseCommond
  84. {
  85. get
  86. {
  87. return new RelayCommand<Window>((view) =>
  88. {
  89. view.DialogResult = false;
  90. });
  91. }
  92. }
  93. /// <summary>
  94. /// 加载风险提示内容
  95. /// </summary>
  96. public void LoadNotices()
  97. {
  98. IsBusy = true;
  99. loginService = SimpleIoc.Default.GetInstance<ILoginService>();
  100. //loginService.SystemClientParamterConfigByID(c_paramId, RateNoticeContent, QueryNoticeError);
  101. ulong lastUpdateTimeUTC = CacheManager.GetLastUpdateTimeBy(Muchinfo.MTPClient.Data.Enums.LastUpdateTimeType.RiskMsgUTime);
  102. loginService.RiskTipQuerySearch(lastUpdateTimeUTC, RateNoticeContent, QueryNoticeError);
  103. }
  104. private void RateComfrimSuccess(bool rateComfrim)
  105. {
  106. }
  107. private void RateComfrimError(ErrorEntity errorEntity)
  108. {
  109. var format = "风险提示确认" + string.Format(ErrorManager.FormatErrorMsg(errorEntity));
  110. NoticeText = Client_Resource.RateNotice_Content;
  111. LogInfoHelper.WriteInfo(format);
  112. }
  113. /// <summary>
  114. /// 显示内容
  115. /// </summary>
  116. /// <param name="parameter"></param>
  117. private void RateNoticeContent(RiskTipQueryRspModel parameter,ulong risktipStamp=0)
  118. {
  119. IsBusy = false;
  120. if (parameter != null)
  121. {
  122. if (string.IsNullOrWhiteSpace(parameter.TipMsg))
  123. {
  124. NoticeText = Client_Resource.RateNotice_Content;
  125. }
  126. else
  127. {
  128. NoticeText = parameter.TipMsg;
  129. }
  130. }
  131. else
  132. {
  133. NoticeText = Client_Resource.RateNotice_Content;
  134. }
  135. }
  136. /// <summary>
  137. /// 风险提示出错
  138. /// </summary>
  139. /// <param name="errorEntity"></param>
  140. private void QueryNoticeError(ErrorEntity errorEntity)
  141. {
  142. IsBusy = false;
  143. var format = "查询:" + string.Format(ErrorManager.FormatErrorMsg(errorEntity));
  144. LogInfoHelper.WriteInfo(format);
  145. }
  146. }
  147. }