diff --git a/CRC.config b/CRC.config index 3b6dc41c9acba26367171fbfd70d7ac68b386a05..3e6063c638a2d9ea4d40f23584393b9d43644288 100644 --- a/CRC.config +++ b/CRC.config @@ -4,4 +4,4 @@ MongoDBData MongoDB/data NodejsPath GeoModelServiceContainer/container_node.exe ContainerPath 1 Containerlog log/containerlog.log -CheckVersionURL http://localhost:8084/GeoModeling/modelContainer \ No newline at end of file +CheckVersionURL http://222.192.7.75:8084/GeoModeling/modelContainer \ No newline at end of file diff --git a/ComputerResourceConsole.suo b/ComputerResourceConsole.suo index c5031b01acc388bdbedbde8761c983b0c824a137..8e4c1dd9b918742efdffbc26efbf9fab36b4e06d 100644 Binary files a/ComputerResourceConsole.suo and b/ComputerResourceConsole.suo differ diff --git a/common/CommonMethod.cs b/common/CommonMethod.cs index 46c947bb46f3767a4437494367c472bffbfaf7bb..bcc0ae14f52f5ecd25207225d03f3e0ea99cb642 100644 --- a/common/CommonMethod.cs +++ b/common/CommonMethod.cs @@ -27,12 +27,25 @@ namespace ComputerResourceConsole.common if (File.Exists(fileName)) { File.Delete(fileName); + Stream s = File.Create(fileName); + s.Close(); + return true; + } + else + { + FileInfo file = new FileInfo(fileName); + DirectoryInfo direct_info = file.Directory; + string directory = direct_info.FullName; + if (!Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + Stream s = File.Create(fileName); + s.Close(); + return true; } - Stream s = File.Create(fileName); - s.Close(); - return true; } - catch (Exception ex) + catch (Exception e) { return false; } diff --git a/view/frm_update.cs b/view/frm_update.cs index 303b496375c60d6522ef99de05d4627bd9c4c832..e5b4b788d3bf8991b334c5b0f15c73e7c8c1687a 100644 --- a/view/frm_update.cs +++ b/view/frm_update.cs @@ -50,9 +50,12 @@ namespace ComputerResourceConsole.view string downloadUrl = this._pConfig.VersionCheckPath + "/downloadNewest"; string filePath = fileDirectory + "\\temp\\" + "container_node.exe"; - DownloadFile(downloadUrl, filePath, this.progressBar1); + bool status = DownloadFile(downloadUrl, filePath, this.progressBar1); //下载完成之后,替换文件 - CopyFileAndReplace(filePath, originPath); + if (status) + { + CopyFileAndReplace(filePath, originPath); + } } else { @@ -67,7 +70,7 @@ namespace ComputerResourceConsole.view this.Close(); } - private void DownloadFile(string url, string filePath, System.Windows.Forms.ProgressBar progress) + private bool DownloadFile(string url, string filePath, System.Windows.Forms.ProgressBar progress) { try { @@ -97,6 +100,7 @@ namespace ComputerResourceConsole.view } so.Close(); st.Close(); + return true; } else @@ -106,6 +110,7 @@ namespace ComputerResourceConsole.view this.Cancel.Enabled = true; this.progressBar1.Visible = false; this.splitContainer1.Panel2.Enabled = false; + return false; } } @@ -116,6 +121,7 @@ namespace ComputerResourceConsole.view this.Cancel.Enabled = true; this.progressBar1.Visible = false; this.splitContainer1.Panel2.Enabled = false; + return false; } } @@ -136,7 +142,7 @@ namespace ComputerResourceConsole.view { File.Delete(destPath); File.Move(fromPath, destPath); - MessageBox.Show("Update Application finished! Please start the Model container", "Update Finish", MessageBoxButtons.OK, MessageBoxIcon.None); + MessageBox.Show("Update Application finished! Please start the Model container!", "Update Finish", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } diff --git a/view/frm_version.cs b/view/frm_version.cs index f24bd441d00fa3efc5df2fe5546a0560ae34cfb3..1fe7010af7f24775a8409781f753020b75720599 100644 --- a/view/frm_version.cs +++ b/view/frm_version.cs @@ -53,6 +53,12 @@ namespace ComputerResourceConsole.view String path_exe = this._pConfig.NodejsPath; String test_Path = CommonMethod.getAppDirection() + path_exe; Console.WriteLine(test_Path); + if (!File.Exists(test_Path)) + { + //文件不存在表明没有模型服务容器exe,为了使后面不报错,返回版本号为0.0.1 + MessageBox.Show("Can not find the current model container application", "System Attention", MessageBoxButtons.OK, MessageBoxIcon.Error); + return "0.0.1"; + } try { Process process = new Process(); @@ -143,7 +149,7 @@ namespace ComputerResourceConsole.view this._frm_update = new frm_update(); this._frm_update.Show(); - this.Close(); + //this.Close(); } } else