当前位置: 首页>>代码示例>>C#>>正文


C# System.Xml.XmlTextWriter.WriteRaw方法代码示例

本文整理汇总了C#中System.Xml.XmlTextWriter.WriteRaw方法的典型用法代码示例。如果您正苦于以下问题:C# System.Xml.XmlTextWriter.WriteRaw方法的具体用法?C# System.Xml.XmlTextWriter.WriteRaw怎么用?C# System.Xml.XmlTextWriter.WriteRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlTextWriter的用法示例。


在下文中一共展示了System.Xml.XmlTextWriter.WriteRaw方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateNotificationContent

        /// <summary>
        /// Generates the content of the notification.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public static string GenerateNotificationContent(string template, Dictionary<string, object> data)
        {
            using(var writer = new System.IO.StringWriter())
            {
                using (System.Xml.XmlWriter xml = new System.Xml.XmlTextWriter(writer))
                {
                    xml.WriteStartElement("root");

                    foreach (DictionaryEntry de in HostSettingManager.GetHostSettings())
                        xml.WriteElementString(string.Concat("HostSetting_", de.Key), de.Value.ToString());

                    foreach (var item in data.Keys)
                    {
                        if (item.StartsWith("RawXml"))
                        {
                            xml.WriteRaw(data[item].ToString());
                        }
                        else if (item.GetType().IsClass)
                        {
                            xml.WriteRaw(data[item].ToXml());
                        }
                        else
                        {
                            xml.WriteElementString(item, data[item].ToString());
                        }
                    }

                    xml.WriteEndElement();

                    return XmlXslTransform.Transform(writer.ToString(), template);
                }
            }
        }
开发者ID:chad247,项目名称:bugnet,代码行数:39,代码来源:NotificationManager.cs

示例2: GenerateNotificationContent

        /// <summary>
        /// Generates the content of the notification.
        /// </summary>
        /// <param name="template">The template.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        public static string GenerateNotificationContent(string template, Dictionary<string, object> data)
        {
            using(var writer = new System.IO.StringWriter())
            {
                using (System.Xml.XmlWriter xml = new System.Xml.XmlTextWriter(writer))
                {
                    xml.WriteStartElement("root");

                    foreach (var de in HostSettingManager.GetHostSettings().Cast<DictionaryEntry>().Where(de => !de.Key.ToString().ToLower().Equals("welcomemessage")))
                    {
                        xml.WriteElementString(string.Concat("HostSetting_", de.Key), de.Value.ToString());
                    }

                    foreach (var item in data.Keys)
                    {
                        if (item.StartsWith("RawXml"))
                        {
                            xml.WriteRaw(data[item].ToString());
                        }
                        else if (item.GetType().IsClass)
                        {
                            xml.WriteRaw(data[item].ToXml());
                        }
                        else
                        {
                            xml.WriteElementString(item, data[item].ToString());
                        }
                    }

                    xml.WriteEndElement();
#if(DEBUG)
                    System.Diagnostics.Debug.WriteLine(writer.ToString()); 
#endif
                    return XmlXslTransform.Transform(writer.ToString(), template);
                }   
            }
        }
开发者ID:ChuckLafferty,项目名称:bugnet,代码行数:43,代码来源:NotificationManager.cs

示例3: CreateHandler_Click

        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);
            }
        }
开发者ID:koksaver,项目名称:CodeHelper,代码行数:21,代码来源:ListViewOperationNode.cs

示例4: GenerateCustomXmlPart1Content

 // 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();
 }
开发者ID:CGHill,项目名称:Hard-To-Find,代码行数:8,代码来源:InvoiceCreator.cs

示例5: GenerateCustomXmlPart4Content

 // 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();
 }
开发者ID:RoryNorman,项目名称:PowerShell,代码行数:8,代码来源:Program.cs

示例6: GenerateCustomXmlPart3Content

 // 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();
 }
开发者ID:RoryNorman,项目名称:PowerShell,代码行数:8,代码来源:Program.cs

示例7: GenerateCustomXmlPart2Content

 // 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();
 }
开发者ID:RoryNorman,项目名称:PowerShell,代码行数:8,代码来源:Program.cs

示例8: GenerateCustomXmlPart1Content

 // 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("<?xml version=\"1.0\" encoding=\"utf-8\"?><ct:contentTypeSchema ct:_=\"\" ma:_=\"\" ma:contentTypeName=\"Document\" ma:contentTypeID=\"0x010100DA191A7983F9F44A9C60D24B5C4D22D7\" ma:contentTypeVersion=\"1\" ma:contentTypeDescription=\"Create a new document.\" ma:contentTypeScope=\"\" ma:versionID=\"221a530deb90796bf295783ddced7382\" 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=\"3c34477644e5086b93ec9184c3231c1e\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:p=\"http://schemas.microsoft.com/office/2006/metadata/properties\">\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: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=\"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/office/internal/2005/internalDocumentation\">\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\" ma:readOnly=\"true\"/>\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=\"lastPrinted\" minOccurs=\"0\" maxOccurs=\"1\" type=\"xsd:dateTime\"/>\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</ct:contentTypeSchema>");
     writer.Flush();
     writer.Close();
 }
开发者ID:RoryNorman,项目名称:PowerShell,代码行数:8,代码来源:Program.cs

示例9: SendIssueNotifications

        /// <summary>
        /// Sends the issue notifications.
        /// </summary>
        /// <param name="issueId">The issue id.</param>
        /// <param name="issueChanges">The issue changes.</param>
        public static void SendIssueNotifications(int issueId, IEnumerable<IssueHistory> issueChanges)
        {
            // validate input
            if (issueId <= Globals.NEW_ID)
            {
                throw (new ArgumentOutOfRangeException("issueId"));
            }

            // TODO - create this via dependency injection at some point.
            IMailDeliveryService mailService = new SmtpMailDeliveryService();

            var issue = DataProviderManager.Provider.GetIssueById(issueId);
            var issNotifications = DataProviderManager.Provider.GetIssueNotificationsByIssueId(issueId);
            var emailFormatType = HostSettingManager.Get(HostSettingNames.SMTPEMailFormat, EmailFormatType.Text);

            var data = new Dictionary<string, object> { { "Issue", issue } };

            var writer = new System.IO.StringWriter();
            using (System.Xml.XmlWriter xml = new System.Xml.XmlTextWriter(writer))
            {
                xml.WriteStartElement("IssueHistoryChanges");

                foreach (var issueHistory in issueChanges)
                {
                    IssueHistoryManager.SaveOrUpdate(issueHistory);
                    xml.WriteRaw(issueHistory.ToXml());
                }

                xml.WriteEndElement();

                data.Add("RawXml_Changes", writer.ToString());
            }

            var templateCache = new List<CultureNotificationContent>();
            var emailFormatKey = (emailFormatType == EmailFormatType.Text) ? "" : "HTML";
            const string subjectKey = "IssueUpdatedSubject";
            var bodyKey = string.Concat("IssueUpdatedWithChanges", emailFormatKey);

            // get a list of distinct cultures
            var distinctCultures = (from c in issNotifications
                                    select c.NotificationCulture
                                   ).Distinct().ToList();

            // populate the template cache of the cultures needed
            foreach (var culture in from culture in distinctCultures let notificationContent = templateCache.FirstOrDefault(p => p.CultureString == culture) where notificationContent == null select culture)
            {
                templateCache.Add(new CultureNotificationContent().LoadContent(culture, subjectKey, bodyKey));
            }

            var displayname = UserManager.GetUserDisplayName(Security.GetUserName());

            foreach (var notification in issNotifications)
            {
                try
                {
                    //send notifications to everyone except who changed it.
                    if (notification.NotificationUsername.ToLower() == Security.GetUserName().ToLower()) continue;

                    var user = UserManager.GetUser(notification.NotificationUsername);

                    // skip to the next user if this user is not approved
                    if (!user.IsApproved) continue;
                    // skip to next user if this user doesn't have notifications enabled.
                    if (!new WebProfile().GetProfile(user.UserName).ReceiveEmailNotifications) continue;

                    var nc = templateCache.First(p => p.CultureString == notification.NotificationCulture);

                    var emailSubject = nc.CultureContents
                        .First(p => p.ContentKey == subjectKey)
                        .FormatContent(issue.FullId, displayname);

                    var bodyContent = nc.CultureContents
                        .First(p => p.ContentKey == bodyKey)
                        .TransformContent(data);

                    var message = new MailMessage
                        {
                            Subject = emailSubject,
                            Body = bodyContent,
                            IsBodyHtml = true
                        };

                    mailService.Send(user.Email, message, issueId);
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            }
        }
开发者ID:ChuckLafferty,项目名称:bugnet,代码行数:95,代码来源:IssueNotificationManager.cs

示例10: Output

        public void Output(IList<ValidationResult> list)
        {
            using (System.Xml.XmlTextWriter output = new System.Xml.XmlTextWriter("output.html", Encoding.Unicode))
            {
                output.WriteRaw("<html><head><title>results</title><style type=\"text/css\">.failedcount-0 { display: none; }</style></head><body>");
                output.WriteStartElement("h1");
                output.WriteRaw("Validation Results");
                output.WriteEndElement();

                output.WriteStartElement("h2");
                output.WriteRaw("Summary");
                output.WriteEndElement();

                output.WriteStartElement("ul");
                output.WriteAttributeString("class", "summary");
                foreach (var s in Enum.GetNames(typeof(XCRI.Validation.ContentValidation.ValidationStatus))
                    .Where(vg => vg.ToLower() != "unknown" && vg.ToLower() != "passed")
                    .Reverse())
                {
                    output.WriteStartElement("li");
                    output.WriteAttributeString("class", s.ToString().ToLower());
                    output.WriteRaw(String.Format("{0} ({1})", s, GetCount(list, s)));

                    var vgList = list
                        .Select(vr => vr.ValidationGroup)
                        .Distinct()
                        .OrderBy(vg => vg);

                    if (list.Where(vr => vr.Status.ToString() == s).Sum(x => x.FailedCount) > 0)
                    {

                        output.WriteStartElement("ul");

                        foreach (var vg in vgList)
                        {
                            var filteredModel = list.Where(vr => vr.ValidationGroup == vg).Where(vr => vr.Status.ToString() == s);
                            var filteredCount = filteredModel.Count();
                            if (filteredCount == 0)
                                continue;
                            output.WriteStartElement("li");
                            output.WriteRaw(String.Format("{0} {1} {2}", filteredModel.Count(), vg.ToLower(), (filteredCount == 1 ? s.ToLower() : s.ToLower() + "s")));
                            output.WriteEndElement(); // li
                        }

                        output.WriteEndElement(); // ul

                    }

                    output.WriteEndElement(); // li
                }
                output.WriteEndElement(); // ul

                output.WriteStartElement("h2");
                output.WriteRaw("Details");
                output.WriteEndElement();

                foreach (var s in Enum.GetNames(typeof(XCRI.Validation.ContentValidation.ValidationStatus))
                    .Where(vg => vg.ToLower() != "unknown"))
                {

                    if (list.Where(vr => vr.Status == (XCRI.Validation.ContentValidation.ValidationStatus)Enum.Parse(typeof(XCRI.Validation.ContentValidation.ValidationStatus), s)).Sum(x => x.FailedCount) == 0)
                        continue;

                    output.WriteStartElement("h3");
                    output.WriteRaw(s);
                    output.WriteEndElement();

                    foreach (var vg in list
                        .Select(vr => vr.ValidationGroup)
                    .Distinct())
                    {
                        var filteredModel = list
                            //.Where(vr => vr.FailedCount > 0)
                                .Where(vr => vr.ValidationGroup == vg && vr.Status == (XCRI.Validation.ContentValidation.ValidationStatus)Enum.Parse(typeof(XCRI.Validation.ContentValidation.ValidationStatus), s))
                                .OrderByDescending(vr => vr.Status);
                        var filteredCount = filteredModel.Count();
                        if (filteredCount == 0)
                            continue;

                        output.WriteStartElement("div");
                        output.WriteAttributeString("class", "failedcount-" + filteredModel.Sum(vr => vr.FailedCount).ToString());

                        output.WriteStartElement("h4");
                        output.WriteRaw(vg);
                        output.WriteEndElement();

                        output.WriteStartElement("ul");

                        foreach (var vr in filteredModel)
                        {

                            output.WriteStartElement("div");
                            output.WriteAttributeString("class", "failedcount-" + vr.FailedCount.ToString());

                            output.WriteStartElement("p");
                            output.WriteRaw(String.Format("{0} ({1} failed instance{2})", vr.Message, vr.FailedCount, (vr.FailedCount == 1 ? String.Empty : "s")));
                            output.WriteEndElement();

                            output.WriteRaw("<table cellspacing=\"0\"><thead><tr><th class=\"status\">Status</th><th class=\"numeric\">Line Number</th><th class=\"numeric\">Line Position</th><th>Details</th></tr></thead><tbody>");

//.........这里部分代码省略.........
开发者ID:BarbaraHarris,项目名称:xcricap-validator,代码行数:101,代码来源:ValidateRunner.cs

示例11: GenerateCustomXmlPart1Content

 // 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("<?xml version=\"1.0\" encoding=\"utf-8\"?><Root><Name>Eric White</Name><Company>Microsoft Corporation</Company><Address>One Microsoft Way</Address><City>Redmond</City><State>WA</State><Country>USA</Country><PostalCode>98052</PostalCode></Root>");
     writer.Flush();
     writer.Close();
 }
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:8,代码来源:GeneratedCode003-Data-Bound-Content-Controls.cs

示例12: GenerateVmlDrawingPart1Content

 // Generates content of vmlDrawingPart1.
 private 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_t202\" coordsize=\"21600,21600\" o:spt=\"202\"\r\n  path=\"m,l,21600r21600,l21600,xe\">\r\n  <v:stroke joinstyle=\"miter\"/>\r\n  <v:path gradientshapeok=\"t\" o:connecttype=\"rect\"/>\r\n </v:shapetype><v:shape id=\"_x0000_s1025\" type=\"#_x0000_t202\" style=\'position:absolute;\r\n  margin-left:1067.25pt;margin-top:247.5pt;width:108pt;height:59.25pt;\r\n  z-index:1;visibility:visible\' fillcolor=\"#ffffe1\" o:insetmode=\"auto\">\r\n  <v:fill color2=\"#ffffe1\"/>\r\n  <v:shadow color=\"black\" obscured=\"t\"/>\r\n  <v:path o:connecttype=\"none\"/>\r\n  <v:textbox style=\'mso-direction-alt:auto\'>\r\n   <div style=\'text-align:left\'></div>\r\n  </v:textbox>\r\n  <x:ClientData ObjectType=\"Note\">\r\n   <x:MoveWithCells/>\r\n   <x:SizeWithCells/>\r\n   <x:Anchor>\r\n    22, 15, 8, 10, 24, 31, 12, 9</x:Anchor>\r\n   <x:AutoFill>False</x:AutoFill>\r\n   <x:Row>9</x:Row>\r\n   <x:Column>21</x:Column>\r\n   <x:Visible/>\r\n  </x:ClientData>\r\n </v:shape></xml>");
     writer.Flush();
     writer.Close();
 }
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:8,代码来源:GeneratedCode002-Complex-XLSX.cs

示例13: SaveXmlDefaultConfigurationFile

        /// <summary>
        /// Create and Save a default configuration Xml file based on a easily specific or default defined xml string
        /// </summary>
        /// <param name="FilePath">The fullpath including filename.xml to save to</param>
        /// <param name="XmlConfigurationFileString">If not specified, then will use the XmlDefaultConfigurationFileString</param>
        /// <returns>True if succesfull created</returns>
        /// <remarks></remarks>
        public bool SaveXmlDefaultConfigurationFile(string FilePath, string XmlConfigurationFileString)
        {
            string theXmlString = ((XmlConfigurationFileString != null) ? XmlConfigurationFileString : XmlDefaultConfigurationFileString);
            //What Method You want to use ?, try any by simply change the var XmlSaveMethod declared at top
            switch (XmlSaveMethod) {
                case enumXmlSaveMethod.StreamWrite:
                    //Easy Method
                    using (System.IO.StreamWriter StreamWriter = new System.IO.StreamWriter(FilePath)) {
                        //Without Compact Framework more easily using file.WriteAllText but, CF doesn't have this method
                        StreamWriter.Write(theXmlString);
                        StreamWriter.Close();
                    }

                    return true;

                case enumXmlSaveMethod.XmlTextWriter:
                    //Alternative Method
                    using (System.Xml.XmlTextWriter XmlTextWriter = new System.Xml.XmlTextWriter(FilePath, System.Text.UTF8Encoding.UTF8)) {
                        XmlTextWriter.WriteStartDocument();
                        XmlTextWriter.WriteStartElement("configuration");
                        XmlTextWriter.WriteStartElement("appSettings");
                        foreach (string Item in GetListItems(theXmlString)) {
                            XmlTextWriter.WriteStartElement("add");

                            XmlTextWriter.WriteStartAttribute("key", string.Empty);
                            XmlTextWriter.WriteRaw(GetKey(Item));
                            XmlTextWriter.WriteEndAttribute();

                            XmlTextWriter.WriteStartAttribute("value", string.Empty);
                            XmlTextWriter.WriteRaw(GetValue(Item));
                            XmlTextWriter.WriteEndAttribute();

                            XmlTextWriter.WriteEndElement();

                        }

                        XmlTextWriter.WriteEndElement();
                        XmlTextWriter.WriteEndElement();
                        //XmlTextWriter.WriteEndDocument()
                        XmlTextWriter.Close();

                    }

                    return true;

                case enumXmlSaveMethod.XmlDocument:
                    //Method you will practice
                    System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
                    System.Xml.XmlElement xRoot = XmlDoc.CreateElement("configuration");
                    XmlDoc.AppendChild(xRoot);
                    System.Xml.XmlElement xAppSettingsElement = XmlDoc.CreateElement("appSettings");
                    xRoot.AppendChild(xAppSettingsElement);

                    System.Xml.XmlElement xElement = default(System.Xml.XmlElement);
                    System.Xml.XmlAttribute xAttrKey = default(System.Xml.XmlAttribute);
                    System.Xml.XmlAttribute xAttrValue = default(System.Xml.XmlAttribute);
                    foreach (string Item in GetListItems(theXmlString)) {
                        xElement = XmlDoc.CreateElement("add");
                        xAttrKey = XmlDoc.CreateAttribute("key");
                        xAttrValue = XmlDoc.CreateAttribute("value");
                        xAttrKey.InnerText = GetKey(Item);
                        xElement.SetAttributeNode(xAttrKey);
                        xAttrValue.InnerText = GetValue(Item);
                        xElement.SetAttributeNode(xAttrValue);
                        xAppSettingsElement.AppendChild(xElement);
                    }

                    System.Xml.XmlProcessingInstruction XmlPI = XmlDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='utf-8'");
                    XmlDoc.InsertBefore(XmlPI, XmlDoc.ChildNodes[0]);
                    XmlDoc.Save(FilePath);

                    return true;
            }
            return false;
        }
开发者ID:hjgode,项目名称:eMdiMail,代码行数:82,代码来源:AppSettings.cs

示例14: SendIssueNotifications

        /// <summary>
        /// Sends the issue notifications.
        /// </summary>
        /// <param name="issueId">The issue id.</param>
        /// <param name="issueChanges">The issue changes.</param>
        public static void SendIssueNotifications(int issueId, IEnumerable<IssueHistory> issueChanges)
        {
            // validate input
            if (issueId <= Globals.NEW_ID)
                throw (new ArgumentOutOfRangeException("issueId"));

            var issue = DataProviderManager.Provider.GetIssueById(issueId);
            var issNotifications = DataProviderManager.Provider.GetIssueNotificationsByIssueId(issueId);
            var emailFormatType = HostSettingManager.Get(HostSettingNames.SMTPEMailFormat, EmailFormatType.Text);

            //load template
            var template = NotificationManager.Instance.LoadEmailNotificationTemplate("IssueUpdatedWithChanges", emailFormatType);
            var data = new Dictionary<string, object> {{"Issue", issue}};

            var writer = new System.IO.StringWriter();
            using (System.Xml.XmlWriter xml = new System.Xml.XmlTextWriter(writer))
            {
                xml.WriteStartElement("IssueHistoryChanges");

                foreach (var issueHistory in issueChanges)
                {
                    IssueHistoryManager.SaveOrUpdate(issueHistory);
                    xml.WriteRaw(issueHistory.ToXml());
                }

                xml.WriteEndElement();

                data.Add("RawXml_Changes", writer.ToString());
            }

            template = NotificationManager.GenerateNotificationContent(template, data);

            var subject = NotificationManager.Instance.LoadNotificationTemplate("IssueUpdatedSubject");
            var displayname = UserManager.GetUserDisplayName(Security.GetUserName());

            foreach (var notify in issNotifications)
            {
                try
                {
                    var context = new NotificationContext
                    {
                        BodyText = template,
                        EmailFormatType = emailFormatType,
                        Subject = String.Format(subject, issue.FullId, displayname),
                        UserDisplayName = UserManager.GetUserDisplayName(notify.NotificationUsername),
                        Username = notify.NotificationUsername
                    };

                    NotificationManager.Instance.SendNotification(context);
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            }
        }
开发者ID:chad247,项目名称:bugnet,代码行数:61,代码来源:IssueNotificationManager.cs


注:本文中的System.Xml.XmlTextWriter.WriteRaw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。