コード例 #1
0
 public static void Login(Action onLoginSuccess, string serverHost = null, Action btnCloseClick = null)
 {
     WpfUtil.Login(onLoginSuccess: () => {
         NTMinerContext.MinerStudioContext.UserAppSettingSet.Init(RpcRoot.RpcUser.LoginedUser.UserAppSettings);
         onLoginSuccess?.Invoke();
     }, serverHost, btnCloseClick);
 }
コード例 #2
0
 public NTMinerFileViewModel()
 {
     _id        = Guid.NewGuid();
     _publishOn = DateTime.Now;
     this.Save  = new DelegateCommand(() => {
         WpfUtil.Login(() => {
             RpcRoot.OfficialServer.NTMinerFileService.AddOrUpdateNTMinerFileAsync(new NTMinerFileData().Update(this), (response, e) => {
                 if (response.IsSuccess())
                 {
                     MainWindowViewModel.Instance.Refresh();
                     UIThread.Execute(() => {
                         WpfUtil.GetTopWindow()?.Close();
                     });
                 }
                 else
                 {
                     Logger.ErrorDebugLine($"AddOrUpdateNTMinerFileAsync失败");
                 }
             });
         });
     });
     this.Edit = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("Icon_Edit", new NTMinerFileViewModel(this));
         window.ShowSoftDialog();
     });
     this.Remove = new DelegateCommand(() => {
         WpfUtil.Login(() => {
             this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => {
                 RpcRoot.OfficialServer.NTMinerFileService.RemoveNTMinerFileAsync(this.Id, (response, e) => {
                     if (response.IsSuccess())
                     {
                         MainWindowViewModel.Instance.Refresh();
                         MainWindowViewModel.Instance.SelectedNTMinerFile = MainWindowViewModel.Instance.NTMinerFiles.FirstOrDefault();
                         if (this.Id == MainWindowViewModel.Instance.ServerLatestVm.Id)
                         {
                             MainWindowViewModel.Instance.ServerLatestVm = MainWindowViewModel.Instance.NTMinerFiles
                                                                           .FirstOrDefault(a => a != this && a.VersionData > MainWindowViewModel.Instance.LocalNTMinerVersion);
                         }
                     }
                     else
                     {
                         VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
                     }
                 });
             }));
         });
     });
 }