Ejemplo n.º 1
0
Archivo: Xml.cs Proyecto: sopindm/bjeb
            public Xml(string rootName)
            {
                _xml = new System.Xml.XmlDocument();

                System.Xml.XmlDeclaration dec = _xml.CreateXmlDeclaration("1.0", null, null);
                _xml.AppendChild(dec);

                _root = _xml.CreateElement(rootName);
                _xml.AppendChild(_root);
            }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        public void invoicesFile()
        {
            if (!File.Exists(this.dataDir + "fakturor.xml"))
            {
                System.Xml.XmlDocument newDoc = new System.Xml.XmlDocument();

                string sTextX = "<fakturor>";
                sTextX += "</fakturor>";

                newDoc.LoadXml(sTextX);
                newDoc.PrependChild(newDoc.CreateXmlDeclaration("1.0", "utf-8", ""));
                newDoc.Save(this.dataDir + @"fakturor.xml");
            }
        }
Ejemplo n.º 5
0
 public static System.IO.Stream GetFileListXML(string startDir)
 {
     System.Xml.XmlDocument  xmlDoc = new System.Xml.XmlDocument();
     System.Xml.XmlNode      node;
     System.IO.DirectoryInfo dir    = new System.IO.DirectoryInfo(startDir);
     System.IO.MemoryStream  stream = new System.IO.MemoryStream();
     xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "utf-8", "yes"));
     //node = xmlDoc.CreateElement( "fil:FileLists", "http://kadgen/filelist.xsd" )
     //xmlDoc.AppendChild( node )
     node = xmlDoc.AppendChild(xmlHelpers.NewElement("fil", "http://kadgen/filelist.xsd", xmlDoc, "FileLists"));
     node = node.AppendChild(xmlHelpers.NewElement("http://kadgen/filelist.xsd", xmlDoc, "fil:FileList"));
     node.Attributes.Append(xmlHelpers.NewAttribute(xmlDoc, "StartDir", startDir));
     node.AppendChild(FileListXML(dir, xmlDoc));
     xmlDoc.Save(stream);
     return(stream);
 }
Ejemplo n.º 6
0
        public Skin GetSkin()
        {
            var resources = new Dictionary <string, System.IO.MemoryStream>();

            var doc    = new System.Xml.XmlDocument();
            var declar = doc.CreateXmlDeclaration("1.0", System.Text.Encoding.UTF8.WebName, null);

            doc.AppendChild(declar);

            var root = doc.CreateElement("Theme");

            root.SetAttribute("version", "1.0");
            root.AppendChild(this.ContainerControl.GetXmlElement(doc, resources));

            doc.AppendChild(root);

            return(new Skin(doc, resources));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Get the xml for this list of datasets
        /// </summary>\
        /// <param name="oDapCommand"></param>
        /// <param name="oDatasets"></param>
        /// <param name="oSelectedDatasets"></param>
        /// <returns></returns>
        public static System.Xml.XmlDocument GetXml(Command oDapCommand, System.Collections.SortedList oDatasets, System.Collections.ArrayList oSelectedDatasets)
        {
            System.Xml.XmlDocument oOutputXml = new System.Xml.XmlDocument();

            oOutputXml.AppendChild(oOutputXml.CreateXmlDeclaration("1.0", "UTF-8", string.Empty));

            System.Xml.XmlElement oGeosoftXml = oOutputXml.CreateElement("geosoft_xml");
            oOutputXml.AppendChild(oGeosoftXml);

            foreach (string strKey in oSelectedDatasets)
            {
                Dap.Common.DataSet oDataset = (Dap.Common.DataSet)oDatasets[strKey];

                if (oDataset != null)
                    OutputDataset(oDapCommand, oGeosoftXml, oDataset);
            }
            return oOutputXml;
        }
        /// <include file='doc\IFormatter.uex' path='docs/doc[@for="IFormatter.Serialize"]/*' />
        public void Serialize(Stream serializationStream, Object graph)
        {

            AccuDataObjectFormatter = new System.Xml.XmlDocument();
            System.Xml.XmlDeclaration Declaration = AccuDataObjectFormatter.CreateXmlDeclaration("1.0", "", "");
            System.Xml.XmlElement Element = AccuDataObjectFormatter.CreateElement("NewDataSet");

            if (graph != null)
            {
                if (graph.GetType().Equals(typeof(System.String)))
                {
                    Element.InnerText = graph.ToString();
                }
                else if (graph.GetType().GetInterface("IEnumerable") != null)
                {
                    Serialize(Element, graph);
                }
                else if (graph.GetType().IsArray)
                {
                    Serialize(Element, graph);
                }
                else if (graph.GetType().IsClass)
                {
                    Serialize(Element, graph);
                }
                else if (graph.GetType().IsPrimitive)
                {
                    Element.InnerText = graph.ToString();
                }
                else if (graph.GetType().IsValueType)
                {
                    System.Xml.XmlElement ValueType = AccuDataObjectFormatter.CreateElement(graph.GetType().Name);
                    Element.AppendChild(ValueType);
                }

            }

            AccuDataObjectFormatter.AppendChild(Declaration);
            AccuDataObjectFormatter.AppendChild(Element);
            System.IO.StreamWriter writer = new StreamWriter(serializationStream);
            writer.Write(AccuDataObjectFormatter.OuterXml);
            writer.Flush();
            writer.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
        }
Ejemplo n.º 9
0
        public void productsFile()
        {
            if (!File.Exists(this.dataDir + "produkter.xml"))
            {
                System.Xml.XmlDocument newDoc = new System.Xml.XmlDocument();

                string sTextX = "<produkter>";
                sTextX += "<produkt>";
                sTextX += "<pnamn></pnamn>";
                sTextX += "<pris></pris>";
                sTextX += "</produkt>";
                sTextX += "<produkt>";
                sTextX += "<pnamn>AL LAMELL 50 mm 6 m²</pnamn>";
                sTextX += "<pris>87</pris>";
                sTextX += "</produkt>";
                sTextX += "<produkt>";
                sTextX += "<pnamn>AL LAMELL 30 mm 9,6 m²</pnamn>";
                sTextX += "<pris>59</pris>";
                sTextX += "</produkt>";
                sTextX += "<produkt>";
                sTextX += "<pnamn>AL TAPE ARMERAD 75 mm 45,7 m</pnamn>";
                sTextX += "<pris>267</pris>";
                sTextX += "</produkt>";
                sTextX += "<produkt>";
                sTextX += "<pnamn>ALU TAPE GF 50 MMX 25 m</pnamn>";
                sTextX += "<pris>135</pris>";
                sTextX += "</produkt>";
                sTextX += "<produkt>";
                sTextX += "<pnamn>ALU TAPE GF 70 MMX 25 m</pnamn>";
                sTextX += "<pris>159</pris>";
                sTextX += "</produkt>";
                sTextX += "<produkt>";
                sTextX += "<pnamn>AGM STIFT 29 mm 500 st</pnamn>";
                sTextX += "<pris>1772</pris>";
                sTextX += "</produkt>";
                sTextX += "</produkter>";

                newDoc.LoadXml(sTextX);
                newDoc.PrependChild(newDoc.CreateXmlDeclaration("1.0", "utf-8", ""));
                newDoc.Save(this.dataDir + @"produkter.xml");
            }
        }
        /// <include file='doc\IFormatter.uex' path='docs/doc[@for="IFormatter.Serialize"]/*' />
        public void Serialize(Stream serializationStream, Object graph)
        {
            AccuDataObjectFormatter = new System.Xml.XmlDocument();
            System.Xml.XmlDeclaration Declaration = AccuDataObjectFormatter.CreateXmlDeclaration("1.0", "", "");
            System.Xml.XmlElement     Element     = AccuDataObjectFormatter.CreateElement("NewDataSet");

            if (graph != null)
            {
                if (graph.GetType().Equals(typeof(System.String)))
                {
                    Element.InnerText = graph.ToString();
                }
                else if (graph.GetType().GetInterface("IEnumerable") != null)
                {
                    Serialize(Element, graph);
                }
                else if (graph.GetType().IsArray)
                {
                    Serialize(Element, graph);
                }
                else if (graph.GetType().IsClass)
                {
                    Serialize(Element, graph);
                }
                else if (graph.GetType().IsPrimitive)
                {
                    Element.InnerText = graph.ToString();
                }
                else if (graph.GetType().IsValueType)
                {
                    System.Xml.XmlElement ValueType = AccuDataObjectFormatter.CreateElement(graph.GetType().Name);
                    Element.AppendChild(ValueType);
                }
            }

            AccuDataObjectFormatter.AppendChild(Declaration);
            AccuDataObjectFormatter.AppendChild(Element);
            System.IO.StreamWriter writer = new StreamWriter(serializationStream);
            writer.Write(AccuDataObjectFormatter.OuterXml);
            writer.Flush();
            writer.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        public void typesFile()
        {
            if (!File.Exists(this.dataDir + "types.xml"))
            {
                System.Xml.XmlDocument newDoc = new System.Xml.XmlDocument();

                string sTextX = "<types>";
                sTextX += "<type>";
                sTextX += "<tnamn></tnamn>";
                sTextX += "</type>";
                sTextX += "<type>";
                sTextX += "<tnamn>Timme</tnamn>";
                sTextX += "</type>";
                sTextX += "<type>";
                sTextX += "<tnamn>Timmar</tnamn>";
                sTextX += "</type>";
                sTextX += "<type>";
                sTextX += "<tnamn>Styck</tnamn>";
                sTextX += "</type>";
                sTextX += "<type>";
                sTextX += "<tnamn>m²</tnamn>";
                sTextX += "</type>";
                sTextX += "<type>";
                sTextX += "<tnamn>Kartong</tnamn>";
                sTextX += "</type>";
                sTextX += "<type>";
                sTextX += "<tnamn>Enhet</tnamn>";
                sTextX += "</type>";
                sTextX += "<type>";
                sTextX += "<tnamn>Enheter</tnamn>";
                sTextX += "</type>";
                sTextX += "<type>";
                sTextX += "<tnamn>Kilo</tnamn>";
                sTextX += "</type>";
                sTextX += "</types>";

                newDoc.LoadXml(sTextX);
                newDoc.PrependChild(newDoc.CreateXmlDeclaration("1.0", "utf-8", ""));
                newDoc.Save(this.dataDir + @"types.xml");
            }
        }
Ejemplo n.º 13
0
        /// <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);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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;
        }
Ejemplo n.º 16
0
        internal static void CreateXMLFile()
        {
            xDoc = new System.Xml.XmlDocument();

            xDoc.AppendChild(xDoc.CreateXmlDeclaration("1.0", "UTF-8", null));
            System.Xml.XmlElement root = xDoc.CreateElement("FolderMonitor");
            Console.WriteLine("creating file");
            try
            {
                XMLDataListEntry current = head;
                while (current != null)
                {
                    root.AppendChild(CreateXMLNodes(current.Data));
                    current = current.Next;
                }
                xDoc.AppendChild(root);
                xDoc.Save(srcFileName);
            }
            catch (System.Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 17
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);
            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;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Get the kml for this list of datasets
        /// </summary>
        /// <param name="strWmsUrl"></param>
        /// <param name="oDatasets"></param>
        /// <param name="oSelectedDatasets"></param>
        /// <returns></returns>
        public static System.Xml.XmlDocument GetKML(string strWmsUrl, System.Collections.SortedList oDatasets, System.Collections.ArrayList oSelectedDatasets)
        {
            System.Xml.XmlDocument oOutputXml = new System.Xml.XmlDocument();

            oOutputXml.AppendChild(oOutputXml.CreateXmlDeclaration("1.0", "UTF-8", string.Empty));

            System.Xml.XmlElement oKml = oOutputXml.CreateElement("kml", "http://earth.google.com/kml/2.1");
            oOutputXml.AppendChild(oKml);

            System.Xml.XmlElement oDocument = oOutputXml.CreateElement("Document", "http://earth.google.com/kml/2.1");
            System.Xml.XmlAttribute oAttr = oOutputXml.CreateAttribute("id");
            oAttr.Value = "Geosoft";
            oDocument.Attributes.Append(oAttr);
            oKml.AppendChild(oDocument);

            System.Xml.XmlElement oName = oOutputXml.CreateElement("name", "http://earth.google.com/kml/2.1");
            oName.InnerText = "Geosoft Catalog";
            oDocument.AppendChild(oName);

            System.Xml.XmlElement oVisibility = oOutputXml.CreateElement("visibility", "http://earth.google.com/kml/2.1");
            oVisibility.InnerText = "1";
            oDocument.AppendChild(oVisibility);

            System.Xml.XmlElement oOpen = oOutputXml.CreateElement("open", "http://earth.google.com/kml/2.1");
            oOpen.InnerText = "1";
            oDocument.AppendChild(oOpen);

            foreach (string strKey in oSelectedDatasets)
            {
                Dap.Common.DataSet oDataset = (Dap.Common.DataSet)oDatasets[strKey];

                if (oDataset != null)
                    OutputDataset(strWmsUrl, oDocument, oDataset);
            }
            return oOutputXml;
        }
Ejemplo n.º 19
0
 public static string CreateSitemap(long siteID, string serverRootPath)
 {
     try
     {
         var SiteList = Models.DataAccess.SitesDAO.GetDatas();
         Models.SitesModels        SitesInfo       = Models.DataAccess.SitesDAO.GetInfo(siteID);
         string                    applicationPath = "/" + HttpContext.Current.Request.ApplicationPath.Trim('/').Trim('/');
         string                    siteUrlRoot     = GetItem.appSet("WebUrl").ToString() + applicationPath + "/w/" + SitesInfo.SN;
         string                    xmlName         = GetSitemapFileName(siteID);
         System.Xml.XmlDocument    xmldoc          = new System.Xml.XmlDocument();
         System.Xml.XmlDeclaration xmldec          = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", "");
         xmldoc.AppendChild(xmldec);
         System.Xml.XmlElement root = xmldoc.CreateElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9");
         var menuList = Areas.Backend.Models.DataAccess.StatisticConditionDAO.GetMenuORPages(siteID, null);
         if (menuList != null && menuList.Count() > 0)
         {
             CreateNode(siteUrlRoot, siteID, xmldoc, ref root, menuList.ToList());
         }
         //List<Models.MenusModels> Menus = Models.DataAccess.MenusDAO.GetFrontMenus(siteID);
         //var MenuU = Menus.Where(dr => dr.AreaID == 1).ToList();
         //CreateMenu(siteUrlRoot, xmldoc, ref root, MenuU, MenuU.Where(m => m.ParentID == 0));
         //var MenuM = Menus.Where(dr => dr.AreaID == 2).ToList();
         //CreateMenu(siteUrlRoot, xmldoc, ref root, MenuM, MenuM.Where(m => m.ParentID == 0));
         xmldoc.AppendChild(root);
         xmldoc.Save(string.Format("{0}\\{1}", serverRootPath, xmlName));
         if (siteID == 1)
         {
             xmldoc.Save(string.Format("{0}\\sitemap.xml", serverRootPath));
         }
         return(xmlName);
     }
     catch (Exception ex)
     {
         return("");
     }
 }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
        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;
        }
Ejemplo n.º 22
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;
        }
Ejemplo n.º 23
0
        public void SaveClassListXML(string filename)
        {
            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
            System.Xml.XmlDeclaration xdec = xdoc.CreateXmlDeclaration("1.0", "utf-8", null);
            xdoc.AppendChild(xdec);
            System.Xml.XmlElement root = xdoc.CreateElement("ClassesList");
            for (int i = 0; i < classList.Count; i++)
            {
                System.Xml.XmlElement classNode = xdoc.CreateElement("Class");
                classNode.Attributes.Append(CreateAttribute("Title", classList[i].Title, xdoc));
                classNode.Attributes.Append(CreateAttribute("Subject", classList[i].Subject.ToString(), xdoc));
                classNode.Attributes.Append(CreateAttribute("Sch", classList[i].Sch.ToString(), xdoc));
                classNode.Attributes.Append(CreateAttribute("Index", classList[i].Index.ToString(), xdoc));
                classNode.Attributes.Append(CreateAttribute("Credits", classList[i].Credits.ToString(), xdoc));
                foreach (ClassSection cs in classList[i].Sections)
                {
                    System.Xml.XmlElement sectionNode = xdoc.CreateElement("Section");
                    sectionNode.Attributes.Append(CreateAttribute("SectionCode", cs.Section, xdoc));
                    sectionNode.Attributes.Append(CreateAttribute("RegistrationIndex", cs.RegistrationIndex, xdoc));

                    foreach (TimeFrame tf in cs.Times)
                    {
                        System.Xml.XmlElement timeframNode = xdoc.CreateElement("TimeFrame");
                        timeframNode.Attributes.Append(CreateAttribute("startDay", Enum.GetName(typeof(DayOfWeek), tf.StartTime.Day), xdoc));
                        timeframNode.Attributes.Append(CreateAttribute("startHour", tf.StartTime.Hour.ToString(), xdoc));
                        timeframNode.Attributes.Append(CreateAttribute("startMin", tf.StartTime.Minute.ToString(), xdoc));

                        timeframNode.Attributes.Append(CreateAttribute("endDay", Enum.GetName(typeof(DayOfWeek), tf.EndTime.Day), xdoc));
                        timeframNode.Attributes.Append(CreateAttribute("endHour", tf.EndTime.Hour.ToString(), xdoc));
                        timeframNode.Attributes.Append(CreateAttribute("endMin", tf.EndTime.Minute.ToString(), xdoc));
                        sectionNode.AppendChild(timeframNode);
                    }

                    classNode.AppendChild(sectionNode);
                }
                root.AppendChild(classNode);
            }
            xdoc.AppendChild(root);
            xdoc.Save(filename);
        }
Ejemplo n.º 24
0
        private void SaveState()
        {
            //file queue
            System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();
            XmlDoc.AppendChild(XmlDoc.CreateElement("nzb"));

            foreach( Article article in m_ServerManager.m_Articles)
            {
                if( article.Status == ArticleStatus.Decoded || article.Status == ArticleStatus.Deleted || article.Status == ArticleStatus.Error)
                    continue;

                System.Xml.XmlNode XmlArticle = XmlDoc.CreateElement( "file");

                DateTime Date = new DateTime(1970, 1, 1, 0, 0, 0, 0);

                XmlAddAttr( XmlArticle, "subject", article.Subject);
                XmlAddAttr( XmlArticle, "date", ((long)article.Date.Subtract(Date).TotalSeconds).ToString());
                XmlAddAttr( XmlArticle, "poster", article.Poster);
                XmlAddAttr( XmlArticle, "importfile", article.ImportFile);

                System.Xml.XmlNode XmlGroups = XmlDoc.CreateElement( "groups");
                foreach( string group in article.Groups)
                {
                    System.Xml.XmlNode XmlGroup = XmlDoc.CreateElement( "group");
                    XmlGroup.InnerText = group;
                    XmlGroups.AppendChild( XmlGroup);
                }
                XmlArticle.AppendChild( XmlGroups);

                System.Xml.XmlNode XmlSegments = XmlDoc.CreateElement( "segments");
                foreach( Segment segment in article.Segments)
                {
                    System.Xml.XmlNode XmlSegment = XmlDoc.CreateElement( "segment");

                    XmlAddAttr( XmlSegment, "bytes", segment.Bytes.ToString());
                    XmlAddAttr( XmlSegment, "number", segment.Number.ToString());

                    XmlSegment.InnerText = segment.ArticleID;
                    XmlSegments.AppendChild( XmlSegment);
                }
                XmlArticle.AppendChild( XmlSegments);

                XmlDoc.DocumentElement.AppendChild(XmlArticle);
            }

            XmlDoc.Save(Global.m_DataDirectory + "nzb-o-matic.xml");

            //servers
            System.Xml.XmlDocument ServerDoc = new System.Xml.XmlDocument();
            System.Xml.XmlDeclaration decleration = ServerDoc.CreateXmlDeclaration("1.0", "utf-8", "");
            ServerDoc.AppendChild(decleration);

            //create server groups element
            System.Xml.XmlNode servergroups = ServerDoc.CreateElement("servergroups");

            //loop through each servergroup
            foreach(ServerGroup sgs in m_ServerManager.m_ServerGroups)
            {
                //create servergroup tag
                System.Xml.XmlNode servergroup = ServerDoc.CreateElement("servergroup");
                //create servers tag
                System.Xml.XmlNode servers = ServerDoc.CreateElement("servers");
                //loop through each server
                foreach(Server serv in sgs.Servers)
                {
                    //add server tag
                    System.Xml.XmlNode snode = ServerDoc.CreateElement("server");
                    XmlAddAttr(snode, "enabled", serv.Enabled.ToString());

                    XmlAddElement(snode, "address", serv.Hostname);
                    XmlAddElement(snode, "port", serv.Port.ToString());
                    //add login
                    System.Xml.XmlNode login = ServerDoc.CreateElement("login");
                    if(serv.RequiresLogin)
                    {
                        XmlAddElement(login, "username", serv.Username);
                        XmlAddElement(login, "password", serv.Password);
                    }
                    snode.AppendChild(login);
                    XmlAddElement(snode, "connections", serv.NoConnections.ToString());

                    XmlAddElement(snode, "needsgroup", serv.NeedsGroup.ToString());

                    XmlAddElement(snode, "ssl", serv.UseSSL.ToString());

                    //add server to servers
                    servers.AppendChild(snode);
                }
                //add servers to servergroup
                servergroup.AppendChild(servers);

                //add servergroup to servergroups
                servergroups.AppendChild(servergroup);
            }

            ServerDoc.AppendChild(servergroups);
            ServerDoc.Save(Global.m_DataDirectory + "servers.xml");

            //options
            System.Xml.XmlDocument OptionsDoc = new System.Xml.XmlDocument();
            System.Xml.XmlDeclaration dec = OptionsDoc.CreateXmlDeclaration("1.0", "utf-8", "");
            OptionsDoc.AppendChild(dec);

            System.Xml.XmlElement options = OptionsDoc.CreateElement("options");

            XmlAddElement(options, "associate", Global.m_Options.AssociateWithNZB.ToString());
            XmlAddElement(options, "autoprune", Global.m_Options.AutoPrune.ToString());
            XmlAddElement(options, "idledelay", Global.m_Options.IdleDelay.ToString());
            XmlAddElement(options, "limitattempts", Global.m_Options.LimitAttempts.ToString());
            XmlAddElement(options, "minitotray", Global.m_Options.MinimizeToTray.ToString());
            XmlAddElement(options, "retryattempts", Global.m_Options.RetryAttempts.ToString());
            XmlAddElement(options, "retryconnections", Global.m_Options.RetryConnections.ToString());
            XmlAddElement(options, "retrydelay", Global.m_Options.RetryDelay.ToString());
            XmlAddElement(options, "connectonstart", Global.m_Options.ConnectOnStart.ToString());
            XmlAddElement(options, "savepath", Global.m_Options.SavePath.ToString());
            XmlAddElement(options, "savefolder", Global.m_Options.SaveFolder.ToString());
            XmlAddElement(options, "deletenzb", Global.m_Options.DeleteNZB.ToString());
            XmlAddElement(options, "disconnectidle", Global.m_Options.DisconnectOnIdle.ToString());
            XmlAddElement(options, "monitorfolder", Global.m_Options.MonitorFolder.ToString());
            XmlAddElement(options, "monitorpath", Global.m_Options.MonitorPath.ToString());
            XmlAddElement(options, "pausepar2", Global.m_Options.PausePar2.ToString());

            XmlAddElement(options, "downloadoffset", ((((double)m_ServerManager.LifetimeBytesReceived / 1024) / 1024) + m_TotalDownloadOffset).ToString());

            XmlAddElement(options, "savewindowstatus", Menu_Main_SaveWindowStatus.Checked.ToString());
            if( Menu_Main_SaveWindowStatus.Checked)
            {
                XmlAddElement(options, "height", Height.ToString());
                XmlAddElement(options, "width", Width.ToString());

                int xLoc = this.Location.X;
                int yLoc = this.Location.Y;
                if (xLoc + this.Width < 0)
                {
                    xLoc = 0;
                }
                if (yLoc + this.Height < 0)
                {
                    yLoc = 0;
                }
                XmlAddElement(options, "xloc", xLoc.ToString());
                XmlAddElement(options, "yloc", yLoc.ToString());
                bool maximized = false;
                if (this.WindowState == FormWindowState.Maximized)
                {
                    maximized = true;
                }
                XmlAddElement(options, "maximized", maximized.ToString());

                XmlAddElement(options, "connections_height", Panel_Connections.Height.ToString());
                XmlAddElement(options, "connections_width_server", chServer.Width.ToString());
                XmlAddElement(options, "connections_width_number", chID.Width.ToString());
                XmlAddElement(options, "connections_width_status", chConnStatus.Width.ToString());
                XmlAddElement(options, "connections_width_progress", chProgress.Width.ToString());
                XmlAddElement(options, "connections_width_speed", chSpeed.Width.ToString());

                XmlAddElement(options, "queue_width_article", chArticle.Width.ToString());
                XmlAddElement(options, "queue_width_size", chSize.Width.ToString());
                XmlAddElement(options, "queue_width_parts", chParts.Width.ToString());
                XmlAddElement(options, "queue_width_status", chStatus.Width.ToString());
                XmlAddElement(options, "queue_width_date", chDate.Width.ToString());
                XmlAddElement(options, "queue_width_groups", chGroups.Width.ToString());
            }

            OptionsDoc.AppendChild(options);

            OptionsDoc.Save(Global.m_DataDirectory + "options.xml");
        }
Ejemplo n.º 25
0
        public void SaveDruzina(TreeNode tnode)
        {
            String file = tnode.Tag.ToString();

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", ""));

            System.Xml.XmlElement root = doc.CreateElement("druzina");
            System.Xml.XmlAttribute att = doc.CreateAttribute("nazev");
            att.Value = tnode.Text;
            root.Attributes.Append(att);

            foreach (TreeNode n in tnode.Nodes)
            {
                ((Postava)n.Tag).Save();
                System.Xml.XmlNode node = doc.CreateElement("postava");
                node.AppendChild(doc.CreateTextNode(((Postava)n.Tag).xmlFileName));
                root.AppendChild(node);
            }
            doc.AppendChild(root);

            doc.Save(file);
        }
		public static multiTable2oneXML_spy2 CreateDocument(string encoding)
		{
			System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
			doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
			return new multiTable2oneXML_spy2(doc);
		}
 public static connStringConfig2 CreateDocument(string encoding)
 {
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
     return new connStringConfig2(doc);
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Very basic SVGfile creation routine to make on SVG the display s two circles and mesh.
        /// kept simple just for this sample; there much better SVG toolkits avalable that cloud.
        /// be used for general purpose routines.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="circle1"></param>
        /// <param name="circle2"></param>
        /// <param name="intersectionMeshes"></param>
        static void WriteSvgFiles(string path, Circle circle1, Circle circle2, Mesh[] intersectionMeshes)
        {
            var doc = new System.Xml.XmlDocument();

            doc.AppendChild(doc.CreateXmlDeclaration("1.0", "UTF-8", "no"));
            doc.XmlResolver = null;
            doc.AppendChild(doc.CreateDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null));
            var svgroot = doc.CreateElement("svg");

            var bbox = circle1.BoundingBox;

            bbox.Union(circle2.BoundingBox);
            var length = (bbox.Max - bbox.Min).Length;

            bbox.Inflate(length * 0.05);

            AppendAttribute(doc, svgroot, "viewBox", $"{bbox.Min.X} {bbox.Min.Y} {bbox.Max.X - bbox.Min.X} {bbox.Max.Y - bbox.Min.Y}");
            AppendAttribute(doc, svgroot, "version", "1.1");
            AppendAttribute(doc, svgroot, "xmlns", "http://www.w3.org/2000/svg");
            doc.AppendChild(svgroot);

            if (intersectionMeshes != null)
            {
                foreach (var mesh in intersectionMeshes)
                {
                    foreach (var face in mesh.Faces)
                    {
                        var elem   = doc.CreateElement("polygon");
                        var attrib = doc.CreateAttribute("fill");
                        attrib.Value = "#008000"; // green
                        elem.Attributes.Append(attrib);
                        attrib       = doc.CreateAttribute("stroke");
                        attrib.Value = "#008000"; // green
                        elem.Attributes.Append(attrib);
                        attrib = doc.CreateAttribute("points");
                        StringBuilder sb     = new StringBuilder();
                        var           points = new List <Rhino.Geometry.Point3d>();
                        points.Add(mesh.Vertices[face.A]);
                        points.Add(mesh.Vertices[face.B]);
                        points.Add(mesh.Vertices[face.C]);
                        if (face.IsQuad)
                        {
                            points.Add(mesh.Vertices[face.D]);
                        }
                        for (int i = 0; i < points.Count; i++)
                        {
                            if (i > 0)
                            {
                                sb.Append(", ");
                            }
                            sb.Append($"{points[i].X}, {points[i].Y}");
                        }
                        attrib.Value = sb.ToString().Trim();
                        elem.Attributes.Append(attrib);
                        svgroot.AppendChild(elem);
                    }
                }
            }

            svgroot.AppendChild(SvgCircle(circle1, doc));
            svgroot.AppendChild(SvgCircle(circle2, doc));

            doc.Save(path);
        }
Ejemplo n.º 29
0
 public System.Xml.XmlDocument CreateXmlDocument()
 {
     System.Xml.XmlDocument document = new System.Xml.XmlDocument();
     document.AppendChild(document.CreateXmlDeclaration("1.0", "utf-8", "yes"));
     document.AppendChild(CreateXmlElement(document));
     return document;
 }
Ejemplo n.º 30
0
        public ActionResult Sonuc()
        {
            var e = Request.Form.GetEnumerator();

            while (e.MoveNext())
            {
                String xkey = (String)e.Current;
                String xval = Request.Form.Get(xkey);
                Response.Write("<tr><td>" + xkey + "</td><td>" + xval + "</td></tr>");
            }

            String hashparams = Request.Form.Get("HASHPARAMS");
            String hashparamsval = Request.Form.Get("HASHPARAMSVAL");
            String storekey = "XXXX";     //Sizin Storkey Adresiniz
            String paramsval = "";
            int    index1 = 0, index2 = 0;

            // hash hesaplamada kullanılacak değerler ayrıştırılıp değerleri birleştiriliyor.
            do
            {
                index2 = hashparams.IndexOf(":", index1);
                String val = Request.Form.Get(hashparams.Substring(index1, index2 - index1)) == null ? "" : Request.Form.Get(hashparams.Substring(index1, index2 - index1));
                paramsval += val;
                index1     = index2 + 1;
            }while (index1 < hashparams.Length);

            //out.println("hashparams="+hashparams+"<br/>");
            //out.println("hashparamsval="+hashparamsval+"<br/>");
            //out.println("paramsval="+paramsval+"<br/>");
            String hashval   = paramsval + storekey;           //elde edilecek hash değeri için paramsval e store key ekleniyor. (işyeri anahtarı)
            String hashparam = Request.Form.Get("HASH");

            System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            byte[] hashbytes  = System.Text.Encoding.GetEncoding("ISO-8859-9").GetBytes(hashval);
            byte[] inputbytes = sha.ComputeHash(hashbytes);

            String hash = Convert.ToBase64String(inputbytes);                //Güvenlik ve kontrol amaçlı oluşturulan hash

            if (!paramsval.Equals(hashparamsval) || !hash.Equals(hashparam)) //oluşturulan hash ile gelen hash ve hash parametreleri değerleri ile ayrıştırılıp edilen edilen aynı olmalı.
            {
                Response.Write("<h4>Güvenlik Uyarısı. Sayısal İmza Geçerli Değil</h4>");
            }
            // Ödeme için gerekli parametreler
            String nameval     = "xxxx";                                                                                                         //İşyeri kullanıcı adı
            String passwordval = "xxxx";                                                                                                         //İşyeri şifresi
            String clientidval = Request.Form.Get("clientid");                                                                                   // İşyeri numarası
            String modeval     = "P";                                                                                                            //P olursa gerçek işlem, T olursa test işlemi yapar.
            String typeval     = "Auth";                                                                                                         //Auth PreAuth PostAuth Credit Void olabilir.
            String expiresval  = Request.Form.Get("Ecom_Payment_Card_ExpDate_Month") + "/" + Request.Form.Get("Ecom_Payment_Card_ExpDate_Year"); //Kredi Kartı son kullanım tarihi mm/yy formatından olmalı
            String cv2val      = Request.Form.Get("cv2");                                                                                        //Güvenlik Kodu
            String totalval    = Request.Form.Get("amount");                                                                                     //Tutar
            String numberval   = Request.Form.Get("md");                                                                                         //Kart numarası olarak 3d sonucu dönem md parametresi kullanılır.
            String taksitval   = "";                                                                                                             //Taksit sayısı peşin satışlar da boş olarak gönderilmelidir.
            String currencyval = "949";                                                                                                          //ytl için
            String orderidval  = "";                                                                                                             //Sipariş numarası


            String mdstatus = Request.Form.Get("mdStatus");                                                   // mdStatus 3d işlemin sonucu ile ilgili bilgi verir. 1,2,3,4 başarılı, 5,6,7,8,9,0 başarısızdır.

            if (mdstatus.Equals("1") || mdstatus.Equals("2") || mdstatus.Equals("3") || mdstatus.Equals("4")) //3D Onayı alınmıştır.
            {
                Response.Write("<h5>3D İşlemi Başarılı</h5><br/>");
                String cardholderpresentcodeval   = "13";
                String payersecuritylevelval      = Request.Form.Get("eci");
                String payertxnidval              = Request.Form.Get("xid");
                String payerauthenticationcodeval = Request.Form.Get("cavv");



                String ipaddressval = "";
                String emailval     = "";
                String groupidval   = "";
                String transidval   = "";
                String useridval    = "";

                //Fatura Bilgileri
                String billnameval       = "";    //Fatur İsmi
                String billstreet1val    = "";    //Fatura adres 1
                String billstreet2val    = "";    //Fatura adres 2
                String billstreet3val    = "";    //Fatura adres 3
                String billcityval       = "";    //Fatura şehir
                String billstateprovval  = "";    //Fatura eyalet
                String billpostalcodeval = "";    //Fatura posta kodu

                //Teslimat Bilgileri
                String shipnameval       = "";    //isim
                String shipstreet1val    = "";    //adres 1
                String shipstreet2val    = "";    //adres 2
                String shipstreet3val    = "";    //adres 3
                String shipcityval       = "";    //şehir
                String shipstateprovval  = "";    //eyalet
                String shippostalcodeval = "";    //posta kodu


                String extraval = "";



                //Ödeme için gerekli xml yapısı oluşturuluyor

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

                System.Xml.XmlDeclaration dec =
                    doc.CreateXmlDeclaration("1.0", "ISO-8859-9", "yes");

                doc.AppendChild(dec);


                System.Xml.XmlElement cc5Request = doc.CreateElement("CC5Request");
                doc.AppendChild(cc5Request);

                System.Xml.XmlElement name = doc.CreateElement("Name");
                name.AppendChild(doc.CreateTextNode(nameval));
                cc5Request.AppendChild(name);

                System.Xml.XmlElement password = doc.CreateElement("Password");
                password.AppendChild(doc.CreateTextNode(passwordval));
                cc5Request.AppendChild(password);

                System.Xml.XmlElement clientid = doc.CreateElement("ClientId");
                clientid.AppendChild(doc.CreateTextNode(clientidval));
                cc5Request.AppendChild(clientid);

                System.Xml.XmlElement ipaddress = doc.CreateElement("IPAddress");
                ipaddress.AppendChild(doc.CreateTextNode(ipaddressval));
                cc5Request.AppendChild(ipaddress);

                System.Xml.XmlElement email = doc.CreateElement("Email");
                email.AppendChild(doc.CreateTextNode(emailval));
                cc5Request.AppendChild(email);

                System.Xml.XmlElement mode = doc.CreateElement("Mode");
                mode.AppendChild(doc.CreateTextNode(modeval));
                cc5Request.AppendChild(mode);

                System.Xml.XmlElement orderid = doc.CreateElement("OrderId");
                orderid.AppendChild(doc.CreateTextNode(orderidval));
                cc5Request.AppendChild(orderid);

                System.Xml.XmlElement groupid = doc.CreateElement("GroupId");
                groupid.AppendChild(doc.CreateTextNode(groupidval));
                cc5Request.AppendChild(groupid);

                System.Xml.XmlElement transid = doc.CreateElement("TransId");
                transid.AppendChild(doc.CreateTextNode(transidval));
                cc5Request.AppendChild(transid);

                System.Xml.XmlElement userid = doc.CreateElement("UserId");
                userid.AppendChild(doc.CreateTextNode(useridval));
                cc5Request.AppendChild(userid);

                System.Xml.XmlElement type = doc.CreateElement("Type");
                type.AppendChild(doc.CreateTextNode(typeval));
                cc5Request.AppendChild(type);

                System.Xml.XmlElement number = doc.CreateElement("Number");
                number.AppendChild(doc.CreateTextNode(numberval));
                cc5Request.AppendChild(number);

                System.Xml.XmlElement expires = doc.CreateElement("Expires");
                expires.AppendChild(doc.CreateTextNode(expiresval));
                cc5Request.AppendChild(expires);

                System.Xml.XmlElement cvv2val = doc.CreateElement("Cvv2Val");
                cvv2val.AppendChild(doc.CreateTextNode(cv2val));
                cc5Request.AppendChild(cvv2val);

                System.Xml.XmlElement total = doc.CreateElement("Total");
                total.AppendChild(doc.CreateTextNode(totalval));
                cc5Request.AppendChild(total);

                System.Xml.XmlElement currency = doc.CreateElement("Currency");
                currency.AppendChild(doc.CreateTextNode(currencyval));
                cc5Request.AppendChild(currency);

                System.Xml.XmlElement taksit = doc.CreateElement("Taksit");
                taksit.AppendChild(doc.CreateTextNode(taksitval));
                cc5Request.AppendChild(taksit);

                System.Xml.XmlElement payertxnid = doc.CreateElement("PayerTxnId");
                payertxnid.AppendChild(doc.CreateTextNode(payertxnidval));
                cc5Request.AppendChild(payertxnid);

                System.Xml.XmlElement payersecuritylevel = doc.CreateElement("PayerSecurityLevel");
                payersecuritylevel.AppendChild(doc.CreateTextNode(payersecuritylevelval));
                cc5Request.AppendChild(payersecuritylevel);

                System.Xml.XmlElement payerauthenticationcode = doc.CreateElement("PayerAuthenticationCode");
                payerauthenticationcode.AppendChild(doc.CreateTextNode(payerauthenticationcodeval));
                cc5Request.AppendChild(payerauthenticationcode);

                System.Xml.XmlElement cardholderpresentcode = doc.CreateElement("CardholderPresentCode");
                cardholderpresentcode.AppendChild(doc.CreateTextNode(cardholderpresentcodeval));
                cc5Request.AppendChild(cardholderpresentcode);

                System.Xml.XmlElement billto = doc.CreateElement("BillTo");
                cc5Request.AppendChild(billto);

                System.Xml.XmlElement billname = doc.CreateElement("Name");
                billname.AppendChild(doc.CreateTextNode(billnameval));
                billto.AppendChild(billname);

                System.Xml.XmlElement billstreet1 = doc.CreateElement("Street1");
                billstreet1.AppendChild(doc.CreateTextNode(billstreet1val));
                billto.AppendChild(billstreet1);

                System.Xml.XmlElement billstreet2 = doc.CreateElement("Street2");
                billstreet2.AppendChild(doc.CreateTextNode(billstreet2val));
                billto.AppendChild(billstreet2);

                System.Xml.XmlElement billstreet3 = doc.CreateElement("Street3");
                billstreet3.AppendChild(doc.CreateTextNode(billstreet3val));
                billto.AppendChild(billstreet3);

                System.Xml.XmlElement billcity = doc.CreateElement("City");
                billcity.AppendChild(doc.CreateTextNode(billcityval));
                billto.AppendChild(billcity);

                System.Xml.XmlElement billstateprov = doc.CreateElement("StateProv");
                billstateprov.AppendChild(doc.CreateTextNode(billstateprovval));
                billto.AppendChild(billstateprov);

                System.Xml.XmlElement billpostalcode = doc.CreateElement("PostalCode");
                billpostalcode.AppendChild(doc.CreateTextNode(billpostalcodeval));
                billto.AppendChild(billpostalcode);



                System.Xml.XmlElement shipto = doc.CreateElement("ShipTo");
                cc5Request.AppendChild(shipto);

                System.Xml.XmlElement shipname = doc.CreateElement("Name");
                shipname.AppendChild(doc.CreateTextNode(shipnameval));
                shipto.AppendChild(shipname);

                System.Xml.XmlElement shipstreet1 = doc.CreateElement("Street1");
                shipstreet1.AppendChild(doc.CreateTextNode(shipstreet1val));
                shipto.AppendChild(shipstreet1);

                System.Xml.XmlElement shipstreet2 = doc.CreateElement("Street2");
                shipstreet2.AppendChild(doc.CreateTextNode(shipstreet2val));
                shipto.AppendChild(shipstreet2);

                System.Xml.XmlElement shipstreet3 = doc.CreateElement("Street3");
                shipstreet3.AppendChild(doc.CreateTextNode(shipstreet3val));
                shipto.AppendChild(shipstreet3);

                System.Xml.XmlElement shipcity = doc.CreateElement("City");
                shipcity.AppendChild(doc.CreateTextNode(shipcityval));
                shipto.AppendChild(shipcity);

                System.Xml.XmlElement shipstateprov = doc.CreateElement("StateProv");
                shipstateprov.AppendChild(doc.CreateTextNode(shipstateprovval));
                shipto.AppendChild(shipstateprov);

                System.Xml.XmlElement shippostalcode = doc.CreateElement("PostalCode");
                shippostalcode.AppendChild(doc.CreateTextNode(shippostalcodeval));
                shipto.AppendChild(shippostalcode);


                System.Xml.XmlElement extra = doc.CreateElement("Extra");
                extra.AppendChild(doc.CreateTextNode(extraval));
                cc5Request.AppendChild(extra);
                String xmlval = doc.OuterXml;         //Oluşturulan xml string olarak alınıyor.
                                                      // Ödeme için bağlantı kuruluyor. ve post ediliyor
                String url = "https://<DonusApiAdresi>/fim/api";
                System.Net.HttpWebResponse resp = null;
                try
                {
                    System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);

                    string postdata      = "DATA=" + xmlval.ToString();
                    byte[] postdatabytes = System.Text.Encoding.GetEncoding("ISO-8859-9").GetBytes(postdata);
                    request.Method        = "POST";
                    request.ContentType   = "application/x-www-form-urlencoded";
                    request.ContentLength = postdatabytes.Length;
                    System.IO.Stream requeststream = request.GetRequestStream();
                    requeststream.Write(postdatabytes, 0, postdatabytes.Length);
                    requeststream.Close();

                    resp = (System.Net.HttpWebResponse)request.GetResponse();
                    System.IO.StreamReader responsereader = new System.IO.StreamReader(resp.GetResponseStream(), System.Text.Encoding.GetEncoding("ISO-8859-9"));



                    String gelenXml = responsereader.ReadToEnd();     //Gelen xml string olarak alındı.


                    System.Xml.XmlDocument gelen = new System.Xml.XmlDocument();
                    gelen.LoadXml(gelenXml);        //string xml dökumanına çevrildi.

                    System.Xml.XmlNodeList list = gelen.GetElementsByTagName("Response");
                    String xmlResponse          = list[0].InnerText;
                    list = gelen.GetElementsByTagName("AuthCode");
                    String xmlAuthCode = list[0].InnerText;
                    list = gelen.GetElementsByTagName("HostRefNum");
                    String xmlHostRefNum = list[0].InnerText;
                    list = gelen.GetElementsByTagName("ProcReturnCode");
                    String xmlProcReturnCode = list[0].InnerText;
                    list = gelen.GetElementsByTagName("TransId");
                    String xmlTransId = list[0].InnerText;
                    list = gelen.GetElementsByTagName("ErrMsg");
                    String xmlErrMsg = list[0].InnerText;
                    if ("Approved".Equals(xmlResponse))
                    {
                        Response.Write("Ödeme başarıyla gerçekleştirildi");
                    }
                    else
                    {
                        Response.Write("Ödemede hata oluştu");
                    }
                    resp.Close();
                }
                catch (Exception ex)
                {
                    Console.Write(ex.ToString());
                }
                finally
                {
                    if (resp != null)
                    {
                        resp.Close();
                    }
                }
            }
            else
            {
                Response.Write("3D Onayı alınamadı");
            }
            return(View());
        }
Ejemplo n.º 31
0
        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);
        }
Ejemplo n.º 32
0
 public static Web_Config2 CreateDocument(string encoding)
 {
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
     return(new Web_Config2(doc));
 }
Ejemplo n.º 33
0
 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);
 }
        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;
        }
Ejemplo n.º 35
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);

            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);
            }
        }
Ejemplo n.º 36
0
        static void Main(string[] args)
        {
            int msgprocessthreads = 4;
            string pstfile = string.Empty;
            string pathtopstfiles = string.Empty;
            string pathtoemlfiles = string.Empty;
            string pathtoeidfile = string.Empty;
            string pathtofolderfile = string.Empty;
            string host = string.Empty;
            PSTMsgParser.PSTMsgParserData.SaveAsType saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Msg;
            string tracefile = string.Empty;
            uint offset = 0;
            uint count = Int32.MaxValue;
            bool isclient = false;
            bool isserver = true;
            bool docount = false;
            bool unicode = false;
            List<string> entryids = new List<string>();
            List<FolderData> folderdata = new List<FolderData>();
            string queuetype = ".netqueue";

            Logger.NLogger.Info("Running: {0}", Environment.CommandLine);

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].ToUpper())
                {
                    case "-OFFSET":
                        offset = Convert.ToUInt32(args[i + 1]);
                        break;

                    case "-COUNT":
                        count = Convert.ToUInt32(args[i + 1]);
                        break;

                    case "-HOST":
                        host = args[i + 1];
                        break;

                    case "-CLIENT":
                        isclient = true;
                        break;

                    case "-SERVER":
                        isserver = true;
                        break;

                    case "-MSGPROCESSTHREADS":
                        msgprocessthreads = Convert.ToInt32(args[i + 1]);
                        break;

                    case "-INPUTDIR":
                        pathtopstfiles = args[i + 1];
                        pathtopstfiles = pathtopstfiles + (pathtopstfiles.EndsWith("\\") ? string.Empty : "\\");
                        break;

                    case "-OUTPUTDIR":
                        pathtoemlfiles = args[i + 1];
                        pathtoemlfiles = pathtoemlfiles + (pathtoemlfiles.EndsWith("\\") ? string.Empty : "\\");
                        break;

                    case "-QUEUETYPE":
                        queuetype = args[i + 1];
                        break;
                }
            }

            // added this code to support old Pst2Msg command line parameters
            List<string> pst2msgparameters = new List<string>() { "-E", "-F", "-M", "-O", "-R", "-S", "-T", "-U"};
            List<string> pst2msgargs = new List<string>();
            string pst2msgargument = string.Empty;
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].Length >= 2 && pst2msgparameters.Contains(args[i].ToUpper().Substring(0, 2)))
                {
                    if (pst2msgargument != string.Empty)
                    {
                        pst2msgargs.Add(pst2msgargument);
                        pst2msgargument = args[i];
                    }
                    else
                        pst2msgargument = args[i];
                }
                else
                    pst2msgargument += (" " + args[i]);
            }
            if (pst2msgargument != string.Empty)
                pst2msgargs.Add(pst2msgargument);
            for (int i = 0; i < pst2msgargs.Count; i++)
            {
                if (pst2msgargs[i].Length > 2)
                {
                    switch (pst2msgargs[i].ToUpper().Substring(0, 2))
                    {
                        case "-E":
                            if (pst2msgargs[i].Substring(0, 4).ToUpper() == "-EID")
                                pathtoeidfile = pst2msgargs[i].Substring(4);
                            break;

                        case "-F":
                            pstfile = pst2msgargs[i].Substring(2);
                            break;

                        case "-M":
                            if (pst2msgargs[i].Substring(2).ToUpper() == "MSG")
                                saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Msg;
                            else if (pst2msgargs[i].Substring(2).ToUpper() == "META")
                                saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Xml;
                            else if (pst2msgargs[i].Substring(2).ToUpper() == "ALL")
                                saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Xml | PSTMsgParser.PSTMsgParserData.SaveAsType.Msg;//						| PSTMsgParser.SaveAsType.Text;
                            else if (pst2msgargs[i].Substring(2).ToUpper() == "COUNT")
                                docount = true;
                            break;

                        case "-O":
                            if (pst2msgargs[i].ToUpper() != "-OFFSET" && pst2msgargs[i].ToUpper() != "-OUTPUTDIR")
                                pathtoemlfiles = pst2msgargs[i].Substring(2);
                            break;

                        case "-R":
                            if (pst2msgargs[i].ToUpper().Substring(0, 3) != "-RT")
                            {
                                pathtoemlfiles = pst2msgargs[i].Substring(2);
                                pathtoemlfiles = pathtoemlfiles + (pathtoemlfiles.EndsWith("\\") ? string.Empty : "\\");
                            }
                            break;

                        case "-S":
                            if (pst2msgargs[i].ToUpper() != "-SERVER")
                                pathtofolderfile = pst2msgargs[i].Substring(2);
                            break;

                        case "-T":
                            tracefile = pst2msgargs[i].Substring(2);
                            break;

                        case "-U":
                            unicode = true;
                            break;
                    }
                }
            }

            if (docount)
            {
                offset = 0;
                count = Int32.MaxValue;
                msgprocessthreads = 0;
                pathtoeidfile = string.Empty;
                pathtofolderfile = string.Empty;
            }

            if (pathtoeidfile != string.Empty)
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(pathtoeidfile))
                {
                    String line = string.Empty;
                    while ((line = sr.ReadLine()) != null)
                    {
                        entryids.Add(line.Split(new char[]{'\t'})[1]);
                    }
                }
            }

            if (pathtofolderfile != string.Empty)
            {
                if (System.IO.File.Exists(pathtofolderfile))
                {
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(pathtofolderfile, true))
                    {
                        String line = string.Empty;
                        while ((line = sr.ReadLine()) != null)
                        {
                            folderdata.Add(new FolderData(line));
                        }
                    }
                }
            }

            if (msgprocessthreads > 0)
                isclient = true;

            KRSrcWorkflow.Interfaces.IWFMessageQueue<PSTMsgParser.PSTMsgParser> msgqueue = null;
            if (queuetype == "rabbbitmq" || queuetype == "msmq")
            {
                if (host == string.Empty)
                    KRSrcWorkflow.WFUtilities.SetHostAndIPAddress(System.Net.Dns.GetHostName(), ref host);
            //				if (queuetype == "rabbbitmq")
            //					msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_RabbitMQ<PSTMsgParser.PSTMsgParser>(host, 5672, "msgqueue", KRSrcWorkflow.Abstracts.WFMessageQueueType.Publisher);
            //				else if (queuetype == "msmq")
            //					msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_MessageQueue<PSTMsgParser.PSTMsgParser>(host, "msgqueue");
            }
            //			else
            //				msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_Queue<PSTMsgParser.PSTMsgParser>();

            List<ManualResetEvent> msgthreadevents = new List<ManualResetEvent>();

            ManualResetEvent msgthreadinterrupt = null;
            if (isclient)
            {
                int threadid = 0;
                KRSrcWorkflow.WFGenericThread<PSTMsgParser.PSTMsgParser> iothread = null;
                if (msgprocessthreads > 0)
                {
                    msgthreadinterrupt = new ManualResetEvent(false);
                    for (int i = 0; i < msgprocessthreads; i++)
                    {
            //						ThreadPool.QueueUserWorkItem((iothread = new KRSrcWorkflow.WFThread<PSTMsgParser.PSTMsgParserData>(msgthreadinterrupt, msgqueue, null, threadid++)).Run);
                        msgthreadevents.Add(iothread.ThreadExitEvent);
                    }
                }
            }

            if (isserver)
            {
                string[] pstfiles = null;

                if (pathtopstfiles != string.Empty)
                    pstfiles = System.IO.Directory.GetFiles(pathtopstfiles, "*.pst", System.IO.SearchOption.TopDirectoryOnly);
                else if (pstfile != string.Empty)
                    pstfiles = new string[1] { pstfile };
                if (pstfiles.Length != 0)
                {
                    foreach (string pfile in pstfiles)
                    {
                        bool append = false;

                        Logger.NLogger.Info("Processing: {0}", pfile);
                        string exportdir = pathtoemlfiles;
                        if(pathtopstfiles != string.Empty)
                            exportdir = pathtoemlfiles + pfile.Substring((pfile.LastIndexOf("\\") == -1 ? 0 : pfile.LastIndexOf("\\")) + 1, pfile.Length - 5 - (pfile.LastIndexOf("\\") == -1 ? 0 : pfile.LastIndexOf("\\")));
                        Logger.NLogger.Info("Export Directory: {0}", exportdir);

                        if (docount)
                        {
                            if (System.IO.File.Exists(exportdir + "\\AllEntryID.txt"))
                                System.IO.File.Delete(exportdir + "\\AllEntryID.txt");

                            if (System.IO.File.Exists(exportdir + "\\FolderInfo.xml"))
                                System.IO.File.Delete(exportdir + "\\FolderInfo.xml");
                        }

                        if (!System.IO.Directory.Exists(exportdir + @"MSG\"))
                            System.IO.Directory.CreateDirectory(exportdir + @"MSG\");

                        if (!System.IO.Directory.Exists(exportdir + @"XML\"))
                            System.IO.Directory.CreateDirectory(exportdir + @"XML\");

                        Logger.NLogger.Info("Logon to PST store: {0}", pfile);
                        pstsdk.definition.pst.IPst rdopststore = null;
                        try
                        {
                            rdopststore = new pstsdk.layer.pst.Pst(pfile);
                        }
                        catch (Exception ex)
                        {
                            Logger.NLogger.ErrorException("Pst constructor failed for " + pfile, ex);
                        }
                        if (rdopststore != null)
                        {
                            Logger.NLogger.Info("Successfully logged on to PST store: {0}", pfile);
                            GetFolderData(rdopststore.OpenRootFolder(), string.Empty, folderdata.Count > 0 ? true : false, docount == true, ref folderdata);
                            uint totmessages = (uint)folderdata.Sum(x => x.NumMessages);
                            uint totattachments = (uint)folderdata.Sum(x => x.NumAttachments);

                            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                            System.Xml.XmlNode foldersnode = null;
                            if (docount == true)
                            {
                                doc = new System.Xml.XmlDocument();// Create the XML Declaration, and append it to XML document
                                System.Xml.XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "windows-1252", null);
                                doc.AppendChild(dec);
                                // create message element
                                System.Xml.XmlElement folders = doc.CreateElement("Folders");
                                foldersnode = doc.AppendChild(folders);
                            }
            //							List<pstsdk.definition.util.primitives.NodeID> foldernodeids = docount == true ? folderdata.Where(x => x.NodeId != 0).Select(x => x.NodeId).ToList() : rdopststore.Folders.Where(x => x.Node != 0).Select(x => x.Node).ToList();
            //							foreach (pstsdk.definition.util.primitives.NodeID foldernodeid in foldernodeids)
                            foreach (FolderData fd in folderdata)
                            {
                                pstsdk.definition.util.primitives.NodeID foldernodeid = fd.NodeId;

                                pstsdk.definition.pst.folder.IFolder folder = null;
                                try
                                {
                                    folder = rdopststore.OpenFolder(foldernodeid);
                                    if (docount == true)
                                        HandleFolder(folder, doc, foldersnode, fd.FolderPath, unicode);
                                    uint idx = 0;
                                    foreach (pstsdk.definition.pst.message.IMessage msg in folder.Messages)
                                    {
                                        if (docount == true)
                                        {
                                            using (System.IO.StreamWriter outfile = new System.IO.StreamWriter(exportdir + "\\AllEntryID.txt", append))
                                            {
                                                outfile.WriteLine(folder.EntryID.ToString() + "\t" + msg.EntryID.ToString());
                                            }
                                            append = true;
                                        }
                                        else
                                        {
                                            if (idx >= offset)
                                            {
            //												if ((entryids.Count == 0) || entryids.Contains(msg.EntryID.ToString()))
            //													msgqueue.Enqueue(new PSTMsgParser.PSTMsgParser(pfile, msg.Node, exportdir) { SaveAsTypes = PSTMsgParser.PSTMsgParser.SaveAsType.Msg | PSTMsgParser.PSTMsgParser.SaveAsType.Xml, SaveAttachments = false, FileToProcess = msg.Node.Value.ToString(), FolderPath = fd.FolderPath, ExportDirectory = exportdir, Pst2MsgCompatible = true });
                                            }
                                            idx++;
                                            if (count != UInt32.MaxValue)
                                            {
                                                if (idx == (offset + count))
                                                    break;
                                            }
                                        }
                                        msg.Dispose();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.NLogger.ErrorException("OpenFolder failed!" + " NodeId=" + foldernodeid + " FolderPath=" + folderdata.FirstOrDefault(x => x.NodeId == foldernodeid).FolderPath, ex);
                                }
                                finally
                                {
                                    if (folder != null)
                                        folder.Dispose();
                                }
                            }
                            if (docount == true)
                            {
                                System.Xml.XmlElement numoffolders = doc.CreateElement("numOfFolders");
                                System.Xml.XmlNode numoffoldersnode = foldersnode.AppendChild(numoffolders);
                                numoffoldersnode.InnerText = rdopststore.Folders.Count().ToString();

                                System.Xml.XmlElement numofmsgs = doc.CreateElement("numOfMsgs");
                                System.Xml.XmlNode numofmsgsnode = foldersnode.AppendChild(numofmsgs);
                                numofmsgsnode.InnerText = totmessages.ToString();

                                System.Xml.XmlElement numoftotattachments = doc.CreateElement("numOfAttachments");
                                System.Xml.XmlNode numoftotattachmentsnode = foldersnode.AppendChild(numoftotattachments);
                                numoftotattachmentsnode.InnerText = totattachments.ToString();

                                System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(exportdir + "\\FolderInfo.xml", System.Text.Encoding.GetEncoding("windows-1252"));
                                writer.Formatting = System.Xml.Formatting.Indented;
                                doc.Save(writer);
                                writer.Close();
                            }
                            rdopststore.Dispose();
                        }
                    }
                }
                else
                    Console.WriteLine("ERROR: No pst files found in directory " + pathtopstfiles);
                if (msgprocessthreads > 0)
                {
                    do
                    {
                        Thread.Sleep(100);
                    } while (msgqueue.Count > 0);
                    System.Diagnostics.Debug.WriteLine("Setting msgthreadinterrupt");
                    msgthreadinterrupt.Set();
                    WaitHandle.WaitAll(msgthreadevents.ToArray());
                    System.Diagnostics.Debug.WriteLine("All message threads exited");
                    Thread.Sleep(5000);
                }
            }
            else
                Thread.Sleep(Int32.MaxValue);
        }
Ejemplo n.º 37
0
        System.Xml.XmlDocument Decompress(byte[] buffer)
        {
            var decompressBuffer = Utils.Zlib.Decompress(buffer);

            var doc    = new System.Xml.XmlDocument();
            var reader = new Utl.BinaryReader(decompressBuffer);

            var   keys    = new Dictionary <Int16, string>();
            Int16 keySize = -1;

            reader.Get(ref keySize);
            for (int i = 0; i < keySize; i++)
            {
                Int16  key  = -1;
                string name = "";
                reader.Get(ref name, Encoding.UTF8, false, 2);
                reader.Get(ref key);
                keys.Add(key, name);
            }

            var   values    = new Dictionary <Int16, string>();
            Int16 valueSize = -1;

            reader.Get(ref valueSize);
            for (int i = 0; i < valueSize; i++)
            {
                Int16  key   = -1;
                string value = "";
                reader.Get(ref value, Encoding.UTF8, false, 2);
                reader.Get(ref key);
                values.Add(key, value);
            }

            Action <System.Xml.XmlNode> decomp = null;

            decomp = (node) =>
            {
                Int16 elementSize = 0;
                reader.Get(ref elementSize);
                for (int i = 0; i < elementSize; i++)
                {
                    Int16 nameKey = -1;
                    reader.Get(ref nameKey);
                    var element = doc.CreateElement(keys[nameKey]);
                    node.AppendChild(element);

                    bool isHaveValue = false;
                    reader.Get(ref isHaveValue);
                    if (isHaveValue)
                    {
                        Int16 value = -1;
                        reader.Get(ref value);
                        var valueNode = doc.CreateNode(System.Xml.XmlNodeType.Text, "", "");
                        valueNode.Value = values[value];
                        element.AppendChild(valueNode);
                    }

                    bool isHaveChildren = false;
                    reader.Get(ref isHaveChildren);
                    if (isHaveChildren)
                    {
                        decomp(element);
                    }
                }
            };


            var declare = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

            doc.AppendChild(declare);
            decomp(doc);

            return(doc);
        }
Ejemplo n.º 38
0
        private void guardarXML(Stream myStream)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            //System.Xml.XmlAttribute atributo;

            System.Xml.XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "");
            doc.AppendChild(declaration);

            System.Xml.XmlNode pmml = doc.CreateElement("PMML");
            /*
            atributo = doc.CreateAttribute("version");
            atributo.InnerText = "3.0";
            pmml.Attributes.Append(atributo);
            atributo = doc.CreateAttribute("xmlns");
            atributo.InnerText = "http://www.dmg.org/PMML-3-0";
            pmml.Attributes.Append(atributo);
            atributo = doc.CreateAttribute("xmlns:xsi");
            atributo.InnerText = "http://www.w3.org/2001/XMLSchema_instance";
            pmml.Attributes.Append(atributo);
              */

            pmml.Attributes.Append(setAtributo(doc, "version", "3.0"));
            pmml.Attributes.Append(setAtributo(doc, "xmlns", "http://www.dmg.org/PMML-3-0"));
            pmml.Attributes.Append(setAtributo(doc, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema_instance"));
            doc.AppendChild(pmml);

            System.Xml.XmlNode sprite = doc.CreateElement("TEXTURA");
            if (textureName.Text.Equals(""))
                sprite.Attributes.Append(setAtributo(doc,"Name","none"));
            else
                sprite.Attributes.Append(setAtributo(doc, "Name", textureName.Text));

            if (useRelativePath.Checked && !relativeFileLoc.Equals(""))
                sprite.Attributes.Append(setAtributo(doc, "TextureFile", relativeFileLoc.Insert(0,"..\\").Replace('\\','/')));
            else
                sprite.Attributes.Append(setAtributo(doc, "TextureFile", fileLoc));

            int colorR = color_click.BackColor.R;
            int colorG = color_click.BackColor.G;
            int colorB = color_click.BackColor.B;
            //sprite.Attributes.Append(setAtributo(doc, "ColorKey", "FF"+R+G+B));
            System.Xml.XmlNode colorKey = doc.CreateElement("ColorKey");
            colorKey.Attributes.Append(setAtributo(doc, "R", colorR.ToString()));
            colorKey.Attributes.Append(setAtributo(doc, "G", colorG.ToString()));
            colorKey.Attributes.Append(setAtributo(doc, "B", colorB.ToString()));
            sprite.AppendChild(colorKey);
            pmml.AppendChild(sprite);

            /*
            doc.AppendChild(XClub);
            System.Xml.XmlNode Pelicula = doc.CreateElement("Pelicula");
            XClub.AppendChild(Pelicula);
            System.Xml.XmlNode Data = doc.CreateElement("Data");
            System.Xml.XmlAttribute atributo = doc.CreateAttribute("Titulo");
            atributo.InnerText = "Garganta Profunda(Deep Throat)";
            Data.Attributes.Append(atributo);
            System.Xml.XmlAttribute atributo2 = doc.CreateAttribute("Director");
            atributo2.InnerText = "";
            Data.Attributes.Append(atributo2);
            Pelicula.AppendChild(Data);*/
            doc.Save(myStream);
        }
Ejemplo n.º 39
0
        /// <summary>
        /// 动态添加日志类型
        /// </summary>
        /// <param name="logRepository"></param>
        /// <param name="typeName"></param>
        private static void CreateXMLLog(log4net.Repository.ILoggerRepository logRepository, string typeName)
        {
            //<?xml version = "1.0" encoding="UTF-8"?>
            // <configuration>
            // <log4net>
            //     <appender name = "JosonLogAppenderAppender" type="log4net.Appender.RollingFileAppender">
            //         <param name = "Encoding" value="utf-8" />
            //         <file value = "Logs/" />
            //         <appendToFile value="true" />
            //         <rollingStyle value = "Composite" />
            //         <staticLogFileName value="false" />
            //         <DatePattern value = "yyyy/yyyy-MM/'JosonLogAppender'-yyyy-MM-dd.log" />
            //         <maxSizeRollBackups value="10" />

            //         <maximumFileSize value = "1MB" />
            //             <layout type="log4net.Layout.PatternLayout">
            //             <conversionPattern value = "$$%date%message%newline" />
            //         </layout>

            //     </appender>
            //     <logger name="JosonLogAppender">
            //         <level value = "DEBUG" />
            //         <appender - ref ref= "JosonLogAppenderAppender" />
            //     </logger >
            // </log4net>
            // </configuration>



            var xmlDoc = new System.Xml.XmlDocument();

            xmlDoc.AppendChild(xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null));
            var configuration = xmlDoc.CreateElement("configuration");
            var root          = xmlDoc.CreateElement("log4net");

            var appender = xmlDoc.CreateElement("appender");

            appender.SetAttribute("name", typeName + "Appender");
            appender.SetAttribute("type", "log4net.Appender.RollingFileAppender");
            var param = xmlDoc.CreateElement("param");

            param.SetAttribute("name", "Encoding");
            param.SetAttribute("value", "utf-8");
            appender.AppendChild(param);

            var file = xmlDoc.CreateElement("file");

            file.SetAttribute("value", "Logs/");
            appender.AppendChild(file);

            var appendToFile = xmlDoc.CreateElement("appendToFile");

            appendToFile.SetAttribute("value", "true");
            appender.AppendChild(appendToFile);

            var rollingStyle = xmlDoc.CreateElement("rollingStyle");

            rollingStyle.SetAttribute("value", "Composite");
            appender.AppendChild(rollingStyle);

            var staticLogFileName = xmlDoc.CreateElement("staticLogFileName");

            staticLogFileName.SetAttribute("value", "false");
            appender.AppendChild(staticLogFileName);

            var DatePattern = xmlDoc.CreateElement("DatePattern");

            DatePattern.SetAttribute("value", $"yyyy/yyyy-MM/yyyy-MM-dd.'{typeName}.log'");
            //DatePattern.SetAttribute("value", $"yyyy/yyyy-MM/dd-'{typeName}.log'");
            appender.AppendChild(DatePattern);


            var maxSizeRollBackups = xmlDoc.CreateElement("maxSizeRollBackups");

            maxSizeRollBackups.SetAttribute("value", "10");
            appender.AppendChild(maxSizeRollBackups);

            var maximumFileSize = xmlDoc.CreateElement("maximumFileSize");

            maximumFileSize.SetAttribute("value", "1MB");
            appender.AppendChild(maximumFileSize);

            var layout = xmlDoc.CreateElement("layout");

            layout.SetAttribute("type", "log4net.Layout.PatternLayout");

            var conversionPattern = xmlDoc.CreateElement("conversionPattern");

            conversionPattern.SetAttribute("value", "%date%message%newline");
            layout.AppendChild(conversionPattern);
            appender.AppendChild(layout);

            var logger = xmlDoc.CreateElement("logger");

            logger.SetAttribute("name", typeName);
            var level = xmlDoc.CreateElement("level");

            level.SetAttribute("value", "DEBUG");
            var appender_ref = xmlDoc.CreateElement("appender-ref");

            appender_ref.SetAttribute("ref", typeName + "Appender");
            logger.AppendChild(level);
            logger.AppendChild(appender_ref);


            root.AppendChild(appender);
            root.AppendChild(logger);

            configuration.AppendChild(root);
            xmlDoc.AppendChild(configuration);

            var array  = System.Text.Encoding.ASCII.GetBytes(xmlDoc.OuterXml);
            var stream = new MemoryStream(array);
            var reader = new StreamReader(stream);

            log4net.Config.XmlConfigurator.Configure(logRepository, reader.BaseStream);
        }
 public static streamTypeDefine2 CreateDocument(string encoding)
 {
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
     return new streamTypeDefine2(doc);
 }
Ejemplo n.º 41
0
        public static void CreateDatabaseXML()
        {
            //Create Dirtectory
            if (!System.IO.Directory.Exists("Database"))
                System.IO.Directory.CreateDirectory("Database");

            //Create XML document and Declaration
            System.Xml.XmlDocument newDoc = new System.Xml.XmlDocument();
            newDoc.AppendChild(newDoc.CreateXmlDeclaration("1.0","UTF-8","yes"));

            //Create root node
            newDoc.AppendChild(newDoc.CreateElement("Backups"));

            newDoc.Save("Database/DBLog.xml");
        }
Ejemplo n.º 42
0
 public static ResidualsDataSet22 CreateDocument(string encoding)
 {
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
     return new ResidualsDataSet22(doc);
 }
Ejemplo n.º 43
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);
            }
        }
Ejemplo n.º 44
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);
        }
Ejemplo n.º 45
0
        private void guardarXML(Stream myStream)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            //System.Xml.XmlAttribute atributo;

            System.Xml.XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "");
            doc.AppendChild(declaration);

            System.Xml.XmlNode pmml = doc.CreateElement("PMML");

            /*
             * atributo = doc.CreateAttribute("version");
             * atributo.InnerText = "3.0";
             * pmml.Attributes.Append(atributo);
             * atributo = doc.CreateAttribute("xmlns");
             * atributo.InnerText = "http://www.dmg.org/PMML-3-0";
             * pmml.Attributes.Append(atributo);
             * atributo = doc.CreateAttribute("xmlns:xsi");
             * atributo.InnerText = "http://www.w3.org/2001/XMLSchema_instance";
             * pmml.Attributes.Append(atributo);
             */

            pmml.Attributes.Append(setAtributo(doc, "version", "3.0"));
            pmml.Attributes.Append(setAtributo(doc, "xmlns", "http://www.dmg.org/PMML-3-0"));
            pmml.Attributes.Append(setAtributo(doc, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema_instance"));
            doc.AppendChild(pmml);

            System.Xml.XmlNode sprite = doc.CreateElement("TEXTURA");
            if (textureName.Text.Equals(""))
            {
                sprite.Attributes.Append(setAtributo(doc, "Name", "none"));
            }
            else
            {
                sprite.Attributes.Append(setAtributo(doc, "Name", textureName.Text));
            }

            if (useRelativePath.Checked && !relativeFileLoc.Equals(""))
            {
                sprite.Attributes.Append(setAtributo(doc, "TextureFile", relativeFileLoc.Insert(0, "..\\").Replace('\\', '/')));
            }
            else
            {
                sprite.Attributes.Append(setAtributo(doc, "TextureFile", fileLoc));
            }

            int colorR = color_click.BackColor.R;
            int colorG = color_click.BackColor.G;
            int colorB = color_click.BackColor.B;

            //sprite.Attributes.Append(setAtributo(doc, "ColorKey", "FF"+R+G+B));
            System.Xml.XmlNode colorKey = doc.CreateElement("ColorKey");
            colorKey.Attributes.Append(setAtributo(doc, "R", colorR.ToString()));
            colorKey.Attributes.Append(setAtributo(doc, "G", colorG.ToString()));
            colorKey.Attributes.Append(setAtributo(doc, "B", colorB.ToString()));
            sprite.AppendChild(colorKey);
            pmml.AppendChild(sprite);

            /*
             * doc.AppendChild(XClub);
             * System.Xml.XmlNode Pelicula = doc.CreateElement("Pelicula");
             * XClub.AppendChild(Pelicula);
             * System.Xml.XmlNode Data = doc.CreateElement("Data");
             * System.Xml.XmlAttribute atributo = doc.CreateAttribute("Titulo");
             * atributo.InnerText = "Garganta Profunda(Deep Throat)";
             * Data.Attributes.Append(atributo);
             * System.Xml.XmlAttribute atributo2 = doc.CreateAttribute("Director");
             * atributo2.InnerText = "";
             * Data.Attributes.Append(atributo2);
             * Pelicula.AppendChild(Data);*/
            doc.Save(myStream);
        }
Ejemplo n.º 46
0
		public static Asn1OutXml2 CreateDocument(string encoding)
		{
			System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
			doc.AppendChild(doc.CreateXmlDeclaration("1.0", encoding, null));
			return new Asn1OutXml2(doc);
		}
Ejemplo n.º 47
0
        static void Main(string[] args)
        {
            int    msgprocessthreads = 4;
            string pstfile           = string.Empty;
            string pathtopstfiles    = string.Empty;
            string pathtoemlfiles    = string.Empty;
            string pathtoeidfile     = string.Empty;
            string pathtofolderfile  = string.Empty;
            string host = string.Empty;

            PSTMsgParser.PSTMsgParserData.SaveAsType saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Msg;
            string            tracefile  = string.Empty;
            uint              offset     = 0;
            uint              count      = Int32.MaxValue;
            bool              isclient   = false;
            bool              isserver   = true;
            bool              docount    = false;
            bool              unicode    = false;
            List <string>     entryids   = new List <string>();
            List <FolderData> folderdata = new List <FolderData>();
            string            queuetype  = ".netqueue";

            Logger.NLogger.Info("Running: {0}", Environment.CommandLine);

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i].ToUpper())
                {
                case "-OFFSET":
                    offset = Convert.ToUInt32(args[i + 1]);
                    break;

                case "-COUNT":
                    count = Convert.ToUInt32(args[i + 1]);
                    break;

                case "-HOST":
                    host = args[i + 1];
                    break;

                case "-CLIENT":
                    isclient = true;
                    break;

                case "-SERVER":
                    isserver = true;
                    break;

                case "-MSGPROCESSTHREADS":
                    msgprocessthreads = Convert.ToInt32(args[i + 1]);
                    break;

                case "-INPUTDIR":
                    pathtopstfiles = args[i + 1];
                    pathtopstfiles = pathtopstfiles + (pathtopstfiles.EndsWith("\\") ? string.Empty : "\\");
                    break;

                case "-OUTPUTDIR":
                    pathtoemlfiles = args[i + 1];
                    pathtoemlfiles = pathtoemlfiles + (pathtoemlfiles.EndsWith("\\") ? string.Empty : "\\");
                    break;

                case "-QUEUETYPE":
                    queuetype = args[i + 1];
                    break;
                }
            }

            // added this code to support old Pst2Msg command line parameters
            List <string> pst2msgparameters = new List <string>()
            {
                "-E", "-F", "-M", "-O", "-R", "-S", "-T", "-U"
            };
            List <string> pst2msgargs     = new List <string>();
            string        pst2msgargument = string.Empty;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].Length >= 2 && pst2msgparameters.Contains(args[i].ToUpper().Substring(0, 2)))
                {
                    if (pst2msgargument != string.Empty)
                    {
                        pst2msgargs.Add(pst2msgargument);
                        pst2msgargument = args[i];
                    }
                    else
                    {
                        pst2msgargument = args[i];
                    }
                }
                else
                {
                    pst2msgargument += (" " + args[i]);
                }
            }
            if (pst2msgargument != string.Empty)
            {
                pst2msgargs.Add(pst2msgargument);
            }
            for (int i = 0; i < pst2msgargs.Count; i++)
            {
                if (pst2msgargs[i].Length > 2)
                {
                    switch (pst2msgargs[i].ToUpper().Substring(0, 2))
                    {
                    case "-E":
                        if (pst2msgargs[i].Substring(0, 4).ToUpper() == "-EID")
                        {
                            pathtoeidfile = pst2msgargs[i].Substring(4);
                        }
                        break;

                    case "-F":
                        pstfile = pst2msgargs[i].Substring(2);
                        break;

                    case "-M":
                        if (pst2msgargs[i].Substring(2).ToUpper() == "MSG")
                        {
                            saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Msg;
                        }
                        else if (pst2msgargs[i].Substring(2).ToUpper() == "META")
                        {
                            saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Xml;
                        }
                        else if (pst2msgargs[i].Substring(2).ToUpper() == "ALL")
                        {
                            saveas = PSTMsgParser.PSTMsgParserData.SaveAsType.Xml | PSTMsgParser.PSTMsgParserData.SaveAsType.Msg;                                    //						| PSTMsgParser.SaveAsType.Text;
                        }
                        else if (pst2msgargs[i].Substring(2).ToUpper() == "COUNT")
                        {
                            docount = true;
                        }
                        break;

                    case "-O":
                        if (pst2msgargs[i].ToUpper() != "-OFFSET" && pst2msgargs[i].ToUpper() != "-OUTPUTDIR")
                        {
                            pathtoemlfiles = pst2msgargs[i].Substring(2);
                        }
                        break;

                    case "-R":
                        if (pst2msgargs[i].ToUpper().Substring(0, 3) != "-RT")
                        {
                            pathtoemlfiles = pst2msgargs[i].Substring(2);
                            pathtoemlfiles = pathtoemlfiles + (pathtoemlfiles.EndsWith("\\") ? string.Empty : "\\");
                        }
                        break;

                    case "-S":
                        if (pst2msgargs[i].ToUpper() != "-SERVER")
                        {
                            pathtofolderfile = pst2msgargs[i].Substring(2);
                        }
                        break;

                    case "-T":
                        tracefile = pst2msgargs[i].Substring(2);
                        break;

                    case "-U":
                        unicode = true;
                        break;
                    }
                }
            }

            if (docount)
            {
                offset            = 0;
                count             = Int32.MaxValue;
                msgprocessthreads = 0;
                pathtoeidfile     = string.Empty;
                pathtofolderfile  = string.Empty;
            }

            if (pathtoeidfile != string.Empty)
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(pathtoeidfile))
                {
                    String line = string.Empty;
                    while ((line = sr.ReadLine()) != null)
                    {
                        entryids.Add(line.Split(new char[] { '\t' })[1]);
                    }
                }
            }

            if (pathtofolderfile != string.Empty)
            {
                if (System.IO.File.Exists(pathtofolderfile))
                {
                    using (System.IO.StreamReader sr = new System.IO.StreamReader(pathtofolderfile, true))
                    {
                        String line = string.Empty;
                        while ((line = sr.ReadLine()) != null)
                        {
                            folderdata.Add(new FolderData(line));
                        }
                    }
                }
            }

            if (msgprocessthreads > 0)
            {
                isclient = true;
            }

            KRSrcWorkflow.Interfaces.IWFMessageQueue <PSTMsgParser.PSTMsgParser> msgqueue = null;
            if (queuetype == "rabbbitmq" || queuetype == "msmq")
            {
                if (host == string.Empty)
                {
                    KRSrcWorkflow.WFUtilities.SetHostAndIPAddress(System.Net.Dns.GetHostName(), ref host);
                }
//				if (queuetype == "rabbbitmq")
//					msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_RabbitMQ<PSTMsgParser.PSTMsgParser>(host, 5672, "msgqueue", KRSrcWorkflow.Abstracts.WFMessageQueueType.Publisher);
//				else if (queuetype == "msmq")
//					msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_MessageQueue<PSTMsgParser.PSTMsgParser>(host, "msgqueue");
            }
//			else
//				msgqueue = new KRSrcWorkflow.MessageQueueImplementations.WFMessageQueue_Queue<PSTMsgParser.PSTMsgParser>();

            List <ManualResetEvent> msgthreadevents = new List <ManualResetEvent>();

            ManualResetEvent msgthreadinterrupt = null;

            if (isclient)
            {
                int threadid = 0;
                KRSrcWorkflow.WFGenericThread <PSTMsgParser.PSTMsgParser> iothread = null;
                if (msgprocessthreads > 0)
                {
                    msgthreadinterrupt = new ManualResetEvent(false);
                    for (int i = 0; i < msgprocessthreads; i++)
                    {
//						ThreadPool.QueueUserWorkItem((iothread = new KRSrcWorkflow.WFThread<PSTMsgParser.PSTMsgParserData>(msgthreadinterrupt, msgqueue, null, threadid++)).Run);
                        msgthreadevents.Add(iothread.ThreadExitEvent);
                    }
                }
            }

            if (isserver)
            {
                string[] pstfiles = null;

                if (pathtopstfiles != string.Empty)
                {
                    pstfiles = System.IO.Directory.GetFiles(pathtopstfiles, "*.pst", System.IO.SearchOption.TopDirectoryOnly);
                }
                else if (pstfile != string.Empty)
                {
                    pstfiles = new string[1] {
                        pstfile
                    }
                }
                ;
                if (pstfiles.Length != 0)
                {
                    foreach (string pfile in pstfiles)
                    {
                        bool append = false;

                        Logger.NLogger.Info("Processing: {0}", pfile);
                        string exportdir = pathtoemlfiles;
                        if (pathtopstfiles != string.Empty)
                        {
                            exportdir = pathtoemlfiles + pfile.Substring((pfile.LastIndexOf("\\") == -1 ? 0 : pfile.LastIndexOf("\\")) + 1, pfile.Length - 5 - (pfile.LastIndexOf("\\") == -1 ? 0 : pfile.LastIndexOf("\\")));
                        }
                        Logger.NLogger.Info("Export Directory: {0}", exportdir);

                        if (docount)
                        {
                            if (System.IO.File.Exists(exportdir + "\\AllEntryID.txt"))
                            {
                                System.IO.File.Delete(exportdir + "\\AllEntryID.txt");
                            }

                            if (System.IO.File.Exists(exportdir + "\\FolderInfo.xml"))
                            {
                                System.IO.File.Delete(exportdir + "\\FolderInfo.xml");
                            }
                        }

                        if (!System.IO.Directory.Exists(exportdir + @"MSG\"))
                        {
                            System.IO.Directory.CreateDirectory(exportdir + @"MSG\");
                        }

                        if (!System.IO.Directory.Exists(exportdir + @"XML\"))
                        {
                            System.IO.Directory.CreateDirectory(exportdir + @"XML\");
                        }

                        Logger.NLogger.Info("Logon to PST store: {0}", pfile);
                        pstsdk.definition.pst.IPst rdopststore = null;
                        try
                        {
                            rdopststore = new pstsdk.layer.pst.Pst(pfile);
                        }
                        catch (Exception ex)
                        {
                            Logger.NLogger.ErrorException("Pst constructor failed for " + pfile, ex);
                        }
                        if (rdopststore != null)
                        {
                            Logger.NLogger.Info("Successfully logged on to PST store: {0}", pfile);
                            GetFolderData(rdopststore.OpenRootFolder(), string.Empty, folderdata.Count > 0 ? true : false, docount == true, ref folderdata);
                            uint totmessages    = (uint)folderdata.Sum(x => x.NumMessages);
                            uint totattachments = (uint)folderdata.Sum(x => x.NumAttachments);

                            System.Xml.XmlDocument doc         = new System.Xml.XmlDocument();
                            System.Xml.XmlNode     foldersnode = null;
                            if (docount == true)
                            {
                                doc = new System.Xml.XmlDocument();                                // Create the XML Declaration, and append it to XML document
                                System.Xml.XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "windows-1252", null);
                                doc.AppendChild(dec);
                                // create message element
                                System.Xml.XmlElement folders = doc.CreateElement("Folders");
                                foldersnode = doc.AppendChild(folders);
                            }
//							List<pstsdk.definition.util.primitives.NodeID> foldernodeids = docount == true ? folderdata.Where(x => x.NodeId != 0).Select(x => x.NodeId).ToList() : rdopststore.Folders.Where(x => x.Node != 0).Select(x => x.Node).ToList();
//							foreach (pstsdk.definition.util.primitives.NodeID foldernodeid in foldernodeids)
                            foreach (FolderData fd in folderdata)
                            {
                                pstsdk.definition.util.primitives.NodeID foldernodeid = fd.NodeId;

                                pstsdk.definition.pst.folder.IFolder folder = null;
                                try
                                {
                                    folder = rdopststore.OpenFolder(foldernodeid);
                                    if (docount == true)
                                    {
                                        HandleFolder(folder, doc, foldersnode, fd.FolderPath, unicode);
                                    }
                                    uint idx = 0;
                                    foreach (pstsdk.definition.pst.message.IMessage msg in folder.Messages)
                                    {
                                        if (docount == true)
                                        {
                                            using (System.IO.StreamWriter outfile = new System.IO.StreamWriter(exportdir + "\\AllEntryID.txt", append))
                                            {
                                                outfile.WriteLine(folder.EntryID.ToString() + "\t" + msg.EntryID.ToString());
                                            }
                                            append = true;
                                        }
                                        else
                                        {
                                            if (idx >= offset)
                                            {
//												if ((entryids.Count == 0) || entryids.Contains(msg.EntryID.ToString()))
//													msgqueue.Enqueue(new PSTMsgParser.PSTMsgParser(pfile, msg.Node, exportdir) { SaveAsTypes = PSTMsgParser.PSTMsgParser.SaveAsType.Msg | PSTMsgParser.PSTMsgParser.SaveAsType.Xml, SaveAttachments = false, FileToProcess = msg.Node.Value.ToString(), FolderPath = fd.FolderPath, ExportDirectory = exportdir, Pst2MsgCompatible = true });
                                            }
                                            idx++;
                                            if (count != UInt32.MaxValue)
                                            {
                                                if (idx == (offset + count))
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                        msg.Dispose();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Logger.NLogger.ErrorException("OpenFolder failed!" + " NodeId=" + foldernodeid + " FolderPath=" + folderdata.FirstOrDefault(x => x.NodeId == foldernodeid).FolderPath, ex);
                                }
                                finally
                                {
                                    if (folder != null)
                                    {
                                        folder.Dispose();
                                    }
                                }
                            }
                            if (docount == true)
                            {
                                System.Xml.XmlElement numoffolders     = doc.CreateElement("numOfFolders");
                                System.Xml.XmlNode    numoffoldersnode = foldersnode.AppendChild(numoffolders);
                                numoffoldersnode.InnerText = rdopststore.Folders.Count().ToString();

                                System.Xml.XmlElement numofmsgs     = doc.CreateElement("numOfMsgs");
                                System.Xml.XmlNode    numofmsgsnode = foldersnode.AppendChild(numofmsgs);
                                numofmsgsnode.InnerText = totmessages.ToString();

                                System.Xml.XmlElement numoftotattachments     = doc.CreateElement("numOfAttachments");
                                System.Xml.XmlNode    numoftotattachmentsnode = foldersnode.AppendChild(numoftotattachments);
                                numoftotattachmentsnode.InnerText = totattachments.ToString();

                                System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(exportdir + "\\FolderInfo.xml", System.Text.Encoding.GetEncoding("windows-1252"));
                                writer.Formatting = System.Xml.Formatting.Indented;
                                doc.Save(writer);
                                writer.Close();
                            }
                            rdopststore.Dispose();
                        }
                    }
                }
                else
                {
                    Console.WriteLine("ERROR: No pst files found in directory " + pathtopstfiles);
                }
                if (msgprocessthreads > 0)
                {
                    do
                    {
                        Thread.Sleep(100);
                    } while (msgqueue.Count > 0);
                    System.Diagnostics.Debug.WriteLine("Setting msgthreadinterrupt");
                    msgthreadinterrupt.Set();
                    WaitHandle.WaitAll(msgthreadevents.ToArray());
                    System.Diagnostics.Debug.WriteLine("All message threads exited");
                    Thread.Sleep(5000);
                }
            }
            else
            {
                Thread.Sleep(Int32.MaxValue);
            }
        }
    }
Ejemplo n.º 48
0
 bool svgconcat(List<string> files, string output, uint delay, uint loop) {
     if (controller_ != null) controller_.appendOutput("TeX2img: Making animation svg...");
     try {
         var outxml = new System.Xml.XmlDocument();
         outxml.XmlResolver = null;
         outxml.AppendChild(outxml.CreateXmlDeclaration("1.0", "utf-8", "no"));
         outxml.AppendChild(outxml.CreateDocumentType("svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null));
         var svg = outxml.CreateElement("svg", "http://www.w3.org/2000/svg");
         var attr = outxml.CreateAttribute("xmlns:xlink");
         attr.Value = "http://www.w3.org/1999/xlink";
         svg.Attributes.Append(attr);
         attr = outxml.CreateAttribute("version");
         attr.Value = "1.1";
         svg.Attributes.Append(attr);
         outxml.AppendChild(svg);
         var defs = outxml.CreateElement("defs", "http://www.w3.org/2000/svg");
         svg.AppendChild(defs);
         var idreg = new System.Text.RegularExpressions.Regex(@"(?<!\&)#");
         foreach (var f in files) {
             var id = Path.GetFileNameWithoutExtension(f);
             var xml = new System.Xml.XmlDocument();
             xml.XmlResolver = null;
             xml.Load(Path.Combine(workingDir, f));
             foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("*")) {
                 foreach (System.Xml.XmlAttribute a in tag.Attributes) {
                     if (a.Name.ToLower() == "id") a.Value = id + "-" + a.Value;
                     else a.Value = idreg.Replace(a.Value, "#" + id + "-");
                 }
             }
             foreach (System.Xml.XmlNode tag in xml.GetElementsByTagName("svg")) {
                 var idattr = xml.CreateAttribute("id");
                 idattr.Value = id;
                 tag.Attributes.Append(idattr);
             }
             foreach (System.Xml.XmlNode n in xml.ChildNodes) {
                 if (n.NodeType != System.Xml.XmlNodeType.DocumentType && n.NodeType != System.Xml.XmlNodeType.XmlDeclaration) {
                     defs.AppendChild(outxml.ImportNode(n, true));
                 }
             }
         }
         var use = outxml.CreateElement("use", "http://www.w3.org/2000/svg");
         svg.AppendChild(use);
         var animate = outxml.CreateElement("animate", "http://www.w3.org/2000/svg");
         use.AppendChild(animate);
         attr = outxml.CreateAttribute("attributeName");
         attr.Value = "xlink:href"; animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("begin");
         attr.Value = "0s"; animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("dur");
         attr.Value = ((decimal)(delay * files.Count) / 100).ToString() + "s";
         animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("repeatCount");
         attr.Value = loop > 0 ? loop.ToString() : "indefinite";
         animate.Attributes.Append(attr);
         attr = outxml.CreateAttribute("values");
         attr.Value = String.Join(";", files.Select(d => "#" + Path.GetFileNameWithoutExtension(d)).ToArray());
         animate.Attributes.Append(attr);
         outxml.Save(Path.Combine(workingDir, output));
         if (controller_ != null) controller_.appendOutput(" done\n");
         return true;
     }
     catch (Exception) { return false; }
 }
Ejemplo n.º 49
0
        public Skin GetSkin()
        {
            var resources = new Dictionary<string, System.IO.MemoryStream>();

            var doc = new System.Xml.XmlDocument();
            var declar = doc.CreateXmlDeclaration("1.0", System.Text.Encoding.UTF8.WebName, null);
            doc.AppendChild(declar);

            var root = doc.CreateElement("Theme");
            root.SetAttribute("version", "1.0");
            root.AppendChild(this.ContainerControl.GetXmlElement(doc, resources));

            doc.AppendChild(root);

            return new Skin(doc, resources);
        }