T
tony.collings
I started a thread here :
http://groups.google.co.uk/group/mi...004a9/c3888efdcb7338f6?hl=en#c3888efdcb7338f6
About creating an Email function to email authors when the Review Date
has expired on their page.
I've managed to now achieve a significant proportion of the work by
writing out the details to an XML file and reading them back.
However I'm a little stuck on Amending an XML file. At the moment I'm
deleting it and recreating, but I need to append to it instead.
I was reading up on the DiffGram method of WriteXml. Anyone got any
pointers ?
Code run at PageLoad
private void ReadWriteXMLDocumentWithXMLReader()
{
// TODO:: Dynamically create the flag, and then append to XML
// Create a DataSet with one table and two columns.
DataSet EmailSentDataSet = new DataSet("EmailSentDataSet");
DataTable EmailSentTable = new DataTable("EmailSentTable");
DataColumn c1 = new DataColumn("url");
DataColumn c2 = new DataColumn("flag",
Type.GetType("System.Int32"));
EmailSentTable.Columns.Add(c1);
EmailSentTable.Columns.Add(c2);
EmailSentDataSet.Tables.Add(EmailSentTable);
DataRow newRow;
{
newRow = EmailSentTable.NewRow();
newRow["url"]= currentContext.Posting.Url.ToString();
newRow["flag"] = true;
EmailSentTable.Rows.Add(newRow);
}
EmailSentDataSet.AcceptChanges();
//Write XML File.
string xmlFilename = @"C:\emailflags.xml";
System.IO.FileStream WriteXml = new System.IO.FileStream
(xmlFilename, System.IO.FileMode.Create);
System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter
(WriteXml, System.Text.Encoding.Unicode);
EmailSentDataSet.WriteXml(xmlWriter);
WriteXml.Close();
//EmailSentDataSet.Dispose();
//Read Data Back In
DataSet newDataSet = new DataSet("New DataSet");
System.IO.FileStream fsReadXml = new System.IO.FileStream
(xmlFilename, System.IO.FileMode.Open);
System.Xml.XmlTextReader myXmlReader =
new System.Xml.XmlTextReader(fsReadXml);
newDataSet.ReadXml(myXmlReader);
myXmlReader.Close();
string url;
if(newDataSet.Tables[0].Rows.Count > 0)
{
url = newDataSet.Tables[0].Rows[0]["url"].ToString();
Trace.Warn (url);
}
else
{
Trace.Warn("Nothing in the Dataset");
}
}
http://groups.google.co.uk/group/mi...004a9/c3888efdcb7338f6?hl=en#c3888efdcb7338f6
About creating an Email function to email authors when the Review Date
has expired on their page.
I've managed to now achieve a significant proportion of the work by
writing out the details to an XML file and reading them back.
However I'm a little stuck on Amending an XML file. At the moment I'm
deleting it and recreating, but I need to append to it instead.
I was reading up on the DiffGram method of WriteXml. Anyone got any
pointers ?
Code run at PageLoad
private void ReadWriteXMLDocumentWithXMLReader()
{
// TODO:: Dynamically create the flag, and then append to XML
// Create a DataSet with one table and two columns.
DataSet EmailSentDataSet = new DataSet("EmailSentDataSet");
DataTable EmailSentTable = new DataTable("EmailSentTable");
DataColumn c1 = new DataColumn("url");
DataColumn c2 = new DataColumn("flag",
Type.GetType("System.Int32"));
EmailSentTable.Columns.Add(c1);
EmailSentTable.Columns.Add(c2);
EmailSentDataSet.Tables.Add(EmailSentTable);
DataRow newRow;
{
newRow = EmailSentTable.NewRow();
newRow["url"]= currentContext.Posting.Url.ToString();
newRow["flag"] = true;
EmailSentTable.Rows.Add(newRow);
}
EmailSentDataSet.AcceptChanges();
//Write XML File.
string xmlFilename = @"C:\emailflags.xml";
System.IO.FileStream WriteXml = new System.IO.FileStream
(xmlFilename, System.IO.FileMode.Create);
System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter
(WriteXml, System.Text.Encoding.Unicode);
EmailSentDataSet.WriteXml(xmlWriter);
WriteXml.Close();
//EmailSentDataSet.Dispose();
//Read Data Back In
DataSet newDataSet = new DataSet("New DataSet");
System.IO.FileStream fsReadXml = new System.IO.FileStream
(xmlFilename, System.IO.FileMode.Open);
System.Xml.XmlTextReader myXmlReader =
new System.Xml.XmlTextReader(fsReadXml);
newDataSet.ReadXml(myXmlReader);
myXmlReader.Close();
string url;
if(newDataSet.Tables[0].Rows.Count > 0)
{
url = newDataSet.Tables[0].Rows[0]["url"].ToString();
Trace.Warn (url);
}
else
{
Trace.Warn("Nothing in the Dataset");
}
}