123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- using System.IO;
- using FileManager;
- namespace MeasureData
- {
- public class ConfigFile : ISlo
- {
- #region 内容
- //是否PT沉积
- private Boolean pt_Depostion;
- public Boolean PT_Depostion
- {
- get { return this.pt_Depostion; }
- set { this.pt_Depostion = value; }
- }
- //模板文件
- private String template_File;
- public String Template_File
- {
- get { return this.template_File; }
- set { this.template_File = value; }
- }
- //样品名称
- private String sample_Name;
- public String Sample_Name
- {
- get { return this.sample_Name; }
- set { this.sample_Name = value; }
- }
-
- #endregion
- public ConfigFile()
- {
- //this.m_Config_Param = new MeasureConfigParam();
- }
- /// <summary>
- /// 创建XML文件
- /// </summary>
- /// <param name="filename">创建XML文件的全路径</param>
- /// <returns>0:失败;1:成功;2:文件已存在</returns>
- public int CreateXml(String filename)
- {
- if (!File.Exists(filename))
- {
- if (XmlManager.CreateXmlFile(filename))
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- else
- {
- XmlManager.CreateXmlFile(filename);
- return 2;
- }
- }
- //保存
- public bool Save(String filename)
- {
- XmlDocument doc = new XmlDocument();
- if (File.Exists(filename))
- {
- doc.Load(filename);//载入xml文件
- }
- else
- {
- return false; //当前路径不存在
- }
- XmlNode root = doc.SelectSingleNode("XMLData");
- Serialize(true, doc, root);
- doc.Save(filename);
- return true;
- }
- //读取
- public bool Read(String filename)
- {
- XmlDocument doc = new XmlDocument();
- if (File.Exists(filename))
- {
- doc.Load(filename);//载入xml文件
- }
- else
- {
- return false; //当前路径不存在
- }
- XmlNode root = doc.SelectSingleNode("XMLData");
- Serialize(false, doc, root);
- //doc.Save(filename);
- return true;
- }
- //XML文件保存
- //样品孔存储xml文档
- public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
- {
- Slo sFile = new Slo();
- Slo sParam = new Slo();
- xBool pt_depostion = new xBool();
- xString template_file = new xString();
- xString sample_name = new xString();
-
-
- pt_depostion.AssignValue(this.pt_Depostion);
- template_file.AssignValue(this.template_File);
- sample_name.AssignValue(this.sample_Name);
- sFile.Register("PT_Depostion", pt_depostion);
- sFile.Register("Template_File", template_file);
- sFile.Register("Sample_Name", sample_name);
- //sFile.Register("MeasureConfigParam", m_Config_Param);
- if (isStoring)
- {
- sFile.Serialize(true, xml, rootNode);
- }
- else
- {
- sFile.Serialize(false, xml, rootNode);
- this.pt_Depostion = pt_depostion.value();
- this.template_File = template_file.value();
- this.sample_Name = sample_name.value();
- }
- }
- }
- }
|