本文整理汇总了C#中System.Xml.XmlTextWriter.WriteEndDocument方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextWriter.WriteEndDocument方法的具体用法?C# System.Xml.XmlTextWriter.WriteEndDocument怎么用?C# System.Xml.XmlTextWriter.WriteEndDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlTextWriter
的用法示例。
在下文中一共展示了System.Xml.XmlTextWriter.WriteEndDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int report_uid;
int new_state;
if (int.TryParse(Request.QueryString["report_uid"], out report_uid) == false)
{
return;
}
if (int.TryParse(Request.QueryString["state"], out new_state) == false)
new_state = 1;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Outputs");
DB.UpdateReportState(report_uid, new_state);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Project");
writer.WriteStartElement("Items");
Dictionary<int, sProject> projectList;
DB.LoadProject(out projectList);
foreach (KeyValuePair<int, sProject> item in projectList)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("uid", item.Key.ToString());
writer.WriteAttributeString("name", item.Value.name);
writer.WriteEndElement();
}
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例3: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int callstack_uid;
if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
callstack_uid = 1;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Callstack");
DB.LoadCallstack(callstack_uid,
delegate(int depth, string funcname, string fileline)
{
writer.WriteStartElement("Singlestep");
writer.WriteAttributeString("depth", depth.ToString());
this.WriteCData(writer, "Funcname", funcname);
this.WriteCData(writer, "Fileline", fileline);
writer.WriteEndElement();
}
);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例4: WriteConfig
// Lecture de la configuration
public static void WriteConfig()
{
string config_file = "config.xml";
var newconf = new System.Xml.XmlTextWriter(config_file, null);
newconf.WriteStartDocument();
newconf.WriteStartElement("config");
newconf.WriteElementString("last_update", LastUpdate.ToShortDateString());
newconf.WriteElementString("auth_token", AuthToken);
newconf.WriteEndElement();
newconf.WriteEndDocument();
newconf.Close();
}
示例5: ReadConfig
// Lecture de la configuration
static void ReadConfig()
{
string config_file = "config.xml";
if (!System.IO.File.Exists(config_file))
{
var newconf = new System.Xml.XmlTextWriter(config_file, null);
newconf.WriteStartDocument();
newconf.WriteStartElement("config");
newconf.WriteElementString("last_update", "0");
newconf.WriteElementString("auth_token", "");
newconf.WriteEndElement();
newconf.WriteEndDocument();
newconf.Close();
}
var conf = new System.Xml.XmlTextReader(config_file);
string CurrentElement = "";
while (conf.Read())
{
switch(conf.NodeType) {
case System.Xml.XmlNodeType.Element:
CurrentElement = conf.Name;
break;
case System.Xml.XmlNodeType.Text:
if (CurrentElement == "last_update")
LastUpdate = DateTime.Parse(conf.Value);
if (CurrentElement == "auth_token")
AuthToken = conf.Value;
break;
}
}
conf.Close();
// On vérifie que le token est encore valide
if (AuthToken.Length > 0)
{
var flickr = new Flickr(Program.ApiKey, Program.SharedSecret);
try
{
Auth auth = flickr.AuthCheckToken(AuthToken);
Username = auth.User.UserName;
}
catch (FlickrApiException ex)
{
//MessageBox.Show(ex.Message, "Authentification requise",
// MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
AuthToken = "";
}
}
}
示例6: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int project_uid;
if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
project_uid = 1;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Report");
writer.WriteAttributeString("project", project_uid.ToString());
writer.WriteStartElement("Items");
DB.LoadReportDeleted(project_uid,
delegate(int report_uid, string login_id, string ipaddr, DateTime reported_time, string relative_time, int callstack_uid, string funcname, string version, string filename, string assigned, string uservoice, int num_comments)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("report_uid", report_uid.ToString());
writer.WriteAttributeString("login_id", login_id);
writer.WriteAttributeString("ipaddr", ipaddr);
writer.WriteAttributeString("reported_time", reported_time.ToString());
writer.WriteAttributeString("relative_time", relative_time);
writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
writer.WriteAttributeString("assigned", assigned);
writer.WriteAttributeString("num_comments", num_comments.ToString());
this.WriteCData(writer, "Funcname", funcname);
this.WriteCData(writer, "Version", version);
this.WriteCData(writer, "Filename", filename);
this.WriteCData(writer, "Uservoice", uservoice);
writer.WriteEndElement();
}
);
writer.WriteEndElement(); // Items
writer.WriteEndElement(); // Report
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例7: SaveQuotes
/// <summary>
/// Saves movie quotes to an xml file
/// </summary>
/// <param name="movie">IIMDbMovie object</param>
/// <param name="xmlPath">path to save xml file to</param>
/// <param name="overwrite">set to true to overwrite existing xml file</param>
public static void SaveQuotes(
IIMDbMovie movie,
string xmlPath,
bool overwrite)
{
System.Xml.XmlTextWriter xmlWr;
try
{
if (File.Exists(xmlPath) == false
|| overwrite)
if (movie.Quotes.Count > 0)
{
xmlWr = new System.Xml.XmlTextWriter(xmlPath, Encoding.Default)
{Formatting = System.Xml.Formatting.Indented};
xmlWr.WriteStartDocument();
xmlWr.WriteStartElement("Quotes");
foreach (IList<IIMDbQuote> quoteBlock in movie.Quotes)
{
xmlWr.WriteStartElement("QuoteBlock");
foreach (IIMDbQuote quote in quoteBlock)
{
xmlWr.WriteStartElement("Quote");
xmlWr.WriteElementString("Character", quote.Character);
xmlWr.WriteElementString("QuoteText", quote.Text);
xmlWr.WriteEndElement();
}
xmlWr.WriteEndElement();
}
xmlWr.WriteEndElement();
xmlWr.WriteEndDocument();
xmlWr.Flush();
xmlWr.Close();
}
}
catch (Exception ex)
{
throw ex;
}
}
示例8: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int project_uid;
int report_uid;
string version;
if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
project_uid = 1;
if (int.TryParse(Request.QueryString["report_uid"], out report_uid) == false)
{
return;
}
version = Request.QueryString["version"];
if (version != null)
{
version.Trim();
if (version.Length == 0)
version = null;
}
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Outputs");
DB.ReserveReparse(project_uid, report_uid, version);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例9: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int callstack_uid;
if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
callstack_uid = 1;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Comment");
writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
DB.ForEachCallstackComment CommentWriter = delegate(string author, string comment, DateTime created)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("author", author);
writer.WriteAttributeString("created", created.ToString());
writer.WriteCData(comment);
writer.WriteEndElement();
};
DB.LoadCallstackComment(callstack_uid, CommentWriter);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例10: SaveToFile
protected virtual void SaveToFile(DataSet pDataSet)
{
if (m_FileName == null)
throw new ApplicationException("FileName is null");
byte[] completeByteArray;
using (System.IO.MemoryStream fileMemStream = new System.IO.MemoryStream())
{
System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(fileMemStream, System.Text.Encoding.UTF8);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("filedataset", c_DataNamespace);
xmlWriter.WriteStartElement("header", c_DataNamespace);
//File Version
xmlWriter.WriteAttributeString(c_FileVersion, c_FileVersionNumber.ToString());
//Data Version
xmlWriter.WriteAttributeString(c_DataVersion, GetDataVersion().ToString());
//Data Format
xmlWriter.WriteAttributeString(c_DataFormat, ((int)mSaveDataFormat).ToString());
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("data", c_DataNamespace);
byte[] xmlByteArray;
using (System.IO.MemoryStream xmlMemStream = new System.IO.MemoryStream())
{
StreamDataSet.Write(xmlMemStream, pDataSet, mSaveDataFormat);
//pDataSet.WriteXml(xmlMemStream);
xmlByteArray = xmlMemStream.ToArray();
xmlMemStream.Close();
}
xmlWriter.WriteBase64(xmlByteArray, 0, xmlByteArray.Length);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
completeByteArray = fileMemStream.ToArray();
fileMemStream.Close();
}
//se tutto è andato a buon fine scrivo effettivamente il file
using (System.IO.FileStream fileStream = new System.IO.FileStream(m_FileName, System.IO.FileMode.Create, System.IO.FileAccess.Write))
{
fileStream.Write(completeByteArray, 0, completeByteArray.Length);
fileStream.Close();
}
}
示例11: OutputFunctionNames
public static void OutputFunctionNames(bool compact, string k_test_results_path, string file_name, string[] script_functions)
{
using (var t = new System.Xml.XmlTextWriter(System.IO.Path.Combine(k_test_results_path, file_name), System.Text.Encoding.ASCII))
{
t.Indentation = 1;
t.IndentChar = '\t';
t.Formatting = System.Xml.Formatting.Indented;
t.WriteStartDocument();
t.WriteStartElement("Functions");
for (int x = 0; x < script_functions.Length; x++)
{
if (script_functions[x] != "123")
{
t.WriteStartElement("entry");
t.WriteAttributeString("key", "0x" + x.ToString("X3"));
t.WriteAttributeString("value", script_functions[x]);
t.WriteEndElement();
}
else if (!compact)
{
t.WriteStartElement("entry");
t.WriteAttributeString("key", "0x" + x.ToString("X3"));
t.WriteAttributeString("value", "UNKNOWN");
t.WriteEndElement();
}
}
t.WriteEndElement();
t.WriteEndDocument();
}
}
示例12: Serialize
/// <summary> Writes the mapping of all mapped classes of the specified assembly in the specified stream. </summary>
/// <param name="stream">Where the xml is written.</param>
/// <param name="assembly">Assembly used to extract user-defined types containing a valid attribute (can be [Class] or [xSubclass]).</param>
public virtual void Serialize(System.IO.Stream stream, System.Reflection.Assembly assembly)
{
if(stream == null)
throw new System.ArgumentNullException("stream");
if(assembly == null)
throw new System.ArgumentNullException("assembly");
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter( stream, System.Text.Encoding.UTF8 );
writer.Formatting = System.Xml.Formatting.Indented;
writer.WriteStartDocument();
if(WriteDateComment)
writer.WriteComment( string.Format( "Generated from NHibernate.Mapping.Attributes on {0}.", System.DateTime.Now.ToString("u") ) );
WriteHibernateMapping(writer, null);
// Write imports (classes decorated with the [ImportAttribute])
foreach(System.Type type in assembly.GetTypes())
{
object[] imports = type.GetCustomAttributes(typeof(ImportAttribute), false);
foreach(ImportAttribute import in imports)
{
writer.WriteStartElement("import");
if(import.Class != null && import.Class != string.Empty)
writer.WriteAttributeString("class", import.Class);
else // Assume that it is the current type that must be imported
writer.WriteAttributeString("class", HbmWriterHelper.GetNameWithAssembly(type));
if(import.Rename != null && import.Rename != string.Empty)
writer.WriteAttributeString("rename", import.Rename);
writer.WriteEndElement();
}
}
// Write classes and x-subclasses (classes must come first if inherited by "external" subclasses)
int classCount = 0;
System.Collections.ArrayList mappedClassesNames = new System.Collections.ArrayList();
foreach(System.Type type in assembly.GetTypes())
{
if( ! IsClass(type) )
continue;
HbmWriter.WriteClass(writer, type);
mappedClassesNames.Add(HbmWriterHelper.GetNameWithAssembly(type));
classCount++;
}
System.Collections.ArrayList subclasses = new System.Collections.ArrayList();
System.Collections.Specialized.StringCollection extendedClassesNames = new System.Collections.Specialized.StringCollection();
foreach(System.Type type in assembly.GetTypes())
{
if( ! IsSubclass(type) )
continue;
bool map = true;
System.Type t = type;
while( (t=t.DeclaringType) != null )
if (IsClass(t) || AreSameSubclass(type, t)) // If a base class is also mapped... (Note: A x-subclass can only contain x-subclasses of the same family)
{
map = false; // This class's mapping is already included in the mapping of the base class
break;
}
if(map)
{
subclasses.Add(type);
if( IsSubclass(type, typeof(SubclassAttribute)) )
extendedClassesNames.Add((type.GetCustomAttributes(typeof(SubclassAttribute), false)[0] as SubclassAttribute).Extends);
else if( IsSubclass(type, typeof(JoinedSubclassAttribute)) )
extendedClassesNames.Add((type.GetCustomAttributes(typeof(JoinedSubclassAttribute), false)[0] as JoinedSubclassAttribute).Extends);
else if( IsSubclass(type, typeof(UnionSubclassAttribute)) )
extendedClassesNames.Add((type.GetCustomAttributes(typeof(UnionSubclassAttribute), false)[0] as UnionSubclassAttribute).Extends);
}
}
classCount += subclasses.Count;
MapSubclasses(subclasses, extendedClassesNames, mappedClassesNames, writer);
writer.WriteEndElement(); // </hibernate-mapping>
writer.WriteEndDocument();
writer.Flush();
if(classCount == 0)
throw new MappingException("The following assembly contains no mapped classes: " + assembly.FullName);
if( ! Validate )
return;
// Validate the generated XML stream
try
{
writer.BaseStream.Position = 0;
System.Xml.XmlTextReader tr = new System.Xml.XmlTextReader(writer.BaseStream);
System.Xml.XmlValidatingReader vr = new System.Xml.XmlValidatingReader(tr);
// Open the Schema
System.IO.Stream schema = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("NHibernate.Mapping.Attributes.nhibernate-mapping.xsd");
vr.Schemas.Add("urn:nhibernate-mapping-2.2", new System.Xml.XmlTextReader(schema));
vr.ValidationType = System.Xml.ValidationType.Schema;
vr.ValidationEventHandler += new System.Xml.Schema.ValidationEventHandler(XmlValidationHandler);
_stop = false;
while(vr.Read() && !_stop) // Read to validate (stop at the first error)
;
}
//.........这里部分代码省略.........
示例13: PublishRSS
//.........这里部分代码省略.........
System.Xml.XmlTextWriter oXmlTextWriter = new System.Xml.XmlTextWriter(rSSRoot.OutputStream, System.Text.Encoding.UTF8);
oXmlTextWriter.WriteStartDocument();
oXmlTextWriter.WriteStartElement("rss");
oXmlTextWriter.WriteAttributeString("version", "2.0");
oXmlTextWriter.WriteStartElement("channel");
oXmlTextWriter.WriteElementString("link", rSSRoot.Channel.Link);
oXmlTextWriter.WriteElementString("title", rSSRoot.Channel.Title);
oXmlTextWriter.WriteElementString("description", rSSRoot.Channel.Description);
if(rSSRoot.Channel.Docs != "")
oXmlTextWriter.WriteElementString("docs", rSSRoot.Channel.Docs);
if(rSSRoot.Channel.PubDate != "")
{
System.DateTime sDateTime = System.Convert.ToDateTime(rSSRoot.Channel.PubDate);
oXmlTextWriter.WriteElementString("pubDate", sDateTime.ToString("ddd, dd MMM yyyy HH:mm:ss G\\MT"));
}
if(rSSRoot.Channel.Generator != "")
oXmlTextWriter.WriteElementString("generator", rSSRoot.Channel.Generator);
if(rSSRoot.Channel.WebMaster != "")
oXmlTextWriter.WriteElementString("webMaster", rSSRoot.Channel.WebMaster);
if(rSSRoot.Channel.Copyright != "")
oXmlTextWriter.WriteElementString("copyright", rSSRoot.Channel.Copyright);
if(rSSRoot.Channel.LastBuildDate != "")
{
System.DateTime sDateTime = System.Convert.ToDateTime(rSSRoot.Channel.LastBuildDate);
oXmlTextWriter.WriteElementString("lastBuildDate", sDateTime.ToString("ddd, dd MMM yyyy HH:mm:ss G\\MT"));
}
if(rSSRoot.Channel.ManagingEditor != "")
oXmlTextWriter.WriteElementString("managingEditor", rSSRoot.Channel.ManagingEditor);
oXmlTextWriter.WriteElementString("language", rSSRoot.Channel.Language.ToString().Replace("_", "-"));
if(rSSRoot.Image != null)
{
oXmlTextWriter.WriteStartElement("image");
oXmlTextWriter.WriteElementString("url", rSSRoot.Image.URL);
oXmlTextWriter.WriteElementString("link", rSSRoot.Image.Link);
oXmlTextWriter.WriteElementString("title", rSSRoot.Image.Title);
if(rSSRoot.Image.Description != "")
oXmlTextWriter.WriteElementString("description", rSSRoot.Image.Description);
if(rSSRoot.Image.Width != 0)
oXmlTextWriter.WriteElementString("width", rSSRoot.Image.Width.ToString());
if(rSSRoot.Image.Height != 0)
oXmlTextWriter.WriteElementString("height", rSSRoot.Image.Height.ToString());
oXmlTextWriter.WriteEndElement();
}
foreach(RSSItem itmCurrent in rSSRoot.Items)
{
oXmlTextWriter.WriteStartElement("item");
if(itmCurrent.Link != "")
oXmlTextWriter.WriteElementString("link", itmCurrent.Link);
if(itmCurrent.Title != "")
oXmlTextWriter.WriteElementString("title", itmCurrent.Title);
if(itmCurrent.Author != "")
oXmlTextWriter.WriteElementString("author", itmCurrent.Author);
if(itmCurrent.PubDate != "")
{
System.DateTime sDateTime = System.Convert.ToDateTime(itmCurrent.PubDate);
oXmlTextWriter.WriteElementString("pubDate", sDateTime.ToString("ddd, dd MMM yyyy HH:mm:ss G\\MT"));
}
if(itmCurrent.Comment != "")
oXmlTextWriter.WriteElementString("comment", itmCurrent.Comment);
if(itmCurrent.Description != "")
oXmlTextWriter.WriteElementString("description", itmCurrent.Description);
oXmlTextWriter.WriteEndElement();
}
oXmlTextWriter.WriteEndElement();
oXmlTextWriter.WriteEndElement();
oXmlTextWriter.WriteEndDocument();
oXmlTextWriter.Flush();
oXmlTextWriter.Close();
return(blnResult);
}
示例14: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "text/xml";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
int project_uid;
int pageNo;
int pageSize;
bool seperate_version;
string specific_version;
int hideResolved = 0;
int fromDate;
int toDate;
if (int.TryParse(Request.QueryString["project"], out project_uid) == false)
project_uid = 1;
if (int.TryParse(Request.QueryString["pageNo"], out pageNo) == false)
pageNo = 1;
if (int.TryParse(Request.QueryString["pageSize"], out pageSize) == false)
pageSize = 30;
if (int.TryParse(Request.QueryString["from"], out fromDate) == false)
fromDate = 0;
if (int.TryParse(Request.QueryString["to"], out toDate) == false)
toDate = 0;
if (bool.TryParse(Request.QueryString["sv"], out seperate_version) == false)
seperate_version = false;
specific_version = Request.QueryString["ver"];
if (specific_version != null)
{
specific_version.Trim();
if (specific_version.Length <= 0)
specific_version = null;
}
string temp1 = Request.QueryString["hideResolved"];
string temp2 = Request.QueryString["hideExamination"];
Boolean check1 = false;
Boolean check2 = false;
if (temp1 != null)
check1 = Boolean.Parse(temp1);
if (temp2 != null)
check2 = Boolean.Parse(temp2);
if (check1 && check2)
hideResolved = 3;
else if (check1)
hideResolved = 1;
else if (check2)
hideResolved = 2;
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
{
writer.WriteStartDocument();
writer.WriteStartElement("Callstack");
writer.WriteAttributeString("project", project_uid.ToString());
writer.WriteAttributeString("pageNo", pageNo.ToString());
writer.WriteAttributeString("pageSize", pageSize.ToString());
writer.WriteAttributeString("req", specific_version);
writer.WriteStartElement("Items");
DB.ForEachCallstackGroup ItemWriter = delegate(int count, int callstack_uid, string funcname, string version, DateTime latest_time, string relative_time, string assigned, int num_comments)
{
writer.WriteStartElement("Item");
writer.WriteAttributeString("count", count.ToString());
writer.WriteAttributeString("callstack_uid", callstack_uid.ToString());
writer.WriteAttributeString("latest_time", latest_time.ToString());
writer.WriteAttributeString("relative_time", relative_time);
writer.WriteAttributeString("assigned", assigned);
writer.WriteAttributeString("num_comments", num_comments.ToString());
this.WriteCData(writer, "Funcname", funcname);
this.WriteCData(writer, "Version", version);
writer.WriteEndElement();
};
int totalPageSize = 0;
DB.LoadCallstackList(project_uid, pageNo, pageSize, fromDate, toDate, seperate_version, specific_version, hideResolved, ItemWriter, out totalPageSize);
writer.WriteEndElement(); // Items
writer.WriteStartElement("Outputs");
this.WriteCData(writer, "TotalPageSize", totalPageSize.ToString());
writer.WriteEndElement(); // Outputs
writer.WriteEndElement(); // Callstack
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
}
示例15: SaveWatchList
private void SaveWatchList()
{
// Sort all the watchlists
if (this.WatchLists != null)
{
foreach (StockWatchList watchList in this.WatchLists)
{
watchList.StockList.Sort();
}
// Save watch list file
string watchListsFileName = Settings.Default.RootFolder + @"\WatchLists.xml";
System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();
settings.Indent = true;
settings.NewLineOnAttributes = true;
using (FileStream fs = new FileStream(watchListsFileName, FileMode.Create))
{
XmlSerializer serializer = new XmlSerializer(typeof(List<StockWatchList>));
System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(fs, null);
xmlWriter.Formatting = System.Xml.Formatting.Indented;
xmlWriter.WriteStartDocument();
serializer.Serialize(xmlWriter, this.WatchLists);
xmlWriter.WriteEndDocument();
}
}
}