| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using System;
- using System.Collections.Generic;
- using GalaSoft.MvvmLight;
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Messaging;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.PC.Common.Extensions;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Model.Account;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using System.Collections.ObjectModel;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- namespace Muchinfo.MTPClient.Account.ViewModels
- {
-
- public class OperateLogViewModel : RegisterMessageBase
- {
- ObservableCollection<UserLog> _logs = new ObservableCollection<UserLog>();
- public ObservableCollection<UserLog> Logs
- {
- get
- {
- return _logs;
- }
- set
- {
- Set(() => Logs, ref _logs, value);
- }
- }
- #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
- public OperateLogViewModel()
- {
-
- }
- public override void RegisterMessage()
- {
- EndTime = ApplicationParameter.ServerTimeNow;
- StartTime = ApplicationParameter.ServerTimeNow.AddDays(-30);
- RefreshCommand.Execute(null);
- MessengerHelper.DefaultUnregister<TradeAccount>(this, MessengerTokens.OrderNotify);
- MessengerHelper.DefaultRegister<TradeAccount>(this, MessengerTokens.OrderNotify, (e) =>
- {
- //接收通知时,防止时间设置错误,弹出错误提示
- EndTime = ApplicationParameter.ServerTimeNow;
- StartTime = ApplicationParameter.ServerTimeNow.AddDays(-30);
- RefreshCommand.Execute(null);
- });
- }
- #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
- /// <summary>
- /// 查询持仓成功回调
- /// </summary>
- /// <param name="holdOrders">持仓内容</param>
- private void QueryHoldOrderCallBack(List<UserLog> userLogs)
- {
- ////获取当前的持仓
- IsBusy = false;
- Logs = new ObservableCollection<UserLog>(userLogs);
-
- }
- /// <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();
- }
- public override void RefreshContent()
- {
- IsBusy = true;
- var queryCommons = new List<QueryCommonParam>();
- queryCommons.Add(new QueryCommonParam() { ParamKey = "accountId", ParamValue = UserManager.CurrentTradeAccount.AccountId + string.Empty });
- queryCommons.Add(new QueryCommonParam() { ParamKey = "startDate", ParamValue = StartTime.ToString("yyyy-MM-dd HH:mm:ss") });
- queryCommons.Add(new QueryCommonParam() { ParamKey = "endDate", ParamValue = EndTime.ToString("yyyy-MM-dd HH:mm:ss") });
- _orderService.QueryUserLogs(QueryStatement.SearchSysLog, queryCommons, QueryHoldOrderCallBack, QueryErrorCallback);
- }
- }
- }
|