|
@@ -596,6 +596,17 @@ namespace Aitex.Core.RT.RecipeCenter
|
|
|
return SaveRecipe(chamId, recipeName, recipeContent, true, true);
|
|
|
}
|
|
|
|
|
|
+ public bool SaveAsRecipe2(string chamId,string type, string recipeName, string recipeContent)
|
|
|
+ {
|
|
|
+ var path = GenerateRecipeFilePath(chamId, recipeName);
|
|
|
+ //if (File.Exists(path))
|
|
|
+ //{
|
|
|
+ // WarningDialog(string.Format(Resources.RecipeFileManager_SaveAsRecipe_RecipeFile0savefailed, recipeName));
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
+ return SaveRecipe2(chamId,type, recipeName, recipeContent, true, true);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// save recipe content
|
|
|
/// </summary>
|
|
@@ -605,17 +616,6 @@ namespace Aitex.Core.RT.RecipeCenter
|
|
|
/// <returns></returns>
|
|
|
public bool SaveRecipe(string chamId, string recipeName, string recipeContent, bool clearBarcode, bool notifyUI)
|
|
|
{
|
|
|
- //validate recipe format when saving a recipe file
|
|
|
- //var reasons1 = new List<string>();
|
|
|
- //var reasons2 = new List<string>();
|
|
|
- //ValidateRecipe(chamId, recipeName, recipeContent, out reasons1);
|
|
|
- //CheckRecipe(chamId, recipeContent, out reasons2);
|
|
|
- //reasons1.AddRange(reasons2);
|
|
|
- //if (reasons1.Count > 0)
|
|
|
- //{
|
|
|
- // EventDialog(string.Format( Resources.RecipeFileManager_SaveRecipe_SaveRecipeContentError, recipeName), reasons1);
|
|
|
- //}
|
|
|
-
|
|
|
bool ret = true;
|
|
|
try
|
|
|
{
|
|
@@ -630,22 +630,42 @@ namespace Aitex.Core.RT.RecipeCenter
|
|
|
|
|
|
File.WriteAllText(path, RecipeUnity.ConvertJsonString(recipeContent), Encoding.UTF8);
|
|
|
|
|
|
- //XmlDocument xml = new XmlDocument();
|
|
|
- //xml.LoadXml(recipeContent);
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LOG.WriteExeption("保存recipe file 出错", ex);
|
|
|
+
|
|
|
+ if (notifyUI)
|
|
|
+ {
|
|
|
+ WarningDialog(string.Format(Resources.RecipeFileManager_SaveRecipe_RecipeFile0SaveFailed, recipeName));
|
|
|
+ }
|
|
|
+ ret = false;
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// save recipe content
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="chamId"></param>
|
|
|
+ /// <param name="recipeName"></param>
|
|
|
+ /// <param name="recipeContent"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public bool SaveRecipe2(string chamId,string type, string recipeName, string recipeContent, bool clearBarcode, bool notifyUI)
|
|
|
+ {
|
|
|
+ bool ret = true;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var path = GenerateRecipeFilePath(chamId, recipeName);
|
|
|
+
|
|
|
+ if (!_rcpContext.EnableEdit(path))
|
|
|
+ return false;
|
|
|
|
|
|
- //XmlTextWriter writer = new XmlTextWriter(path, null);
|
|
|
- //writer.Formatting = Formatting.Indented;
|
|
|
- //xml.Save(writer);
|
|
|
- //writer.Close();
|
|
|
+ FileInfo fi = new FileInfo(path);
|
|
|
+ if (!fi.Directory.Exists)
|
|
|
+ fi.Directory.Create();
|
|
|
+
|
|
|
+ File.WriteAllText(path, RecipeUnity.ConvertJsonString(recipeContent), Encoding.UTF8);
|
|
|
|
|
|
- //if (notifyUI)
|
|
|
- //{
|
|
|
- // InfoDialog(string.Format(Resources.RecipeFileManager_SaveRecipe_RecipeFile0SaveCompleted, recipeName));
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // EV.PostMessage("System", EventEnum.GeneralInfo, string.Format(Resources.RecipeFileManager_SaveRecipe_RecipeFile0SaveCompleted, recipeName));
|
|
|
- //}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -660,7 +680,6 @@ namespace Aitex.Core.RT.RecipeCenter
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// move recipe file
|
|
|
/// </summary>
|