| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.IO;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Xml;
 
- using Aitex.Common.Util;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.Util;
 
- using VirgoCommon;
 
- namespace VirgoCommon
 
- {
 
-     public class LeakCheckResultManager : Singleton<LeakCheckResultManager>
 
-     {
 
-         private string _template = "<?xml version=\"1.0\" encoding=\"utf-16\"?> <LeakCheckResult xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"></LeakCheckResult>";
 
-         private Dictionary<string, XmlDocument> _dicXmlFile = new Dictionary<string, XmlDocument>();
 
-         string _filePath = PathManager.GetAppDir() + "\\LeakCheckResult\\";
 
-         string _fileName = "\\LeakCheckResult.xml";
 
-         public void Initialize(string Module)
 
-         {
 
-             try
 
-             {
 
-                 XmlDocument _dom = new XmlDocument();
 
-                 if (!Directory.Exists(_filePath + Module))
 
-                 {
 
-                     Directory.CreateDirectory(_filePath + Module);
 
-                 }
 
-                 if (!File.Exists(_filePath + Module + _fileName))
 
-                 {
 
-                     _dom.LoadXml(_template);
 
-                     _dom.Save(_filePath + Module + _fileName);
 
-                 }
 
-                 else
 
-                 {
 
-                     _dom.Load(_filePath + Module + _fileName);
 
-                 }
 
-                 _dicXmlFile.Add(Module, _dom);
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 LOG.Write(ex);
 
-                 throw;
 
-             }
 
-         }
 
-         /*
 
-          * 
 
-          * 
 
-          *                             Date = Convert.ToDateTime(element.GetAttribute("Date")),
 
-                             LeakCheckStatus = element.GetAttribute("LeakCheckStatus"),
 
-                             LeakRate = Convert.ToDouble(element.GetAttribute("LeakCheckStatus")),
 
-                             StartPressure = Convert.ToInt32(element.GetAttribute("StartPressure")),
 
-                             StopPressure = Convert.ToInt32(element.GetAttribute("StopPressure")),
 
-                             LeakCheckMode = element.GetAttribute("LeakCheckMode"),
 
-                             LeakCheckTime = Convert.ToInt32(element.GetAttribute("LeakCheckTime")),
 
-          * 
 
-          */
 
-         public void AddLeakCheck(string Module, DateTime date, int leakCheckTime, int beginPressure, int endPressure, double leakRate, string status, string mode)
 
-         {
 
-             try
 
-             {
 
-                 XmlElement node = _dicXmlFile[Module].CreateNode(XmlNodeType.Element, "LeakCheck", _dicXmlFile[Module].NamespaceURI) as XmlElement;
 
-                 node.SetAttribute("Id", Guid.NewGuid().ToString());
 
-                 node.SetAttribute("Date", date.ToString("yyyy-MM-dd HH:mm:ss.fff"));
 
-                 node.SetAttribute("LeakCheckStatus", status);
 
-                 node.SetAttribute("LeakRate", leakRate.ToString("F5"));
 
-                 node.SetAttribute("StartPressure", beginPressure.ToString());
 
-                 node.SetAttribute("StopPressure", endPressure.ToString());
 
-                 node.SetAttribute("LeakCheckMode", mode);
 
-                 node.SetAttribute("LeakCheckTime", leakCheckTime.ToString());
 
-                 XmlElement root = _dicXmlFile[Module].SelectSingleNode("/LeakCheckResult") as XmlElement;
 
-                 root.AppendChild(node);
 
-                 _dicXmlFile[Module].Save(_filePath + Module + _fileName);
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 LOG.Write(ex);
 
-             }
 
-         }
 
-         /*
 
-          * 
 
-          <LeakCheck Date="" StartPressure="" StopPressure 
 
-          */
 
-         public List<LeakCheckResultItem> GetHistoryLeakCheck(string Module)
 
-         {
 
-             List<LeakCheckResultItem> result = new List<LeakCheckResultItem>();
 
-             try
 
-             {
 
-                 XmlNodeList lst = _dicXmlFile[Module].SelectNodes("/LeakCheckResult/LeakCheck");
 
-                 if (lst != null)
 
-                 {
 
-                     foreach (XmlElement element in lst)
 
-                     {
 
-                         result.Add(new LeakCheckResultItem()
 
-                         {
 
-                             Id = element.GetAttribute("Id"),
 
-                             Date = Convert.ToDateTime(element.GetAttribute("Date")),
 
-                             LeakCheckStatus = element.GetAttribute("LeakCheckStatus"),
 
-                             LeakRate = Convert.ToDouble(element.GetAttribute("LeakRate")),
 
-                             StartPressure = Convert.ToInt32(element.GetAttribute("StartPressure")),
 
-                             StopPressure = Convert.ToInt32(element.GetAttribute("StopPressure")),
 
-                             LeakCheckMode = element.GetAttribute("LeakCheckMode"),
 
-                             LeakCheckTime = Convert.ToInt32(element.GetAttribute("LeakCheckTime")),
 
-                         });
 
-                     }
 
-                 }
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 LOG.Write(ex);
 
-             }
 
-             return result;
 
-         }
 
-         public void Delete(string Module, string id)
 
-         {
 
-             try
 
-             {
 
-                 XmlElement node = _dicXmlFile[Module].SelectSingleNode(string.Format("/LeakCheckResult/LeakCheck[@Id='{0}']", id)) as XmlElement;
 
-                 node.ParentNode.RemoveChild(node);
 
-                 _dicXmlFile[Module].Save(_filePath + Module + _fileName);
 
-             }
 
-             catch (Exception ex)
 
-             {
 
-                 LOG.Write(ex);
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |