示例#1
0
 public NTMinerFileViewModel()
 {
     _id        = Guid.NewGuid();
     _publishOn = DateTime.Now;
     this.Save  = new DelegateCommand(() => {
         LoginWindow.Login(() => {
             RpcRoot.OfficialServer.FileUrlService.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(() => {
         LoginWindow.Login(() => {
             this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => {
                 RpcRoot.OfficialServer.FileUrlService.RemoveNTMinerFileAsync(this.Id, (response, e) => {
                     if (response.IsSuccess())
                     {
                         MainWindowViewModel.Instance.Refresh();
                         MainWindowViewModel.Instance.SelectedNTMinerFile = MainWindowViewModel.Instance.NTMinerFiles.FirstOrDefault();
                         if (this == MainWindowViewModel.Instance.ServerLatestVm)
                         {
                             MainWindowViewModel.Instance.ServerLatestVm = MainWindowViewModel.Instance.NTMinerFiles
                                                                           .FirstOrDefault(a => a != this && a.VersionData > MainWindowViewModel.Instance.LocalNTMinerVersion);
                         }
                     }
                     else
                     {
                         VirtualRoot.Out.ShowError(response.ReadMessage(e), autoHideSeconds: 4);
                     }
                 });
             }));
         });
     });
 }
示例#2
0
 public NTMinerFileViewModel()
 {
     _id        = Guid.NewGuid();
     _publishOn = DateTime.Now;
     this.Save  = new DelegateCommand(() => {
         if (Login())
         {
             OfficialServer.FileUrlService.AddOrUpdateNTMinerFileAsync(new NTMinerFileData().Update(this), (response, e) => {
                 if (response.IsSuccess())
                 {
                     MainWindowViewModel.Instance.Refresh();
                     UIThread.Execute(() => {
                         TopWindow.GetTopWindow()?.Close();
                     });
                 }
                 else
                 {
                     Logger.ErrorDebugLine($"AddOrUpdateNTMinerFileAsync失败");
                 }
             });
         }
     });
     this.Edit = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("Icon_Edit", new NTMinerFileViewModel(this));
         window.ShowDialogEx();
     });
     this.Remove = new DelegateCommand(() => {
         if (Login())
         {
             this.ShowDialog(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => {
                 OfficialServer.FileUrlService.RemoveNTMinerFileAsync(this.Id, (response, e) => {
                     MainWindowViewModel.Instance.SelectedNTMinerFile = MainWindowViewModel.Instance.NTMinerFiles.FirstOrDefault();
                     if (this == MainWindowViewModel.Instance.ServerLatestVm)
                     {
                         MainWindowViewModel.Instance.ServerLatestVm = MainWindowViewModel.Instance.NTMinerFiles
                                                                       .FirstOrDefault(a => a != this && a.VersionData > MainWindowViewModel.Instance.LocalNTMinerVersion);
                     }
                     MainWindowViewModel.Instance.Refresh();
                 });
             }, icon: IconConst.IconConfirm);
         }
     });
 }
 public NTMinerFileViewModel()
 {
     _id        = Guid.NewGuid();
     _publishOn = DateTime.Now;
     this.Save  = new DelegateCommand(() => {
         if (Login())
         {
             Server.FileUrlService.AddOrUpdateNTMinerFile(new NTMinerFileData().Update(this), response => {
                 if (response != null && response.IsSuccess())
                 {
                     MainWindowViewModel.Current.Refresh();
                     Execute.OnUIThread(() => {
                         TopWindow.GetTopWindow()?.Close();
                     });
                 }
             });
         }
     });
     this.Edit = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("编辑", "Icon_Edit", new NTMinerFileViewModel(this));
         window.ShowDialogEx();
     });
     this.Remove = new DelegateCommand(() => {
         if (Login())
         {
             DialogWindow.ShowDialog(message: $"确定删除{this.Version}({this.VersionTag})吗?", title: "确认", onYes: () => {
                 Server.FileUrlService.RemoveNTMinerFile(this.Id, isSuccess => {
                     MainWindowViewModel.Current.SelectedNTMinerFile = MainWindowViewModel.Current.NTMinerFiles.FirstOrDefault();
                     if (this == MainWindowViewModel.Current.ServerLatestVm)
                     {
                         MainWindowViewModel.Current.ServerLatestVm = MainWindowViewModel.Current.NTMinerFiles
                                                                      .FirstOrDefault(a => a != this && a.VersionData > MainWindowViewModel.Current.LocalNTMinerVersion);
                     }
                     MainWindowViewModel.Current.Refresh();
                 });
             }, icon: "Icon_Confirm");
         }
     });
 }
示例#4
0
 private MainWindowViewModel()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     this.ShowServerLatestDescription = new DelegateCommand(() => {
         VirtualRoot.Out.ShowInfo(ServerLatestVm.Description, header: $"{ServerLatestVm.Version}({ServerLatestVm.VersionTag})", autoHideSeconds: 0);
     });
     this.CancelDownload = new DelegateCommand(() => {
         this._cancel?.Invoke();
     });
     this.Install = new DelegateCommand(() => {
         this.IsDownloading = true;
         string ntminerFile = string.Empty;
         string version     = string.Empty;
         if (IsHistoryVisible == Visibility.Collapsed)
         {
             if (ServerLatestVm != null)
             {
                 ntminerFile = ServerLatestVm.FileName;
                 version     = ServerLatestVm.Version;
             }
         }
         else
         {
             ntminerFile = SelectedNTMinerFile.FileName;
             version     = SelectedNTMinerFile.Version;
         }
         Download(ntminerFile, version,
                  progressChanged: (percent) => {
             this.DownloadMessage = percent + "%";
             this.DownloadPercent = (double)percent / 100;
         },
                  downloadComplete: (isSuccess, message, saveFileFullName) => {
             this.DownloadMessage = message;
             this.DownloadPercent = 0;
             if (isSuccess)
             {
                 this.DownloadMessage = "更新成功,正在重启";
                 void callback()
                 {
                     3.SecondsDelay().ContinueWith((t) => {
                         string location = NTMinerRegistry.GetLocation(App.AppType);
                         if (string.IsNullOrEmpty(location) || !File.Exists(location))
                         {
                             location = Path.Combine(HomePath.AppDomainBaseDirectory, ntminerFile);
                         }
                         try {
                             Process process = Process.GetProcessesByName(Path.GetFileName(location)).FirstOrDefault();
                             if (process != null)
                             {
                                 process.Kill();
                             }
                         }
                         catch (Exception e) {
                             Logger.ErrorDebugLine(e);
                         }
                         try {
                             if (File.Exists(location))
                             {
                                 Guid kernelBrandId = VirtualRoot.GetBrandId(location, NTKeyword.KernelBrandId);
                                 if (kernelBrandId != Guid.Empty)
                                 {
                                     VirtualRoot.TagBrandId(NTKeyword.KernelBrandId, kernelBrandId, saveFileFullName, saveFileFullName);
                                 }
                                 Guid poolBrandId = VirtualRoot.GetBrandId(location, NTKeyword.PoolBrandId);
                                 if (poolBrandId != Guid.Empty)
                                 {
                                     VirtualRoot.TagBrandId(NTKeyword.PoolBrandId, poolBrandId, saveFileFullName, saveFileFullName);
                                 }
                             }
                         }
                         catch (Exception e) {
                             Logger.ErrorDebugLine(e);
                         }
                         int failCount = 0;
                         while (true)
                         {
                             try {
                                 File.Copy(saveFileFullName, location, overwrite: true);
                                 break;
                             }
                             catch (Exception e) {
                                 failCount++;
                                 if (failCount == 3)
                                 {
                                     VirtualRoot.Out.ShowError(e.Message);
                                     break;
                                 }
                                 else
                                 {
                                     System.Threading.Thread.Sleep(3000);
                                 }
                             }
                         }
                         try {
                             File.Delete(saveFileFullName);
                         }
                         catch (Exception e) {
                             Logger.ErrorDebugLine(e);
                         }
                         string arguments = NTMinerRegistry.GetMinerClientArguments(App.AppType);
                         Process.Start(location, arguments);
                         this.IsDownloading = false;
                         2.SecondsDelay().ContinueWith(_ => {
                             UIThread.Execute(() => {
                                 Application.Current.MainWindow?.Close();
                             });
                         });
                     });
                 }
                 if (AppStatic.IsMinerStudio)
                 {
                     RpcRoot.Client.MinerStudioService.CloseMinerStudioAsync(callback);
                 }
                 else
                 {
                     RpcRoot.Client.MinerClientService.CloseNTMinerAsync(callback);
                 }
             }
             else
             {
                 2.SecondsDelay().ContinueWith((t) => {
                     this.IsDownloading = false;
                 });
             }
         }, cancel: out _cancel);
     }, () => !IsDownloading);
     this.ShowHistory = new DelegateCommand(() => {
         if (IsHistoryVisible == Visibility.Visible)
         {
             IsHistoryVisible = Visibility.Collapsed;
         }
         else
         {
             IsHistoryVisible = Visibility.Visible;
         }
     });
     this.AddNTMinerFile = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("Icon_Add", new NTMinerFileViewModel()
         {
             AppType = App.AppType
         });
         window.ShowSoftDialog();
     });
     VirtualRoot.BuildEventPath <NTMinerFileSetInitedEvent>("开源矿工程序版本文件集初始化后刷新Vm内存", LogEnum.DevConsole, this.GetType(), PathPriority.Normal, path: message => {
         var ntminerFiles  = _readOnlyNTMinerFileSet.AsEnumerable().Where(a => a.AppType == App.AppType);
         this.NTMinerFiles = ntminerFiles.Select(a => new NTMinerFileViewModel(a)).OrderByDescending(a => a.VersionData).ToList();
         if (this.NTMinerFiles == null || this.NTMinerFiles.Count == 0)
         {
             LocalIsLatest = true;
         }
         else
         {
             ServerLatestVm = this.NTMinerFiles.OrderByDescending(a => a.VersionData).FirstOrDefault();
             if (ServerLatestVm.VersionData > LocalNTMinerVersion)
             {
                 this.SelectedNTMinerFile = ServerLatestVm;
                 LocalIsLatest            = false;
             }
             else
             {
                 LocalIsLatest = true;
             }
         }
         OnPropertyChanged(nameof(IsBtnInstallVisible));
         IsReady = true;
         if (!string.IsNullOrEmpty(CommandLineArgs.NTMinerFileName))
         {
             NTMinerFileViewModel ntminerFileVm = this.NTMinerFiles.FirstOrDefault(a => a.FileName == CommandLineArgs.NTMinerFileName);
             if (ntminerFileVm != null)
             {
                 IsHistoryVisible         = Visibility.Visible;
                 this.SelectedNTMinerFile = ntminerFileVm;
                 Install.Execute(null);
             }
         }
     });
     this.Refresh();
 }
示例#5
0
 private MainWindowViewModel()
 {
     if (App.IsInDesignMode)
     {
         return;
     }
     this.Refresh();
     this.CancelDownload = new DelegateCommand(() => {
         this._cancel?.Invoke();
     });
     this.Install = new DelegateCommand(() => {
         this.IsDownloading = true;
         string ntMinerFile = string.Empty;
         string version     = string.Empty;
         if (IsHistoryVisible == Visibility.Collapsed)
         {
             if (ServerLatestVm != null)
             {
                 ntMinerFile = ServerLatestVm.FileName;
                 version     = ServerLatestVm.Version;
             }
         }
         else
         {
             ntMinerFile = SelectedNTMinerFile.FileName;
             version     = SelectedNTMinerFile.Version;
         }
         Download(ntMinerFile, version, progressChanged: (percent) => {
             this.DownloadMessage = percent + "%";
             this.DownloadPercent = (double)percent / 100;
         }, downloadComplete: (isSuccess, message, saveFileFullName) => {
             this.DownloadMessage = message;
             this.DownloadPercent = 0;
             if (isSuccess)
             {
                 this.DownloadMessage = "更新成功,正在重启";
                 if (VirtualRoot.IsMinerStudio)
                 {
                     Client.MinerStudioService.CloseMinerStudio();
                 }
                 else
                 {
                     Client.MinerClientService.CloseNTMiner();
                 }
                 TimeSpan.FromSeconds(3).Delay().ContinueWith((t) => {
                     string location = NTMinerRegistry.GetLocation();
                     if (string.IsNullOrEmpty(location) || !File.Exists(location))
                     {
                         location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ntMinerFile);
                     }
                     try {
                         if (File.Exists(location))
                         {
                             Guid kernelBrandId = VirtualRoot.GetBrandId(location, Consts.KernelBrandId);
                             if (kernelBrandId != Guid.Empty)
                             {
                                 Logger.InfoDebugLine("内核品牌打码开始");
                                 VirtualRoot.TagBrandId(Consts.KernelBrandId, kernelBrandId, saveFileFullName, saveFileFullName);
                                 Logger.OkDebugLine("内核品牌打码成功");
                             }
                             Guid poolBrandId = VirtualRoot.GetBrandId(location, Consts.PoolBrandId);
                             if (poolBrandId != Guid.Empty)
                             {
                                 Logger.InfoDebugLine("矿池打码开始");
                                 VirtualRoot.TagBrandId(Consts.PoolBrandId, poolBrandId, saveFileFullName, saveFileFullName);
                                 Logger.OkDebugLine("矿池打码成功");
                             }
                         }
                     }
                     catch (Exception e) {
                         Logger.ErrorDebugLine(e);
                     }
                     Logger.InfoDebugLine("复制开始");
                     File.Copy(saveFileFullName, location, overwrite: true);
                     File.Delete(saveFileFullName);
                     Logger.InfoDebugLine("复制完成,删除旧文件");
                     string arguments = NTMinerRegistry.GetArguments();
                     Logger.InfoDebugLine("启动新程序");
                     Process.Start(location, arguments);
                     this.IsDownloading = false;
                     UIThread.Execute(() => {
                         Logger.InfoDebugLine("退出升级器");
                         Application.Current.MainWindow?.Close();
                     });
                 });
             }
             else
             {
                 TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
                     this.IsDownloading = false;
                 });
             }
         }, cancel: out _cancel);
     }, () => !IsDownloading);
     this.ShowHistory = new DelegateCommand(() => {
         if (IsHistoryVisible == Visibility.Visible)
         {
             IsHistoryVisible = Visibility.Collapsed;
         }
         else
         {
             IsHistoryVisible = Visibility.Visible;
         }
     });
     this.AddNTMinerFile = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("添加", "Icon_Add", new NTMinerFileViewModel()
         {
             AppType = App.AppType
         });
         window.ShowDialogEx();
     });
 }
示例#6
0
 private MainWindowViewModel()
 {
     if (App.IsInDesignMode)
     {
         return;
     }
     this.Refresh();
     this.CancelDownload = new DelegateCommand(() => {
         this.cancel?.Invoke();
         this.IsDownloading = false;
     });
     this.Install = new DelegateCommand(() => {
         object locationValue  = Windows.Registry.GetValue(Registry.Users, ClientId.NTMinerRegistrySubKey, "Location");
         object argumentsValue = Windows.Registry.GetValue(Registry.Users, ClientId.NTMinerRegistrySubKey, "Arguments");
         if (locationValue == null)
         {
             return;
         }
         if (this.IsDownloading)
         {
             return;
         }
         this.IsDownloading = true;
         string ntMinerFile = string.Empty;
         string version     = string.Empty;
         if (IsHistoryVisible == Visibility.Collapsed)
         {
             if (ServerLatestVm != null)
             {
                 ntMinerFile = ServerLatestVm.FileName;
                 version     = ServerLatestVm.Version;
             }
         }
         else
         {
             ntMinerFile = SelectedNTMinerFile.FileName;
             version     = SelectedNTMinerFile.Version;
         }
         Download(ntMinerFile, version, progressChanged: (percent) => {
             this.DownloadMessage = percent + "%";
             this.DownloadPercent = (double)percent / 100;
         }, downloadComplete: (isSuccess, message, saveFileFullName) => {
             this.DownloadMessage  = message;
             this.DownloadPercent  = 0;
             this.BtnCancelVisible = Visibility.Collapsed;
             if (isSuccess)
             {
                 this.DownloadMessage = "更新成功,正在重启";
                 Task.Factory.StartNew(CloseNTMinerMainWindow);
                 TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
                     string location = (string)locationValue;
                     File.Copy(saveFileFullName, location, overwrite: true);
                     File.Delete(saveFileFullName);
                     Process.Start(location, (string)argumentsValue);
                     this.IsDownloading = false;
                     Execute.OnUIThread(() => {
                         Application.Current.MainWindow.Close();
                     });
                 });
             }
             else
             {
                 TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
                     this.IsDownloading = false;
                 });
             }
         }, cancel: out cancel);
     });
     this.ShowHistory = new DelegateCommand(() => {
         if (IsHistoryVisible == Visibility.Visible)
         {
             IsHistoryVisible = Visibility.Collapsed;
             if (ServerLatestVm != null)
             {
                 this.IsBtnInstallVisible = Visibility.Visible;
             }
             else
             {
                 this.IsBtnInstallVisible = Visibility.Collapsed;
             }
         }
         else
         {
             IsHistoryVisible = Visibility.Visible;
             if (this.NTMinerFiles.Count != 0)
             {
                 this.IsBtnInstallVisible = Visibility.Visible;
             }
         }
     });
     this.AddNTMinerFile = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("添加", "Icon_Add", new NTMinerFileViewModel());
         window.ShowDialogEx();
     });
 }
示例#7
0
 private MainWindowViewModel()
 {
     if (WpfUtil.IsInDesignMode)
     {
         return;
     }
     this.Refresh();
     this.ShowServerLatestDescription = new DelegateCommand(() => {
         VirtualRoot.Out.ShowInfo(ServerLatestVm.Description, header: $"{ServerLatestVm.Version}({ServerLatestVm.VersionTag})", autoHideSeconds: 0);
     });
     this.CancelDownload = new DelegateCommand(() => {
         this._cancel?.Invoke();
     });
     this.Install = new DelegateCommand(() => {
         this.IsDownloading = true;
         string ntminerFile = string.Empty;
         string version     = string.Empty;
         if (IsHistoryVisible == Visibility.Collapsed)
         {
             if (ServerLatestVm != null)
             {
                 ntminerFile = ServerLatestVm.FileName;
                 version     = ServerLatestVm.Version;
             }
         }
         else
         {
             ntminerFile = SelectedNTMinerFile.FileName;
             version     = SelectedNTMinerFile.Version;
         }
         Download(ntminerFile, version,
                  progressChanged: (percent) => {
             this.DownloadMessage = percent + "%";
             this.DownloadPercent = (double)percent / 100;
         },
                  downloadComplete: (isSuccess, message, saveFileFullName) => {
             this.DownloadMessage = message;
             this.DownloadPercent = 0;
             if (isSuccess)
             {
                 this.DownloadMessage = "更新成功,正在重启";
                 void callback()
                 {
                     3.SecondsDelay().ContinueWith((t) => {
                         string location = NTMinerRegistry.GetLocation(App.AppType);
                         if (string.IsNullOrEmpty(location) || !File.Exists(location))
                         {
                             location = Path.Combine(HomePath.AppDomainBaseDirectory, ntminerFile);
                         }
                         try {
                             if (File.Exists(location))
                             {
                                 Guid kernelBrandId = VirtualRoot.GetBrandId(location, NTKeyword.KernelBrandId);
                                 if (kernelBrandId != Guid.Empty)
                                 {
                                     VirtualRoot.TagBrandId(NTKeyword.KernelBrandId, kernelBrandId, saveFileFullName, saveFileFullName);
                                 }
                                 Guid poolBrandId = VirtualRoot.GetBrandId(location, NTKeyword.PoolBrandId);
                                 if (poolBrandId != Guid.Empty)
                                 {
                                     VirtualRoot.TagBrandId(NTKeyword.PoolBrandId, poolBrandId, saveFileFullName, saveFileFullName);
                                 }
                             }
                         }
                         catch (Exception e) {
                             Logger.ErrorDebugLine(e);
                         }
                         int failCount = 0;
                         while (true)
                         {
                             try {
                                 File.Copy(saveFileFullName, location, overwrite: true);
                                 break;
                             }
                             catch (Exception e) {
                                 failCount++;
                                 if (failCount == 3)
                                 {
                                     VirtualRoot.Out.ShowError(e.Message);
                                     break;
                                 }
                                 else
                                 {
                                     System.Threading.Thread.Sleep(3000);
                                 }
                             }
                         }
                         try {
                             File.Delete(saveFileFullName);
                         }
                         catch (Exception e) {
                             Logger.ErrorDebugLine(e);
                         }
                         string arguments = NTMinerRegistry.GetMinerClientArguments(App.AppType);
                         Process.Start(location, arguments);
                         this.IsDownloading = false;
                         2.SecondsDelay().ContinueWith(_ => {
                             UIThread.Execute(() => {
                                 Application.Current.MainWindow?.Close();
                             });
                         });
                     });
                 }
                 if (AppStatic.IsMinerStudio)
                 {
                     RpcRoot.Client.MinerStudioService.CloseMinerStudioAsync(callback);
                 }
                 else
                 {
                     RpcRoot.Client.MinerClientService.CloseNTMinerAsync(callback);
                 }
             }
             else
             {
                 2.SecondsDelay().ContinueWith((t) => {
                     this.IsDownloading = false;
                 });
             }
         }, cancel: out _cancel);
     }, () => !IsDownloading);
     this.ShowHistory = new DelegateCommand(() => {
         if (IsHistoryVisible == Visibility.Visible)
         {
             IsHistoryVisible = Visibility.Collapsed;
         }
         else
         {
             IsHistoryVisible = Visibility.Visible;
         }
     });
     this.AddNTMinerFile = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("Icon_Add", new NTMinerFileViewModel()
         {
             AppType = App.AppType
         });
         window.ShowSoftDialog();
     });
 }
示例#8
0
 private MainWindowViewModel()
 {
     if (App.IsInDesignMode)
     {
         return;
     }
     this.Refresh();
     this.CancelDownload = new DelegateCommand(() => {
         this.cancel?.Invoke();
         this.IsDownloading = false;
     });
     this.Install = new DelegateCommand(() => {
         if (this.IsDownloading)
         {
             return;
         }
         this.IsDownloading = true;
         string ntMinerFile = string.Empty;
         string version     = string.Empty;
         if (IsHistoryVisible == Visibility.Collapsed)
         {
             if (ServerLatestVm != null)
             {
                 ntMinerFile = ServerLatestVm.FileName;
                 version     = ServerLatestVm.Version;
             }
         }
         else
         {
             ntMinerFile = SelectedNTMinerFile.FileName;
             version     = SelectedNTMinerFile.Version;
         }
         Download(ntMinerFile, version, progressChanged: (percent) => {
             this.DownloadMessage = percent + "%";
             this.DownloadPercent = (double)percent / 100;
         }, downloadComplete: (isSuccess, message, saveFileFullName) => {
             this.DownloadMessage  = message;
             this.DownloadPercent  = 0;
             this.BtnCancelVisible = Visibility.Collapsed;
             if (isSuccess)
             {
                 this.DownloadMessage = "更新成功,正在重启";
                 if (VirtualRoot.IsMinerStudio)
                 {
                     Client.MinerStudioService.CloseMinerStudio();
                 }
                 else
                 {
                     Client.MinerClientService.CloseNTMiner();
                 }
                 TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
                     string location = NTMinerRegistry.GetLocation();
                     if (string.IsNullOrEmpty(location) || !File.Exists(location))
                     {
                         location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ntMinerFile);
                     }
                     File.Copy(saveFileFullName, location, overwrite: true);
                     File.Delete(saveFileFullName);
                     string arguments = NTMinerRegistry.GetArguments();
                     Process.Start(location, arguments);
                     this.IsDownloading = false;
                     UIThread.Execute(() => {
                         Application.Current.MainWindow.Close();
                     });
                 });
             }
             else
             {
                 TimeSpan.FromSeconds(2).Delay().ContinueWith((t) => {
                     this.IsDownloading = false;
                 });
             }
         }, cancel: out cancel);
     });
     this.ShowHistory = new DelegateCommand(() => {
         if (IsHistoryVisible == Visibility.Visible)
         {
             IsHistoryVisible = Visibility.Collapsed;
         }
         else
         {
             IsHistoryVisible = Visibility.Visible;
         }
     });
     this.AddNTMinerFile = new DelegateCommand(() => {
         NTMinerFileEdit window = new NTMinerFileEdit("添加", "Icon_Add", new NTMinerFileViewModel()
         {
             AppType = App.AppType
         });
         window.ShowDialogEx();
     });
 }