| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2016/12/27 20:05:44
- //Author
- //Description Create
- //----------------------------------------------------------------
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Data.Model.Delivery;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.MessageBox;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.Infrastructure.Windows;
- using Muchinfo.MTPClient.IService;
- namespace Muchinfo.MTPClient.Delivery.ViewModels
- {
- public class DeliveryCompleteViewModel : QueryPanelModelBase
- {
- private IDeliveryService _deliveryService;
- public DeliveryCompleteViewModel()
- {
- _deliveryService = SimpleIoc.Default.GetInstance<IDeliveryService>();
- }
- #region "接口重写/Interface implementation Or override"
- /// <summary>
- /// 初始化注册消息
- /// </summary>
- public override void RegisterMessage()
- {
- EndTime = ApplicationParameter.ServerTimeNow;
- StartTime = ApplicationParameter.ServerTimeNow.AddDays(-30);
- RefreshCommand.Execute(null);
-
- }
- public override void UnRegisterMessage()
- {
- MessengerHelper.DefaultUnregister(this);
- }
- /// <summary>
- /// 查询交收申报单
- /// </summary>
- public override void RefreshContent()
- {
- if (!Vailed())
- {
- return;
- }
- IsBusy = true;
- var accountid = UserManager.CurrentTradeAccount.AccountId;
- //if (UserManager.CurrentTradeAccount.FundsAccounts != null && UserManager.CurrentTradeAccount.FundsAccounts.Any())
- //{
- // accountid = UserManager.CurrentTradeAccount.FundsAccounts[0].AccountId;
- //}
- _deliveryService.QueryDeliveryComplete(accountid, StartTime.Date, EndTime.Date.AddHours(24), MarketOrderSuccess, QueryErrorCallback);
- }
- #endregion "Interface implementation Or override"
- #region "Public Properties To Get/Set "
- #region 开始时间
- private DateTime startTime;
- /// <summary>
- /// 开始时间
- /// </summary>
- public DateTime StartTime
- {
- get { return startTime; }
- set { Set(() => StartTime, ref startTime, value); }
- }
- #endregion
- #region 结束时间
- private DateTime _endTime;
- /// <summary>
- /// 结束时间
- /// </summary>
- public DateTime EndTime
- {
- get { return _endTime; }
- set { Set(() => EndTime, ref _endTime, value); }
- }
- #endregion
- private List<DeliveryCompleteModel> _deliveryCompleteModels;
- public List<DeliveryCompleteModel> DeliveryCompleteModels
- {
- get { return _deliveryCompleteModels; }
- set { Set(() => DeliveryCompleteModels, ref _deliveryCompleteModels, value); }
- }
-
-
- #endregion "Public Properties To Get/Set "
- #region 重置查询时间命令Command
- private RelayCommand _resetCommand;
- /// <summary>
- /// Gets the ResetCommand.
- /// </summary>
- public RelayCommand ResetCommand
- {
- get
- {
- return _resetCommand
- ?? (_resetCommand = new RelayCommand(
- () =>
- {
- EndTime = ApplicationParameter.ServerTimeNow;
- StartTime = ApplicationParameter.ServerTimeNow.AddDays(-30);
- }));
- }
- }
- #endregion
- #region "Other Methods like Validated"
- /// <summary>
- /// 数据验证
- /// </summary>
- /// <returns></returns>
- private bool Vailed()
- {
- if (StartTime > EndTime)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.DateTimeVaided_StartEnd, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true);
- return false;
- }
- else if ((EndTime - StartTime).Days > 30)
- {
- MessageBoxHelper.ShowInfo(Muchinfo.MTPClient.Resources.Client_Resource.DateTimeVaided_Over30days, Muchinfo.MTPClient.Resources.Client_Resource.Models_Tips, true);
- return false;
- }
- return true;
- }
- #endregion "Other Methods like Validated"
- /// <summary>
- /// 查询成功返回
- /// </summary>
- /// <param name="orders"></param>
- protected void MarketOrderSuccess(List<DeliveryCompleteModel> orders)
- {
- DeliveryCompleteModels = orders;
- IsBusy = false;
- }
- /// <summary>
- /// 查询失败返回
- /// </summary>
- /// <param name="errorEntity"></param>
- public override void QueryErrorCallback(ErrorEntity errorEntity)
- {
- IsBusy = false;
- var errorMsg = string.Format("{0}:{1}", errorEntity.RequestFunc, ErrorManager.FormatErrorMsg(errorEntity)); //错误信息显示到状态
- MessengerHelper.DefaultSend(errorMsg, MessengerTokens.ErrorMessage);
- // base.QueryErrorCallback();
- }
- }
- }
|