ntminer 5 years ago
parent
commit
9b0a951355

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

@@ -81,7 +81,7 @@ namespace NTMiner.MinerStudio.Vms {
         }
 
         private void DoEdit(FormType? formType) {
-            if (!MinerStudioRoot.MineWorkVms.TryGetMineWorkVm(this.Id, out MineWorkViewModel mineWorkVm)) {
+            if (!MinerStudioRoot.MineWorkVms.TryGetMineWorkVm(this.Id, out MineWorkViewModel mineWorkVm) || this.Id == MineWorkData.SelfMineWorkId) {
                 WpfUtil.ShowInputDialog("作业名称", string.Empty, string.Empty, workName => {
                     if (string.IsNullOrEmpty(workName)) {
                         return "作业名称是必须的";
@@ -93,17 +93,17 @@ namespace NTMiner.MinerStudio.Vms {
             }
             else {
                 _minerClientVm = MinerStudioRoot.MinerClientsWindowVm.SelectedMinerClients.FirstOrDefault();
+                if (_minerClientVm == null) {
+                    VirtualRoot.Out.ShowError("未选中矿机", autoHideSeconds: 4);
+                    return;
+                }
                 if (this.Id == MineWorkData.SelfMineWorkId) {
-                    if (_minerClientVm == null) {
-                        VirtualRoot.Out.ShowError("未选中矿机", autoHideSeconds: 4);
-                        return;
-                    }
-                    if (!_minerClientVm.IsOuterUserEnabled) {
-                        VirtualRoot.Out.ShowError("无法操作,因为选中的矿机未开启外网群控。", autoHideSeconds: 6);
-                        return;
-                    }
                     SelfMineWork.Description = $"{_minerClientVm.GetMinerOrClientName()} 矿机的单机作业";
                     if (RpcRoot.IsOuterNet) {
+                        if (!_minerClientVm.IsOuterUserEnabled) {
+                            VirtualRoot.Out.ShowError("无法操作,因为选中的矿机未开启外网群控。", autoHideSeconds: 6);
+                            return;
+                        }
                         VirtualRoot.AddOnecePath<GetSelfWorkLocalJsonResponsedEvent>("获取到响应结果后填充Vm内存", LogEnum.DevConsole, action: message => {
                             if (message.ClientId == _minerClientVm.ClientId) {
                                 string data = message.Data;

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

@@ -97,22 +97,22 @@ namespace NTMiner.MinerStudio.Vms {
                 #endregion
             });
             this.RestartWindows = new DelegateCommand(() => {
-                this.ShowSoftDialog(new DialogWindowViewModel(message: $"您确定重启{this.MinerName}({this.MinerIp})电脑吗?", title: "确认", onYes: () => {
+                this.ShowSoftDialog(new DialogWindowViewModel(message: $"您确定重启{this.GetMinerText()}电脑吗?", title: "确认", onYes: () => {
                     MinerStudioRoot.MinerStudioService.RestartWindowsAsync(this);
                 }));
             });
             this.ShutdownWindows = new DelegateCommand(() => {
-                this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定关闭{this.MinerName}({this.MinerIp})电脑吗?", title: "确认", onYes: () => {
+                this.ShowSoftDialog(new DialogWindowViewModel(message: $"确定关闭{this.GetMinerText()}电脑吗?", title: "确认", onYes: () => {
                     MinerStudioRoot.MinerStudioService.ShutdownWindowsAsync(this);
                 }));
             });
             this.StartMine = new DelegateCommand(() => {
-                this.ShowSoftDialog(new DialogWindowViewModel(message: $"{this.MinerName}({this.MinerIp}):确定开始挖矿吗?", title: "确认", onYes: () => {
+                this.ShowSoftDialog(new DialogWindowViewModel(message: $"{this.GetMinerText()}:确定开始挖矿吗?", title: "确认", onYes: () => {
                     MinerStudioRoot.MinerStudioService.StartMineAsync(this, WorkId);
                 }));
             });
             this.StopMine = new DelegateCommand(() => {
-                this.ShowSoftDialog(new DialogWindowViewModel(message: $"{this.MinerName}({this.MinerIp}):确定停止挖矿吗?", title: "确认", onYes: () => {
+                this.ShowSoftDialog(new DialogWindowViewModel(message: $"{this.GetMinerText()}:确定停止挖矿吗?", title: "确认", onYes: () => {
                     MinerStudioRoot.MinerStudioService.StopMineAsync(this);
                 }));
             });

+ 7 - 0
src/NTMinerDataSchemas/Core/MinerServer/MinerDataExtensions.cs

@@ -0,0 +1,7 @@
+namespace NTMiner.Core.MinerServer {
+    public static class MinerDataExtensions {
+        public static string GetMinerText(this IMinerData minerData) {
+            return $"{minerData.MinerName}({minerData.MinerIp})";
+        }
+    }
+}

+ 1 - 0
src/NTMinerDataSchemas/NTMinerDataSchemas.csproj

@@ -53,6 +53,7 @@
     <Compile Include="Core\MinerServer\GetWorkJsonResponse.cs" />
     <Compile Include="Core\MinerServer\IClientData.cs" />
     <Compile Include="Core\MinerServer\IMinerSign.cs" />
+    <Compile Include="Core\MinerServer\MinerDataExtensions.cs" />
     <Compile Include="Core\MinerServer\MinerSign.cs" />
     <Compile Include="Core\Profile\IProfile.cs" />
     <Compile Include="DataSchemaIdAttribute.cs" />