Browse Source

添加日志记录

jiangjy 1 week ago
parent
commit
1243f97b49
1 changed files with 45 additions and 39 deletions
  1. 45 39
      FrameworkLocal/Common/RecipeCenter/RecipeFileManager.cs

+ 45 - 39
FrameworkLocal/Common/RecipeCenter/RecipeFileManager.cs

@@ -62,50 +62,56 @@ namespace Aitex.Core.RT.RecipeCenter
         }
         public void CheckFile()
         {
-            if (!SC.ContainsItem("System.EnableCheckRecipe") || !SC.GetValue<bool>("System.EnableCheckRecipe"))
-            {
-                return;
-            }
-            string recipePath = PathManager.GetRecipeDir() + SC.GetStringValue("System.Recipe.SupportedChamberType") + "\\";
-            var di = new DirectoryInfo(recipePath);
-            if (!Directory.Exists(recipePath))
-            {
-                return;
-            }
-            var fis = di.GetFiles("*.rcp", System.IO.SearchOption.TopDirectoryOnly);
-            if (fis.Length > 0)
-            {
-
-            }
-            else
+            try
             {
+                if (!SC.ContainsItem("System.EnableCheckRecipe") || !SC.GetValue<bool>("System.EnableCheckRecipe"))
+                {
+                    return;
+                }
+                string recipePath = PathManager.GetRecipeDir() + SC.GetStringValue("System.Recipe.SupportedChamberType") + "\\";
+                var di = new DirectoryInfo(recipePath); if (!Directory.Exists(recipePath))
+                {
+                    return;
+                }
+                var fis = di.GetFiles("*.rcp", System.IO.SearchOption.TopDirectoryOnly);
+                if (fis.Length > 0)
+                {
 
-                foreach (var item in di.GetDirectories())
+                }
+                else
                 {
-                    var recipeFolderRecipe = item.GetFiles("*.rcp", System.IO.SearchOption.TopDirectoryOnly);
-                    if (recipeFolderRecipe.Length > 0)
+
+                    foreach (var item in di.GetDirectories())
                     {
-                        var defaultFolder = $"{item.FullName}\\default";
-                        if (!Directory.Exists(defaultFolder))
+                        var recipeFolderRecipe = item.GetFiles("*.rcp", System.IO.SearchOption.TopDirectoryOnly);
+                        if (recipeFolderRecipe.Length > 0)
                         {
-                            Directory.CreateDirectory(defaultFolder);
-                        }
+                            var defaultFolder = $"{item.FullName}\\default";
+                            if (!Directory.Exists(defaultFolder))
+                            {
+                                Directory.CreateDirectory(defaultFolder);
+                            }
 
-                        var diDefault = new DirectoryInfo(defaultFolder);
-                        foreach (var errorRecipe in recipeFolderRecipe)
-                        {  // 构建目标文件的完整路径
-                            string destinationPath = Path.Combine(defaultFolder, Path.GetFileName(errorRecipe.FullName));
+                            var diDefault = new DirectoryInfo(defaultFolder);
+                            foreach (var errorRecipe in recipeFolderRecipe)
+                            {  // 构建目标文件的完整路径
+                                string destinationPath = Path.Combine(defaultFolder, Path.GetFileName(errorRecipe.FullName));
+
+                                errorRecipe.CopyTo(destinationPath);
+                                errorRecipe.Delete();
+                            }
 
-                            errorRecipe.CopyTo(destinationPath);
-                            errorRecipe.Delete();
                         }
 
                     }
-
                 }
             }
-
+            catch (Exception ex)
+            {
+                LOG.Error($"CheckFile:{ex.Message}");
+            }
         }
+
         public void Initialize(IRecipeFileContext rcpContext, ISequenceFileContext seqContext, bool enableService)
         {
             _rcpContext = rcpContext == null ? new DefaultRecipeFileContext() : rcpContext;
@@ -1231,9 +1237,9 @@ namespace Aitex.Core.RT.RecipeCenter
                                                 }
                                                 if (strModuleName == "COT")
                                                 {
-                                                    string subCotPath = GenerateRecipeFilePath($"{ _chamberId}\\{strModuleName}", subRecipeName);
+                                                    string subCotPath = GenerateRecipeFilePath($"{_chamberId}\\{strModuleName}", subRecipeName);
                                                     var subXmlRecipe = new XmlDocument();
-                                                    string subRecipeContent = LoadRecipe($"{ _chamberId}\\{strModuleName}", subRecipeName, false);
+                                                    string subRecipeContent = LoadRecipe($"{_chamberId}\\{strModuleName}", subRecipeName, false);
                                                     if (string.IsNullOrEmpty(subRecipeContent))
                                                         continue;
                                                     subXmlRecipe.LoadXml(subRecipeContent);
@@ -1729,9 +1735,9 @@ namespace Aitex.Core.RT.RecipeCenter
                                             }
                                             if (strModuleName == "COT")
                                             {
-                                                string subCotPath = GenerateBackupRecipeFilePath($"{ _chamberId}\\{strModuleName}", subRecipeName);
+                                                string subCotPath = GenerateBackupRecipeFilePath($"{_chamberId}\\{strModuleName}", subRecipeName);
                                                 var subXmlRecipe = new XmlDocument();
-                                                string subRecipeContent = LoadRecipe($"{ _chamberId}\\{strModuleName}", subRecipeName, false);
+                                                string subRecipeContent = LoadRecipe($"{_chamberId}\\{strModuleName}", subRecipeName, false);
                                                 if (string.IsNullOrEmpty(subRecipeContent))
                                                     continue;
                                                 subXmlRecipe.LoadXml(subRecipeContent);
@@ -2255,7 +2261,7 @@ namespace Aitex.Core.RT.RecipeCenter
             {
                 string oldPath = getRecipeDirPath(chamId) + oldName;
                 string newPath = getRecipeDirPath(chamId) + newName;
-              
+
                 Directory.Move(oldPath, newPath);
                 EventInfo(string.Format(Resources.RecipeFileManager_RenameFolder_RecipeFolder0renamed, oldName, newName));
             }
@@ -4569,7 +4575,7 @@ namespace Aitex.Core.RT.RecipeCenter
                 subFileNodeItem.FullPath = fullStr;// $"{chamberId}\\{dirInfo.Name}";
                 nodeItem.Files.Add(subFileNodeItem);
                 GenerateFileNodeParameterList(chamberId, dirInfo, subFileNodeItem);
-               
+
             }
             FileInfo[] fileInfos = currentDir.GetFiles("*.rcp");
             foreach (FileInfo fileInfo in fileInfos)
@@ -4577,7 +4583,7 @@ namespace Aitex.Core.RT.RecipeCenter
                 string fileStr = fileInfo.FullName.Substring(trimLength).TrimStart(new char[] { '\\' }); ;
                 FileNodeItem subNodeItem = new FileNodeItem();
                 subNodeItem.Name = fileInfo.Name.Replace(".rcp", "");
-                if (!string.IsNullOrEmpty(currentDir.Name) && (currentDir.FullName.IndexOf(chamberId)+ chamberId.Length + 1 != currentDir.FullName.Length))
+                if (!string.IsNullOrEmpty(currentDir.Name) && (currentDir.FullName.IndexOf(chamberId) + chamberId.Length + 1 != currentDir.FullName.Length))
                 {
                     subNodeItem.FullPath = $"{currentDir.Name}\\{subNodeItem.Name}";
                 }
@@ -4667,7 +4673,7 @@ namespace Aitex.Core.RT.RecipeCenter
         private void ReadFileSetFileNode(string chamberId, string fileName, FileNodeItem fileNodeItem)
         {
             string content = LoadRecipe(chamberId, fileName, false);
-            if ( string.IsNullOrEmpty(content)) { return; }
+            if (string.IsNullOrEmpty(content)) { return; }
             XmlDocument _doc = new XmlDocument();
             _doc.LoadXml(content);
             XmlElement nodeData = _doc.SelectSingleNode($"Aitex/TableRecipeData") as XmlElement;