本文整理汇总了C#中Models.GetXElement方法的典型用法代码示例。如果您正苦于以下问题:C# Models.GetXElement方法的具体用法?C# Models.GetXElement怎么用?C# Models.GetXElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Models
的用法示例。
在下文中一共展示了Models.GetXElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCompany
public void AddCompany(Models.CompanyInformation source)
{
logger.Info("Adding new company " + source.CompanyName + "(" + source.CompanyID + ")");
try { System.IO.Directory.CreateDirectory(DatabasePath + source.CompanyID); }
catch (Exception e) { logger.Fatal("Error creating directory", e); }
try
{
var temp = new XElement("Settings", source.GetXElement());
File.WriteAllText(DatabasePath + source.CompanyID + "\\Others.xml", temp.ToString(), Encoding.UTF8);
}
catch (Exception e) { logger.Fatal("Error saving the initial settings document", e); }
}
示例2: ChangeCompany
public async Task<bool> ChangeCompany(Models.CompanyInformation target)
{
logger.Info("Request to change company to " + target.CompanyName + " (" + target.CompanyID + ")");
XElement doc;
if (!File.Exists(DatabasePath + "Settings.xml"))
{
logger.Debug(DatabasePath + "Settings.xml" + " didn't exist. Maybe no company was set before.");
doc = new XElement("ApplicationSettings", new XElement("CurrentCompany", target.GetXElement()));
}
else
{
//Case when FirstLoad is true
try
{
doc = XElement.Parse(File.ReadAllText(DatabasePath + "Settings.xml", Encoding.UTF8));
doc.Element("CurrentCompany").Element(CurrentCompany.XElementName).ReplaceWith(target.GetXElement());
}
catch (Exception e) { logger.Fatal("Error while parsing or replacing the current company. Exiting the methode without changeing the company.", e); return false; }
}
try { File.WriteAllText(DatabasePath + "Settings.xml", doc.ToString(), Encoding.UTF8); }
catch (Exception e) { logger.Fatal("Could not write the changes into the file", e); }
logger.Info("Reconnecting database");
return await Connect();
}