public string CreateXml(string systemManagedItemName, List<string> userRoles) { //Initialize writers using (Utility.StringWriterWithEncoding sw = new Utility.StringWriterWithEncoding(Encoding.UTF8)) { using (System.Xml.XmlTextWriter writer = new XmlTextWriter(sw)) { //"write" XML using writer writer.WriteStartDocument(); WriteSummaryDocument(writer, systemManagedItemName, userRoles); writer.WriteEndDocument(); writer.Flush(); return sw.ToString(); } } }
//This call is used to generate an xml format for database updates //If gracePeriod > 0, // include any events that have occurred < gracePeriod days ago (even if already executed) public static string GetXml(Guid managedItemID, List<ProcessScheduledEvent> processScheduledEvents, bool includeDates, bool includeExecuted, int gracePeriod) { if (processScheduledEvents == null) return null; using (Utility.StringWriterWithEncoding sw = new Utility.StringWriterWithEncoding(Encoding.UTF8)) { using (System.Xml.XmlTextWriter writer = new XmlTextWriter(sw)) { writer.WriteStartDocument(); writer.WriteStartElement(XMLNames._E_Events); foreach (ProcessScheduledEvent processScheduledEvent in processScheduledEvents) { if (IncludeEvent(processScheduledEvent, includeExecuted, gracePeriod)) { writer.WriteStartElement(XMLNames._E_Event); writer.WriteAttributeString(XMLNames._A_ManagedItemNumber, managedItemID.ToString()); writer.WriteAttributeString(XMLNames._A_ScheduledEventId, processScheduledEvent.ScheduledEventId.ToString()); writer.WriteAttributeString(XMLNames._A_ID, processScheduledEvent.EventId.ToString()); writer.WriteAttributeString(XMLNames._A_Executed, (processScheduledEvent.Executed ? "1" : "0")); if (includeDates) writer.WriteAttributeString(XMLNames._A_ExecutionDate, processScheduledEvent.EventDate.ToString()); writer.WriteEndElement(); // Event } } writer.WriteEndElement(); //Events writer.WriteEndDocument(); writer.Flush(); return sw.ToString(); } } }