VirgoSequenceFileContext.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml;
  7. using Aitex.Common.Util;
  8. using Aitex.Core.RT.Event;
  9. using Aitex.Core.RT.Log;
  10. using Aitex.Core.Util;
  11. using MECF.Framework.Common.RecipeCenter;
  12. namespace VirgoRT.Modules.PMs
  13. {
  14. public class VirgoSequenceFileContext : ISequenceFileContext
  15. {
  16. public string GetConfigXml()
  17. {
  18. try
  19. {
  20. string configContent = PathManager.GetCfgDir() + @"\SequenceFormat.xml";
  21. XmlDocument xmlDom = new XmlDocument();
  22. xmlDom.Load(configContent);
  23. CustomSequenceItem(xmlDom);
  24. return xmlDom.OuterXml;
  25. }
  26. catch (Exception ex)
  27. {
  28. LOG.Write(ex);
  29. return "";
  30. }
  31. }
  32. public virtual bool Validation(string content)
  33. {
  34. try
  35. {
  36. XmlDocument xmlDom = new XmlDocument();
  37. xmlDom.LoadXml(content);
  38. CustomValidation(xmlDom);
  39. return CustomValidation(xmlDom);
  40. }
  41. catch (Exception ex)
  42. {
  43. LOG.Write(ex);
  44. EV.PostWarningLog("Recipe", "sequence file not valid, " + ex.Message);
  45. return false;
  46. }
  47. }
  48. public bool EnableEdit(string sequencePathName)
  49. {
  50. if (Singleton<RouteManager>.Instance.CheckSequenceUsedInJob(sequencePathName))
  51. {
  52. EV.PostWarningLog("System", "Sequence is used in auto running jobs, can not be modified");
  53. return false;
  54. }
  55. return true;
  56. }
  57. public virtual void CustomSequenceItem(XmlDocument xmlContent)
  58. {
  59. }
  60. public virtual bool CustomValidation(XmlDocument xmlContent)
  61. {
  62. return true;
  63. }
  64. }
  65. }