ntminer 5 years ago
parent
commit
8f6a85bc14

+ 0 - 1
src/AppModels/AppModels.csproj

@@ -95,7 +95,6 @@
     <Compile Include="MinerStudio\Vms\CpuDataViewModel.cs" />
     <Compile Include="MinerStudio\Vms\IWsStateViewModel.cs" />
     <Compile Include="Messages.cs" />
-    <Compile Include="MinerStudio\EmptyMinerStudioService.cs" />
     <Compile Include="MinerStudio\ILocalMinerStudioService.cs" />
     <Compile Include="MinerStudio\IMinerStudioService.cs" />
     <Compile Include="MinerStudio\Impl\LocalMinerStudioService.cs" />

+ 0 - 124
src/AppModels/MinerStudio/EmptyMinerStudioService.cs

@@ -1,124 +0,0 @@
-using NTMiner.Core.MinerClient;
-using NTMiner.Core.MinerServer;
-using System;
-using System.Collections.Generic;
-
-namespace NTMiner.MinerStudio {
-    public class EmptyMinerStudioService : ILocalMinerStudioService {
-        public static readonly EmptyMinerStudioService Instance = new EmptyMinerStudioService();
-
-        private EmptyMinerStudioService() { }
-
-        public void AddClientsAsync(List<string> clientIps, Action<ResponseBase, Exception> callback) {
-            // 什么也不做
-        }
-
-        public void GetLatestSnapshotsAsync(int limit, Action<GetCoinSnapshotsResponse, Exception> callback) {
-            // 什么也不做
-        }
-
-        public void QueryClientsAsync(QueryClientsRequest query, Action<QueryClientsResponse, Exception> callback) {
-            // 什么也不做
-        }
-
-        public void RefreshClientsAsync(List<string> objectIds, Action<DataResponse<List<ClientData>>, Exception> callback) {
-            // 什么也不做
-        }
-
-        public void RemoveClientsAsync(List<string> objectIds, Action<ResponseBase, Exception> callback) {
-            // 什么也不做
-        }
-
-        public void GetConsoleOutLinesAsync(IMinerData client, long afterTime) {
-            // 什么也不做
-        }
-
-        public void EnableRemoteDesktopAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void BlockWAUAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void AtikmdagPatcherAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void SwitchRadeonGpuAsync(IMinerData client, bool on) {
-            // 什么也不做
-        }
-
-        public void RestartWindowsAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void SetAutoBootStartAsync(IMinerData client, SetAutoBootStartRequest request) {
-            // 什么也不做
-        }
-
-        public void ShutdownWindowsAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void StartMineAsync(IMinerData client, Guid workId) {
-            // 什么也不做
-        }
-
-        public void StopMineAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void UpdateClientAsync(string objectId, string propertyName, object value, Action<ResponseBase, Exception> callback) {
-            // 什么也不做
-        }
-
-        public void UpdateClientsAsync(string propertyName, Dictionary<string, object> values, Action<ResponseBase, Exception> callback) {
-            // 什么也不做
-        }
-
-        public void UpgradeNTMinerAsync(IMinerData client, string ntminerFileName) {
-            // 什么也不做
-        }
-
-        public void GetDrivesAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void SetVirtualMemoryAsync(IMinerData client, Dictionary<string, int> data) {
-            // 什么也不做
-        }
-
-        public void GetLocalIpsAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void SetLocalIpsAsync(IMinerData client, List<LocalIpInput> data) {
-            // 什么也不做
-        }
-
-        public void GetOperationResultsAsync(IMinerData client, long afterTime) {
-            // 什么也不做
-        }
-
-        public void GetSelfWorkLocalJsonAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void SaveSelfWorkLocalJsonAsync(IMinerData client, string localJson, string serverJson) {
-            // 什么也不做
-        }
-
-        public void GetGpuProfilesJsonAsync(IMinerData client) {
-            // 什么也不做
-        }
-
-        public void SaveGpuProfilesJsonAsync(IMinerData client, string json) {
-            // 什么也不做
-        }
-
-        public void GetLocalMessagesAsync(IMinerData client, long afterTime) {
-            throw new NotImplementedException();
-        }
-    }
-}

+ 1 - 12
src/AppModels/MinerStudio/MinerStudioRoot.cs

@@ -5,23 +5,12 @@ using NTMiner.Ws;
 namespace NTMiner.MinerStudio {
     public static partial class MinerStudioRoot {
         public static IWsClient WsClient { get; private set; } = EmptyWsClient.Instance;
-        public static IMinerStudioService MinerStudioService { get; private set; } = EmptyMinerStudioService.Instance;
         public static MinerClientConsoleViewModel MinerClientConsoleVm { get; private set; } = new MinerClientConsoleViewModel();
         public static MinerClientMessagesViewModel MinerClientMessagesVm { get; private set; } = new MinerClientMessagesViewModel();
         public static MinerClientOperationResultsViewModel MinerClientOperationResultsVm { get; private set; } = new MinerClientOperationResultsViewModel();
 
-        /// <summary>
-        /// 
-        /// </summary>
-        /// <param name="wsClient">之所以从外部传入是因为IWsClient的实现类在外部的类库中</param>
         public static void Init(IWsClient wsClient) {
-            if (RpcRoot.IsOuterNet) {
-                MinerStudioService = new ServerMinerStudioService();
-                WsClient = wsClient;
-            }
-            else {
-                MinerStudioService = new LocalMinerStudioService();
-            }
+            WsClient = wsClient;
         }
 
         public static MinerClientsWindowViewModel MinerClientsWindowVm {

+ 1 - 1
src/AppModels/MinerStudio/MinerStudioRoot.partials.MinerClientConsoleViewModel.cs

@@ -91,7 +91,7 @@ namespace NTMiner.MinerStudio {
                         afterTime = item.Timestamp;
                     }
                 }
-                MinerStudioService.GetConsoleOutLinesAsync(minerClientVm, afterTime);
+                MinerStudioService.Instance.GetConsoleOutLinesAsync(minerClientVm, afterTime);
             }
         }
     }

+ 1 - 1
src/AppModels/MinerStudio/MinerStudioRoot.partials.MinerClientMessagesViewModel.cs

@@ -89,7 +89,7 @@ namespace NTMiner.MinerStudio {
                         afterTime = item.Timestamp;
                     }
                 }
-                MinerStudioService.GetLocalMessagesAsync(minerClientVm, afterTime);
+                MinerStudioService.Instance.GetLocalMessagesAsync(minerClientVm, afterTime);
             }
         }
     }

+ 1 - 1
src/AppModels/MinerStudio/MinerStudioRoot.partials.MinerClientOperationResultsViewModel.cs

@@ -120,7 +120,7 @@ namespace NTMiner.MinerStudio {
                         afterTime = item.Timestamp;
                     }
                 }
-                MinerStudioService.GetOperationResultsAsync(minerClientVm, afterTime);
+                MinerStudioService.Instance.GetOperationResultsAsync(minerClientVm, afterTime);
             }
         }
     }

+ 1 - 1
src/AppModels/MinerStudio/Vms/GpuProfilesPageViewModel.cs

@@ -65,7 +65,7 @@ namespace NTMiner.MinerStudio.Vms {
                 }
                 string json = VirtualRoot.JsonSerializer.Serialize(jsonObj);
                 foreach (var client in minerClientsWindowVm.SelectedMinerClients) {
-                    MinerStudioRoot.MinerStudioService.SaveGpuProfilesJsonAsync(client, json);
+                    MinerStudioService.Instance.SaveGpuProfilesJsonAsync(client, json);
                 }
                 VirtualRoot.Execute(new CloseWindowCommand(this.Id));
             });

+ 1 - 1
src/AppModels/MinerStudio/Vms/LocalIpConfigViewModel.cs

@@ -24,7 +24,7 @@ namespace NTMiner.MinerStudio.Vms {
                         vm.DNSServer1Vm.SetAddress(NTKeyword.DNSServer1);
                     }
                 }
-                MinerStudioRoot.MinerStudioService.SetLocalIpsAsync(minerClientVm, _localIpVms.Select(a => LocalIpInput.Create(a, a.IsAutoDNSServer)).ToList());
+                MinerStudioService.Instance.SetLocalIpsAsync(minerClientVm, _localIpVms.Select(a => LocalIpInput.Create(a, a.IsAutoDNSServer)).ToList());
                 if (_localIpVms.Count == 1) {
                     VirtualRoot.Execute(new CloseWindowCommand(this.Id));
                 }

+ 3 - 3
src/AppModels/MinerStudio/Vms/MineWorkViewModel.cs

@@ -110,7 +110,7 @@ namespace NTMiner.MinerStudio.Vms {
                                 EditJson(formType, WorkType.SelfWork, data);
                             }
                         }, PathId.Empty, typeof(MineWorkViewModel));
-                        MinerStudioRoot.MinerStudioService.GetSelfWorkLocalJsonAsync(_minerClientVm);
+                        MinerStudioService.Instance.GetSelfWorkLocalJsonAsync(_minerClientVm);
                     }
                     else {
                         RpcRoot.Client.NTMinerDaemonService.GetSelfWorkLocalJsonAsync(_minerClientVm, (json, e) => {
@@ -242,7 +242,7 @@ namespace NTMiner.MinerStudio.Vms {
                     if (isMinerProfileChanged) {
                         NTMinerContext.ExportWorkJson(mineWorkData, out string localJson, out string serverJson);
                         if (!string.IsNullOrEmpty(localJson) && !string.IsNullOrEmpty(serverJson)) {
-                            MinerStudioRoot.MinerStudioService.SaveSelfWorkLocalJsonAsync(_minerClientVm, localJson, serverJson);
+                            MinerStudioService.Instance.SaveSelfWorkLocalJsonAsync(_minerClientVm, localJson, serverJson);
                         }
                         if (mineWorkData.ServerJsonSha1 != this.ServerJsonSha1) {
                             this.ServerJsonSha1 = mineWorkData.ServerJsonSha1;
@@ -284,7 +284,7 @@ namespace NTMiner.MinerStudio.Vms {
                     if (isMinerProfileChanged) {
                         NTMinerContext.ExportWorkJson(mineWorkData, out string localJson, out string serverJson);
                         if (!string.IsNullOrEmpty(localJson) && !string.IsNullOrEmpty(serverJson)) {
-                            MinerStudioRoot.MinerStudioService.SaveSelfWorkLocalJsonAsync(_minerClientVm, localJson, serverJson);
+                            MinerStudioService.Instance.SaveSelfWorkLocalJsonAsync(_minerClientVm, localJson, serverJson);
                         }
                         if (mineWorkData.ServerJsonSha1 != this.ServerJsonSha1) {
                             this.ServerJsonSha1 = mineWorkData.ServerJsonSha1;

+ 2 - 2
src/AppModels/MinerStudio/Vms/MinerClientAddViewModel.cs

@@ -41,7 +41,7 @@ namespace NTMiner.MinerStudio.Vms {
                         VirtualRoot.Out.ShowError("没有IP", autoHideSeconds: 4);
                         return;
                     }
-                    ((ILocalMinerStudioService)MinerStudioRoot.MinerStudioService).AddClientsAsync(clientIps, (response, e) => {
+                    ((ILocalMinerStudioService)MinerStudioService.Instance).AddClientsAsync(clientIps, (response, e) => {
                         if (!response.IsSuccess()) {
                             VirtualRoot.Out.ShowError(response.ReadMessage(e));
                         }
@@ -52,7 +52,7 @@ namespace NTMiner.MinerStudio.Vms {
                     });
                 }
                 else {
-                    ((ILocalMinerStudioService)MinerStudioRoot.MinerStudioService).AddClientsAsync(new List<string> { this.LeftIp }, (response, e) => {
+                    ((ILocalMinerStudioService)MinerStudioService.Instance).AddClientsAsync(new List<string> { this.LeftIp }, (response, e) => {
                         if (!response.IsSuccess()) {
                             VirtualRoot.Out.ShowError(response.ReadMessage(e));
                         }

+ 1 - 1
src/AppModels/MinerStudio/Vms/MinerClientSettingViewModel.cs

@@ -26,7 +26,7 @@ namespace NTMiner.MinerStudio.Vms {
             this.Save = new DelegateCommand(() => {
                 if (minerClients != null && minerClients.Length != 0) {
                     foreach (var item in minerClients) {
-                        MinerStudioRoot.MinerStudioService.SetAutoBootStartAsync(item, new SetAutoBootStartRequest {
+                        MinerStudioService.Instance.SetAutoBootStartAsync(item, new SetAutoBootStartRequest {
                             AutoStart = this.IsAutoStart,
                             AutoBoot = this.IsAutoBoot
                         });

+ 10 - 10
src/AppModels/MinerStudio/Vms/MinerClientViewModel.cs

@@ -55,7 +55,7 @@ namespace NTMiner.MinerStudio.Vms {
             this.Remove = new DelegateCommand(() => {
                 #region
                 this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定删除该矿机吗?", title: "确认", onYes: () => {
-                    MinerStudioRoot.MinerStudioService.RemoveClientsAsync(new List<string> { this.Id }, (response, e) => {
+                    MinerStudioService.Instance.RemoveClientsAsync(new List<string> { this.Id }, (response, e) => {
                         if (!response.IsSuccess()) {
                             VirtualRoot.Out.ShowError("删除矿机失败:" + response.ReadMessage(e), autoHideSeconds: 4, toConsole: true);
                         }
@@ -98,22 +98,22 @@ namespace NTMiner.MinerStudio.Vms {
             });
             this.RestartWindows = new DelegateCommand(() => {
                 this.ShowSoftDialog(new DialogWindowViewModel(message: $"您确定重启{this.GetMinerText()}电脑吗?", title: "确认", onYes: () => {
-                    MinerStudioRoot.MinerStudioService.RestartWindowsAsync(this);
+                    MinerStudioService.Instance.RestartWindowsAsync(this);
                 }));
             });
             this.ShutdownWindows = new DelegateCommand(() => {
                 this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定关闭{this.GetMinerText()}电脑吗?", title: "确认", onYes: () => {
-                    MinerStudioRoot.MinerStudioService.ShutdownWindowsAsync(this);
+                    MinerStudioService.Instance.ShutdownWindowsAsync(this);
                 }));
             });
             this.StartMine = new DelegateCommand(() => {
                 this.ShowSoftDialog(new DialogWindowViewModel(message: $"{this.GetMinerText()}:确定开始挖矿吗?", title: "确认", onYes: () => {
-                    MinerStudioRoot.MinerStudioService.StartMineAsync(this, WorkId);
+                    MinerStudioService.Instance.StartMineAsync(this, WorkId);
                 }));
             });
             this.StopMine = new DelegateCommand(() => {
                 this.ShowSoftDialog(new DialogWindowViewModel(message: $"{this.GetMinerText()}:确定停止挖矿吗?", title: "确认", onYes: () => {
-                    MinerStudioRoot.MinerStudioService.StopMineAsync(this);
+                    MinerStudioService.Instance.StopMineAsync(this);
                 }));
             });
         }
@@ -284,7 +284,7 @@ namespace NTMiner.MinerStudio.Vms {
                     var old = _selectedMineWork;
                     this.WorkId = value.Id;
                     _selectedMineWork = value;
-                    MinerStudioRoot.MinerStudioService.UpdateClientAsync(
+                    MinerStudioService.Instance.UpdateClientAsync(
                         this.Id, nameof(WorkId), value.Id, (response, exception) => {
                             if (!response.IsSuccess()) {
                                 _selectedMineWork = old;
@@ -504,7 +504,7 @@ namespace NTMiner.MinerStudio.Vms {
                 if (_data.WorkerName != value) {
                     var old = _data.WorkerName;
                     _data.WorkerName = value;
-                    MinerStudioRoot.MinerStudioService.UpdateClientAsync(this.Id, nameof(WorkerName), value, (response, e) => {
+                    MinerStudioService.Instance.UpdateClientAsync(this.Id, nameof(WorkerName), value, (response, e) => {
                         if (!response.IsSuccess()) {
                             _data.WorkerName = old;
                             VirtualRoot.Out.ShowError($"设置群控名失败:{this.WorkerName} {this.MinerIp} {response.ReadMessage(e)}", toConsole: true);
@@ -572,7 +572,7 @@ namespace NTMiner.MinerStudio.Vms {
                     var old = _selectedMinerGroup;
                     _selectedMinerGroup = value;
                     this.GroupId = value.Id;
-                    MinerStudioRoot.MinerStudioService.UpdateClientAsync(this.Id, nameof(GroupId), value.Id, (response, exception) => {
+                    MinerStudioService.Instance.UpdateClientAsync(this.Id, nameof(GroupId), value.Id, (response, exception) => {
                         if (!response.IsSuccess()) {
                             _selectedMinerGroup = old;
                             this.GroupId = old.Id;
@@ -601,7 +601,7 @@ namespace NTMiner.MinerStudio.Vms {
                 if (_data.WindowsLoginName != value) {
                     var old = _data.WindowsLoginName;
                     _data.WindowsLoginName = value;
-                    MinerStudioRoot.MinerStudioService.UpdateClientAsync(this.Id, nameof(WindowsLoginName), value, (response, exception) => {
+                    MinerStudioService.Instance.UpdateClientAsync(this.Id, nameof(WindowsLoginName), value, (response, exception) => {
                         if (!response.IsSuccess()) {
                             _data.WindowsLoginName = old;
                             VirtualRoot.Out.ShowError($"设置Windows远程登录用户名失败:{this.MinerName} {this.MinerIp} {response.ReadMessage(exception)}", toConsole: true);
@@ -628,7 +628,7 @@ namespace NTMiner.MinerStudio.Vms {
                 if (_data.WindowsPassword != value) {
                     var old = _data.WindowsPassword;
                     _data.WindowsPassword = value;
-                    MinerStudioRoot.MinerStudioService.UpdateClientAsync(this.Id, nameof(WindowsPassword), value, (response, exception) => {
+                    MinerStudioService.Instance.UpdateClientAsync(this.Id, nameof(WindowsPassword), value, (response, exception) => {
                         if (!response.IsSuccess()) {
                             _data.WindowsPassword = old;
                             VirtualRoot.Out.ShowError($"设置Widnows远程登录密码失败:{this.MinerName} {this.MinerIp} {response.ReadMessage(exception)}", toConsole: true);

+ 13 - 13
src/AppModels/MinerStudio/Vms/MinerClientsWindowViewModel.cs

@@ -147,7 +147,7 @@ namespace NTMiner.MinerStudio.Vms {
                     wallet = this.Wallet;
                 }
             }
-            MinerStudioRoot.MinerStudioService.QueryClientsAsync(new QueryClientsRequest {
+            MinerStudioService.Instance.QueryClientsAsync(new QueryClientsRequest {
                 PageIndex = this.PageIndex,
                 PageSize = this.PageSize,
                 WorkId = workId,
@@ -392,7 +392,7 @@ namespace NTMiner.MinerStudio.Vms {
                         namesByObjectId: this.SelectedMinerClients.Select(a => new Tuple<string, string>(a.Id, string.Empty)).ToList(),
                         onOk: () => {
                             this.CountDown = 10;
-                            MinerStudioRoot.MinerStudioService.UpdateClientsAsync(nameof(MinerClientViewModel.WorkerName), vm.NamesByObjectId.ToDictionary(a => a.Item1, a => (object)a.Item2), callback: (response, e) => {
+                            MinerStudioService.Instance.UpdateClientsAsync(nameof(MinerClientViewModel.WorkerName), vm.NamesByObjectId.ToDictionary(a => a.Item1, a => (object)a.Item2), callback: (response, e) => {
                                 if (response.IsSuccess()) {
                                     foreach (var kv in vm.NamesByObjectId) {
                                         var item = this.SelectedMinerClients.FirstOrDefault(a => a.Id == kv.Item1);
@@ -435,7 +435,7 @@ namespace NTMiner.MinerStudio.Vms {
                 else {
                     this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定删除选中的矿机吗?", title: "确认", onYes: () => {
                         this.CountDown = 10;
-                        MinerStudioRoot.MinerStudioService.RemoveClientsAsync(SelectedMinerClients.Select(a => a.Id).ToList(), (response, e) => {
+                        MinerStudioService.Instance.RemoveClientsAsync(SelectedMinerClients.Select(a => a.Id).ToList(), (response, e) => {
                             if (!response.IsSuccess()) {
                                 VirtualRoot.Out.ShowError("删除矿机失败:" + response.ReadMessage(e), autoHideSeconds: 4, toConsole: true);
                             }
@@ -456,7 +456,7 @@ namespace NTMiner.MinerStudio.Vms {
                 else {
                     this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定重启选中的电脑吗?", title: "确认", onYes: () => {
                         foreach (var item in SelectedMinerClients) {
-                            MinerStudioRoot.MinerStudioService.RestartWindowsAsync(item);
+                            MinerStudioService.Instance.RestartWindowsAsync(item);
                         }
                     }));
                 }
@@ -470,7 +470,7 @@ namespace NTMiner.MinerStudio.Vms {
                 else {
                     this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定关闭选中的电脑吗?", title: "确认", onYes: () => {
                         foreach (var item in SelectedMinerClients) {
-                            MinerStudioRoot.MinerStudioService.ShutdownWindowsAsync(item);
+                            MinerStudioService.Instance.ShutdownWindowsAsync(item);
                         }
                     }));
                 }
@@ -485,7 +485,7 @@ namespace NTMiner.MinerStudio.Vms {
                     this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定将选中的矿机开始挖矿吗?", title: "确认", onYes: () => {
                         foreach (var item in SelectedMinerClients) {
                             // 不能直接调用item的StopMine命令,因为该命令内部会有弹窗确认
-                            MinerStudioRoot.MinerStudioService.StartMineAsync(item, item.WorkId);
+                            MinerStudioService.Instance.StartMineAsync(item, item.WorkId);
                         }
                     }));
                 }
@@ -500,7 +500,7 @@ namespace NTMiner.MinerStudio.Vms {
                     this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定将选中的矿机停止挖矿吗?", title: "确认", onYes: () => {
                         foreach (var item in SelectedMinerClients) {
                             // 不能直接调用item的StopMine命令,因为该命令内部会有弹窗确认
-                            MinerStudioRoot.MinerStudioService.StopMineAsync(item);
+                            MinerStudioService.Instance.StopMineAsync(item);
                         }
                     }));
                 }
@@ -517,7 +517,7 @@ namespace NTMiner.MinerStudio.Vms {
                 else {
                     this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定启用选中的矿机的Windows远程桌面功能吗?", title: "确认", onYes: () => {
                         foreach (var item in SelectedMinerClients) {
-                            MinerStudioRoot.MinerStudioService.EnableRemoteDesktopAsync(item);
+                            MinerStudioService.Instance.EnableRemoteDesktopAsync(item);
                         }
                     }));
                 }
@@ -556,7 +556,7 @@ namespace NTMiner.MinerStudio.Vms {
                 else {
                     this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定禁用选中的矿机的Windows自动更新功能吗?", title: "确认", onYes: () => {
                         foreach (var item in SelectedMinerClients) {
-                            MinerStudioRoot.MinerStudioService.BlockWAUAsync(item);
+                            MinerStudioService.Instance.BlockWAUAsync(item);
                         }
                     }));
                 }
@@ -590,7 +590,7 @@ namespace NTMiner.MinerStudio.Vms {
                                 {"Auto", virtualMemoryMb }
                             };
                             foreach (var item in this.SelectedMinerClients) {
-                                MinerStudioRoot.MinerStudioService.SetVirtualMemoryAsync(item, data);
+                                MinerStudioService.Instance.SetVirtualMemoryAsync(item, data);
                             }
                         }
                     });
@@ -614,11 +614,11 @@ namespace NTMiner.MinerStudio.Vms {
                     btnNoToolTip: "注意:关闭计算模式挖矿算力会减半",
                     message: $"过程大概需要花费5到10秒钟,最好矿机没有处在挖矿中否则内核会重启。", title: "确认", onYes: () => {
                         foreach (var item in SelectedMinerClients) {
-                            MinerStudioRoot.MinerStudioService.SwitchRadeonGpuAsync(item, on: true);
+                            MinerStudioService.Instance.SwitchRadeonGpuAsync(item, on: true);
                         }
                     }, onNo: () => {
                         foreach (var item in SelectedMinerClients) {
-                            MinerStudioRoot.MinerStudioService.SwitchRadeonGpuAsync(item, on: false);
+                            MinerStudioService.Instance.SwitchRadeonGpuAsync(item, on: false);
                         }
                         return true;
                     }, btnYesText: "开启计算模式", btnNoText: "关闭计算模式");
@@ -628,7 +628,7 @@ namespace NTMiner.MinerStudio.Vms {
             this.AtikmdagPatcher = new DelegateCommand(() => {
                 this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定对选中的矿机进行A卡驱动签名吗?", title: "确认", onYes: () => {
                     foreach (var item in SelectedMinerClients) {
-                        MinerStudioRoot.MinerStudioService.AtikmdagPatcherAsync(item);
+                        MinerStudioService.Instance.AtikmdagPatcherAsync(item);
                     }
                 }));
             }, IsSelectedAny);

+ 1 - 1
src/AppModels/MinerStudio/Vms/VirtualMemoryViewModel.cs

@@ -21,7 +21,7 @@ namespace NTMiner.MinerStudio.Vms {
         public VirtualMemoryViewModel(MinerClientViewModel minerClientVm) {
             this.MinerClientVm = minerClientVm;
             this.Apply = new DelegateCommand(() => {
-                MinerStudioRoot.MinerStudioService.SetVirtualMemoryAsync(minerClientVm, _drives.ToDictionary(a => a.Name, a => a.VirtualMemoryMaxSizeMb));
+                MinerStudioService.Instance.SetVirtualMemoryAsync(minerClientVm, _drives.ToDictionary(a => a.Name, a => a.VirtualMemoryMaxSizeMb));
                 OnPropertyChanged(nameof(TotalVirtualMemoryMb));
                 OnPropertyChanged(nameof(IsStateChanged));
             });

+ 1 - 1
src/AppViews0/MinerStudio/Views/ChartsWindow.xaml.cs

@@ -51,7 +51,7 @@ namespace NTMiner.MinerStudio.Views {
 
         #region 刷新总算力图表
         private void RefreshTotalSpeedChart(int limit) {
-            MinerStudioRoot.MinerStudioService.GetLatestSnapshotsAsync(
+            MinerStudioService.Instance.GetLatestSnapshotsAsync(
                 limit,
                 (response, exception) => {
                     if (response == null) {

+ 1 - 1
src/AppViews0/MinerStudio/Views/Ucs/GpuProfilesPage.xaml.cs

@@ -66,7 +66,7 @@ namespace NTMiner.MinerStudio.Views.Ucs {
                     }
                     vm.SetData(message.Data);
                 }, typeof(GpuProfilesPage));
-                MinerStudioRoot.MinerStudioService.GetGpuProfilesJsonAsync(minerClientVm);
+                MinerStudioService.Instance.GetGpuProfilesJsonAsync(minerClientVm);
                 return uc;
             }, fixedSize: false);
         }

+ 1 - 1
src/AppViews0/MinerStudio/Views/Ucs/LocalIpConfig.xaml.cs

@@ -29,7 +29,7 @@ namespace NTMiner.MinerStudio.Views.Ucs {
                     }
                     vm.LocalIpVms = message.Data.Select(a => new NTMiner.Vms.LocalIpViewModel(a)).ToList();
                 }, typeof(LocalIpConfig));
-                MinerStudioRoot.MinerStudioService.GetLocalIpsAsync(vm.MinerClientVm);
+                MinerStudioService.Instance.GetLocalIpsAsync(vm.MinerClientVm);
                 return uc;
             }, fixedSize: true);
         }

+ 1 - 1
src/AppViews0/MinerStudio/Views/Ucs/MinerClientsToolBar.xaml.cs

@@ -103,7 +103,7 @@ namespace NTMiner.MinerStudio.Views.Ucs {
                     }
                     DialogWindow.ShowSoftDialog(new DialogWindowViewModel(message: selectedResult.Description, title: $"确定将选中的矿机升级到{selectedResult.Version}吗?", onYes: () => {
                         foreach (var item in Vm.SelectedMinerClients) {
-                            MinerStudioRoot.MinerStudioService.UpgradeNTMinerAsync(item, selectedResult.FileName);
+                            MinerStudioService.Instance.UpgradeNTMinerAsync(item, selectedResult.FileName);
                         }
                     }));
                     popup.IsOpen = false;

+ 1 - 1
src/AppViews0/MinerStudio/Views/Ucs/VirtualMemory.xaml.cs

@@ -20,7 +20,7 @@ namespace NTMiner.MinerStudio.Views.Ucs {
                 IsMaskTheParent = true,
                 FooterVisible = Visibility.Collapsed
             }, ucFactory: (window) => {
-                MinerStudioRoot.MinerStudioService.GetDrivesAsync(vm.MinerClientVm);
+                MinerStudioService.Instance.GetDrivesAsync(vm.MinerClientVm);
                 window.AddEventPath<GetDrivesResponsedEvent>("收到了GetDrives的响应时绑定到界面", LogEnum.DevConsole, action: message => {
                     if (message.ClientId != vm.MinerClientVm.ClientId) {
                         return;

+ 1 - 5
src/MinerStudio/App.xaml.cs

@@ -43,11 +43,7 @@ namespace NTMiner {
                 NotiCenterWindow.ShowWindow();
                 AppRoot.RemoteDesktop = MsRdpRemoteDesktop.OpenRemoteDesktop;
                 LoginWindow.Login(() => {
-                    IWsClient wsClient = null;
-                    if (RpcRoot.IsOuterNet) {
-                        wsClient = new MinerStudioWsClient();
-                    }
-                    MinerStudioRoot.Init(wsClient);
+                    MinerStudioRoot.Init(new MinerStudioWsClient());
                     NTMinerContext.Instance.Init(() => {
                         _appViewFactory.Link();
                         UIThread.Execute(() => {