예제 #1
0
        public static System.Xml.XmlDocument SetInfopathForm(
            System.Xml.XmlDocument part, string InfopathFormUrl)
        {
            // Delete existing processing instructions.
            foreach (System.Xml.XmlNode pi in part.SelectNodes(
                         "processing-instruction()"))
            {
                pi.ParentNode.RemoveChild(pi);
            }
            // Add an xml declaration
            System.Xml.XmlDeclaration decl =
                part.CreateXmlDeclaration("1.0", null, null);
            part.InsertBefore(decl, part.DocumentElement);
            // Create the mso-application procesing instruction.
            System.Xml.XmlProcessingInstruction progid = part.CreateProcessingInstruction(
                "mso-application", "progid='InfoPath.Document'");
            part.InsertBefore(progid, part.DocumentElement);
            // Create the mso-infoPathSolution processing instruction
            System.Xml.XmlProcessingInstruction form = part.CreateProcessingInstruction(
                "mso-infoPathSolution", "PIVersion='1.0.0.0' href='" +
                InfopathFormUrl + "'");
            part.InsertBefore(form, part.DocumentElement);

            return(part);
        }
예제 #2
0
        private static double MSXMLapproach(int numberOfElements, int numerOfAttributes, List <string> elemetNames, List <string> attributeNames, List <string> attributeValues)
        {
            DateTime now = DateTime.Now;

            System.Xml.XmlDocument    doc    = new System.Xml.XmlDocument();
            System.Xml.XmlDeclaration header = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
            System.Xml.XmlElement     root   = doc.DocumentElement;
            doc.InsertBefore(header, root);
            System.Xml.XmlElement rootElement = doc.CreateElement(string.Empty, "root", string.Empty);
            doc.AppendChild(rootElement);
            for (int i = 0; i < numberOfElements; i++)
            {
                System.Xml.XmlElement element = doc.CreateElement(string.Empty, elemetNames[i], string.Empty);
                for (int j = 0; j < numerOfAttributes; j++)
                {
                    //element.SetAttribute(attributeNameTemplate + j, attributeValueTemplate);
                    element.SetAttribute(attributeNames[j], attributeValues[j]);
                }
                rootElement.AppendChild(element);
            }
            string   output = doc.OuterXml;
            TimeSpan t      = DateTime.Now - now;

            return(t.TotalMilliseconds);
        }
예제 #3
0
파일: Manager.cs 프로젝트: durswd/Effekseer
        public static void SaveWindowConfig(string path)
        {
            var size = Manager.NativeManager.GetSize();

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            System.Xml.XmlElement project_root = doc.CreateElement("Root");
            project_root.AppendChild(doc.CreateTextElement("WindowWidth", size.X.ToString()));
            project_root.AppendChild(doc.CreateTextElement("WindowHeight", size.Y.ToString()));

            System.Xml.XmlElement docks = doc.CreateElement("Docks");

            foreach (var panel in panels)
            {
                if (panel != null)
                {
                    docks.AppendChild(doc.CreateTextElement(panel.GetType().ToString(), "Open"));
                }
            }

            project_root.AppendChild(docks);

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);
            doc.Save(path);
        }
예제 #4
0
        public void Save(string path)
        {
            System.Xml.XmlDocument doc          = new System.Xml.XmlDocument();
            System.Xml.XmlElement  project_root = doc.CreateElement("Root");

            {
                var e = doc.CreateElement("Target");
                e.AppendChild(doc.CreateTextNode(Target.ToString()));
                project_root.AppendChild(e);
            }

            {
                var e = doc.CreateElement("Port");
                e.AppendChild(doc.CreateTextNode(Port.ToString()));
                project_root.AppendChild(e);
            }

            {
                var e = doc.CreateElement("AutoConnect");
                e.AppendChild(doc.CreateTextNode(AutoConnect.ToString()));
                project_root.AppendChild(e);
            }

            {
                var e = doc.CreateElement("SendOnLoad");
                e.AppendChild(doc.CreateTextNode(SendOnLoad.ToString()));
                project_root.AppendChild(e);
            }

            {
                var e = doc.CreateElement("SendOnEdit");
                e.AppendChild(doc.CreateTextNode(SendOnEdit.ToString()));
                project_root.AppendChild(e);
            }

            {
                var e = doc.CreateElement("SendOnSave");
                e.AppendChild(doc.CreateTextNode(SendOnSave.ToString()));
                project_root.AppendChild(e);
            }

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);

            // For failing to save
            try
            {
                doc.Save(path);
            }
            catch
            {
            }
        }
        private System.Xml.XmlDocument XmlEmptyDocument()
        {
            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();

            System.Xml.XmlDeclaration xmlDeclaration = xmlDocument.CreateXmlDeclaration("1.0", "utf-8", String.Empty);

            xmlDocument.InsertBefore(xmlDeclaration, xmlDocument.DocumentElement);


            return(xmlDocument);
        }
예제 #6
0
        internal static void SaveConfig()
        {
            {
                var rf = GetRecentFiles();

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement project_root = doc.CreateElement("Recent");

                foreach (var f in rf.Reverse())
                {
                    project_root.AppendChild(doc.CreateTextElement("File", f));
                }

                doc.AppendChild(project_root);

                var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                doc.InsertBefore(dec, project_root);
                doc.Save(configRecentPath);
            }

            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement project_root = doc.CreateElement("GUI");

                if (MainForm.WindowState == FormWindowState.Normal)
                {
                    project_root.AppendChild(doc.CreateTextElement("X", MainForm.Location.X.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Y", MainForm.Location.Y.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Width", MainForm.Width.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Height", MainForm.Height.ToString()));
                }
                else                 // 最小化、最大化中はその前の位置とサイズを保存
                {
                    project_root.AppendChild(doc.CreateTextElement("X", MainForm.BeforeResizeLocation.X.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Y", MainForm.BeforeResizeLocation.Y.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Width", MainForm.BeforeResizeWidth.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Height", MainForm.BeforeResizeHeight.ToString()));
                }
                doc.AppendChild(project_root);

                var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                doc.InsertBefore(dec, project_root);
                doc.Save(configGuiPath);
            }

            MainForm.Panel.SaveAsXml(configGuiPanelPath, Encoding.UTF8);

            Network.Save(configNetworkPath);
        }
예제 #7
0
        public static void SaveTo(string path)
        {
            path = System.IO.Path.GetFullPath(path);

            FullPath = path;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var element = Data.IO.SaveObjectToElement(doc, "Root", Core.Root, false);

            var behaviorElement = Data.IO.SaveObjectToElement(doc, "Behavior", EffectBehavior, false);
            var cullingElement  = Data.IO.SaveObjectToElement(doc, "Culling", Culling, false);
            var globalElement   = Data.IO.SaveObjectToElement(doc, "Global", Global, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");

            project_root.AppendChild(element);

            if (behaviorElement != null)
            {
                project_root.AppendChild(behaviorElement);
            }
            if (cullingElement != null)
            {
                project_root.AppendChild(cullingElement);
            }
            if (globalElement != null)
            {
                project_root.AppendChild(globalElement);
            }

            project_root.AppendChild(doc.CreateTextElement("ToolVersion", Core.Version));
            project_root.AppendChild(doc.CreateTextElement("Version", 3));
            project_root.AppendChild(doc.CreateTextElement("StartFrame", StartFrame));
            project_root.AppendChild(doc.CreateTextElement("EndFrame", EndFrame));
            project_root.AppendChild(doc.CreateTextElement("IsLoop", IsLoop.ToString()));

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);
            doc.Save(path);
            IsChanged = false;

            if (OnAfterSave != null)
            {
                OnAfterSave(null, null);
            }
        }
예제 #8
0
        public void SetDTDLocation(string dtdLocation)
        {
            System.Xml.XmlDocument doc = (System.Xml.XmlDocument)Node;
            string publicId            = null;
            string internalSubset      = null;

            if (doc.DocumentElement == null)
            {
                throw new System.InvalidOperationException("SetDTDLocation requires a root element.");
            }
            if (doc.DocumentType != null)
            {
                publicId       = doc.DocumentType.PublicId;
                internalSubset = doc.DocumentType.InternalSubset;

                doc.RemoveChild(doc.DocumentType);
            }
            doc.InsertBefore(doc.DocumentElement, doc.CreateDocumentType(doc.DocumentElement.Name, publicId, dtdLocation, internalSubset));
        }
예제 #9
0
        internal static void SaveRecentConfig()
        {
            var rf = GetRecentFiles();

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            System.Xml.XmlElement project_root = doc.CreateElement("Recent");

            foreach (var f in rf.Reverse())
            {
                project_root.AppendChild(doc.CreateTextElement("File", f));
            }

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);
            doc.Save(configRecentPath);
        }
예제 #10
0
파일: Manager.cs 프로젝트: OmaeY/Effekseer
        /// <summary>
        /// TODO refactor
        /// </summary>
        /// <param name="path"></param>
        public static void SaveWindowConfig(string path)
        {
            var size = Manager.NativeManager.GetSize();

            const int minimumSize = 200;

            var state = MainWindow.GetState();

            if (state.Width <= minimumSize || state.Height <= minimumSize)
            {
                return;
            }

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            System.Xml.XmlElement project_root = doc.CreateElement("Root");
            project_root.AppendChild(doc.CreateTextElement("WindowWidth", state.Width.ToString()));
            project_root.AppendChild(doc.CreateTextElement("WindowHeight", state.Height.ToString()));
            project_root.AppendChild(doc.CreateTextElement("WindowPosX", state.PosX.ToString()));
            project_root.AppendChild(doc.CreateTextElement("WindowPosY", state.PosY.ToString()));
            project_root.AppendChild(doc.CreateTextElement("WindowIsMaximumMode", state.IsMaximumMode ? "1" : "0"));

            System.Xml.XmlElement docks = doc.CreateElement("Docks");

            foreach (var panel in panels)
            {
                if (panel != null)
                {
                    docks.AppendChild(doc.CreateTextElement(panel.GetType().ToString(), "Open"));
                }
            }

            project_root.AppendChild(docks);

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);
            doc.Save(path);
        }
예제 #11
0
        internal PropertySet PsFromXml(string Xml)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(Xml);
            //System.Xml.XmlTextReader r  =new System.Xml.XmlTextReader(Xml,
            PropertySet ps = new PropertySet();

            //ps.PsValue = Xml;
            //System.Xml.XmlWriter w = System.Xml.XmlWriter.Create(
            //System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            //doc.LoadXml(Xml);
            System.Xml.XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "UTF-8", "");
            doc.InsertBefore(decl, doc.DocumentElement);
            ps.PsValue = doc.OuterXml;

/*          ps.PsValue = @"<?xml version='1.0' encoding='UTF-16'?><?Siebel-Property-Set EscapeNames='true'?><AAA>aaa</AAA>";
 *          ps.PsValue = @"<?xml version='1.0' encoding='UTF-16'?><AAA>aaa</AAA>";
 */
            ps = InvokeMethod(m_mainBsName, m_FuncXml2PsName, ps).FunctionResult;
            return(ps);
        }
예제 #12
0
        public ActionResult ajxPreviewTemplate(string tempName)
        {
            InvTemplate         it          = new InvTemplate();
            IInvTemplateService _invTempSrc = IoC.Resolve <IInvTemplateService>();

            it = _invTempSrc.GetByName(tempName);
            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
            xdoc.PreserveWhitespace = true;
            xdoc.LoadXml(it.XmlFile);
            System.Xml.XmlProcessingInstruction newPI;
            String PItext = "type='text/xsl' href='" + FX.Utils.UrlUtil.GetSiteUrl() + "/InvoiceTemplate/GetXSLTbyTempName?tempname=" + it.TemplateName + "'";

            newPI = xdoc.CreateProcessingInstruction("xml-stylesheet", PItext);
            xdoc.InsertBefore(newPI, xdoc.DocumentElement);
            logtest.Info("tempName: " + tempName + " href: " + PItext);

            //IViewer _iViewerSrv = IoC.Resolve<IViewer>();
            IViewer _iViewerSrv = InvServiceFactory.GetViewer(tempName);

            return(Json(_iViewerSrv.GetHtml(System.Text.Encoding.UTF8.GetBytes(xdoc.OuterXml))));
        }
예제 #13
0
        static public void SaveOption()
        {
            var path = System.IO.Path.Combine(GetEntryDirectory(), OptionFilePath);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var optionElement = Data.IO.SaveObjectToElement(doc, "Option", Option, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");
            if (optionElement != null)
            {
                project_root.AppendChild(optionElement);
            }

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);
            doc.Save(path);
            IsChanged = false;
        }
예제 #14
0
파일: Core.cs 프로젝트: yczxf/Effekseer
        static public void SaveOption()
        {
            var path = System.IO.Path.Combine(GetEntryDirectory(), OptionFilePath);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var optionElement     = Data.IO.SaveObjectToElement(doc, "Option", Option, false);
            var postEffectElement = Data.IO.SaveObjectToElement(doc, "PostEffect", PostEffect, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");
            if (optionElement != null)
            {
                project_root.AppendChild(optionElement);
            }
            if (postEffectElement != null)
            {
                project_root.AppendChild(postEffectElement);
            }

            // recording option (this option is stored in local or global)
            if (recording.RecordingStorageTarget.Value == Data.RecordingStorageTargetTyoe.Global)
            {
                var recordingElement = Data.IO.SaveObjectToElement(doc, "Recording", Recording, false);
                if (recordingElement != null)
                {
                    project_root.AppendChild(recordingElement);
                }
            }

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);
            doc.Save(path);
            IsChanged = false;
        }
예제 #15
0
        private double MSXMLapproach(int elementCounter, int attributeCounter, string elementNameTemplate, string attributeNameTemplate, string attributeValueTemplate)
        {
            DateTime now = DateTime.Now;

            System.Xml.XmlDocument    doc    = new System.Xml.XmlDocument();
            System.Xml.XmlDeclaration header = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
            System.Xml.XmlElement     root   = doc.DocumentElement;
            doc.InsertBefore(header, root);
            System.Xml.XmlElement rootElement = doc.CreateElement(string.Empty, "root", string.Empty);
            doc.AppendChild(rootElement);
            for (int i = 0; i < elementCounter; i++)
            {
                System.Xml.XmlElement element = doc.CreateElement(string.Empty, elementNameTemplate, string.Empty);
                for (int j = 0; j < attributeCounter; j++)
                {
                    element.SetAttribute(attributeNameTemplate + j, attributeValueTemplate);
                }
                rootElement.AppendChild(element);
            }
            string   output = doc.OuterXml;
            TimeSpan t      = DateTime.Now - now;

            return(t.TotalMilliseconds);
        }
예제 #16
0
파일: Core.cs 프로젝트: kou-yeung/Effekseer
        public static void SaveOption()
        {
            var path = System.IO.Path.Combine(GetEntryDirectory(), OptionFilePath);

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var optionElement = Data.IO.SaveObjectToElement(doc, "Option", Option, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");
            if(optionElement != null) project_root.AppendChild(optionElement);

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.InsertBefore(dec, project_root);
            doc.Save(path);
            IsChanged = false;
        }
예제 #17
0
        /// <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;
        }
예제 #18
0
        public object SaveXmlCurrentConfiguration(string StrPath, string StrFilename /*= "AppSettings.xml"*/)
        {
            //Conform the Path
            string FilePath = (!(StrPath == null) ? StrPath : System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)) + "\\" + StrFilename;

            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);
            //For Each Item As String In Me.ListItems
            for (int i = 0; i <= this.ListItems.Count - 1; i++) {
                xElement = XmlDoc.CreateElement("add");
                xAttrKey = XmlDoc.CreateAttribute("key");
                xAttrValue = XmlDoc.CreateAttribute("value");
                xAttrKey.InnerText = this.ListItems.GetKey(i);
                xElement.SetAttributeNode(xAttrKey);
                xAttrValue.InnerText = this.ListItems[i];
                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;
        }
예제 #19
0
        public void Fax(Public.Faxing.FaxServerConfiguration forFaxServerConfiguration, FaxSender forSender, FaxRecipient forRecipient, FaxDocument forDocument, Dictionary <String, String> extendedProperties)
        {
            faxServerConfiguration = forFaxServerConfiguration;

            sender = forSender;

            recipient = forRecipient;

            document = forDocument;


            String controlFileName = document.UniqueId + ".xml";

            String attachmentFileName = document.UniqueId + "." + document.Attachment.Extension;

            String statusFileName = controlFileName + ".status";


            System.Diagnostics.Debug.WriteLine("Source ID:" + document.UniqueId);


            // CREATE FAX CONTROL FILE


            System.Xml.XmlDocument controlDocument = new System.Xml.XmlDocument();

            System.Xml.XmlDeclaration xmlDeclaration = controlDocument.CreateXmlDeclaration("1.0", "utf-8", String.Empty);

            System.Xml.XmlElement controlElementNode = controlDocument.CreateElement("faxmakerdata");

            System.Xml.XmlElement fieldsElementNode = controlDocument.CreateElement("fields");

            System.Xml.XmlElement senderElementNode = controlDocument.CreateElement("sender");

            System.Xml.XmlElement recipientsElementNode = controlDocument.CreateElement("recipients");

            System.Xml.XmlElement recipientsFaxElementNode = controlDocument.CreateElement("fax");

            System.Xml.XmlElement recipientElementNode = controlDocument.CreateElement("recipient");


            #region Initialize Document Structure

            controlDocument.InsertBefore(xmlDeclaration, controlDocument.DocumentElement);

            controlDocument.AppendChild(controlElementNode);

            controlElementNode.AppendChild(fieldsElementNode);

            controlElementNode.AppendChild(senderElementNode);

            controlElementNode.AppendChild(recipientsElementNode);

            recipientsElementNode.AppendChild(recipientsFaxElementNode);

            recipientsFaxElementNode.AppendChild(recipientElementNode);


            // FAXMAKERDATA

            // +-- FIELDS

            // +-- SENDER

            // +-- RECIPIENTS

            // +-- +-- FAX

            // +-- +-- +-- RECIPIENT

            #endregion


            #region Sender Node

            if (!String.IsNullOrWhiteSpace(sender.Name))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "lastname", sender.Name);
            }

            if (!String.IsNullOrWhiteSpace(sender.Company))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "company", sender.Company);
            }

            if (!String.IsNullOrWhiteSpace(sender.Department))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "department", sender.Department);
            }

            if (!String.IsNullOrWhiteSpace(sender.FaxNumber))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "faxnumber", sender.FaxNumber);
            }

            if (!String.IsNullOrWhiteSpace(sender.VoiceNumber))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "voicenumber", sender.VoiceNumber);
            }

            // if (!String.IsNullOrWhiteSpace (sender.Email)) { Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode (controlDocument, senderElementNode, "emailaddress", sender.Email); }

            Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, senderElementNode, "emailaddress", sender.Email);

            #endregion


            #region Recipient Node

            String faxNumber = recipient.FaxNumber;

            faxNumber = (faxNumber.Length == 7) ? faxNumber.Substring(0, 3) + "-" + faxNumber.Substring(3, 4) : faxNumber;

            faxNumber = (faxNumber.Length == 10) ? "1-" + faxNumber.Substring(0, 3) + "-" + faxNumber.Substring(3, 3) + "-" + faxNumber.Substring(6, 4) : faxNumber;



            if (!String.IsNullOrWhiteSpace(recipient.RecipientName))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "lastname", recipient.RecipientName);
            }

            if (!String.IsNullOrWhiteSpace(recipient.CompanyName))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "company", recipient.CompanyName);
            }

            if (!String.IsNullOrWhiteSpace(recipient.DepartmentName))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "department", recipient.DepartmentName);
            }

            Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "faxnumber", faxNumber);

            if (!String.IsNullOrWhiteSpace(recipient.RecipientEmail))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, recipientElementNode, "emaladdress", recipient.RecipientEmail);
            }

            #endregion


            #region Fields Node

            if (!String.IsNullOrWhiteSpace(document.Subject))
            {
                Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, fieldsElementNode, "subject", document.Subject);
            }

            Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, fieldsElementNode, "resolution", "high");

            Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, fieldsElementNode, "attachment", attachmentFileName);

            Mercury.Server.Public.CommonFunctions.XmlDocumentAppendNode(controlDocument, fieldsElementNode, "uid", document.UniqueId);

            #endregion


            attachmentFileName = faxServerConfiguration.FaxUrl + @"\" + attachmentFileName;

            attachmentFileName = attachmentFileName.Replace(@"\\" + attachmentFileName, @"\" + attachmentFileName);


            System.IO.FileStream attachmentFile = new System.IO.FileStream(attachmentFileName, System.IO.FileMode.Create);

            document.Attachment.Image.Seek(0, System.IO.SeekOrigin.Begin);

            document.Attachment.Image.WriteTo(attachmentFile);

            attachmentFile.Flush();

            attachmentFile.Close();


            controlFileName = faxServerConfiguration.FaxUrl + @"\" + controlFileName;

            controlFileName = controlFileName.Replace(@"\\" + controlFileName, @"\" + controlFileName);

            controlDocument.Save(controlFileName);


            statusWatchStartTime = DateTime.Now;

            statusWatcher = new System.IO.FileSystemWatcher();

            statusWatcher.Filter = "*.status";

            statusWatcher.Created += new System.IO.FileSystemEventHandler(StatusWatcher_OnFileCreated);

            statusWatcher.Path = faxServerConfiguration.FaxUrl;

            statusWatcher.EnableRaisingEvents = true;


            return;
        }
        private void DataExplorerNodeResultsGrid_ExportToExcel()
        {
            if (DataExplorerTreeView.CheckedNodes.Count == 0)
            {
                return;
            }


            Boolean usesEntityCurrentMailingAddress = false;

            Boolean usesEntityCurrentContactInformation = false;

            Boolean usesMemberCurrentEnrollment = false;

            Boolean usesMemberCurrentEnrollmentCoverage = false;

            Boolean usesMemberCurrentEnrollmentPcp = false;


            System.Xml.XmlElement styleElement;

            System.Xml.XmlElement fontElement;


            System.Xml.XmlElement column;

            System.Xml.XmlElement row;

            System.Xml.XmlElement cell;

            System.Xml.XmlElement cellData;

            Int32 columnIndex = 0;


            System.Xml.XmlDocument excelDocument = new System.Xml.XmlDocument();

            System.Xml.XmlDeclaration xmlDeclaration = excelDocument.CreateXmlDeclaration("1.0", "utf-8", String.Empty);

            excelDocument.InsertBefore(xmlDeclaration, excelDocument.DocumentElement);

            excelDocument.AppendChild(excelDocument.CreateProcessingInstruction("mso-application", "progid=\"Excel.Sheet\""));


            #region Create Workbook and Worksheet and Styles

            System.Xml.XmlElement workbookElement = excelDocument.CreateElement("Workbook");

            workbookElement.SetAttribute("xmlns", "urn:schemas-microsoft-com:office:spreadsheet");

            workbookElement.SetAttribute("xmlns:o", "urn:schemas-microsoft-com:office:office");

            workbookElement.SetAttribute("xmlns:ss", "urn:schemas-microsoft-com:office:spreadsheet");

            workbookElement.SetAttribute("xmlns:x", "urn:schemas-microsoft-com:office:excel");

            excelDocument.AppendChild(workbookElement);


            System.Xml.XmlElement stylesCollectionElement = excelDocument.CreateElement("Styles");

            workbookElement.AppendChild(stylesCollectionElement);


            styleElement = excelDocument.CreateElement("Style");

            styleElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "ID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleNormal"));

            stylesCollectionElement.AppendChild(styleElement);

            fontElement = excelDocument.CreateElement("Font");

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "FontName", "urn:schemas-microsoft-com:office:spreadsheet", "Arial"));

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "x", "Family", "urn:schemas-microsoft-com:office:excel", "Swiss"));

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Size", "urn:schemas-microsoft-com:office:spreadsheet", "8"));

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Color", "urn:schemas-microsoft-com:office:spreadsheet", "#000000"));

            styleElement.AppendChild(fontElement);



            styleElement = excelDocument.CreateElement("Style");

            styleElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "ID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleBold"));

            stylesCollectionElement.AppendChild(styleElement);

            fontElement = excelDocument.CreateElement("Font");

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "FontName", "urn:schemas-microsoft-com:office:spreadsheet", "Arial"));

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "x", "Family", "urn:schemas-microsoft-com:office:excel", "Swiss"));

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Size", "urn:schemas-microsoft-com:office:spreadsheet", "8"));

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Color", "urn:schemas-microsoft-com:office:spreadsheet", "#000000"));

            fontElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Bold", "urn:schemas-microsoft-com:office:spreadsheet", "1"));

            styleElement.AppendChild(fontElement);



            System.Xml.XmlElement worksheetElement = excelDocument.CreateElement("Worksheet");

            worksheetElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Name", "urn:schemas-microsoft-com:office:spreadsheet", "Data"));

            workbookElement.AppendChild(worksheetElement);


            System.Xml.XmlElement worksheetTableElement = excelDocument.CreateElement("Table");

            worksheetTableElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "StyleID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleNormal"));

            worksheetTableElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "DefaultRowHeight", "urn:schemas-microsoft-com:office:spreadsheet", "15"));

            worksheetElement.AppendChild(worksheetTableElement);

            #endregion


            #region Create Header Row

            System.Xml.XmlElement headerRow = excelDocument.CreateElement("Row");


            columnIndex = 0;

            foreach (Telerik.Web.UI.RadTreeNode currentCheckedNode in DataExplorerTreeView.CheckedNodes)
            {
                columnIndex = columnIndex + 1;


                column = excelDocument.CreateElement("Column");

                column.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Width", "urn:schemas-microsoft-com:office:spreadsheet", "100"));

                column.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "StyleID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleNormal"));

                worksheetTableElement.AppendChild(column);


                cell = excelDocument.CreateElement("Cell");

                cell.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "StyleID", "urn:schemas-microsoft-com:office:spreadsheet", "StyleBold"));

                cell.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Index", "urn:schemas-microsoft-com:office:spreadsheet", columnIndex.ToString()));

                headerRow.AppendChild(cell);


                cellData = excelDocument.CreateElement("Data");

                cellData.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Type", "urn:schemas-microsoft-com:office:spreadsheet", "String"));

                cellData.InnerText = currentCheckedNode.Text;

                cell.AppendChild(cellData);



                usesEntityCurrentMailingAddress |= currentCheckedNode.Value.StartsWith("Entity.CurrentMailingAddress.");

                usesEntityCurrentContactInformation |= currentCheckedNode.Value.StartsWith("Entity.CurrentContactInformation");

                usesMemberCurrentEnrollment |= currentCheckedNode.Value.StartsWith("CurrentEnrollment.");

                usesMemberCurrentEnrollmentCoverage |= currentCheckedNode.Value.StartsWith("CurrentEnrollmentCoverage");

                usesMemberCurrentEnrollmentPcp |= currentCheckedNode.Value.StartsWith("CurrentEnrollmentPcp");
            }

            worksheetTableElement.AppendChild(headerRow);


            #endregion


            #region Create Data Rows

            // RETREIVE LIST OF MEMBERS AND PRE-CACHE RELATED DATA

            List <Client.Core.Member.Member> members = MercuryApplication.DataExplorerNodeResultsGetForMember(NodeInstanceId, 1, NodeInstanceCount);

            List <Client.Core.Member.MemberEnrollment> allMemberEnrollments = null;

            List <Client.Core.Member.MemberEnrollmentCoverage> allMemberEnrollmentCoverages = null;

            List <Client.Core.Member.MemberEnrollmentPcp> allMemberEnrollmentPcps = null;

            //  THESE ITEMS ARE AUTOMATICALLY CACHED AND AVAILABLE

            if (usesEntityCurrentMailingAddress)
            {
                MercuryApplication.DataExplorerNodeResultsGetForMemberEntityCurrentAddress(NodeInstanceId, 1, NodeInstanceCount);
            }

            if (usesEntityCurrentContactInformation)
            {
                MercuryApplication.DataExplorerNodeResultsGetForMemberEntityCurrentContactInformation(NodeInstanceId, 1, NodeInstanceCount);
            }

            // THESE ITEMS MUST BE STORED AND USED LOCALLY (COULD BE LARG RESULT SETS!)

            if ((usesMemberCurrentEnrollment) || (usesMemberCurrentEnrollmentCoverage) || (usesMemberCurrentEnrollmentPcp))
            {
                // MUST GET CURRENT ENROLLMENTS TO WALK TO CHILD OBJECTS COVERAGE AND PCP

                allMemberEnrollments = MercuryApplication.DataExplorerNodeResultsGetForMemberCurrentEnrollment(NodeInstanceId, 1, NodeInstanceCount);

                if (usesMemberCurrentEnrollmentCoverage)
                {
                    allMemberEnrollmentCoverages = MercuryApplication.DataExplorerNodeResultsGetForMemberCurrentEnrollmentCoverage(NodeInstanceId, 1, NodeInstanceCount);
                }

                if (usesMemberCurrentEnrollmentPcp)
                {
                    allMemberEnrollmentPcps = MercuryApplication.DataExplorerNodeResultsGetForMemberCurrentEnrollmentPcp(NodeInstanceId, 1, NodeInstanceCount);
                }
            }

            foreach (Client.Core.Member.Member currentMember in members)
            {
                row = excelDocument.CreateElement("Row");

                columnIndex = 0;


                #region Precache Data Elements

                // PRECACHE CURRENT MEMBER ENROLLMENT FOR MULTI-PROPERTY ACCESS

                // MUST GET CURRENT ENROLLMENTS TO WALK TO CHILD OBJECTS COVERAGE AND PCP

                Client.Core.Member.MemberEnrollment currentMemberEnrollment = null;

                if ((usesMemberCurrentEnrollment) || (usesMemberCurrentEnrollmentCoverage) || (usesMemberCurrentEnrollmentPcp))
                {
                    List <Client.Core.Member.MemberEnrollment> filteredMemberEnrollment =

                        (from memberEnrollment in allMemberEnrollments

                         where memberEnrollment.MemberId == currentMember.Id

                         select memberEnrollment).ToList();

                    if (filteredMemberEnrollment.Count > 0)
                    {
                        currentMemberEnrollment = filteredMemberEnrollment[0];
                    }
                }

                // PRECACHE CURRENT MEMBER ENROLLMENT COVERAGE FOR MULTI-PROPERTY ACCESS

                Client.Core.Member.MemberEnrollmentCoverage currentMemberEnrollmentCoverage = null;

                if ((usesMemberCurrentEnrollmentCoverage) && (currentMemberEnrollment != null))
                {
                    List <Client.Core.Member.MemberEnrollmentCoverage> filteredMemberEnrollmentCoverage =

                        (from memberEnrollmentCoverage in allMemberEnrollmentCoverages

                         where memberEnrollmentCoverage.MemberEnrollmentId == currentMemberEnrollment.Id

                         select memberEnrollmentCoverage).ToList();

                    if (filteredMemberEnrollmentCoverage.Count > 0)
                    {
                        currentMemberEnrollmentCoverage = filteredMemberEnrollmentCoverage[0];
                    }
                }

                Client.Core.Member.MemberEnrollmentPcp currentMemberEnrollmentPcp = null;

                if ((usesMemberCurrentEnrollmentPcp) && (currentMemberEnrollment != null))
                {
                    List <Client.Core.Member.MemberEnrollmentPcp> filteredMemberEnrollmentPcp =

                        (from memberEnrollmentPcp in allMemberEnrollmentPcps

                         where memberEnrollmentPcp.MemberEnrollmentId == currentMemberEnrollment.Id

                         select memberEnrollmentPcp).ToList();

                    if (filteredMemberEnrollmentPcp.Count > 0)
                    {
                        currentMemberEnrollmentPcp = filteredMemberEnrollmentPcp[0];
                    }
                }

                #endregion


                #region Create Cells and Data Values

                foreach (Telerik.Web.UI.RadTreeNode currentCheckedNode in DataExplorerTreeView.CheckedNodes)
                {
                    columnIndex = columnIndex + 1;

                    String contentProperty = String.Empty;

                    Object contentValueObject = null;

                    String contentValue = String.Empty;

                    if (currentCheckedNode.Value.StartsWith("CurrentEnrollment."))
                    {
                        if (currentMemberEnrollment != null)
                        {
                            contentProperty = currentCheckedNode.Value.Substring("CurrentEnrollment.".Length, currentCheckedNode.Value.Length - "CurrentEnrollment.".Length);

                            contentValueObject = Mercury.Server.CommonFunctions.GetPropertyValue(currentMemberEnrollment, contentProperty);
                        }
                    }

                    else if (currentCheckedNode.Value.StartsWith("CurrentEnrollmentCoverage."))
                    {
                        if (currentMemberEnrollment != null)
                        {
                            contentProperty = currentCheckedNode.Value.Substring("CurrentEnrollmentCoverage.".Length, currentCheckedNode.Value.Length - "CurrentEnrollmentCoverage.".Length);

                            contentValueObject = Mercury.Server.CommonFunctions.GetPropertyValue(currentMemberEnrollmentCoverage, contentProperty);
                        }
                    }

                    else if (currentCheckedNode.Value.StartsWith("CurrentEnrollmentPcp."))
                    {
                        if (currentMemberEnrollment != null)
                        {
                            contentProperty = currentCheckedNode.Value.Substring("CurrentEnrollmentPcp.".Length, currentCheckedNode.Value.Length - "CurrentEnrollmentPcp.".Length);

                            contentValueObject = Mercury.Server.CommonFunctions.GetPropertyValue(currentMemberEnrollmentPcp, contentProperty);
                        }
                    }

                    else
                    {
                        contentValueObject = Mercury.Server.CommonFunctions.GetPropertyValue(currentMember, currentCheckedNode.Value);
                    }

                    if (contentValueObject != null)
                    {
                        contentValue = contentValueObject.ToString();
                    }


                    cell = excelDocument.CreateElement("Cell");

                    cell.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Index", "urn:schemas-microsoft-com:office:spreadsheet", columnIndex.ToString()));

                    row.AppendChild(cell);


                    cellData = excelDocument.CreateElement("Data");

                    cellData.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "ss", "Type", "urn:schemas-microsoft-com:office:spreadsheet", "String"));

                    cellData.InnerText = contentValue;

                    cell.AppendChild(cellData);
                }

                #endregion


                worksheetTableElement.AppendChild(row);
            }

            #endregion


            System.Xml.XmlElement worksheetAutoFilterElement = excelDocument.CreateElement("AutoFilter");

            worksheetAutoFilterElement.SetAttributeNode(XmlDocument_CreateAttribute(excelDocument, "x", "Range", "urn:schemas-microsoft-com:office:excel", "R1C1:R1C1"));

            worksheetAutoFilterElement.SetAttribute("xmlns", "urn:schemas-microsoft-com:office:excel");

            worksheetElement.AppendChild(worksheetAutoFilterElement);


            Response.Clear();

            Response.AddHeader("Content-Disposition", "attachment; filename=DataExplorerResults.xml");

            Response.AddHeader("Content-Length", excelDocument.OuterXml.Length.ToString());

            Response.ContentType = "application/octet-stream";

            Response.OutputStream.Write(new System.Text.ASCIIEncoding().GetBytes(excelDocument.OuterXml.ToCharArray()), 0, excelDocument.OuterXml.Length);

            Response.End();



            return;
        }
예제 #21
0
        /// <summary>
        /// Modifica l'header del file XML della fatturazione elettronica con
        /// l'intestazione per il xlst in modo da essere visualizzato in modo umano
        /// Faillace 23/6/2014
        /// </summary>
        /// <param name="xmlByteArray">xml in ingresso</param>
        /// <returns>xml in uscita, se non è di tipo fatturazione , restituisce null</returns>
        private byte[] fatturazioneElettronicaInsertXlst(byte[] xmlByteArray)
        {
            System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
            //Predisposizione FIX xml 1.1 se escono anomalie decommenta il codice sotto e sostituisci la xd.Load con la xd.LoadXml nel try.

            System.IO.TextReader tr = new System.IO.StreamReader(new System.IO.MemoryStream(xmlByteArray));
            string fattura          = tr.ReadToEnd();

            fattura = fattura.Replace("<?xml version=\"1.1", "<?xml version=\"1.0");  //FIX per l'xml 1.1 (che non viene processato da dotnet)
            bool isFattura = false;

            try
            {
                xd.LoadXml(fattura);
                //xd.Load(new System.IO.MemoryStream(xmlByteArray));
                //controllo se il namespace è tipo fattura elettronica
                if (xd.DocumentElement.NamespaceURI.ToLower().Equals("http://www.fatturapa.gov.it/sdi/fatturapa/v1.0") ||
                    xd.DocumentElement.NamespaceURI.ToLower().Equals("http://www.fatturapa.gov.it/sdi/fatturapa/v1.1") ||
                    xd.DocumentElement.NamespaceURI.ToLower().Equals("http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fatture/v1.2"))
                {
                    System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(xd.NameTable);
                    //se lo è aggiungo il namespace e il prefix
                    mgr.AddNamespace(xd.DocumentElement.Prefix, xd.DocumentElement.NamespaceURI);
                    //faccio una ricerca xpat per trovare il nodo FatturaElettronica
                    // Old Code
                    //System.Xml.XmlNode xn = xd.SelectSingleNode("//p:FatturaElettronica", mgr);
                    // New Code
                    System.Xml.XmlNode xn = null;

                    if (!string.IsNullOrEmpty(xd.DocumentElement.Prefix))
                    {
                        xn = xd.SelectSingleNode("//" + xd.DocumentElement.Prefix + ":FatturaElettronica", mgr);
                    }
                    else
                    {
                        //xn = xd.SelectSingleNode("FatturaElettronica");
                        if (xd.DocumentElement != null &&
                            !string.IsNullOrEmpty(xd.DocumentElement.Name) &&
                            xd.DocumentElement.Name.Equals("FatturaElettronica"))
                        {
                            xn = xd.DocumentElement;
                        }
                        else
                        {
                            xn = xd.SelectSingleNode("FatturaElettronica");
                        }
                    }

                    if (xn != null)
                    {
                        string nsUri = xd.DocumentElement.NamespaceURI.ToLower();
                        //Se è una fattura elettronica creo l'intestazione xlst con in path il file di trasfomazione che sta nell'xml di DPA
                        System.Xml.XmlProcessingInstruction dpaProcessingInformation = xd.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"../xml/fatturapa_v1.0.xsl\"");
                        if (nsUri.EndsWith("v1.1"))
                        {
                            dpaProcessingInformation = xd.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"../xml/fatturapa_v1.1.xsl\"");
                        }
                        else if (nsUri.EndsWith("v1.2"))
                        {
                            dpaProcessingInformation = xd.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"../xml/fatturapa_v1.2.xsl\"");
                        }

                        //Ricerco il un eventuale xlst preessitente nel file xml
                        System.Xml.XmlProcessingInstruction foundProcessingInformation = xd.SelectSingleNode("//processing-instruction(\"xml-stylesheet\")") as System.Xml.XmlProcessingInstruction;
                        if (foundProcessingInformation != null)
                        {
                            // se lo trova lo rimpazza con quello geenrato sopra
                            xd.ReplaceChild(dpaProcessingInformation, foundProcessingInformation);
                        }
                        else
                        {
                            //inserisce l'xlst in cima al documento prima del primo tag
                            xd.InsertBefore(dpaProcessingInformation, xn);
                        }
                        //preparo un memorystream per l'output
                        System.IO.MemoryStream msOut = new System.IO.MemoryStream();
                        //salvo il risultato sul memorystream
                        xd.Save(msOut);
                        isFattura = true;
                        //esco con il risultato
                        return(msOut.ToArray());
                    }
                }
                if (!isFattura && (xd.DocumentElement.NamespaceURI.ToLower().Equals("http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fattura/messaggi/v1.0") ||
                                   xd.DocumentElement.NamespaceURI.ToLower().Equals("http://www.fatturapa.gov.it/sdi/fatturapa/v1.0") ||
                                   xd.DocumentElement.NamespaceURI.ToLower().Equals("http://www.fatturapa.gov.it/sdi/messaggi/v1.0")))
                {
                    // Ricevute SDI
                    System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(xd.NameTable);

                    if (xd.DocumentElement.NamespaceURI.ToLower().Equals("http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fattura/messaggi/v1.0"))
                    {
                        mgr.AddNamespace("ns3", "http://ivaservizi.agenziaentrate.gov.it/docs/xsd/fattura/messaggi/v1.0");
                    }
                    else if (xd.DocumentElement.NamespaceURI.ToLower().Equals("http://www.fatturapa.gov.it/sdi/fatturapa/v1.0"))
                    {
                        mgr.AddNamespace("ns3", "http://www.fatturapa.gov.it/sdi/fatturapa/v1.0");
                    }
                    else if (xd.DocumentElement.NamespaceURI.ToLower().Equals("http://www.fatturapa.gov.it/sdi/messaggi/v1.0"))
                    {
                        mgr.AddNamespace("ns3", "http://www.fatturapa.gov.it/sdi/messaggi/v1.0");
                    }
                    else
                    {
                        return(null);
                    }

                    string urlXSL = string.Empty;

                    if (xd.SelectSingleNode("//ns3:RicevutaConsegna", mgr) != null)
                    {
                        urlXSL = "../xml/RC_v1.1.xsl";
                    }
                    else if (xd.SelectSingleNode("//ns3:NotificaMancataConsegna", mgr) != null || xd.SelectSingleNode("//ns3:RicevutaImpossibilitaRecapito", mgr) != null)
                    {
                        urlXSL = "../xml/MC_v1.1.xsl";
                    }
                    else if (xd.SelectSingleNode("//ns3:NotificaScarto", mgr) != null || xd.SelectSingleNode("//ns3:RicevutaScarto", mgr) != null)
                    {
                        urlXSL = "../xml/NS_v1.1.xsl";
                    }
                    else if (xd.SelectSingleNode("//ns3:NotificaEsito", mgr) != null)
                    {
                        urlXSL = "../xml/EC_v1.0.xsl";
                    }
                    else if (xd.SelectSingleNode("//ns3:NotificaDecorrenzaTermini", mgr) != null)
                    {
                        urlXSL = "../xml/DT_v1.0.xsl";
                    }
                    else if (xd.SelectSingleNode("//types:ScartoEsitoCommittente", mgr) != null)
                    {
                        urlXSL = "../xml/SE_v1.0.xsl";
                    }


                    string decl  = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
                    string decl8 = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
                    string pi    = "<?xml-stylesheet type=\"text/xsl\" href=\"" + urlXSL + "\"?>";

                    string previewXml = fattura.Replace(decl, decl + "\n" + pi);
                    previewXml = previewXml.Replace(decl8, decl8 + "\n" + pi);
                    xd.LoadXml(previewXml);
                    Byte[] bytes = System.Text.Encoding.UTF8.GetBytes(xd.OuterXml);

                    return(bytes);
                }
            }
            catch (Exception)
            {
            }

            return(null);
        }
예제 #22
0
        void CheckAndFixXMLInput(string Filename)
        {
            System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
            xmld.Load(Filename);
            if (xmld.FirstChild.NodeType != System.Xml.XmlNodeType.XmlDeclaration)
            {
                System.Xml.XmlAttribute atr;
                System.Xml.XmlNode node;
                DateTime dt;

                atr = xmld.CreateAttribute("xmlns:xsd");
                atr.Value = "http://www.w3.org/2001/XMLSchema";
                xmld.FirstChild.Attributes.Append(atr);
                atr = xmld.CreateAttribute("xmlns:xsi");
                atr.Value = "http://www.w3.org/2001/XMLSchema-instance" ;
                xmld.FirstChild.Attributes.Append(atr);
                atr = xmld.CreateAttribute("xmlns");
                atr.Value = "http://carverlab.com/xsd/VideoExchange.xsd";
                xmld.FirstChild.Attributes.Append(atr);
                xmld.InsertBefore(xmld.CreateXmlDeclaration("1.0","utf-8",""),xmld.FirstChild);
                node = xmld.SelectSingleNode("CARDVIDEO/TIMESTART");
                dt = DateTime.Parse(node.InnerText);
                node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
                node = xmld.SelectSingleNode("CARDVIDEO/TIMESTOP");
                dt = DateTime.Parse(node.InnerText);
                node.InnerText = dt.ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
                xmld.Save(Filename);
            }
        }
예제 #23
0
파일: Core.cs 프로젝트: yczxf/Effekseer
        public static System.Xml.XmlDocument SaveAsXmlDocument(string basePath)
        {
            basePath = System.IO.Path.GetFullPath(basePath);

            FullPath = basePath;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var element = Data.IO.SaveObjectToElement(doc, "Root", Core.Root, false);

            var behaviorElement = Data.IO.SaveObjectToElement(doc, "Behavior", EffectBehavior, false);
            var cullingElement  = Data.IO.SaveObjectToElement(doc, "Culling", Culling, false);
            var globalElement   = Data.IO.SaveObjectToElement(doc, "Global", Global, false);
            var dynamicElement  = Data.IO.SaveObjectToElement(doc, "Dynamic", Dynamic, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");

            project_root.AppendChild(element);

            if (behaviorElement != null)
            {
                project_root.AppendChild(behaviorElement);
            }
            if (cullingElement != null)
            {
                project_root.AppendChild(cullingElement);
            }
            if (globalElement != null)
            {
                project_root.AppendChild(globalElement);
            }
            if (dynamicElement != null)
            {
                project_root.AppendChild(dynamicElement);
            }

            // recording option (this option is stored in local or global)
            if (recording.RecordingStorageTarget.Value == Data.RecordingStorageTargetTyoe.Local)
            {
                var recordingElement = Data.IO.SaveObjectToElement(doc, "Recording", Recording, false);
                if (recordingElement != null)
                {
                    project_root.AppendChild(recordingElement);
                }
            }

            project_root.AppendChild(doc.CreateTextElement("ToolVersion", Core.Version));
            project_root.AppendChild(doc.CreateTextElement("Version", 3));
            project_root.AppendChild(doc.CreateTextElement("StartFrame", StartFrame));
            project_root.AppendChild(doc.CreateTextElement("EndFrame", EndFrame));
            project_root.AppendChild(doc.CreateTextElement("IsLoop", IsLoop.ToString()));

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.InsertBefore(dec, project_root);

            IsChanged = false;

            if (OnAfterSave != null)
            {
                OnAfterSave(null, null);
            }

            return(doc);
        }
예제 #24
0
파일: Core.cs 프로젝트: kou-yeung/Effekseer
        public static void SaveTo(string path)
        {
            path = System.IO.Path.GetFullPath(path);

            FullPath = path;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            var element = Data.IO.SaveObjectToElement(doc, "Root", Core.Root, false);

            var behaviorElement = Data.IO.SaveObjectToElement(doc, "Behavior", EffectBehavior, false);
            var cullingElement = Data.IO.SaveObjectToElement(doc, "Culling", Culling, false);

            System.Xml.XmlElement project_root = doc.CreateElement("EffekseerProject");

            project_root.AppendChild(element);

            if(behaviorElement != null) project_root.AppendChild(behaviorElement);
            if (cullingElement != null) project_root.AppendChild(cullingElement);

            project_root.AppendChild(doc.CreateTextElement("ToolVersion", Core.Version));
            project_root.AppendChild(doc.CreateTextElement("Version", 3));
            project_root.AppendChild(doc.CreateTextElement("StartFrame", StartFrame));
            project_root.AppendChild(doc.CreateTextElement("EndFrame", EndFrame));
            project_root.AppendChild(doc.CreateTextElement("IsLoop", IsLoop.ToString()));

            doc.AppendChild(project_root);

            var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.InsertBefore(dec, project_root);
            doc.Save(path);
            IsChanged = false;

            if (OnAfterSave != null)
            {
                OnAfterSave(null, null);
            }
        }
예제 #25
0
        internal static void SaveConfig()
        {
            {
                var rf = GetRecentFiles();

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement project_root = doc.CreateElement("Recent");

                foreach (var f in rf.Reverse())
                {
                    project_root.AppendChild(doc.CreateTextElement("File", f));
                }

                doc.AppendChild(project_root);

                var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                doc.InsertBefore(dec, project_root);
                doc.Save(configRecentPath);
            }

            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement project_root = doc.CreateElement("GUI");

                if (MainForm.WindowState == FormWindowState.Normal)
                {
                    project_root.AppendChild(doc.CreateTextElement("X", MainForm.Location.X.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Y", MainForm.Location.Y.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Width", MainForm.Width.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Height", MainForm.Height.ToString()));
                }
                else // 最小化、最大化中はその前の位置とサイズを保存
                {
                    project_root.AppendChild(doc.CreateTextElement("X", MainForm.BeforeResizeLocation.X.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Y", MainForm.BeforeResizeLocation.Y.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Width", MainForm.BeforeResizeWidth.ToString()));
                    project_root.AppendChild(doc.CreateTextElement("Height", MainForm.BeforeResizeHeight.ToString()));
                }
                doc.AppendChild(project_root);

                var dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                doc.InsertBefore(dec, project_root);
                doc.Save(configGuiPath);
            }

            MainForm.Panel.SaveAsXml(configGuiPanelPath, Encoding.UTF8);

            Network.Save(configNetworkPath);
        }
예제 #26
0
        /// <summary>
        /// Modifica l'header del file XML della fatturazione elettronica con
        /// l'intestazione per il xlst in modo da essere visualizzato in modo umano
        /// Faillace 23/6/2014
        /// </summary>
        /// <param name="xmlByteArray">xml in ingresso</param>
        /// <returns>xml in uscita, se non è di tipo fatturazione , restituisce null</returns>
        private byte[] fatturazioneElettronicaInsertXlst(byte[] xmlByteArray)
        {
            System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
            System.IO.TextReader   tr = new System.IO.StreamReader(new System.IO.MemoryStream(xmlByteArray));
            string fattura            = tr.ReadToEnd();

            fattura = fattura.Replace("<?xml version=\"1.1", "<?xml version=\"1.0"); //FIX per l'xml 1.1 (che non viene processato da dotnet)
            try
            {
                xd.LoadXml(fattura);
                //controllo se il namespace è tipo fattura elettronica
                if (xd.DocumentElement.NamespaceURI.ToLower().Equals("http://www.fatturapa.gov.it/sdi/fatturapa/v1.0") ||
                    xd.DocumentElement.NamespaceURI.ToLower().Equals("http://www.fatturapa.gov.it/sdi/fatturapa/v1.1"))
                {
                    System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(xd.NameTable);
                    //se lo è aggiungo il namespace e il prefix
                    mgr.AddNamespace(xd.DocumentElement.Prefix, xd.DocumentElement.NamespaceURI);
                    //faccio una ricerca xpat per trovare il nodo FatturaElettronica
                    // Old Code
                    //System.Xml.XmlNode xn = xd.SelectSingleNode("//p:FatturaElettronica", mgr);
                    // New Code
                    System.Xml.XmlNode xn = null;

                    if (!string.IsNullOrEmpty(xd.DocumentElement.Prefix))
                    {
                        xn = xd.SelectSingleNode("//" + xd.DocumentElement.Prefix + ":FatturaElettronica", mgr);
                    }
                    else
                    {
                        //xn = xd.SelectSingleNode("FatturaElettronica");
                        if (xd.DocumentElement != null &&
                            !string.IsNullOrEmpty(xd.DocumentElement.Name) &&
                            xd.DocumentElement.Name.Equals("FatturaElettronica"))
                        {
                            xn = xd.DocumentElement;
                        }
                        else
                        {
                            xn = xd.SelectSingleNode("FatturaElettronica");
                        }
                    }

                    if (xn != null)
                    {
                        string nsUri = xd.DocumentElement.NamespaceURI.ToLower();
                        //Se è una fattura elettronica creo l'intestazione xlst con in path il file di trasfomazione che sta nell'xml di DPA
                        System.Xml.XmlProcessingInstruction dpaProcessingInformation = xd.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"../xml/fatturapa_v1.0.xsl\"");
                        if (nsUri.EndsWith("v1.1"))
                        {
                            dpaProcessingInformation = xd.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"../xml/fatturapa_v1.1.xsl\"");
                        }

                        //Ricerco il un eventuale xlst preessitente nel file xml
                        System.Xml.XmlProcessingInstruction foundProcessingInformation = xd.SelectSingleNode("//processing-instruction(\"xml-stylesheet\")") as System.Xml.XmlProcessingInstruction;
                        if (foundProcessingInformation != null)
                        {
                            // se lo trova lo rimpazza con quello geenrato sopra
                            xd.ReplaceChild(dpaProcessingInformation, foundProcessingInformation);
                        }
                        else
                        {
                            //inserisce l'xlst in cima al documento prima del primo tag
                            xd.InsertBefore(dpaProcessingInformation, xn);
                        }
                        //preparo un memorystream per l'output
                        System.IO.MemoryStream msOut = new System.IO.MemoryStream();
                        //salvo il risultato sul memorystream
                        xd.Save(msOut);
                        //esco con il risultato
                        return(msOut.ToArray());
                    }
                }
            }
            // il caricamento dell'xml ha dato errore (xml non formattato, tag non chiusi etc etc etc)
            catch
            { }
            //l'eleaborazione è avvenuta in modo corretto, o non è una fattura  elettronica
            //oppure non è un xml oppure si è verificato un errore
            return(null);
        }
예제 #27
0
파일: asx.cs 프로젝트: CarverLab/Oyster
 public void Read(string Filename)
 {
     // now load this bugger up and get rid or all the junk that WMP can't parse
     System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
     xmld.Load(Filename);
     System.Xml.XmlDeclaration xmldecl = xmld.CreateXmlDeclaration("1.0",null,null);
     xmld.InsertBefore(xmldecl,xmld.DocumentElement);
     string TempFile = System.IO.Path.GetTempFileName();
     xmld.Save(TempFile);
     System.IO.TextReader tw = System.IO.File.OpenText(TempFile);
     m_asx = (CarverLab.Utility.ASX)base.Deserialize(tw);
     tw.Close();
     System.IO.File.Delete(TempFile);
 }