Ver código fonte

Merge branch 'master' of http://139.155.15.221:3000/zoulei/XdCxRhDW54

wyq 10 meses atrás
pai
commit
d5f166ee2b

+ 33 - 1
Service/CheckServer/MainForm.cs

@@ -132,6 +132,7 @@ namespace CheckServer
             });
             bool preSucceed = false;
             long id = 0;
+            _ = ClearLocalFile();
             while (!this.Disposing)
             {
                 try
@@ -218,7 +219,38 @@ namespace CheckServer
                 await Task.Delay(6000);
             }
         }
-
+        //清理10分钟之前的文件
+        private async Task ClearLocalFile()
+        {
+            while (true)
+            {
+                try
+                {
+                    var uploadFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot");
+                    var files = Directory.EnumerateFiles(uploadFolder);
+                    foreach (var file in files)
+                    {
+                        FileInfo info = new FileInfo(file);
+                        if (info.CreationTime < DateTime.Now.AddMinutes(-10))
+                        {
+                            try
+                            {
+                                info.Delete();
+                            }
+                            catch (Exception ex)
+                            {
+                                await LogHelper.Error("清理wwwroot历史文件异常", ex);
+                            }
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    await LogHelper.Error("清理wwwroot历史文件异常", ex);
+                }
+                await Task.Delay(60 * 1000);
+            }
+        }
         private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
         {
             try

+ 1 - 1
Service/ClearServiceData/Program.cs

@@ -28,7 +28,7 @@ namespace ClearServiceData
             var dir4 = Directory.GetDirectories(".\\", "*tmp", SearchOption.AllDirectories);
             var dir5 = Directory.GetDirectories(".\\", "*Logs", SearchOption.AllDirectories);
             var dir6 = Directory.GetDirectories(".\\", "*wwwroot", SearchOption.AllDirectories);
-            var dir7 = Directory.GetDirectories(".\\", "*信号仿真", SearchOption.AllDirectories);
+            var dir7 = Directory.GetDirectories(".\\", "*信号仿真", SearchOption.TopDirectoryOnly);
             var dirs = dir1.Concat(dir2).Concat(dir3).Concat(dir4).Concat(dir5).Concat(dir6).Concat(dir7);
             foreach (var dir in dirs)
             {

+ 33 - 1
Service/CpuCgServer/MainForm.cs

@@ -34,7 +34,38 @@ namespace CpuCgServer
                 { }
             };
         }
-
+        //清理10分钟之前的文件
+        private async Task ClearLocalFile()
+        {
+            while (true)
+            {
+                try
+                {
+                    var uploadFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot");
+                    var files = Directory.EnumerateFiles(uploadFolder);
+                    foreach (var file in files)
+                    {
+                        FileInfo info = new FileInfo(file);
+                        if (info.CreationTime < DateTime.Now.AddMinutes(-10))
+                        {
+                            try
+                            {
+                                info.Delete();
+                            }
+                            catch (Exception ex)
+                            {
+                                await LogHelper.Error("清理wwwroot历史文件异常", ex);
+                            }
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    await LogHelper.Error("清理wwwroot历史文件异常", ex);
+                }
+                await Task.Delay(60 * 1000);
+            }
+        }
         private async void MainForm_LoadAsync(object sender, EventArgs e)
         {
             if (Debugger.IsAttached)//结束已启动的进程,方便调试
@@ -132,6 +163,7 @@ namespace CpuCgServer
             });
             bool preSucceed = false;
             long id = 0;
+            _=ClearLocalFile();
             while (!this.Disposing)
             {
                 try

+ 33 - 1
Service/GpuCgServer/MainForm.cs

@@ -34,7 +34,38 @@ namespace GpuCgServer
                 { }
             };
         }
-
+        //清理10分钟之前的文件
+        private async Task ClearLocalFile()
+        {
+            while (true)
+            {
+                try
+                {
+                    var uploadFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot");
+                    var files = Directory.EnumerateFiles(uploadFolder);
+                    foreach (var file in files)
+                    {
+                        FileInfo info = new FileInfo(file);
+                        if (info.CreationTime < DateTime.Now.AddMinutes(-10))
+                        {
+                            try
+                            {
+                                info.Delete();
+                            }
+                            catch (Exception ex)
+                            {
+                                await LogHelper.Error("清理wwwroot历史文件异常", ex);
+                            }
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    await LogHelper.Error("清理wwwroot历史文件异常", ex);
+                }
+                await Task.Delay(60 * 1000);
+            }
+        }
         private async void MainForm_LoadAsync(object sender, EventArgs e)
         {
             if (Debugger.IsAttached)//结束已启动的进程,方便调试
@@ -132,6 +163,7 @@ namespace GpuCgServer
             });
             bool preSucceed = false;
             long id = 0;
+            _ = ClearLocalFile();
             while (!this.Disposing)
             {
                 try

+ 29 - 5
Service/X1LeoTaskServer54/Service/TaskService.cs

@@ -398,11 +398,35 @@ namespace X1LeoTaskServer54.Service
         {
             await LogHelper.Info($"【获取一星配置信息");
             LeoSat1AppSettingDto settingDto = new LeoSat1AppSettingDto();
-            settingDto.CapDir = ConfigurationManager.AppSettings["CapDir"].Trim();
-            settingDto.Time1SatInfo = ConfigurationManager.AppSettings["Time1SatInfo"].Replace(",", ",").Trim();
-            settingDto.Time2SatInfo = ConfigurationManager.AppSettings["Time2SatInfo"].Replace(",", ",").Trim();
-            settingDto.Time3SatInfo = ConfigurationManager.AppSettings["Time3SatInfo"].Replace(",", ",").Trim();
-            return settingDto;
+            try
+            {
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["CapDir"]))
+                {
+                    throw new Exception($"未配置采集数据目录");
+                }
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["Time1SatInfo"]))
+                {
+                    throw new Exception($"未配置卫星及星历Time1SatInfo");
+                }
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["Time2SatInfo"]))
+                {
+                    throw new Exception($"未配置卫星及星历Time2SatInfo");
+                }
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["Time3SatInfo"]))
+                {
+                    throw new Exception($"未配置卫星及星历Time3SatInfo");
+                }
+                settingDto.CapDir = ConfigurationManager.AppSettings["CapDir"].Trim();
+                settingDto.Time1SatInfo = ConfigurationManager.AppSettings["Time1SatInfo"].Replace(",", ",").Trim();
+                settingDto.Time2SatInfo = ConfigurationManager.AppSettings["Time2SatInfo"].Replace(",", ",").Trim();
+                settingDto.Time3SatInfo = ConfigurationManager.AppSettings["Time3SatInfo"].Replace(",", ",").Trim();
+                return settingDto;
+            }
+            catch (Exception ex)
+            {
+                await LogHelper.Error($"【获取一星配置信息】异常:{ex.Message}");
+                throw new Exception($"【获取一星配置信息】异常:{ex.Message}");
+            }
         }
 
         private AdFile StringToAdFile(string file)

+ 22 - 5
Service/X2LeoTaskServer54/Service/TaskService.cs

@@ -482,18 +482,35 @@ namespace X2LeoTaskServer54.Service
             try
             {
                 await LogHelper.Info($"【获取两星配置信息");
-                var RefFreqDownMHzstr = ConfigurationManager.AppSettings["RefFreqDownMHz"].Trim();
-                RefFreqDownMHz = Convert.ToDouble(RefFreqDownMHzstr);
-               
+                var RefFreqDownMHzstr = ConfigurationManager.AppSettings["RefFreqDownMHz"];
+                if (string.IsNullOrWhiteSpace(RefFreqDownMHzstr))
+                {
+                    throw new Exception($"未配置参考下行频点");
+                }
+                double.TryParse(RefFreqDownMHzstr.Trim(), out RefFreqDownMHz);
+
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["CapDir"]))
+                {
+                    throw new Exception($"未配置采集数据目录");
+                }
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["MainSatInfo"]))
+                {
+                    throw new Exception($"未配置卫星及星历MainSatInfo");
+                }
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["Adja1SatInfo"]))
+                {
+                    throw new Exception($"未配置卫星及星历Adja1SatInfo");
+                }
                 settingDto.CapDir = ConfigurationManager.AppSettings["CapDir"].Trim();
                 settingDto.MainSatInfo = ConfigurationManager.AppSettings["MainSatInfo"].Replace(",", ",").Trim();
                 settingDto.Adja1SatInfo = ConfigurationManager.AppSettings["Adja1SatInfo"].Replace(",", ",").Trim();
                 settingDto.RefFreqDownMHz = RefFreqDownMHz;
                 return settingDto;
             }
-            catch
+            catch (Exception ex)
             {
-                return settingDto;
+                await LogHelper.Error($"【获取两星配置信息】异常:{ex.Message}");
+                throw new Exception($"【获取两星配置信息】异常:{ex.Message}");
             }
         }
 

+ 30 - 5
Service/X3LeoTaskServer54/Service/TaskService.cs

@@ -394,11 +394,36 @@ namespace X3LeoTaskServer54.Service
         {
             await LogHelper.Info($"【获取三星配置信息");
             LeoSat3AppSettingDto settingDto = new LeoSat3AppSettingDto();
-            settingDto.CapDir = ConfigurationManager.AppSettings["CapDir"].Trim();
-            settingDto.MainSatInfo = ConfigurationManager.AppSettings["MainSatInfo"].Replace(",", ",").Trim();
-            settingDto.Adja1SatInfo = ConfigurationManager.AppSettings["Adja1SatInfo"].Replace(",", ",").Trim();
-            settingDto.Adja2SatInfo = ConfigurationManager.AppSettings["Adja2SatInfo"].Replace(",", ",").Trim(); ;
-            return settingDto;
+            try
+            {
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["CapDir"]))
+                {
+                    throw new Exception($"未配置采集数据目录");
+                }
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["MainSatInfo"]))
+                {
+                    throw new Exception($"未配置卫星及星历MainSatInfo");
+                }
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["Adja1SatInfo"]))
+                {
+                    throw new Exception($"未配置卫星及星历Adja1SatInfo");
+                }
+                if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["Adja2SatInfo"]))
+                {
+                    throw new Exception($"未配置卫星及星历Adja2SatInfo");
+                }
+                settingDto.CapDir = ConfigurationManager.AppSettings["CapDir"].Trim();
+                settingDto.MainSatInfo = ConfigurationManager.AppSettings["MainSatInfo"].Replace(",", ",").Trim();
+                settingDto.Adja1SatInfo = ConfigurationManager.AppSettings["Adja1SatInfo"].Replace(",", ",").Trim();
+                settingDto.Adja2SatInfo = ConfigurationManager.AppSettings["Adja2SatInfo"].Replace(",", ",").Trim(); ;
+                return settingDto;
+            }
+            catch (Exception ex)
+            {
+                await LogHelper.Error($"【获取三星配置信息】异常:{ex.Message}");
+                throw new Exception($"【获取三星配置信息】异常:{ex.Message}");
+            }
+        
         }
 
         private AdFile StringToAdFile(string file)

+ 1 - 2
XdCxRhDW.App/EditForms/TarDfoLeoX2Calc.cs

@@ -122,9 +122,8 @@ namespace XdCxRhDW.App.EditForms
                 }
 
             }
-            catch (Exception)
+            catch (Exception )
             {
-
             }
 
 

+ 2 - 1
XdCxRhDW.App/MainForm.cs

@@ -350,8 +350,9 @@ namespace XdCxRhDW
                             {
                                 info.Delete();
                             }
-                            catch
+                            catch(Exception ex)
                             {
+                                await LogHelper.Error("清理wwwroot历史文件异常", ex);
                             }
                         }
                     }