/// <summary> /// 实例化一个新的操作视图的基类 /// </summary> /// <param name="selectedButtonName">高亮按键的名称</param> public ManagerViewModelBase(string selectedButtonName) { //初始化参数 this.PageName = selectedButtonName; //初始化命令 this.JumpCommand = new UniversalCommand(new Action<object>(Jump)); this.LogoutCommand = new UniversalCommand(new Action<object>(Logout)); this.CloseNoticeWindowCommand = new UniversalCommand(new Action<object>(CloseNoticeWindow)); //加载公告列表 ShowBulletins(2); DispatcherTimer timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 5); timer.Tick += (sender, e) => { ShowBulletins(2); }; timer.Start(); DispatcherTimer timer2 = new DispatcherTimer(); timer2.Interval = new TimeSpan(0, 0, 1); timer2.Tick += (sender, e) => { ShowUnreadNotices(); }; timer2.Start(); #region 加载中奖排行 Dictionary<string, List<TopBonus>> tD = DataManager.GetValue<Dictionary<string, List<TopBonus>>>(DataKey.IWorld_Client_TopBouns); if (ContrastManager.Contrasts.Any(c => c.ButtonNames.Any(bName => bName == selectedButtonName))) { if (!tD.Keys.Any(key => key == selectedButtonName)) { GetTopBonusImport import = new GetTopBonusImport { Notes = 7, TicketId = DataManager.GetValue<List<LotteryService.LotteryTicketExport>>(DataKey.IWorld_Client_Tickets) .First(x => x.Name == selectedButtonName).Id, Token = DataManager.GetValue<string>(DataKey.IWorld_Client_Token) }; LotteryServiceClient client = new LotteryServiceClient(); client.GetTopBonusCompleted += (sender, e) => { if (e.Result.Success) { return; } tD.Add(selectedButtonName, e.Result.Info); DataManager.SetValue(DataKey.IWorld_Client_TopBouns, tD); e.Result.Info.OrderByDescending(x => x.Sum).ToList(); }; } else { tD[selectedButtonName].OrderByDescending(x => x.Sum).ToList().ForEach(x => this.TopBonus.Add(x)); } } else { tD["_all"].OrderByDescending(x => x.Sum).ToList().ForEach(x => this.TopBonus.Add(x)); } #endregion }
//处理加载彩票信息的结果 void ShowGetTicketsResult(object sender, GetTicketsCompletedEventArgs e) { if (e.Result.Success) { DataManager.SetValue(DataKey.IWorld_Client_Tickets, e.Result.Info); GetTopBonusImport import = new GetTopBonusImport { Notes = 7, Token = DataManager.GetValue<string>(DataKey.IWorld_Client_Token) }; LotteryServiceClient client = (LotteryServiceClient)sender; client.GetTopBonusCompleted += ShowGetTopBonusResult; this.LoadingMessage = "加载历史记录(5/7)..."; client.GetTopBonusAsync(import); } else { ShowLoginError(e.Result.Error); } }