public static WorkStation Load(string path) { //XElement doc = XElement.Load(path); try { return(XmlSerialHelp.DeSerializeAES <WorkStation>(path)); //var _licenKey = doc.Elements("licence").First().Attribute("key").Value; //var _companyid = doc.Elements("company").First().Attribute("id").Value;// rwc.readxmlp("company", "id"); //var _companyName = doc.Elements("company").First().Attribute("name").Value; //rwc.readxmlp("company", "name"); //var _ClientType = EClientTypeEnum.职业经理版本; //string _ClientTypeStr = ""; //if (doc.Element("licence").Attributes("ClientType").Count() > 0) //{ // _ClientTypeStr = doc.Element("licence").Attributes("ClientType").First().Value; // if (_ClientTypeStr == "") // { // _ClientType = EClientTypeEnum.职业经理版本; // } // else // { // var str = AESEncryption.AESDecryptStr(_ClientTypeStr); // str = str.Substring(_companyid.Length, str.Length - _companyid.Length); // _ClientType = (EClientTypeEnum)Enum.Parse(typeof(EClientTypeEnum), str); // } //} //return new XLicen() { CompanyID = _companyid, CompanyKey = _licenKey, CompanyName = _companyName, ClientTypeStr = _ClientTypeStr, ClientType = _ClientType }; } catch (Exception ee) { ee.ToString(); throw (new Exception("授权信息读取错误")); } }
public void Save(string path) { FileOperantion.CreatCompletePathOfFile(path); File.Delete(path); XmlSerialHelp.SerializeAES(this, path); // if (ClientTypeStr == null) ClientTypeStr = ""; // XDocument doc = new XDocument( // new XDeclaration("1.0", "utf-8", "yes"), // new XElement("config", // new XElement("licence", // new XAttribute("key", CompanyKey), // new XAttribute("ClientType", ClientTypeStr) // ), // new XElement("company", // new XAttribute("id", CompanyID), // new XAttribute("name", CompanyName) // ) // ) //); // ///保存XML文件到指定地址 // doc.Save(path); }
public ReportType Clone() { return(XmlSerialHelp.Clone <ReportType>(this)); }