Beispiel #1
0
        private void CreateRSS()
        {
            //...XmlTextWriter RSSFeed = new XmlTextWriter(MapPath("./" + "RSS.rss"), System.Text.Encoding.UTF8);

            System.Xml.XmlTextWriter RSSFeed = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
            // Write the rss tags like title, version,
            // Channel, title, link description copyright etc.
            RSSFeed.WriteStartDocument();
            RSSFeed.WriteStartElement("rss");
            RSSFeed.WriteAttributeString("version", "2.0");
            RSSFeed.WriteStartElement("channel");
            RSSFeed.WriteElementString("title", "Mehdi Naseri RSS");
            RSSFeed.WriteElementString("description", "This Website has been made by: Mehdi Naseri");
            RSSFeed.WriteElementString("link", "http://naseri.somee.com");
            RSSFeed.WriteElementString("pubDate", DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss +0000"));
            RSSFeed.WriteElementString("copyright", "Copyright Mehdi Naseri 2012");
            //Items of RSS
            for (int i = 0; i < 3; i++)
            {
                RSSFeed.WriteStartElement("item");
                RSSFeed.WriteElementString("title", string.Format("Title " + (i + 1).ToString()));
                RSSFeed.WriteElementString("description", string.Format("Description " + (i + 1).ToString()));
                RSSFeed.WriteElementString("link", "http://naseri.somee.com/RSS.aspx");
                //RSSFeed.WriteElementString("pubDate", "Mon, 06 Sep 2009 16:45:00 +0000");
                RSSFeed.WriteElementString("pubDate", DateTime.Now.ToUniversalTime().ToString("ddd, dd MMM yyyy HH:mm:ss +0000"));
                RSSFeed.WriteEndElement();
            }
            RSSFeed.WriteEndElement();
            RSSFeed.WriteEndElement();
            RSSFeed.WriteEndDocument();
            RSSFeed.Flush();
            RSSFeed.Close();
            Response.End();
        }
Beispiel #2
0
        public static void CreateEmptyXmlRepository()
        {
            if (!System.IO.File.Exists(Util.GetXML_RepoPath()))
            {
                System.Xml.XmlTextWriter text = new System.Xml.XmlTextWriter(Util.GetXML_RepoPath(), null);
                text.Formatting  = System.Xml.Formatting.Indented;
                text.Indentation = 4;
                text.WriteStartDocument();

                text.WriteStartElement("root");

                text.WriteStartElement("book");
                text.WriteStartAttribute("folder");
                text.WriteEndAttribute();


                text.WriteStartElement("page");
                text.WriteStartAttribute("src");
                text.WriteEndAttribute();
                text.WriteEndElement();

                text.WriteEndElement();


                text.WriteEndElement();

                text.WriteEndDocument();
                text.Flush();
                text.Close();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 保存配置到配置文件
        /// </summary>
        /// <param name="fileName">配置文件名</param>
        public virtual void SaveConfig(String fileName)
        {
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(fileName, Encoding.UTF8);

            try
            {
                writer.Formatting = System.Xml.Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("Jeelu.WordSegmentor");


                foreach (CfgItem item in GetCfgItems())
                {
                    writer.WriteComment(item.Comment);
                    writer.WriteStartElement("Item");
                    writer.WriteAttributeString("Name", item.Pi.Name);
                    writer.WriteAttributeString("Value", item.Pi.GetValue(this, null).ToString());
                    writer.WriteEndElement(); //Item
                }

                writer.WriteEndElement(); //Jeelu.WordSegmentor
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
            catch (Exception e)
            {
                WriteLog(String.Format("Save config fail, errmsg:{0}", e.Message));
            }
        }
Beispiel #4
0
        private string SerializeAllValuesToString()
        {
            if (_storageFormat == StorageFormat.JSON)
            {
                string json = Procurios.Public.JSON.JsonEncode(_values);
                return(json);
            }
            else if (_storageFormat == StorageFormat.XML)
            {
                var serializer = new System.Runtime.Serialization.DataContractSerializer(_values.GetType());

                using (var sw = new System.IO.StringWriter())
                {
                    using (var writer = new System.Xml.XmlTextWriter(sw))
                    {
                        writer.Formatting = System.Xml.Formatting.Indented; // to make it easier to read
                        serializer.WriteObject(writer, _values);
                        writer.Flush();
                        return(sw.ToString());
                    }
                }
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        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();
            }
        }
        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();
            }
        }
        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();
            }
        }
Beispiel #8
0
        private void SendCommand(string command, Dictionary <string, string> cmdParameters)
        {
            StringBuilder sb = new System.Text.StringBuilder();

            using (System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(new System.IO.StringWriter(sb, CultureInfo.InvariantCulture)))
            {
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("ndd");

                AddCommand(command, xmlWriter, cmdParameters);

                xmlWriter.WriteStartElement("Patients");
                AddGuiPatient(xmlWriter);
                xmlWriter.WriteEndElement();//Patients
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndDocument();

                xmlWriter.Flush();
                xmlWriter.Close();
            }
            _emrPlugIn.SendMessage(sb.ToString());

            // ndd internal code
            if (textBoxPatientID.Text.StartsWith("Exception", StringComparison.CurrentCultureIgnoreCase))
            {
                throw new Exception("This Exception is for testing purpose");
            }
        }
Beispiel #9
0
        private void saveButton_Click(object sender, System.EventArgs e)
        {
            if (System.IO.File.Exists(jmjcmptst))
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(jmjcmptst);
                saveFileDialog1.InitialDirectory = sr.ReadToEnd();
                sr.Close();
            }

            if (saveFileDialog1.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            System.IO.File.Delete(jmjcmptst);
            System.IO.StreamWriter sw = new System.IO.StreamWriter(jmjcmptst);
            sw.Write(System.IO.Path.GetDirectoryName(saveFileDialog1.FileName));
            sw.Flush();
            sw.Close();

            sw = new System.IO.StreamWriter(saveFileDialog1.FileName);
            System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(sw);
            xw.WriteStartDocument();
            xw.WriteStartElement("JMJComponentTestCase");
            xw.WriteElementString("component_wrapper_class", "EncounterPRO.OS.Component." + ddlWrapperClass.Text);
            xw.WriteElementString("component_class", tClass.Text);
            xw.WriteElementString("component_version", tAssembly.Text);
            xw.WriteElementString("component_attributes_xml", tComponentAttributes.Text);
            xw.WriteElementString("credential_attributes_xml", tCredentialAttributes.Text);
            xw.WriteElementString("context_xml", tClinicalContext.Text);
            xw.WriteEndElement();
            xw.WriteEndDocument();
            xw.Flush();
            xw.Close();
        }
        public static string FormatXmlDocument(string xml)
        {
            var xmlDocument = new System.Xml.XmlDocument();

            xmlDocument.LoadXml(xml);

            var stream = new System.IO.MemoryStream();
            var writer = new System.Xml.XmlTextWriter(stream, Encoding.Unicode);

            // indent setting
            writer.Formatting  = System.Xml.Formatting.Indented;
            writer.Indentation = 2;   // indent length
            writer.IndentChar  = ' '; // indent character

            // formatting write
            xmlDocument.WriteContentTo(writer);
            writer.Flush();
            stream.Flush();
            stream.Position = 0;

            // to string
            var    reader       = new System.IO.StreamReader(stream);
            string formattedXml = reader.ReadToEnd();

            return(formattedXml);
        }
Beispiel #11
0
        private void buttonSyncPatient_Click(object sender, EventArgs e)
        {
            if (_ReceiveMsgMethod == null)
            {
                return;
            }

            StringBuilder sb = new System.Text.StringBuilder();

            using (System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(new System.IO.StringWriter(sb, CultureInfo.InvariantCulture)))
            {
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("ndd");
                AddCommand(Commands.TestResult.Command, xmlWriter, Commands.ShowTest.OrderID, textBoxOrderID.Text);

                xmlWriter.WriteStartElement("Patients");
                AddGuiPatient(xmlWriter);
                xmlWriter.WriteEndElement();//Patients
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndDocument();

                xmlWriter.Flush();
                xmlWriter.Close();
            }

            CallReceiveMsgMethod(sb.ToString());
        }
Beispiel #12
0
        /// <summary>
        /// Creates XML string which represents search patient result</summary>
        /// <param name="parameters">query parameter</param>
        protected override string ReturnSearchPatientResult(Dictionary <string, string> parameters)
        {
            using (System.Xml.XmlWriter xmlWriter = new System.Xml.XmlTextWriter(XmlExchangeFile, Encoding.UTF8))
            {
                try
                {
                    xmlWriter.WriteStartDocument();
                    xmlWriter.WriteStartElement("ndd");
                    xmlWriter.WriteStartElement("Command");
                    xmlWriter.WriteAttributeString("Type", Commands.SearchPatientsResult.Command);
                    xmlWriter.WriteEndElement();//command
                    xmlWriter.WriteStartElement("Patients");

                    _benchForm.AddGuiPatient(xmlWriter);
                    _benchForm.AddGuiPatient(xmlWriter);
                    _benchForm.AddGuiPatient(xmlWriter);

                    xmlWriter.WriteEndElement();//Patients
                    xmlWriter.WriteEndElement();
                    xmlWriter.WriteEndDocument();
                    xmlWriter.Flush();
                    xmlWriter.Close();
                    return(XmlExchangeFile);
                }
                finally
                {
                    xmlWriter.Close();
                }
            }
        }
Beispiel #13
0
        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;
            string author  = Request.QueryString["author"];
            string comment = Request.QueryString["comment"];

            if (int.TryParse(Request.QueryString["callstack_uid"], out callstack_uid) == false)
            {
                return;
            }

            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Outputs");

                bool res = DB.InsertCallstackComment(callstack_uid, author, comment);
                writer.WriteAttributeString("result", res.ToString());

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
Beispiel #14
0
        static void WriteKeePassFile(string filePath)
        {
            XDocument xDoc         = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
            XElement  xKeyPassFile = new XElement("KeePassFile");
            XElement  xRoot        = new XElement("Root");
            XElement  xGroup       = new XElement("Group",
                                                  new XElement("UUID", "Pysc/OPNvEOBrCYOGuQJ8g=="),
                                                  new XElement("Name", "Passwords"),
                                                  new XElement("Notes"));

            xDoc.Add(xKeyPassFile);
            xKeyPassFile.Add(xRoot);
            xRoot.Add(xGroup);

            List <IEntry> entries = _root.Entries;

            AddEntriesToXml(entries, xGroup);

            MemoryStream ms           = new MemoryStream();
            var          docXmlWriter = new System.Xml.XmlTextWriter(ms, System.Text.Encoding.UTF8);

            docXmlWriter.Formatting = System.Xml.Formatting.Indented;
            xDoc.WriteTo(docXmlWriter);
            docXmlWriter.Flush();
            ms.Flush();

            ms.Seek(0, SeekOrigin.Begin);

            StreamReader sr        = new StreamReader(ms);
            string       xmlResult = sr.ReadToEnd();

            File.WriteAllText(filePath, xmlResult);
        }
        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();
            }
        }
Beispiel #16
0
        public static void Export(string filename, Topic t, bool configOnly)
        {
            if (filename == null || t == null)
            {
                throw new ArgumentNullException();
            }
            XDocument doc = new XDocument(new XElement("xst", new XAttribute("path", t.path)));

            doc.Declaration = new XDeclaration("1.0", "utf-8", "yes");
            var s = t.GetState();

            if (s.Exists && (t.CheckAttribute(Topic.Attribute.Saved, Topic.Attribute.Config) || (!configOnly && t.CheckAttribute(Topic.Attribute.Saved, Topic.Attribute.DB))))
            {
                doc.Root.Add(new XAttribute("s", JsLib.Stringify(s)));
            }
            var m = t.GetField(null);

            doc.Root.Add(new XAttribute("m", JsLib.Stringify(m)));
            foreach (Topic c in t.children)
            {
                Export(doc.Root, c, configOnly);
            }
            using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(filename, Encoding.UTF8)) {
                writer.Formatting = System.Xml.Formatting.Indented;
                writer.QuoteChar  = '\'';
                doc.WriteTo(writer);
                writer.Flush();
            }
        }
Beispiel #17
0
        /// <summary>
        /// Returns the list of features this plug-in supports: like Worklist, CurveData, Attachment_Type, Attachment_Path</summary>
        protected virtual string ReturnSupportedFeatures()
        {
            //- Example -
            //<?xml version="1.0" encoding="utf-16"?>
            //<ndd>
            //    <Command Type="SupportedFeatures">
            //        <Parameter Name="SearchPatients"></Parameter>
            //    </Command>
            //</ndd>


            StringBuilder sb = new System.Text.StringBuilder();

            using (System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(new System.IO.StringWriter(sb, CultureInfo.InvariantCulture)))
            {
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("ndd");
                xmlWriter.WriteStartElement("Command");
                xmlWriter.WriteAttributeString("Type", Commands.SupportedFeatures.Command);

                foreach (string strFeature in GetSupportedFeatures())
                {
                    xmlWriter.WriteStartElement("Parameter");
                    xmlWriter.WriteAttributeString("Name", strFeature);
                    xmlWriter.WriteValue("True");
                    xmlWriter.WriteEndElement();//parameter
                }
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndDocument();
                xmlWriter.Flush();
                xmlWriter.Close();
                return(sb.ToString());
            }
        }
Beispiel #18
0
        private void SendCommand(string command, Dictionary <string, string> cmdParameters, Dictionary <string, string> data, string token = "", string h_w_e = "")
        {
            //MessageBox.Show("Entra en SEND COMMAND: " + command + ":" + cmdParameters["OrderID"]);
            StringBuilder sb = new System.Text.StringBuilder();

            using (System.Xml.XmlTextWriter xmlWriter = new System.Xml.XmlTextWriter(new System.IO.StringWriter(sb, CultureInfo.InvariantCulture)))
            {
                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("ndd");

                AddCommand(command, xmlWriter, cmdParameters);

                if (command.Equals("AddToWorklist") || command.Equals("RemoveWorklist"))
                //if (command.Equals("AddToWorklist"))
                {
                    xmlWriter.WriteStartElement("Patients");
                    AddGuiPatient(xmlWriter, data, command, token, h_w_e);
                    xmlWriter.WriteEndElement();//Patients
                }

                xmlWriter.WriteEndElement();
                xmlWriter.WriteEndDocument();

                xmlWriter.Flush();
                xmlWriter.Close();

                Console.Write(xmlWriter);
            }
            SendMessage(sb.ToString());

            // ndd internal code
            //if (textBoxPatientID.Text.StartsWith("Exception", StringComparison.CurrentCultureIgnoreCase))
            //    throw new Exception("This Exception is for testing purpose");
        }
        public IRequest Marshall(SubscribeRequest publicRequest)
        {
            MemoryStream stream = new MemoryStream();

            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
            writer.WriteStartDocument();
            writer.WriteStartElement(MNSConstants.XML_ROOT_SUBSCRIPTION, MNSConstants.MNS_XML_NAMESPACE);
            writer.WriteElementString(MNSConstants.XML_ELEMENT_ENDPOINT, publicRequest.EndPoint);
            if (publicRequest.IsSetFilterTag())
            {
                writer.WriteElementString(MNSConstants.XML_ELEMENT_FILTER_TAG, publicRequest.FilterTag);
            }
            if (publicRequest.IsSetStrategy())
            {
                writer.WriteElementString(MNSConstants.XML_ELEMENT_NOTIFY_STRATEGY, publicRequest.Strategy.ToString());
            }
            if (publicRequest.IsSetContentFormat())
            {
                writer.WriteElementString(MNSConstants.XML_ELEMENT_NOTIFY_CONTENT_FORMAT, publicRequest.ContentFormat.ToString());
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
            stream.Seek(0, SeekOrigin.Begin);

            IRequest request = new DefaultRequest(publicRequest, MNSConstants.MNS_SERVICE_NAME);

            request.HttpMethod    = HttpMethod.PUT.ToString();
            request.ContentStream = stream;
            request.ResourcePath  = MNSConstants.MNS_TOPIC_PRE_RESOURCE + publicRequest.TopicName
                                    + MNSConstants.MNS_SUBSCRIBE_PRE_RESOURCE + publicRequest.SubscriptionName;
            return(request);
        }
 private static void GenerateVmlDrawingPart1Content(VmlDrawingPart vmlDrawingPart1)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(vmlDrawingPart1.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<xml xmlns:v=\"urn:schemas-microsoft-com:vml\"\r\n xmlns:o=\"urn:schemas-microsoft-com:office:office\"\r\n xmlns:x=\"urn:schemas-microsoft-com:office:excel\">\r\n <o:shapelayout v:ext=\"edit\">\r\n  <o:idmap v:ext=\"edit\" data=\"1\"/>\r\n </o:shapelayout><v:shapetype id=\"_x0000_t75\" coordsize=\"21600,21600\" o:spt=\"75\"\r\n  o:preferrelative=\"t\" path=\"m@4@5l@4@11@9@11@9@5xe\" filled=\"f\" stroked=\"f\">\r\n  <v:stroke joinstyle=\"miter\"/>\r\n  <v:formulas>\r\n   <v:f eqn=\"if lineDrawn pixelLineWidth 0\"/>\r\n   <v:f eqn=\"sum @0 1 0\"/>\r\n   <v:f eqn=\"sum 0 0 @1\"/>\r\n   <v:f eqn=\"prod @2 1 2\"/>\r\n   <v:f eqn=\"prod @3 21600 pixelWidth\"/>\r\n   <v:f eqn=\"prod @3 21600 pixelHeight\"/>\r\n   <v:f eqn=\"sum @0 0 1\"/>\r\n   <v:f eqn=\"prod @6 1 2\"/>\r\n   <v:f eqn=\"prod @7 21600 pixelWidth\"/>\r\n   <v:f eqn=\"sum @8 21600 0\"/>\r\n   <v:f eqn=\"prod @7 21600 pixelHeight\"/>\r\n   <v:f eqn=\"sum @10 21600 0\"/>\r\n  </v:formulas>\r\n  <v:path o:extrusionok=\"f\" gradientshapeok=\"t\" o:connecttype=\"rect\"/>\r\n  <o:lock v:ext=\"edit\" aspectratio=\"t\"/>\r\n </v:shapetype><v:shape id=\"LH\" o:spid=\"_x0000_s1025\" type=\"#_x0000_t75\"\r\n  style=\';margin-left:0;margin-top:0;width:207pt;height:156pt;\r\n  z-index:1\'>\r\n  <v:imagedata o:relid=\"rId1\" o:title=\"WOPI\"/>\r\n  <o:lock v:ext=\"edit\" rotation=\"t\"/>\r\n </v:shape></xml>");
     writer.Flush();
     writer.Close();
 }
Beispiel #21
0
        /// <summary>
        /// Construct an StreamContent from a provided populated OFX object
        /// </summary>
        /// <param name="ofxObject">A populated OFX message with request or response data</param>
        /// <returns>Created StreamContent ready to send with HttpClient.Post</returns>
        public static StreamContent Create(Protocol.OFX ofxObject)
        {
            // Serialized data will be written to a MemoryStream
            var memoryStream = new System.IO.MemoryStream();

            // XMLWriter will be used to encode the data using UTF8Encoding without a Byte Order Marker (BOM)
            var xmlWriter = new System.Xml.XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false));

            // Write xml processing instruction
            xmlWriter.WriteStartDocument();
            // Our OFX protocol uses a version 2.0.0 header with 2.1.1 protocol body
            xmlWriter.WriteProcessingInstruction("OFX", "OFXHEADER=\"200\" VERSION=\"211\" SECURITY=\"NONE\" OLDFILEUID=\"NONE\" NEWFILEUID=\"NONE\"");

            // Don't include namespaces in the root element
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("", "");

            // Generate XML to the stream
            m_serializer.Serialize(xmlWriter, ofxObject, ns);

            // Flush writer to stream
            xmlWriter.Flush();

            // Position the stream back to the start for reading
            memoryStream.Position = 0;

            // Wrap in our HttpContent-derived class to provide headers and other HTTP encoding information
            return(new StreamContent(memoryStream));
        }
        public IRequest Marshall(CreateTopicRequest publicRequest)
        {
            MemoryStream stream = new MemoryStream();

            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
            writer.WriteStartDocument();
            writer.WriteStartElement(MNSConstants.XML_ROOT_TOPIC, MNSConstants.MNS_XML_NAMESPACE);
            var attrs = publicRequest.Attributes;

            if (attrs.IsSetMaximumMessageSize())
            {
                writer.WriteElementString(MNSConstants.XML_ELEMENT_MAXIMUM_MESSAGE_SIZE, attrs.MaximumMessageSize.ToString());
            }
            if (attrs.IsSetLoggingEnabled())
            {
                writer.WriteElementString(MNSConstants.XML_ELEMENT_LOGGING_ENABLED, attrs.LoggingEnabled.ToString());
            }
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Flush();
            stream.Seek(0, SeekOrigin.Begin);

            IRequest request = new DefaultRequest(publicRequest, MNSConstants.MNS_SERVICE_NAME);

            request.HttpMethod    = HttpMethod.PUT.ToString();
            request.ContentStream = stream;
            request.ResourcePath  = MNSConstants.MNS_TOPIC_PRE_RESOURCE + publicRequest.TopicName;
            return(request);
        }
Beispiel #23
0
        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();
            }
        }
 public static void GenerateCustomXmlPart3Content(CustomXmlPart customXmlPart3)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart3.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?mso-contentType?><FormTemplates xmlns=\"http://schemas.microsoft.com/sharepoint/v3/contenttype/forms\"><Display>DocumentLibraryForm</Display><Edit>DocumentLibraryForm</Edit><New>DocumentLibraryForm</New></FormTemplates>");
     writer.Flush();
     writer.Close();
 }
Beispiel #25
0
        } // End Sub PostRequest

        public static void SaveDocument(System.Xml.XmlDocument origDoc, string strSavePath)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.PreserveWhitespace = true;

            string strXml = origDoc.OuterXml.Replace("xmlns=\"\"", "");

            strXml = System.Text.RegularExpressions.Regex.Replace(strXml, @"(\r\n?|\n)+", " ");
            doc.LoadXml(strXml);
            doc.PreserveWhitespace = true;

            // XElement.Parse(str).ToString(SaveOptions.DisableFormatting)

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(strSavePath, System.Text.Encoding.UTF8))
            {
                xtw.Formatting  = System.Xml.Formatting.Indented; // if you want it indented
                xtw.Indentation = 4;
                xtw.IndentChar  = ' ';

                // xtw.Formatting = System.Xml.Formatting.None; // if you want it indented
                // doc.PreserveWhitespace = true;
                // doc.PreserveWhitespace = false;



                doc.Save(xtw);
                xtw.Flush();
                xtw.Close();
            } // End Using xtw

            doc = null;
        } // End Sub SaveDocument
Beispiel #26
0
        public static string SerializeObjectUTF8 <T>(this T toSerialize)
        {
            XmlSerializer serializer = new XmlSerializer(toSerialize.GetType());

            // create a MemoryStream here, we are just working
            // exclusively in memory
            System.IO.Stream stream = new System.IO.MemoryStream();

            // The XmlTextWriter takes a stream and encoding
            // as one of its constructors
            System.Xml.XmlTextWriter xtWriter = new System.Xml.XmlTextWriter(stream, Encoding.UTF8);

            serializer.Serialize(xtWriter, toSerialize);

            xtWriter.Flush();

            // go back to the beginning of the Stream to read its contents
            stream.Seek(0, System.IO.SeekOrigin.Begin);

            // read back the contents of the stream and supply the encoding
            System.IO.StreamReader reader = new System.IO.StreamReader(stream, Encoding.UTF8);

            string result = reader.ReadToEnd();

            return(result);
        }
Beispiel #27
0
        public static void Serialize(cSettings cs, string xmlFileName)
        {
            string xmlString = "";
            DataContractSerializer serializer = null;

            try
            {
                serializer = new DataContractSerializer(typeof(cSettings));//XmlSerializer(typeof(cSettings));
            }
            catch (Exception ex)
            { Console.WriteLine(ex.Message); }
            if (serializer != null)
            {
                using (var sw = new StringWriter())
                {
                    using (var writer = new System.Xml.XmlTextWriter(sw))
                    {
                        writer.Formatting = System.Xml.Formatting.Indented;
                        serializer.WriteObject(writer, cs);
                        writer.Flush();
                        xmlString = sw.ToString();
                        //x.Serialize(writer, cs);
                    }
                }
            }
            if (xmlString != "")
            {
                File.WriteAllText(xmlFileName, xmlString, Encoding.ASCII);
            }
        }
        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");

                string callstack;
                if (DB.LoadCallstackPreview(callstack_uid, out callstack))
                {
                    writer.WriteCData(callstack);
                }

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Flush();
                writer.Close();
            }
        }
Beispiel #29
0
        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();
            }
        }
 public static void GenerateCustomXmlPart2Content(CustomXmlPart customXmlPart2)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart2.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?><ct:contentTypeSchema ct:_=\"\" ma:_=\"\" ma:contentTypeName=\"Document\" ma:contentTypeID=\"0x0101004B3CC135CC07AD41A19C6A3D7A557156\" ma:contentTypeVersion=\"\" ma:contentTypeDescription=\"Create a new document.\" ma:contentTypeScope=\"\" ma:versionID=\"ed709af8e00f2f37000702baf4108691\" xmlns:ct=\"http://schemas.microsoft.com/office/2006/metadata/contentType\" xmlns:ma=\"http://schemas.microsoft.com/office/2006/metadata/properties/metaAttributes\">\r\n<xsd:schema targetNamespace=\"http://schemas.microsoft.com/office/2006/metadata/properties\" ma:root=\"true\" ma:fieldsID=\"6d238f72868eae9cb05cfc0c92331025\" ns2:_=\"\" ns3:_=\"\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:p=\"http://schemas.microsoft.com/office/2006/metadata/properties\" xmlns:ns2=\"4fc81810-4f98-4e7e-b20e-7b2a690091c4\" xmlns:ns3=\"067d236f-0129-4702-b692-531fc2f871d2\">\r\n<xsd:import namespace=\"4fc81810-4f98-4e7e-b20e-7b2a690091c4\"/>\r\n<xsd:import namespace=\"067d236f-0129-4702-b692-531fc2f871d2\"/>\r\n<xsd:element name=\"properties\">\r\n<xsd:complexType>\r\n<xsd:sequence>\r\n<xsd:element name=\"documentManagement\">\r\n<xsd:complexType>\r\n<xsd:all>\r\n<xsd:element ref=\"ns2:MediaServiceMetadata\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceFastMetadata\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceDateTaken\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceAutoTags\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceOCR\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns2:MediaServiceLocation\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns3:SharedWithUsers\" minOccurs=\"0\"/>\r\n<xsd:element ref=\"ns3:SharedWithDetails\" minOccurs=\"0\"/>\r\n</xsd:all>\r\n</xsd:complexType>\r\n</xsd:element>\r\n</xsd:sequence>\r\n</xsd:complexType>\r\n</xsd:element>\r\n</xsd:schema>\r\n<xsd:schema targetNamespace=\"4fc81810-4f98-4e7e-b20e-7b2a690091c4\" elementFormDefault=\"qualified\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:dms=\"http://schemas.microsoft.com/office/2006/documentManagement/types\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\">\r\n<xsd:import namespace=\"http://schemas.microsoft.com/office/2006/documentManagement/types\"/>\r\n<xsd:import namespace=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\"/>\r\n<xsd:element name=\"MediaServiceMetadata\" ma:index=\"8\" nillable=\"true\" ma:displayName=\"MediaServiceMetadata\" ma:hidden=\"true\" ma:internalName=\"MediaServiceMetadata\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Note\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceFastMetadata\" ma:index=\"9\" nillable=\"true\" ma:displayName=\"MediaServiceFastMetadata\" ma:hidden=\"true\" ma:internalName=\"MediaServiceFastMetadata\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Note\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceDateTaken\" ma:index=\"10\" nillable=\"true\" ma:displayName=\"MediaServiceDateTaken\" ma:hidden=\"true\" ma:internalName=\"MediaServiceDateTaken\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Text\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceAutoTags\" ma:index=\"11\" nillable=\"true\" ma:displayName=\"Tags\" ma:internalName=\"MediaServiceAutoTags\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Text\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceOCR\" ma:index=\"12\" nillable=\"true\" ma:displayName=\"Extracted Text\" ma:internalName=\"MediaServiceOCR\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Note\">\r\n<xsd:maxLength value=\"255\"/>\r\n</xsd:restriction>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n<xsd:element name=\"MediaServiceLocation\" ma:index=\"13\" nillable=\"true\" ma:displayName=\"Location\" ma:internalName=\"MediaServiceLocation\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Text\"/>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n</xsd:schema>\r\n<xsd:schema targetNamespace=\"067d236f-0129-4702-b692-531fc2f871d2\" elementFormDefault=\"qualified\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:dms=\"http://schemas.microsoft.com/office/2006/documentManagement/types\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\">\r\n<xsd:import namespace=\"http://schemas.microsoft.com/office/2006/documentManagement/types\"/>\r\n<xsd:import namespace=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\"/>\r\n<xsd:element name=\"SharedWithUsers\" ma:index=\"14\" nillable=\"true\" ma:displayName=\"Shared With\" ma:internalName=\"SharedWithUsers\" ma:readOnly=\"true\">\r\n<xsd:complexType>\r\n<xsd:complexContent>\r\n<xsd:extension base=\"dms:UserMulti\">\r\n<xsd:sequence>\r\n<xsd:element name=\"UserInfo\" minOccurs=\"0\" maxOccurs=\"unbounded\">\r\n<xsd:complexType>\r\n<xsd:sequence>\r\n<xsd:element name=\"DisplayName\" type=\"xsd:string\" minOccurs=\"0\"/>\r\n<xsd:element name=\"AccountId\" type=\"dms:UserId\" minOccurs=\"0\" nillable=\"true\"/>\r\n<xsd:element name=\"AccountType\" type=\"xsd:string\" minOccurs=\"0\"/>\r\n</xsd:sequence>\r\n</xsd:complexType>\r\n</xsd:element>\r\n</xsd:sequence>\r\n</xsd:extension>\r\n</xsd:complexContent>\r\n</xsd:complexType>\r\n</xsd:element>\r\n<xsd:element name=\"SharedWithDetails\" ma:index=\"15\" nillable=\"true\" ma:displayName=\"Shared With Details\" ma:internalName=\"SharedWithDetails\" ma:readOnly=\"true\">\r\n<xsd:simpleType>\r\n<xsd:restriction base=\"dms:Note\">\r\n<xsd:maxLength value=\"255\"/>\r\n</xsd:restriction>\r\n</xsd:simpleType>\r\n</xsd:element>\r\n</xsd:schema>\r\n<xsd:schema targetNamespace=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" blockDefault=\"#all\" xmlns=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:odoc=\"http://schemas.microsoft.com/internal/obd\">\r\n<xsd:import namespace=\"http://purl.org/dc/elements/1.1/\" schemaLocation=\"http://dublincore.org/schemas/xmls/qdc/2003/04/02/dc.xsd\"/>\r\n<xsd:import namespace=\"http://purl.org/dc/terms/\" schemaLocation=\"http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd\"/>\r\n<xsd:element name=\"coreProperties\" type=\"CT_coreProperties\"/>\r\n<xsd:complexType name=\"CT_coreProperties\">\r\n<xsd:all>\r\n<xsd:element ref=\"dc:creator\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element ref=\"dcterms:created\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element ref=\"dc:identifier\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element name=\"contentType\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\" ma:index=\"0\" ma:displayName=\"Content Type\"/>\r\n<xsd:element ref=\"dc:title\" minOccurs=\"0\" maxOccurs=\"1\" ma:index=\"4\" ma:displayName=\"Title\"/>\r\n<xsd:element ref=\"dc:subject\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element ref=\"dc:description\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element name=\"keywords\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n<xsd:element ref=\"dc:language\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element name=\"category\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n<xsd:element name=\"version\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n<xsd:element name=\"revision\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\">\r\n<xsd:annotation>\r\n<xsd:documentation>\r\n                        This value indicates the number of saves or revisions. The application is responsible for updating this value after each revision.\r\n                    </xsd:documentation>\r\n</xsd:annotation>\r\n</xsd:element>\r\n<xsd:element name=\"lastModifiedBy\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n<xsd:element ref=\"dcterms:modified\" minOccurs=\"0\" maxOccurs=\"1\"/>\r\n<xsd:element name=\"contentStatus\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:string\"/>\r\n</xsd:all>\r\n</xsd:complexType>\r\n</xsd:schema>\r\n<xs:schema targetNamespace=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\" elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\r\n<xs:element name=\"Person\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:DisplayName\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:AccountId\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:AccountType\" minOccurs=\"0\"></xs:element>\r\n</xs:sequence>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:element name=\"DisplayName\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"AccountId\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"AccountType\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"BDCAssociatedEntity\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:BDCEntity\" minOccurs=\"0\" maxOccurs=\"unbounded\"></xs:element>\r\n</xs:sequence>\r\n<xs:attribute ref=\"pc:EntityNamespace\"></xs:attribute>\r\n<xs:attribute ref=\"pc:EntityName\"></xs:attribute>\r\n<xs:attribute ref=\"pc:SystemInstanceName\"></xs:attribute>\r\n<xs:attribute ref=\"pc:AssociationName\"></xs:attribute>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:attribute name=\"EntityNamespace\" type=\"xs:string\"></xs:attribute>\r\n<xs:attribute name=\"EntityName\" type=\"xs:string\"></xs:attribute>\r\n<xs:attribute name=\"SystemInstanceName\" type=\"xs:string\"></xs:attribute>\r\n<xs:attribute name=\"AssociationName\" type=\"xs:string\"></xs:attribute>\r\n<xs:element name=\"BDCEntity\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:EntityDisplayName\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityInstanceReference\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId1\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId2\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId3\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId4\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:EntityId5\" minOccurs=\"0\"></xs:element>\r\n</xs:sequence>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:element name=\"EntityDisplayName\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityInstanceReference\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId1\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId2\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId3\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId4\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"EntityId5\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"Terms\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:TermInfo\" minOccurs=\"0\" maxOccurs=\"unbounded\"></xs:element>\r\n</xs:sequence>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:element name=\"TermInfo\">\r\n<xs:complexType>\r\n<xs:sequence>\r\n<xs:element ref=\"pc:TermName\" minOccurs=\"0\"></xs:element>\r\n<xs:element ref=\"pc:TermId\" minOccurs=\"0\"></xs:element>\r\n</xs:sequence>\r\n</xs:complexType>\r\n</xs:element>\r\n<xs:element name=\"TermName\" type=\"xs:string\"></xs:element>\r\n<xs:element name=\"TermId\" type=\"xs:string\"></xs:element>\r\n</xs:schema>\r\n</ct:contentTypeSchema>");
     writer.Flush();
     writer.Close();
 }
Beispiel #31
0
        } // End Sub SaveDocument

        public static void SaveDocument(System.Xml.XmlDocument origDoc, string strFilename, bool bDoReplace)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            string strSavePath         = ReportServerTools.GetSavePath();

            strSavePath = System.IO.Path.Combine(strSavePath, System.IO.Path.GetFileName(strFilename));

            if (bDoReplace)
            {
                doc.LoadXml(origDoc.OuterXml.Replace("xmlns=\"\"", ""));
                // doc.LoadXml(doc.OuterXml.Replace(strTextToReplace, strReplacementText));
            }

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(strSavePath, System.Text.Encoding.UTF8))
            {
                xtw.Formatting  = System.Xml.Formatting.Indented; // if you want it indented
                xtw.Indentation = 4;
                xtw.IndentChar  = ' ';

                doc.Save(xtw);
                xtw.Flush();
                xtw.Close();
            } // End Using xtw

            doc = null;
        } // End Sub SaveDocument
Beispiel #32
0
        /// <summary>
        /// Construct an StreamContent from a provided populated OFX object
        /// </summary>
        /// <param name="ofxObject">A populated OFX message with request or response data</param>
        /// <returns>Created StreamContent ready to send with HttpClient.Post</returns>
        public static StreamContent Create(Protocol.OFX ofxObject)
        {
            // Serialized data will be written to a MemoryStream
            var memoryStream = new System.IO.MemoryStream();

            // XMLWriter will be used to encode the data using UTF8Encoding without a Byte Order Marker (BOM)
            var xmlWriter = new System.Xml.XmlTextWriter(memoryStream, new System.Text.UTF8Encoding(false));

            // Write xml processing instruction
            xmlWriter.WriteStartDocument();
            // Our OFX protocol uses a version 2.0.0 header with 2.1.1 protocol body
            xmlWriter.WriteProcessingInstruction("OFX", "OFXHEADER=\"200\" VERSION=\"211\" SECURITY=\"NONE\" OLDFILEUID=\"NONE\" NEWFILEUID=\"NONE\"");

            // Don't include namespaces in the root element
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            ns.Add("", "");

            // Generate XML to the stream
            m_serializer.Serialize(xmlWriter, ofxObject, ns);

            // Flush writer to stream
            xmlWriter.Flush();

            // Position the stream back to the start for reading
            memoryStream.Position = 0;

            // Wrap in our HttpContent-derived class to provide headers and other HTTP encoding information
            return new StreamContent(memoryStream);
        }
 public static void GenerateCustomXmlPart1Content(CustomXmlPart customXmlPart1)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart1.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?><p:properties xmlns:p=\"http://schemas.microsoft.com/office/2006/metadata/properties\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:pc=\"http://schemas.microsoft.com/office/infopath/2007/PartnerControls\"><documentManagement/></p:properties>");
     writer.Flush();
     writer.Close();
 }
        public static void IsolatedStorage_Read_and_Write_Sample()
        {
            string fileName = @"SelfWindow.xml";

            IsolatedStorageFile storFile = IsolatedStorageFile.GetUserStoreForDomain();
            IsolatedStorageFileStream storStream = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write);
            System.Xml.XmlWriter writer = new System.Xml.XmlTextWriter(storStream, Encoding.UTF8);
            writer.WriteStartDocument();

            writer.WriteStartElement("Settings");

            writer.WriteStartElement("UserID");
            writer.WriteValue(42);
            writer.WriteEndElement();
            writer.WriteStartElement("UserName");
            writer.WriteValue("kingwl");
            writer.WriteEndElement();

            writer.WriteEndElement();

            writer.Flush();
            writer.Close();
            storStream.Close();

            string[] userFiles = storFile.GetFileNames();

            foreach(var userFile in userFiles)
            {
                if(userFile == fileName)
                {
                    var storFileStreamnew =  new IsolatedStorageFileStream(fileName,FileMode.Open,FileAccess.Read);
                    StreamReader storReader = new StreamReader(storFileStreamnew);
                    System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(storReader);

                    int UserID = 0;
                    string UserName = null;

                    while(reader.Read())
                    {
                        switch(reader.Name)
                        {
                            case "UserID":
                                UserID = int.Parse(reader.ReadString());
                                break;
                            case "UserName":
                                UserName = reader.ReadString();
                                break;
                            default:
                                break;
                        }
                    }

                    Console.WriteLine("{0} {1}", UserID, UserName);

                    storFileStreamnew.Close();
                }
            }
            storFile.Close();
        }
        private String GetPrintXML(String xml)
        {
            if (String.IsNullOrEmpty(xml))
            {
                return(String.Empty);
            }

            /*try
             * {
             *  System.Xml.Linq.XDocument doc = System.Xml.Linq.XDocument.Parse(xml);
             *  return doc.ToString();
             * }
             * catch (Exception)
             * {
             *  return xml;
             * }*/

            String Result = String.Empty;

            using (System.IO.MemoryStream mStream = new System.IO.MemoryStream())
            {
                System.Xml.XmlTextWriter writer   = new System.Xml.XmlTextWriter(mStream, Encoding.UTF8);
                System.Xml.XmlDocument   document = new System.Xml.XmlDocument();

                try
                {
                    // Load the XmlDocument with the XML.
                    document.LoadXml(xml);

                    writer.Formatting = System.Xml.Formatting.Indented;

                    // Write the XML into a formatting XmlTextWriter
                    document.WriteContentTo(writer);
                    writer.Flush();
                    mStream.Flush();

                    // Have to rewind the MemoryStream in order to read
                    // its contents.
                    mStream.Position = 0;

                    // Read MemoryStream contents into a StreamReader.
                    System.IO.StreamReader sReader = new System.IO.StreamReader(mStream);

                    // Extract the text from the StreamReader.
                    String FormattedXML = sReader.ReadToEnd();

                    Result = FormattedXML;
                }
                catch (System.Xml.XmlException)
                {
                    return(xml);
                }
                finally
                {
                    writer.Close();
                }
            }
            return(Result);
        }
 public void WriteTo(object entity, IHttpEntity response, string[] codecParameters)
 {
     if (entity == null || !(entity is SparqlEndpoint)) return;
     var sparqlEndpoint = entity as SparqlEndpoint;
     var client = BrightstarService.GetClient();
     using (var resultStream = client.ExecuteQuery(sparqlEndpoint.Store, sparqlEndpoint.SparqlQuery))
     {
         var resultsDoc = XDocument.Load(resultStream);
         var resultsWriter = new System.Xml.XmlTextWriter(response.Stream, Encoding.Unicode);
         resultsDoc.WriteTo(resultsWriter);
         resultsWriter.Flush();
     }
 }
        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();
            }
        }
Beispiel #38
0
 internal void AddReport(int errorCode, string errorMessage, object actual = null, object expected = null)
 {
     string path = Environment.GetFolderPath(Environment.SpecialFolder.Templates);
     string fileName = System.IO.Path.Combine(path,"WATF.xml");
     string data = "";
     List<WATF.Plugin.HPST.HPSTStruct.Message> messages = null;
     using (System.IO.FileStream fileStream = System.IO.File.Open(fileName, FileMode.OpenOrCreate))
     {
         using(StreamReader sr = new StreamReader(fileStream))
         {
             data = sr.ReadToEnd();
         }
     }
     XmlSerializer mySerializer = new XmlSerializer(typeof(List<WATF.Plugin.HPST.HPSTStruct.Message>), new Type[] { typeof(WATF.Plugin.HPST.HPSTStruct.ReportMessages) });
     if (data.Length > 1)
     {
         using (StreamReader mem2 = new StreamReader(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(data)), System.Text.Encoding.UTF8))
         {
             messages = new List<WATF.Plugin.HPST.HPSTStruct.Message>((List<WATF.Plugin.HPST.HPSTStruct.Message>)mySerializer.Deserialize(mem2));
         }
     }
     else
     {
         messages = new List<WATF.Plugin.HPST.HPSTStruct.Message>();
     }
     WATF.Plugin.HPST.HPSTStruct.Message message = new HPSTStruct.Message();
     message.ErrorCode = errorCode;
     message.ErrorMessage = errorMessage;
     if (actual == null) message.Actual = "Null Value";
     else message.Actual = actual.ToString();
     if (expected == null) message.Expected = "Null Value";
     else message.Expected = expected.ToString();
     message.DateTime = DateTime.Now.ToString();
     messages.Add(message);
     using (System.IO.FileStream fileStream = System.IO.File.Open(fileName, FileMode.OpenOrCreate))
     {
         using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(fileStream, Encoding.UTF8))
         {
             mySerializer.Serialize(writer, messages);
             writer.Flush();
         }
     }
 }
        public static void SaveDocument(System.Xml.XmlDocument origDoc, System.IO.Stream strm, bool bDoReplace)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            if (bDoReplace)
                doc.LoadXml(origDoc.OuterXml.Replace("xmlns=\"\"", ""));

            using (System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(strm, System.Text.Encoding.UTF8))
            {
                xtw.Formatting = System.Xml.Formatting.Indented; // if you want it indented
                xtw.Indentation = 4;
                xtw.IndentChar = ' ';

                doc.Save(xtw);
                xtw.Flush();
                xtw.Close();
            } // End Using xtw

            doc = null;
        }
        /// <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;
            }
        }
        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();
            }
        }
        /// <summary>
        /// Automatically create the table of contents for the specified document.
        /// Insert an ID in the document if the heading doesn't have it.
        /// Returns the XHTML for the TOC
        /// </summary>
        public static string GenerateTOC(System.Xml.XmlDocument doc)
        {
            System.Xml.XmlNodeList headings = doc.SelectNodes("//*");

              Heading root = new Heading("ROOT", null, 0);
              int index = 0;
              GenerateHeadings(headings, root, ref index);

              using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
              {
            System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
            writer.WriteStartElement("div");
            root.WriteChildrenToXml(writer);
            writer.WriteEndElement();
            writer.Flush();

            stream.Seek(0, System.IO.SeekOrigin.Begin);
            System.IO.StreamReader reader = new System.IO.StreamReader(stream, System.Text.Encoding.UTF8);

            return reader.ReadToEnd();
              }
        }
        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();
            }
        }
Beispiel #44
0
        private void onXMLSent(string xml, long socketId)
        {
            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.LoadXml(xml);

                System.IO.StringWriter sw = new System.IO.StringWriter();
                System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(sw);
                w.Formatting = System.Xml.Formatting.Indented;
                w.Indentation = 4;

                doc.Save(w);
                w.Flush();
                w.Close();

                string s = sw.ToString();
                int lineEnd = s.IndexOf("<", 2);
                s = s.Substring(lineEnd);

                string t = String.Format("{2}Sent at {0}: {2}{1}{2}", DateTime.Now.ToShortTimeString(), s, "\r\n");
                AppendTextThreadSafe(t);
            }
            catch(Exception)
            {
            }
        }
Beispiel #45
0
 // Generates content of customXmlPart1.
 private void GenerateCustomXmlPart1Content(CustomXmlPart customXmlPart1)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart1.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<b:Sources SelectedStyle=\"\\APASixthEditionOfficeOnline.xsl\" StyleName=\"APA\" Version=\"6\" xmlns:b=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\" xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\"></b:Sources>\r\n");
     writer.Flush();
     writer.Close();
 }
        /// <summary>
        /// Saves movie goofs 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 void SaveGoofs(
            IIMDbMovie movie,
            string xmlPath,
            bool overwrite)
        {
            System.Xml.XmlTextWriter xmlWr;

            try
            {
                if (System.IO.File.Exists(xmlPath) == false
                    || overwrite)
                    if (movie.Goofs.Count > 0)
                    {
                        xmlWr = new System.Xml.XmlTextWriter(xmlPath, Encoding.Default);
                        xmlWr.Formatting = System.Xml.Formatting.Indented;
                        xmlWr.WriteStartDocument();
                        xmlWr.WriteStartElement("Goofs");
                        foreach (IIMDbGoof goof in movie.Goofs)
                        {
                            xmlWr.WriteStartElement("Goof");
                            xmlWr.WriteElementString("Category", goof.Category);
                            xmlWr.WriteElementString("Description", goof.Description);
                            xmlWr.WriteEndElement();
                        }
                        xmlWr.WriteEndElement();
                        xmlWr.WriteEndDocument();
                        xmlWr.Flush();
                        xmlWr.Close();
                        xmlWr = null;
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Saves movie trivia 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 void SaveTrivia(
            IIMDbMovie movie,
            string xmlPath,
            bool overwrite)
        {
            System.Xml.XmlTextWriter xmlWr;

            try
            {
                if (System.IO.File.Exists(xmlPath) == false
                    || overwrite)
                    if (movie.Trivia.Count > 0)
                    {
                        xmlWr = new System.Xml.XmlTextWriter(xmlPath, Encoding.Default);
                        xmlWr.Formatting = System.Xml.Formatting.Indented;
                        xmlWr.WriteStartDocument();
                        xmlWr.WriteStartElement("Trivias");
                        foreach (string trivia in movie.Trivia)
                        {
                            xmlWr.WriteElementString("Trivia", trivia);
                        }
                        xmlWr.WriteEndElement();
                        xmlWr.WriteEndDocument();
                        xmlWr.Flush();
                        xmlWr.Close();
                        xmlWr = null;
                    }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void GenerateEventSchemas(UPnPDevice d, System.IO.DirectoryInfo dirInfo, bool cleanSchema)
        {
            System.IO.MemoryStream ms = new MemoryStream();
            System.Xml.XmlTextWriter X = new System.Xml.XmlTextWriter(ms,System.Text.Encoding.UTF8);
            X.Formatting = System.Xml.Formatting.Indented;

            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                GenerateEventSchemas(ed,dirInfo,cleanSchema);
            }
            foreach(UPnPService s in d.Services)
            {
                Hashtable h = new Hashtable();
                int j=1;

                foreach(string sn in s.GetSchemaNamespaces())
                {
                    h[sn] = "CT"+j.ToString();
                    ++j;
                }
                X.WriteStartDocument();
                X.WriteStartElement("xsd","schema","http://www.w3.org/2001/XMLSchema");
                X.WriteAttributeString("targetNamespace","urn:schemas-upnp-org:event-1-0");
                X.WriteAttributeString("xmlns","upnp",null,"http://www.upnp.org/Schema/DataTypes");
                X.WriteAttributeString("xmlns","urn:schemas-upnp-org:event-1-0");

                foreach(UPnPStateVariable v in s.GetStateVariables())
                {
                    if (v.SendEvent)
                    {
                        X.WriteStartElement("xsd","element",null); // Element1
                        X.WriteAttributeString("name","propertyset");
                        X.WriteAttributeString("type","propertysetType");

                        if (!cleanSchema)
                        {
                            X.WriteComment("Note: Some schema validation tools may consider the following xsd:any element to be ambiguous in its placement");
                            X.WriteStartElement("xsd","any",null);
                            X.WriteAttributeString("namespace","##other");
                            X.WriteAttributeString("minOccurs","0");
                            X.WriteAttributeString("maxOccurs","unbounded");
                            X.WriteAttributeString("processContents","lax");
                            X.WriteEndElement(); //ANY
                        }

                        X.WriteStartElement("xsd","complexType",null);
                        X.WriteAttributeString("name","propertysetType");

                        X.WriteStartElement("xsd","sequence",null);
                        X.WriteStartElement("xsd","element",null); // Element2
                        X.WriteAttributeString("name","property");
                        X.WriteAttributeString("maxOccurs","unbounded");
                        X.WriteStartElement("xsd","complexType",null);
                        X.WriteStartElement("xsd","sequence",null);

                        X.WriteStartElement("xsd","element",null); // Element3
                        X.WriteAttributeString("name",v.Name);
                        if (v.ComplexType==null)
                        {
                            // Simple Type
                            X.WriteStartElement("xsd","complexType",null);
                            X.WriteStartElement("xsd","simpleContent",null);
                            X.WriteStartElement("xsd","extension",null);
                            X.WriteAttributeString("base","upnp:"+v.ValueType);
                            if (!cleanSchema)
                            {
                                X.WriteStartElement("xsd","anyAttribute",null);
                                X.WriteAttributeString("namespace","##other");
                                X.WriteAttributeString("processContents","lax");
                                X.WriteEndElement(); // anyAttribute
                            }
                            X.WriteEndElement(); // extension
                            X.WriteEndElement(); // simpleContent
                            X.WriteEndElement(); // complexType
                        }
                        else
                        {
                            // Complex Type
                            X.WriteAttributeString("type",h[v.ComplexType.Name_NAMESPACE].ToString()+":"+v.ComplexType.Name_LOCAL);
                        }
                        X.WriteEndElement(); // Element3
                        if (!cleanSchema)
                        {
                            X.WriteStartElement("xsd","any",null);
                            X.WriteAttributeString("namespace","##other");
                            X.WriteAttributeString("minOccurs","0");
                            X.WriteAttributeString("maxOccurs","unbounded");
                            X.WriteAttributeString("processContents","lax");
                            X.WriteEndElement(); // any
                        }
                        X.WriteEndElement(); // sequence
                        if (!cleanSchema)
                        {
                            X.WriteStartElement("xsd","anyAttribute",null);
                            X.WriteAttributeString("namespace","##other");
                            X.WriteAttributeString("processContents","lax");
                            X.WriteEndElement(); // anyAttribute
                        }
                        X.WriteEndElement(); // complexType
                        X.WriteEndElement(); // Element2
                        if (!cleanSchema)
                        {
                            X.WriteStartElement("xsd","any",null);
                            X.WriteAttributeString("namespace","##other");
                            X.WriteAttributeString("minOccurs","0");
                            X.WriteAttributeString("maxOccurs","unbounded");
                            X.WriteAttributeString("processContents","lax");
                            X.WriteEndElement(); // any
                        }
                        X.WriteEndElement(); // sequence
                        if (!cleanSchema)
                        {
                            X.WriteStartElement("xsd","anyAttribute",null);
                            X.WriteAttributeString("namespace","##other");
                            X.WriteAttributeString("processContents","lax");
                            X.WriteEndElement(); // anyAttribute
                        }
                        X.WriteEndElement(); // complexType;
                        X.WriteEndElement(); // Element1
                    }
                }

                X.WriteEndElement(); // schema
                X.WriteEndDocument();

                StreamWriter writer3;

                DText PP = new DText();
                PP.ATTRMARK = ":";
                PP[0] = s.ServiceURN;
                writer3 = File.CreateText(dirInfo.FullName + "\\"+PP[PP.DCOUNT()-1]+"_Events.xsd");

                System.Text.UTF8Encoding U = new System.Text.UTF8Encoding();
                X.Flush();
                ms.Flush();
                writer3.Write(U.GetString(ms.ToArray(),2,ms.ToArray().Length-2));
                writer3.Close();
                ms = new MemoryStream();
                X = new System.Xml.XmlTextWriter(ms,System.Text.Encoding.UTF8);
                X.Formatting = System.Xml.Formatting.Indented;
            }
        }
        /// <summary>
        /// Serialize the source object into an StringBuilder following "Shallow Copy" business logic.
        /// </summary>
        /// <param name="source">The object to serialize.</param>
        /// <returns>The serialized object.</returns>
        /// <remarks></remarks>
        public System.Text.StringBuilder WriteText(object source)
        {
            System.Text.StringBuilder _xmlText = new System.Text.StringBuilder();

            //Serialize the class to Xml
            System.IO.StringWriter _TextStreamWriter = new System.IO.StringWriter(_xmlText);
            System.Xml.XmlTextWriter _xmlWriter = new System.Xml.XmlTextWriter(_TextStreamWriter);
            WriteXml(source, _xmlWriter);
            _xmlWriter.Flush();
            return _xmlText;
        }
		protected virtual void WriteToStream(System.IO.Stream stream, PersistenceFlags flags)
		{
//			System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
//			
//			writer.Formatting = System.Xml.Formatting.Indented;
//			writer.WriteStartDocument();
//			writer.WriteStartElement("settings");
//
//			writer.WriteStartElement("items");
//			writer.WriteAttributeString("schemaversion", "1");
//			
//			foreach (PersistableItem item in m_Dictionary.Values)
//			{
//				if ( (flags & PersistenceFlags.OnlyChanges) == PersistenceFlags.OnlyChanges &&
//					item.IsChanged == false)
//					continue;
//
//				writer.WriteStartElement("item");
//				writer.WriteAttributeString("name", item.Name);
//				writer.WriteAttributeString("type", item.Type.FullName);
//				writer.WriteAttributeString("schemaversion", "1");
//				writer.WriteString(item.Validator.ValueToString(item.Value));
//				writer.WriteEndElement();
//			}
//
//			writer.WriteEndElement();
//
//			writer.WriteEndElement();
//			writer.WriteEndDocument();
//			writer.Flush();


			System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
			doc.AppendChild(doc.CreateElement("settings"));
			WriteToXmlElement(doc.DocumentElement, flags);

			System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(stream, System.Text.Encoding.UTF8);
			writer.Formatting = System.Xml.Formatting.Indented;
			doc.WriteTo(writer);
			writer.Flush();
		}
        void CreateHandler_Click(object sender, EventArgs args)
        {
            try
            {
                System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter("1.xml", UTF8Encoding.UTF8);
                w.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                ModelNode model = (ModelNode)this.Reslove(typeof(ModelNode), null);
                w.WriteRaw(model.DataInfo.DomNode.OuterXml);
                w.Flush();
                w.Close();

                GenHandler gen = new GenHandler(@"Xsl/ListOperationHandler.xslt", "1.xml");
                StringBuilder builder = new StringBuilder();
                gen.Generate(builder);
                this.OnGenerate(this, builder);
            }
            catch (Exception ex)
            {
                MessageBox.Show("生成失败:" + ex.Message);
            }
        }
Beispiel #52
0
		public void Export(GridVirtual grid)
		{
			System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(Stream, 
				System.Text.Encoding.UTF8);
			
			//write HTML and BODY
			if ( (Mode & ExportHTMLMode.HTMLAndBody) == ExportHTMLMode.HTMLAndBody)
			{
				writer.WriteStartElement("html");
				writer.WriteStartElement("body");
			}

			writer.WriteStartElement("table");

			writer.WriteAttributeString("cellspacing","0");
			writer.WriteAttributeString("cellpadding","0");

			for (int r = 0; r < grid.Rows.Count; r++)
			{
				writer.WriteStartElement("tr");

				for (int c = 0; c < grid.Columns.Count; c++)
				{
					Cells.ICellVirtual cell = grid.GetCell(r,c);
					Position pos = new Position(r,c);
					CellContext context = new CellContext(grid, pos, cell);
					ExportHTMLCell(context, writer);
				}

				//tr
				writer.WriteEndElement();
			}

			//table
			writer.WriteEndElement();

			//write end HTML and BODY
			if ( (Mode & ExportHTMLMode.HTMLAndBody) == ExportHTMLMode.HTMLAndBody)
			{
				//body
				writer.WriteEndElement();
				//html
				writer.WriteEndElement();
			}

			writer.Flush();
		}
Beispiel #53
0
 // Generates content of customXmlPart2.
 private void GenerateCustomXmlPart2Content(CustomXmlPart customXmlPart2)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart2.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?><p:properties xmlns:p=\"http://schemas.microsoft.com/office/2006/metadata/properties\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><documentManagement/></p:properties>");
     writer.Flush();
     writer.Close();
 }
	//Activate This Construntor to log All To Standard output
	//public TestClass():base(true){}

	//Activate this constructor to log Failures to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, false){}


	//Activate this constructor to log All to a log file
	//public TestClass(System.IO.TextWriter tw):base(tw, true){}

	//BY DEFAULT LOGGING IS DONE TO THE STANDARD OUTPUT ONLY FOR FAILURES

	public void run()
	{
		Exception exp = null;
	
		DataSet ds1 = new DataSet();
		ds1.Tables.Add(GHTUtils.DataProvider.CreateParentDataTable());
		ds1.Tables.Add(GHTUtils.DataProvider.CreateChildDataTable());
		
		System.IO.StringWriter sw = new System.IO.StringWriter();
		System.Xml.XmlTextWriter xmlTW = new System.Xml.XmlTextWriter(sw);
		//write xml file, schema only
		ds1.WriteXmlSchema(xmlTW);
		xmlTW.Flush();


		System.IO.StringReader sr = new System.IO.StringReader(sw.ToString());
		System.Xml.XmlTextReader xmlTR = new System.Xml.XmlTextReader(sr);
		
		//copy both data and schema
		DataSet ds2 = new DataSet();
		ds2.ReadXmlSchema(xmlTR);
	
	
		//check xml schema
		try
		{
			BeginCase("ReadXmlSchema - Tables count");
			Compare(ds1.Tables.Count ,ds2.Tables.Count );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("ReadXmlSchema - Tables 0 Col count");
			Compare(ds2.Tables[0].Columns.Count ,ds1.Tables[0].Columns.Count  );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("ReadXmlSchema - Tables 1 Col count");
			Compare(ds2.Tables[1].Columns.Count  ,ds1.Tables[1].Columns.Count  );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		//check some colummns types
		try
		{
			BeginCase("ReadXmlSchema - Tables 0 Col type");
			Compare(ds2.Tables[0].Columns[0].GetType() ,ds1.Tables[0].Columns[0].GetType() );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("ReadXmlSchema - Tables 1 Col type");
			Compare(ds2.Tables[1].Columns[3].GetType() ,ds1.Tables[1].Columns[3].GetType() );
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}
		
		//check that no data exists
		try
		{
			BeginCase("ReadXmlSchema - Table 1 row count");
			Compare(ds2.Tables[0].Rows.Count ,0);
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}

		try
		{
			BeginCase("ReadXmlSchema - Table 2 row count");
			Compare(ds2.Tables[1].Rows.Count ,0);
		}
		catch(Exception ex)	{exp = ex;}
		finally	{EndCase(exp); exp = null;}



	}
Beispiel #55
0
 // Generates content of customXmlPart4.
 private void GenerateCustomXmlPart4Content(CustomXmlPart customXmlPart4)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart4.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><b:Sources SelectedStyle=\"\\APA.XSL\" StyleName=\"APA\" xmlns:b=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\" xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/bibliography\"></b:Sources>");
     writer.Flush();
     writer.Close();
 }
Beispiel #56
0
		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();
			}
		}
        private void GenerateControlSchemas(UPnPDevice d, System.IO.DirectoryInfo dirInfo, bool cleanSchema)
        {
            System.IO.MemoryStream ms = new MemoryStream();
            System.Xml.XmlTextWriter X = new System.Xml.XmlTextWriter(ms,System.Text.Encoding.UTF8);
            X.Formatting = System.Xml.Formatting.Indented;

            foreach(UPnPDevice ed in d.EmbeddedDevices)
            {
                GenerateControlSchemas(ed,dirInfo,cleanSchema);
            }
            foreach(UPnPService s in d.Services)
            {
                Hashtable h = new Hashtable();
                int j=1;

                foreach(string sn in s.GetSchemaNamespaces())
                {
                    h[sn] = "CT"+j.ToString();
                    ++j;
                }
                X.WriteStartDocument();
                X.WriteStartElement("xsd","schema","http://www.w3.org/2001/XMLSchema");
                X.WriteAttributeString("targetNamespace",s.ServiceURN);
                X.WriteAttributeString("xmlns",s.ServiceURN);
                X.WriteAttributeString("xmlns","upnp",null,"http://www.upnp.org/Schema/DataTypes");
                IDictionaryEnumerator NE = h.GetEnumerator();
                while(NE.MoveNext())
                {
                    X.WriteAttributeString("xmlns",NE.Value.ToString(),null,NE.Key.ToString());
                }

                foreach(UPnPAction a in s.Actions)
                {
                    X.WriteStartElement("xsd","element",null);
                    X.WriteAttributeString("name",a.Name);
                    X.WriteAttributeString("type",a.Name+"Type");
                    X.WriteEndElement();
                    X.WriteStartElement("xsd","element",null);
                    X.WriteAttributeString("name",a.Name+"Response");
                    X.WriteAttributeString("type",a.Name+"ResponseType");
                    X.WriteEndElement();

                    if (!cleanSchema)
                    {
                        X.WriteComment("Note: Some schema validation tools may consider the following xsd:any element ambiguous in this placement");
                        X.WriteStartElement("xsd","any",null);
                        X.WriteAttributeString("namespace","##other");
                        X.WriteAttributeString("minOccurs","0");
                        X.WriteAttributeString("maxOccurs","unbounded");
                        X.WriteAttributeString("processContents","lax");
                        X.WriteEndElement(); // ANY
                    }

                    X.WriteStartElement("xsd","complexType",null);
                    X.WriteAttributeString("name",a.Name+"Type");

                    X.WriteStartElement("xsd","sequence",null);

                    foreach(UPnPArgument arg in a.Arguments)
                    {
                        if (arg.Direction=="in")
                        {
                            X.WriteStartElement("xsd","element",null);
                            X.WriteAttributeString("name",arg.Name);
                            if (arg.RelatedStateVar.ComplexType==null)
                            {
                                // Simple Types
                                X.WriteStartElement("xsd","complexType",null);
                                X.WriteStartElement("xsd","simpleContent",null);
                                X.WriteStartElement("xsd","extension",null);
                                X.WriteAttributeString("base","upnp:"+arg.RelatedStateVar.ValueType);

                                if (!cleanSchema)
                                {
                                    X.WriteStartElement("xsd","anyAttribute",null);
                                    X.WriteAttributeString("namespace","##other");
                                    X.WriteAttributeString("processContents","lax");
                                    X.WriteEndElement(); // anyAttribute
                                }

                                X.WriteEndElement(); // Extension
                                X.WriteEndElement(); // simpleConent
                                X.WriteEndElement(); // complexType
                            }
                            else
                            {
                                // Complex Types
                                X.WriteAttributeString("type",h[arg.RelatedStateVar.ComplexType.Name_NAMESPACE].ToString()+":"+arg.RelatedStateVar.ComplexType.Name_LOCAL);
                            }
                            X.WriteEndElement(); // element
                        }
                    }

                    if (!cleanSchema)
                    {
                        X.WriteStartElement("xsd","any",null);
                        X.WriteAttributeString("namespace","##other");
                        X.WriteAttributeString("minOccurs","0");
                        X.WriteAttributeString("maxOccurs","unbounded");
                        X.WriteAttributeString("processContents","lax");
                        X.WriteEndElement(); // any
                    }

                    X.WriteEndElement(); // sequence

                    if (!cleanSchema)
                    {
                        X.WriteStartElement("xsd","anyAttribute",null);
                        X.WriteAttributeString("namespace","##other");
                        X.WriteAttributeString("processContents","lax");
                        X.WriteEndElement(); // anyAttribute
                    }
                    X.WriteEndElement(); // complexType

                    // ActionResponse
                    X.WriteStartElement("xsd","complexType",null);
                    X.WriteAttributeString("name",a.Name+"ResponseType");
                    X.WriteStartElement("xsd","sequence",null);

                    foreach(UPnPArgument arg in a.Arguments)
                    {
                        if (arg.Direction=="out" || arg.IsReturnValue)
                        {
                            X.WriteStartElement("xsd","element",null);
                            X.WriteAttributeString("name",arg.Name);
                            if (arg.RelatedStateVar.ComplexType==null)
                            {
                                // Simple
                                X.WriteStartElement("xsd","complexType",null);
                                X.WriteStartElement("xsd","simpleContent",null);
                                X.WriteStartElement("xsd","extension",null);
                                X.WriteAttributeString("base","upnp:"+arg.RelatedStateVar.ValueType);
                                if (!cleanSchema)
                                {
                                    X.WriteStartElement("xsd","anyAttribute",null);
                                    X.WriteAttributeString("namespace","##other");
                                    X.WriteAttributeString("processContents","lax");
                                    X.WriteEndElement(); // anyAttribute
                                }
                                X.WriteEndElement(); // extension
                                X.WriteEndElement(); // simpleContent
                                X.WriteEndElement(); // complexType
                            }
                            else
                            {
                                // Complex
                                X.WriteAttributeString("type",h[arg.RelatedStateVar.ComplexType.Name_NAMESPACE].ToString()+":"+arg.RelatedStateVar.ComplexType.Name_LOCAL);
                            }
                            X.WriteEndElement(); // Element
                        }
                    }
                    // After all arguments
                    if (!cleanSchema)
                    {
                        X.WriteStartElement("xsd","any",null);
                        X.WriteAttributeString("namespace","##other");
                        X.WriteAttributeString("minOccurs","0");
                        X.WriteAttributeString("maxOccurs","unbounded");
                        X.WriteAttributeString("processContents","lax");
                        X.WriteEndElement(); // any
                    }
                    X.WriteEndElement(); // sequence
                    if (!cleanSchema)
                    {
                        X.WriteStartElement("xsd","anyAttribute",null);
                        X.WriteAttributeString("namespace","##other");
                        X.WriteAttributeString("processContents","lax");
                        X.WriteEndElement(); // anyAttribute
                    }
                    X.WriteEndElement(); // complexType
                }

                X.WriteEndElement(); //schema
                X.WriteEndDocument();

                StreamWriter writer3;

                DText PP = new DText();
                PP.ATTRMARK = ":";
                PP[0] = s.ServiceURN;
                writer3 = File.CreateText(dirInfo.FullName + "\\"+PP[PP.DCOUNT()-1]+".xsd");

                System.Text.UTF8Encoding U = new System.Text.UTF8Encoding();
                X.Flush();
                ms.Flush();
                writer3.Write(U.GetString(ms.ToArray(),2,ms.ToArray().Length-2));
                writer3.Close();
                ms = new MemoryStream();
                X = new System.Xml.XmlTextWriter(ms,System.Text.Encoding.UTF8);
                X.Formatting = System.Xml.Formatting.Indented;
            }
        }
Beispiel #58
0
    public void ToXml (System.IO.Stream stream)
    {
        System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter (stream, null);
        writer.WriteStartDocument ();
        writer.WriteStartElement ("world");

        writer.WriteStartElement ("locks");
        ToXmlHelper helper = new ToXmlHelper (this, writer);
        this.ForeachLock (new PackageMatchDelegate (helper.ForeachLock));
        writer.WriteEndElement ();

        this.ToXml (writer);

        writer.WriteEndElement ();
        writer.WriteEndDocument ();
        writer.Flush ();
    }
Beispiel #59
0
 // Generates content of customXmlPart3.
 private void GenerateCustomXmlPart3Content(CustomXmlPart customXmlPart3)
 {
     System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(customXmlPart3.GetStream(System.IO.FileMode.Create), System.Text.Encoding.UTF8);
     writer.WriteRaw("<?mso-contentType?><FormTemplates xmlns=\"http://schemas.microsoft.com/sharepoint/v3/contenttype/forms\"><Display>DocumentLibraryForm</Display><Edit>DocumentLibraryForm</Edit><New>DocumentLibraryForm</New></FormTemplates>");
     writer.Flush();
     writer.Close();
 }
 public void Ask(SelectableSource source, TextWriter output)
 {
     bool result = Ask(source);
     if (MimeType == SparqlXmlQuerySink.MimeType || MimeType == "text/xml") {
         System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(output);
         w.Formatting = System.Xml.Formatting.Indented;
         w.WriteStartElement("sparql");
         w.WriteAttributeString("xmlns", "http://www.w3.org/2001/sw/DataAccess/rf1/result");
         w.WriteStartElement("head");
         w.WriteEndElement();
         w.WriteStartElement("boolean");
         w.WriteString(result ? "true" : "false");
         w.WriteEndElement();
         w.WriteEndElement();
         w.Flush();
     } else if (MimeType == "text/plain") {
         output.WriteLine(result ? "true" : "false");
     } else {
     }
 }