if (System.IO.File.Exists(filepath))
System.IO.File.Delete(filepath);
using System.Xml.Serialization;
/// <summary>
/// 获取系统信息
/// </summary>
/// <returns></returns>
#region GetSystemInfo
public static Entity.SystemInfo GetSystemInfo()
{
string key = Common.Config.BaseConfig.SystemKey();
Entity.SystemInfo model = null;
try
{
if (Common.Utils.GetAppSettings("SystemRoot") == null)
return new Entity.SystemInfo();
string systempath = Common.Utils.GetAppSettings("SystemRoot").ToString();
var serializer = new XmlSerializer(typeof(Entity.SystemInfo));
string filepath = System.IO.Path.Combine(@"" + systempath, key + ".xml");
if (System.IO.File.Exists(filepath))
{
using (System.Xml.XmlReader reader = new System.Xml.XmlTextReader(filepath))
{
model = (Entity.SystemInfo)serializer.Deserialize(reader);
}
}
else
{
model = Logic.SystemLogic.GetModel(out errMsg);
if (model == null)
return model;
System.IO.File.Create(filepath).Close();
using (System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(filepath, Encoding.GetEncoding("gb2312")))
{
serializer.Serialize(writer, model);
}
}
}
catch (Exception ex)
{
errMsg = 50069;//获取当前网站系统表异常
Common.Config.GenericsLog<String>.WriteExceptionLog(log, ex, errMsg);
}
return model;
}
#endregion