#region Write operations log----------------this format
<log operator = "Admin" Operation result = "Success" Result details = "Data export succeeded!" "Operating time =" 2014/5/2714:37 "/>
<summary>
Write operation Log
</summary>
<param name= "Loginfo" > What to write to the log </param>
<param name= "Flagofresult" > Success or Failure </param>
public static void Writelog (string loginfo, int flagofresult, string path)
{
Try
{
if (! System.IO.Directory.Exists ((path)))
System.IO.Directory.CreateDirectory (path);
String LogPath = path + "Log.xml";
XmlDocument doc = new XmlDocument ();
if (! File.exists (LogPath))
{
XmlNode node = doc. Createxmldeclaration ("1.0", "Utf-8", "" ");
Doc. AppendChild (node);
Creating the root node
XmlNode root1 = doc. CreateElement ("Logs");
XmlElement XE = Doc. CreateElement ("Log");
Xe. SetAttribute ("operator", "Admin");
Xe. SetAttribute ("Operation result", Flagofresult = = 1?) "Success": "Failure");
Xe. SetAttribute ("Result details", loginfo);
Xe. SetAttribute ("Operating Time", DateTime.Now.ToShortDateString () + DateTime.Now.ToShortTimeString ());
Root1. AppendChild (XE);
Doc. AppendChild (ROOT1);
Doc. Save (LogPath);
}
Else
{
Doc. Load (LogPath);
Find root node
XmlNode root = Doc. selectSingleNode ("Logs");
Create a Datainfos node
XmlElement XE = Doc. CreateElement ("Log");
Xe. SetAttribute ("operator", "Admin");
Xe. SetAttribute ("Operation result", Flagofresult = = 1?) "Success": "Failure");
Xe. SetAttribute ("Result details", loginfo);
Xe. SetAttribute ("Operating Time", DateTime.Now.ToShortDateString () + DateTime.Now.ToShortTimeString ());
Root. AppendChild (XE);
Doc. Save (LogPath);
}
}
catch (Exception)
{
Return
}
}
#endregion
C # Action XML if there is no direct append created existence