Ejemplo n.º 1
0
        public System.Xml.XmlDocument getClaims()
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            System.Xml.XmlElement claims = doc.CreateElement("claims");

            foreach(TurfWarsGame.Claim c in TurfWars.Global.game.getClaims())
            {
                System.Xml.XmlElement claim = doc.CreateElement("claim");

                System.Xml.XmlElement owners = doc.CreateElement("owners");
                foreach (string u in c.getOwners().Keys)
                {
                    System.Xml.XmlElement owner = doc.CreateElement("owner");
                    owner.SetAttribute("name", u);
                    owner.SetAttribute("share", c.getOwners()[u].ToString());
                    owners.AppendChild(owner);
                }

                System.Xml.XmlElement tile = doc.CreateElement("tile");
                tile.SetAttribute("north",c.box.north.ToString());
                tile.SetAttribute("south",c.box.south.ToString());
                tile.SetAttribute("west", c.box.west.ToString());
                tile.SetAttribute("east", c.box.east.ToString());
                claim.AppendChild(owners);
                claim.AppendChild(tile);
                claims.AppendChild(claim);
            }

            doc.AppendChild(claims);
            return doc;
        }
Ejemplo n.º 2
0
        public System.Xml.XmlElement GenerateDefinitionXmlElement(EntitiesGenerator.Definitions.DataTable table)
        {
            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            System.Xml.XmlElement definitionElement = xmlDocument.CreateElement("Definition");
            System.Xml.XmlElement xmlElement = xmlDocument.CreateElement("DataTable");

            System.Xml.XmlAttribute tableNameXmlAttribute = xmlDocument.CreateAttribute("TableName");
            tableNameXmlAttribute.Value = table.TableName.Trim();
            xmlElement.Attributes.Append(tableNameXmlAttribute);

            System.Xml.XmlAttribute sourceNameXmlAttribute = xmlDocument.CreateAttribute("SourceName");
            sourceNameXmlAttribute.Value = table.SourceName.Trim();
            xmlElement.Attributes.Append(sourceNameXmlAttribute);

            foreach (EntitiesGenerator.Definitions.DataColumn column in table.Columns)
            {
                System.Xml.XmlElement dataColumnXmlElement = xmlDocument.CreateElement("DataColumn");

                System.Xml.XmlAttribute dataColumnColumnNameXmlAttribute = xmlDocument.CreateAttribute("ColumnName");
                dataColumnColumnNameXmlAttribute.Value = column.ColumnName.Trim();
                dataColumnXmlElement.Attributes.Append(dataColumnColumnNameXmlAttribute);

                System.Xml.XmlAttribute dataColumnSourceNameXmlAttribute = xmlDocument.CreateAttribute("SourceName");
                dataColumnSourceNameXmlAttribute.Value = column.SourceName.Trim();
                dataColumnXmlElement.Attributes.Append(dataColumnSourceNameXmlAttribute);

                System.Xml.XmlAttribute dataColumnDataTypeXmlAttribute = xmlDocument.CreateAttribute("DataType");
                dataColumnDataTypeXmlAttribute.Value = column.DataType.Trim();
                dataColumnXmlElement.Attributes.Append(dataColumnDataTypeXmlAttribute);

                if (column.PrimaryKey)
                {
                    System.Xml.XmlAttribute dataColumnPrimaryKeyXmlAttribute = xmlDocument.CreateAttribute("PrimaryKey");
                    dataColumnPrimaryKeyXmlAttribute.Value = column.PrimaryKey ? "true" : "false";
                    dataColumnXmlElement.Attributes.Append(dataColumnPrimaryKeyXmlAttribute);
                }

                if (!column.AllowDBNull)
                {
                    System.Xml.XmlAttribute dataColumnAllowDBNullXmlAttribute = xmlDocument.CreateAttribute("AllowDBNull");
                    dataColumnAllowDBNullXmlAttribute.Value = column.AllowDBNull ? "true" : "false";
                    dataColumnXmlElement.Attributes.Append(dataColumnAllowDBNullXmlAttribute);
                }

                if (column.AutoIncrement)
                {
                    System.Xml.XmlAttribute dataColumnAutoIncrementXmlAttribute = xmlDocument.CreateAttribute("AutoIncrement");
                    dataColumnAutoIncrementXmlAttribute.Value = column.AutoIncrement ? "true" : "false";
                    dataColumnXmlElement.Attributes.Append(dataColumnAutoIncrementXmlAttribute);
                }

                // TODO: caption.

                xmlElement.AppendChild(dataColumnXmlElement);
            }
            definitionElement.AppendChild(xmlElement);
            xmlDocument.AppendChild(definitionElement);
            return xmlDocument.DocumentElement;
        }
Ejemplo n.º 3
0
        private static void SetNode(string cpath)
        {   
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(cpath);
            Console.WriteLine("Adding to machine.config path: {0}", cpath);

            foreach (DataProvider dp in dataproviders)
            {
                System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
                if (node == null)
                {
                    System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
                    node = doc.CreateElement("add");
                    System.Xml.XmlAttribute at = doc.CreateAttribute("name");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("invariant");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("description");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("type");
                    node.Attributes.Append(at);
                    root.AppendChild(node);
                }
                node.Attributes["name"].Value = dp.name;
                node.Attributes["invariant"].Value = dp.invariant;
                node.Attributes["description"].Value = dp.description;
                node.Attributes["type"].Value = dp.type;
                Console.WriteLine("Added Data Provider node in machine.config.");
            }            

            doc.Save(cpath);
            Console.WriteLine("machine.config saved: {0}", cpath);
        }
Ejemplo n.º 4
0
        public System.Xml.XmlNode Serialize(System.Xml.XmlDocument doc)
        {
            string connectionString = string.Empty;
            string tableName        = string.Empty;
            string projectPath      = string.Empty;
            string viewName         = string.Empty;

            if (dashboardHelper.View == null)
            {
                connectionString = dashboardHelper.Database.ConnectionString;
                tableName        = dashboardHelper.TableName;
            }
            else
            {
                projectPath = dashboardHelper.View.Project.FilePath;
                viewName    = dashboardHelper.View.Name;
            }
            string          dataKey   = cbxDataKey.SelectedItem.ToString();
            string          shapeKey  = cbxShapeKey.SelectedItem.ToString();
            string          value     = cbxValue.SelectedItem.ToString();
            SolidColorBrush dotColor  = (SolidColorBrush)rctDotColor.Fill;
            string          xmlString = "<shapeFile>" + shapeFilePath + "</shapeFile><dotValue>" + txtDotValue.Text + "</dotValue><dotColor>" + dotColor.Color.ToString() + "</dotColor><dataKey>" + dataKey + "</dataKey><shapeKey>" + shapeKey + "</shapeKey><value>" + value + "</value>";

            System.Xml.XmlElement element = doc.CreateElement("dataLayer");
            element.InnerXml = xmlString;
            element.AppendChild(dashboardHelper.Serialize(doc));

            System.Xml.XmlAttribute type = doc.CreateAttribute("layerType");
            type.Value = "EpiDashboard.Mapping.DotDensityLayerProperties";
            element.Attributes.Append(type);

            return(element);
        }
Ejemplo n.º 5
0
        CreateLaunchActions(
            System.Xml.XmlDocument doc,
            System.Xml.XmlElement schemeElement,
            Target target)
        {
            var launchActionEl = doc.CreateElement("LaunchAction");

            schemeElement.AppendChild(launchActionEl);
            {
                launchActionEl.SetAttribute("selectedDebuggerIdentifier", "Xcode.DebuggerFoundation.Debugger.LLDB");
                launchActionEl.SetAttribute("selectedLauncherIdentifier", "Xcode.DebuggerFoundation.Launcher.LLDB");
                launchActionEl.SetAttribute("buildConfiguration", target.ConfigurationList.ElementAt(0).Name);

                var productRunnableEl = doc.CreateElement("BuildableProductRunnable");
                launchActionEl.AppendChild(productRunnableEl);

                var buildableRefEl = doc.CreateElement("BuildableReference");
                productRunnableEl.AppendChild(buildableRefEl);

                buildableRefEl.SetAttribute("BuildableIdentifier", "primary");

                if (null != target.FileReference)
                {
                    buildableRefEl.SetAttribute("BlueprintIdentifier", target.GUID);
                    buildableRefEl.SetAttribute("BuildableName", target.FileReference.Name);
                    buildableRefEl.SetAttribute("BlueprintName", target.Name);
                }

                if (target.Project.ProjectDir == this.Project.ProjectDir)
                {
                    buildableRefEl.SetAttribute("ReferencedContainer",
                                                "container:" + System.IO.Path.GetFileName(target.Project.ProjectDir.Parse()));
                }
                else
                {
                    var relative = this.Project.GetRelativePathToProject(target.Project.ProjectDir);
                    buildableRefEl.SetAttribute("ReferencedContainer",
                                                "container:" + relative);
                }

                if ((target.Module is C.ConsoleApplication) && (target.Module as C.ConsoleApplication).WorkingDirectory != null)
                {
                    launchActionEl.SetAttribute("useCustomWorkingDirectory", "YES");
                    launchActionEl.SetAttribute("customWorkingDirectory", (target.Module as C.ConsoleApplication).WorkingDirectory.Parse());
                }
            }
        }
Ejemplo n.º 6
0
        public virtual string ToXML()
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            //doc.Name = "pays";

            System.Xml.XmlElement pay = doc.CreateElement("pay");

            pay.SetAttribute("prv_id", Prv_id.ToString());
            pay.SetAttribute("amount", From_amount.ToString());
            pay.SetAttribute("to-amount", To_amount.ToString());
            pay.SetAttribute("txn_id", Txn_id);
            pay.SetAttribute("receipt", Recept.ToString());
            pay.SetAttribute("txn_date", Txn_date.ToString("yyyyMMdd HH:mm:ss"));

            /*
             * foreach (string line in Ipaybox.curPay.Options.Split('|'))
             * {
             *  if (line != "")
             *  {
             *      string[] param = line.Split('-');
             *      if (param[0] != null)
             *      {
             *          XmlElement extra = Ipaybox.pays.CreateElement("extra");
             *          if (param[1] == "account")
             *              Ipaybox.curPay.account = param[2];
             *          extra.SetAttribute("name", param[1]);
             *          extra.SetAttribute("value", param[2]);
             *          extra.SetAttribute("CRC", Ipaybox.getMd5Hash("n" + param[1] + "v" + param[2]));
             *          pay.AppendChild(extra);
             *      }
             *  }
             * }
             */
            for (int i = 0; i < Extra.Count; i++)
            {
                if (!string.IsNullOrEmpty(Extra.GetKey(i)))
                {
                    System.Xml.XmlElement extra = doc.CreateElement("extra");
                    extra.SetAttribute("name", Extra.GetKey(i));
                    extra.SetAttribute("value", Extra[i]);
                    extra.SetAttribute("CRC", Ipaybox.getMd5Hash("n" + Extra.GetKey(i) + "v" + Extra[i]));
                    pay.AppendChild(extra);
                }
            }
            doc.AppendChild(pay);
            return(doc.ChildNodes[0].ToString());
        }
Ejemplo n.º 7
0
        private void MyXml(CLAS.JudgmentRow jr, System.Xml.XmlDocument xd)
        {
            if (jr.ProcessTypeCode != "TP")
            {
                System.Xml.XmlElement xe = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@type='judgment' and @id=" + jr.JudgmentID.ToString() + "]");
                if (xe == null)
                {
                    xe = xd.CreateElement("toc");
                    xe.SetAttribute("type", "judgment");
                }
                xe.SetAttribute("id", jr.JudgmentID.ToString());
                string title           = "";
                bool   isTextStruckout = false;
                if (!jr.IsActionNumberNull())
                {
                    title += jr.ActionNumber;
                }

                if (!jr.IsWithdrawalRemovalDateNull())
                {
                    isTextStruckout = true;
                    string withdrawnTooltipE = "Judgment Withdrawal/Removal Date: " + jr.WithdrawalRemovalDate.ToString("yyyy/MM/dd");
                    string withdrawnTooltipF = "Jugement retiré le : " + jr.WithdrawalRemovalDate.ToString("yyyy/MM/dd");

                    xe.SetAttribute("tooltipe", withdrawnTooltipE);
                    xe.SetAttribute("tooltipf", withdrawnTooltipF);
                    title += " (" + Properties.Resources.JudgmentJudgmentDate + " " + jr.JudgmentDate.ToString("yyyy/MM/dd") + ")";
                }
                else if (!jr.IsJudgmentDateNull())
                {
                    title += " (" + Properties.Resources.JudgmentJudgmentDate + " " + jr.JudgmentDate.ToString("yyyy/MM/dd") + ")";
                }
                else if (!jr.IsDefenceDateNull())
                {
                    title += " (" + Properties.Resources.JudgmentDefenceDate + " " + jr.DefenceDate.ToString("yyyy/MM/dd") + ")";
                }
                else if (!jr.IsStatementofClaimServedDateNull())
                {
                    title += " (" + Properties.Resources.JudgmentStatementofClaimServedDate + " " + jr.StatementofClaimServedDate.ToString("yyyy/MM/dd") + ")";
                }
                else if (!jr.IsStatementofClaimIssuedDateNull())
                {
                    title += " (" + Properties.Resources.JudgmentStatementofClaimIssuedDate + " " + jr.StatementofClaimIssuedDate.ToString("yyyy/MM/dd") + ")";
                }


                xe.SetAttribute("titlee", title);
                xe.SetAttribute("titlef", title);
                xe.SetAttribute("strikeout", isTextStruckout.ToString().ToLower());



                if (xe.ParentNode == null)
                {
                    System.Xml.XmlElement xes = EFileBE.XmlAddFld(xd, "judgment", "Litigation", "Litige", 250);
                    xes.AppendChild(xe);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates an xml Element to be added to a Project xml
        /// </summary>
        /// <param name="artifactToInclude">Name of the artifact to include</param>
        /// <param name="origXMLDoc"></param>
        /// <returns>XmlElement of type ItemGroup</returns>
        private System.Xml.XmlElement CreateItemGroupContentNode(string artifactToInclude, System.Xml.XmlDocument origXMLDoc)
        {
            System.Xml.XmlElement itemGroupNode = origXMLDoc.CreateElement("ItemGroup");

            itemGroupNode.AppendChild(GetProjectContentNode(artifactToInclude, origXMLDoc));

            return(itemGroupNode);
        }
Ejemplo n.º 9
0
        public System.Xml.XmlNode GetConfig(System.Xml.XmlDocument doc)
        {
            System.Xml.XmlNode xn = doc.CreateElement(this.GetType().Name);

            System.Xml.XmlNode xnFileName = doc.CreateElement("FileName");
            xnFileName.InnerText = this.FileName;
            xn.AppendChild(xnFileName);

            if (this.Password != null && this.Password.Length > 0)
            {
                System.Xml.XmlNode xnPassword = doc.CreateElement("Password");
                xnPassword.InnerText = this.Password;
                xn.AppendChild(xnPassword);
            }

            return(xn);
        }
Ejemplo n.º 10
0
 // TODO: This is not really an extension, more a helper and so should be moved...
 public static System.Xml.XmlElement CreateXmlElement(string tag, string content)
 {
     System.Xml.XmlDocument doc     = new System.Xml.XmlDocument();
     System.Xml.XmlElement  element = doc.CreateElement(tag);
     doc.AppendChild(element);
     element.AppendChild(doc.CreateTextNode(content));
     return(doc.DocumentElement);
 }
Ejemplo n.º 11
0
 public System.Xml.XmlDocument CreateXmlDocument()
 {
     System.Xml.XmlDocument doc  = new System.Xml.XmlDocument();
     System.Xml.XmlNode     node = doc.CreateElement("root");
     doc.AppendChild(node);
     this.AddToXml(node);
     return(doc);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 获取当前设备驱动的配置信息,将序列化的内容填充至 XmlNode 的 InnerText 属性或者 ChildNodes 子节点中。
        /// </summary>
        /// <param name="xmlDoc">创建 XmlNode 时所需使用到的 System.Xml.XmlDocument。</param>
        public override System.Xml.XmlNode GetDriveConfig(System.Xml.XmlDocument xmlDoc)
        {
            System.Xml.XmlNode xnConfig = xmlDoc.CreateElement(this.GetType().Name);

            xnConfig.AppendChild(this.ChannelServiceMemberInfos.GetConfig(xmlDoc));

            return(xnConfig);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 保存文档
 /// </summary>
 /// <param name="filename">文件名</param>
 public void Save(string filename)
 {
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.AppendChild(doc.CreateElement("CHMDocument"));
     ToXML(doc.DocumentElement);
     doc.Save(filename);
     _fileName = filename;
 }
Ejemplo n.º 14
0
 // TODO: This is not really an extension, more a helper and so should be moved...
 public static System.Xml.XmlElement CreateXmlElement( string tag, string content )
 {
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     System.Xml.XmlElement element = doc.CreateElement(tag);
     doc.AppendChild(element);
     element.AppendChild(doc.CreateTextNode(content));
     return doc.DocumentElement;
 }
        public System.Xml.XmlNode GetSettings(System.Xml.XmlDocument document)
        {
            var settingsNode = document.CreateElement("Settings");

            var node = document.CreateElement("autoReset");

            node.InnerText = autoReset.ToString();
            settingsNode.AppendChild(node);
            node           = document.CreateElement("autoStart");
            node.InnerText = autoStart.ToString();
            settingsNode.AppendChild(node);
            node           = document.CreateElement("autoSplit");
            node.InnerText = autoSplit.ToString();
            settingsNode.AppendChild(node);

            return(settingsNode);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 发送消息 多边形范围
        /// </summary>
        /// <param name="strProjectName">工程名称</param>
        /// <param name="pointarray">点集合</param>
        /// <param name="interpret">标志多边形类型</param>
        /// <returns>是否发送成功,true:消息发送成功;false:消息发送失败</returns>
        public bool SendPolygonUpdateMsg(string strProjectName, string pointarray, string interpret)
        {
            //声明xml变量
            System.Xml.XmlDocument vDoc = new System.Xml.XmlDocument();
            //添加xml节点
            System.Xml.XmlNode vRoot = vDoc.AppendChild(vDoc.CreateElement("CMD"));
            //创建节点
            AppendXmlAtt(vDoc, vRoot, "val", STRGEOONE_UPDATE);
            //创建工程名称呢个节点并赋值
            vRoot.AppendChild(vDoc.CreateElement("ProjectName")).InnerText = strProjectName;

            //创建范围节点及其自己坐标
            System.Xml.XmlNode vNode = vRoot.AppendChild(vDoc.CreateElement("Polygon"));
            AppendXmlAtt(vDoc, vNode, "Coord", pointarray);
            //发送消息
            return(SendUpdateMsg(vDoc.OuterXml));
        }
Ejemplo n.º 17
0
        public System.Xml.XmlElement Serialize(System.Xml.XmlDocument doc)
        {
            var element = doc.CreateElement("Error-Message");

            element.AppendTextNode("Error-Number", Code);
            element.AppendTextNode("Error", Message);
            return(element);
        }
Ejemplo n.º 18
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument workQueueTeamDocument = base.XmlSerialize();

            System.Xml.XmlElement workQueueTeamNode = workQueueTeamDocument.CreateElement("WorkQueueTeam");

            System.Xml.XmlElement propertiesNode;



            workQueueTeamDocument.AppendChild(workQueueTeamNode);

            workQueueTeamNode.SetAttribute("WorkQueueId", workTeamId.ToString());

            workQueueTeamNode.SetAttribute("WorkTeamId", workTeamId.ToString());

            workQueueTeamNode.SetAttribute("Name", workTeamName);

            propertiesNode = workQueueTeamDocument.CreateElement("Properties");

            workQueueTeamNode.AppendChild(propertiesNode);


            #region Population Properties

            CommonFunctions.XmlDocumentAppendPropertyNode(workQueueTeamDocument, propertiesNode, "WorkQueueId", workQueueId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(workQueueTeamDocument, propertiesNode, "WorkTeamId", workTeamId.ToString());

            CommonFunctions.XmlDocumentAppendPropertyNode(workQueueTeamDocument, propertiesNode, "WorkTeamName", workTeamName);

            CommonFunctions.XmlDocumentAppendPropertyNode(workQueueTeamDocument, propertiesNode, "Permission", ((Int32)permission).ToString());

            #endregion


            if (WorkTeam != null)
            {
                workQueueTeamNode.AppendChild(workQueueTeamDocument.ImportNode(WorkTeam.XmlSerialize().ChildNodes[1], true));
            }



            return(workQueueTeamDocument);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 获取账号配置信息。
        /// </summary>
        /// <returns>账号配置信息</returns>
        public System.Xml.XmlNode GetConfig(System.Xml.XmlDocument doc)
        {
            System.Xml.XmlNode xn = doc.CreateElement(this.GetType().Name);

            System.Xml.XmlNode xnFirstName = doc.CreateElement("FirstName");
            xnFirstName.InnerText = this.FirstName;
            xn.AppendChild(xnFirstName);

            System.Xml.XmlNode xnLastName = doc.CreateElement("LastName");
            xnLastName.InnerText = this.LastName;
            xn.AppendChild(xnLastName);


            System.Xml.XmlNode xnEName = doc.CreateElement("EName");
            xnEName.InnerText = this.EName;
            xn.AppendChild(xnEName);

            System.Xml.XmlNode xnMobile = doc.CreateElement("Mobile");
            xnMobile.InnerText = this.Mobile;
            xn.AppendChild(xnMobile);

            System.Xml.XmlNode xnLastIP = doc.CreateElement("LastIP");
            xnLastIP.InnerText = this.LastIP;
            xn.AppendChild(xnLastIP);

            System.Xml.XmlNode xnLastDateTime = doc.CreateElement("LastDateTime");
            xnLastDateTime.InnerText = this.LastDateTime;
            xn.AppendChild(xnLastDateTime);

            return(xn);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 获取通道服务成员配置信息。
        /// </summary>
        /// <param name="xmlDoc"></param>
        /// <returns></returns>
        public System.Xml.XmlNode GetConfig(System.Xml.XmlDocument xmlDoc)
        {
            System.Xml.XmlNode xnConfig = xmlDoc.CreateElement(this.GetType().Name);

            System.Xml.XmlNode xnAddresses = xmlDoc.CreateElement("Addresses");
            xnConfig.AppendChild(xnAddresses);

            foreach (IPAddress address in this.Addresses)
            {
                System.Xml.XmlNode xnAddress = xmlDoc.CreateElement("Address");
                xnAddress.InnerText = address.ToString();
                xnAddresses.AppendChild(xnAddress);
            }

            System.Xml.XmlNode xnPort = xmlDoc.CreateElement("Port");
            xnPort.InnerText = this.Port.ToString();
            xnConfig.AppendChild(xnPort);

            System.Xml.XmlNode xnPassword = xmlDoc.CreateElement("Password");
            xnPassword.InnerText = this.Password;
            xnConfig.AppendChild(xnPassword);

            System.Xml.XmlNode xnMaxConnection = xmlDoc.CreateElement("MaxConnection");
            xnMaxConnection.InnerText = this.MaxConnection.ToString();
            xnConfig.AppendChild(xnMaxConnection);

            System.Xml.XmlNode xnDelay = xmlDoc.CreateElement("Delay");
            xnDelay.InnerText = this.Delay.ToString();
            xnConfig.AppendChild(xnDelay);

            return(xnConfig);
        }
Ejemplo n.º 21
0
        public System.Xml.XmlElement Serialize(System.Xml.XmlDocument doc)
        {
            var element = doc.CreateElement("User-Authorized");

            element.AppendTextNode("FSO-Version", FSOVersion);
            element.AppendTextNode("FSO-Branch", FSOBranch);
            element.AppendTextNode("FSO-UpdateUrl", FSOUpdateUrl);
            return(element);
        }
Ejemplo n.º 22
0
 public static string ToXML(DataTable dt)
 {
     System.Xml.XmlDocument objDoc  = new System.Xml.XmlDocument();
     System.Xml.XmlElement  objRoot = objDoc.CreateElement("users");
     foreach (DataRow dr in dt.Rows)
     {
         System.Xml.XmlElement objUser = objDoc.CreateElement("user");
         foreach (DataColumn dc in dt.Columns)
         {
             System.Xml.XmlAttribute objAttr = objDoc.CreateAttribute(dc.ColumnName);
             objAttr.Value = string.Format("{0}", dr[dc.ColumnName]);
             objUser.Attributes.Append(objAttr);
         }
         objRoot.AppendChild(objUser);
     }
     objDoc.AppendChild(objRoot);
     return(objDoc.InnerXml);
 }
Ejemplo n.º 23
0
 /// <summary>prepare internal XmlDocument with basic Document-Root</summary>
 private void _initializeXML()
 {
     System.Xml.XmlDocument    _tmpdoc  = new System.Xml.XmlDocument();
     System.Xml.XmlDeclaration _tmpdec  = _tmpdoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");
     System.Xml.XmlElement     _tmproot = _tmpdoc.CreateElement("UserSettings");
     _tmpdoc.AppendChild(_tmpdec);
     _tmpdoc.AppendChild(_tmproot);
     _intXml = _tmpdoc;
 }
Ejemplo n.º 24
0
        internal static System.Xml.XmlNode CreateXMLNodes(XMLData data)
        {
            System.Xml.XmlNode xNode = xDoc.CreateNode(System.Xml.XmlNodeType.Element,
                                                       "Monitee", null);

            System.Xml.XmlElement name     = xDoc.CreateElement("Source");
            System.Xml.XmlElement type     = xDoc.CreateElement("Type");
            System.Xml.XmlElement destPath = xDoc.CreateElement("Destination");
            name.InnerText     = data.MoniteePath;
            type.InnerText     = data.Type.ToString();
            destPath.InnerText = data.DestinationPath;

            xNode.AppendChild(name);
            xNode.AppendChild(type);
            xNode.AppendChild(destPath);

            return(xNode);
        }
Ejemplo n.º 25
0
 internal void SaveToXml(System.Xml.XmlElement xmlEl, System.Xml.XmlDocument doc)
 {
     foreach (DataMember dmem in this)            //members
     {
         System.Xml.XmlElement childEl = doc.CreateElement("M");
         dmem.SaveToXml(childEl, doc);
         xmlEl.AppendChild(childEl);
     }
 }
Ejemplo n.º 26
0
 public void Save(System.Xml.XmlElement element, System.Xml.XmlDocument doc)
 {
     foreach (var property in this.GetType().GetProperties())
     {
         var cElement = doc.CreateElement(property.Name);
         cElement.InnerText = property.GetValue(this, null).ToString();
         element.AppendChild(cElement);
     }
 }
        /// <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.º 28
0
        public void Dispose()
        {
            if (_closeWriter)
            {
                _wr.Close();
                string str = _sb.ToString();
                _wr = null;
                _tw = null;
                _sb = null;
                if (_cnt > 1)
                {
                    lock (this.GetType())
                    {
                        System.Xml.XmlDocument xdoc = null;
                        bool cl = xdoc == null;
                        if (cl)
                        {
                            xdoc = new System.Xml.XmlDocument();
                            if (!System.IO.File.Exists(_fn))
                            {
                                System.Xml.XmlElement root = xdoc.CreateElement("root");
                                xdoc.AppendChild(root);
                            }
                            else
                            {
                                xdoc.Load(_fn);
                            }
                        }
                        System.Xml.XmlDocumentFragment e = xdoc.CreateDocumentFragment();
                        e.InnerXml = str;
                        xdoc.DocumentElement.AppendChild(e);
                        if (cl)
                        {
                            xdoc.Save(_fn);
                            xdoc = null;
                        }
                    }
                }
                _cnt = 0;
            }
            else
            {
                _wr.WriteEndElement();
            }

            //lock (typeof(CSScopeMgr_Debug))
            //{
            //    if (_first)
            //    {
            //        _xdoc.Save(_fn);
            //        _xdoc = null;
            //    }
            //}

            Unlock(_lock_obj);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 获取当前筛选器的状态,将序列化的内容填充至 XmlNode 的 InnerText 属性或者 ChildNodes 子节点中。
        /// </summary>
        /// <param name="xmlDoc">创建 XmlNode 时所需使用到的 System.Xml.XmlDocument。</param>
        public System.Xml.XmlNode GetFilterConfig(System.Xml.XmlDocument xmlDoc)
        {
            if (this.Addresss != null && this.Addresss.Length > 0)
            {
                System.Xml.XmlNode xnConfig = xmlDoc.CreateElement(this.GetType().Name);

                foreach (string strAddress in this.Addresss)
                {
                    System.Xml.XmlNode xnId = xmlDoc.CreateElement("Address");
                    xnId.InnerText = strAddress.ToString();
                    xnConfig.AppendChild(xnId);
                }
                return(xnConfig);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 获取当前筛选器的状态,将序列化的内容填充至 XmlNode 的 InnerText 属性或者 ChildNodes 子节点中。
        /// </summary>
        /// <param name="xmlDoc">创建 XmlNode 时所需使用到的 System.Xml.XmlDocument。</param>
        public System.Xml.XmlNode GetFilterConfig(System.Xml.XmlDocument xmlDoc)
        {
            if (this.SIds != null && this.SIds.Length > 0)
            {
                System.Xml.XmlNode xnConfig = xmlDoc.CreateElement(this.GetType().Name);

                foreach (int intId in this.SIds)
                {
                    System.Xml.XmlNode xnId = xmlDoc.CreateElement("StateOption");
                    xnId.InnerText = intId.ToString();
                    xnConfig.AppendChild(xnId);
                }
                return(xnConfig);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 31
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.º 32
0
        public SVG(System.Xml.XmlDocument document, string SVGnamespace, string version)
        {
            System.Xml.XmlElement element = document.CreateElement("svg", SVGnamespace);

            System.Xml.XmlAttribute attribute = document.CreateAttribute("version");;
            attribute.Value = version;
            element.Attributes.Append(attribute);

            (this as ISVGElement).Element = element;
        }
Ejemplo n.º 33
0
        public override System.Xml.XmlDocument XmlSerialize()
        {
            System.Xml.XmlDocument document = base.XmlSerialize();


            #region Field Definitions

            System.Xml.XmlNode fieldDefinitionsNodes = document.CreateElement("FieldDefinitions");

            document.LastChild.AppendChild(fieldDefinitionsNodes);

            foreach (WorkQueueViewFieldDefinition currentFieldDefinition in fieldDefinitions)
            {
                // TODO:
            }

            #endregion


            #region Filter Definitions

            System.Xml.XmlNode filterDefinitionsNodes = document.CreateElement("FilterDefinitions");

            document.LastChild.AppendChild(filterDefinitionsNodes);

            // TODO:

            #endregion


            #region Sort Definitions

            System.Xml.XmlNode sortDefinitionsNodes = document.CreateElement("SortDefinitions");

            document.LastChild.AppendChild(sortDefinitionsNodes);

            // TODO:

            #endregion


            return(document);
        }
Ejemplo n.º 34
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.º 35
0
        private void SaveColumnDefinition(System.Data.DataTable sheet, System.Xml.XmlNode sheetNode, System.Xml.XmlDocument ownerDocument)
        {
            System.Xml.XmlNode columnDefinition = ownerDocument.CreateElement("table:table-column", this.GetNamespaceUri("table"));

            System.Xml.XmlAttribute columnsCount = ownerDocument.CreateAttribute("table:number-columns-repeated", this.GetNamespaceUri("table"));
            columnsCount.Value = sheet.Columns.Count.ToString(System.Globalization.CultureInfo.InvariantCulture);
            columnDefinition.Attributes.Append(columnsCount);

            sheetNode.AppendChild(columnDefinition);
        }
Ejemplo n.º 36
0
        CreateBuildActions(
            System.Xml.XmlDocument doc,
            System.Xml.XmlElement schemeElement,
            Target target)
        {
            var buildActionEl = doc.CreateElement("BuildAction");

            schemeElement.AppendChild(buildActionEl);
            {
                buildActionEl.SetAttribute("parallelizeBuildables", "YES");
                buildActionEl.SetAttribute("buildImplicitDependencies", "YES");

                var buildActionEntries = doc.CreateElement("BuildActionEntries");
                buildActionEl.AppendChild(buildActionEntries);

                var buildActionsCreated = new Bam.Core.Array <Target>();
                this.CreateBuildActionEntry(doc, buildActionEntries, target, buildActionsCreated);
            }
        }
Ejemplo n.º 37
0
        public static string XmlUnescape(string escaped)
        {
            string strReturnValue = null;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            System.Xml.XmlNode node = doc.CreateElement("root");
            node.InnerXml = escaped;
            strReturnValue = node.InnerText;
            node = null;
            doc = null;

            return strReturnValue;
        }
Ejemplo n.º 38
0
        public System.Xml.XmlDocument getUserStats(string user)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            TurfWarsGame.User u = TurfWars.Global.game.getUser(user);

            System.Xml.XmlElement xmlUser = doc.CreateElement("user");
            xmlUser.SetAttribute("name", user);
            xmlUser.SetAttribute("balance", u.getAccountBalance().ToString());
            xmlUser.SetAttribute("shares", u.shares.ToString());

            doc.AppendChild(xmlUser);
            return doc;
        }
Ejemplo n.º 39
0
 public string ToDocumentXmlText()
 {
     System.Xml.XmlDocument datagram = new System.Xml.XmlDocument();
     System.Xml.XmlNode b1 = datagram.CreateElement(_Datagram.ToUpper());
     foreach (KeyValuePair<string, string> curr in Parameters)
     {
         System.Xml.XmlAttribute b2 = datagram.CreateAttribute(curr.Key);
         b2.Value = curr.Value;
         b1.Attributes.Append(b2);
     }
     b1.InnerText = this._InnerText;
     datagram.AppendChild(b1);
     return datagram.InnerXml;
 }
Ejemplo n.º 40
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.º 41
0
        public System.Xml.XmlDocument addClaim(string user, double lat, double lon)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

            Geo.Box box = TurfWars.Global.game.addClaim(user, lat, lon);

            System.Xml.XmlElement tile = doc.CreateElement("tile");
            tile.SetAttribute("north", box.north.ToString());
            tile.SetAttribute("south", box.south.ToString());
            tile.SetAttribute("west", box.west.ToString());
            tile.SetAttribute("east", box.east.ToString());

            doc.AppendChild(tile);
            return doc;
        }
Ejemplo n.º 42
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;
        }
		/// <summary> <p>Creates an XML Document that corresponds to the given Message object. </p>
		/// <p>If you are implementing this method, you should create an XML Document, and insert XML Elements
		/// into it that correspond to the groups and segments that belong to the message type that your subclass
		/// of XMLParser supports.  Then, for each segment in the message, call the method
		/// <code>encode(Segment segmentObject, Element segmentElement)</code> using the Element for
		/// that segment and the corresponding Segment object from the given Message.</p>
		/// </summary>
		public override System.Xml.XmlDocument encodeDocument(Message source)
		{
			System.String messageClassName = source.GetType().FullName;
			System.String messageName = messageClassName.Substring(messageClassName.LastIndexOf('.') + 1);
			System.Xml.XmlDocument doc = null;
			try
			{
				doc = new System.Xml.XmlDocument();
				System.Xml.XmlElement root = doc.CreateElement(messageName);
				doc.AppendChild(root);
			}
			catch (System.Exception e)
			{
				throw new NuGenHL7Exception("Can't create XML document - " + e.GetType().FullName, NuGenHL7Exception.APPLICATION_INTERNAL_ERROR, e);
			}
			encode(source, (System.Xml.XmlElement) doc.DocumentElement);
			return doc;
		}
Ejemplo n.º 44
0
        private void BtnAdd_Click(object sender, System.EventArgs e)
        {
            if (doc == null)
            {
                doc = Framework.Class.XmlTool.GetInstance();
                System.Xml.XmlNode project = doc.CreateElement("PROJECT");
                doc.AppendChild(project);

                Framework.Interface.Project.FrmProjectInfo win = new Framework.Interface.Project.FrmProjectInfo();
                win.ShowDialog();
                //doc.Save("aaa.xml");
                RefreshChapterTree();
            }
            else
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("不允许重复创建工程!", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            }
        }
Ejemplo n.º 45
0
        /// <summary>
        /// 根据Key修改Value
        /// </summary>
        /// <param name="key">要修改的Key</param>
        /// <param name="value">要修改为的值</param>
        public static void SetValue(string key, string value)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
            System.Xml.XmlNode xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
            if (xElem1 != null) xElem1.SetAttribute("value", value);
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", key);
                xElem2.SetAttribute("value", value);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
        }
Ejemplo n.º 46
0
        /// <summary>
        /// WinForm更新App.config中,key对应的value,没有则添加
        /// </summary>
        /// <param name="appKey">key</param>
        /// <param name="appValue">value</param>
        public static void AddOrUpdate(string appKey, string appValue)
        {
            var xDoc = new System.Xml.XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");

            var xNode = xDoc.SelectSingleNode("//appSettings");
            if (xNode != null)
            {
                var xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
                if (xElem1 != null) xElem1.SetAttribute("value", appValue);
                else
                {
                    var xElem2 = xDoc.CreateElement("add");
                    xElem2.SetAttribute("key", appKey);
                    xElem2.SetAttribute("value", appValue);
                    xNode.AppendChild(xElem2);
                }
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }
Ejemplo n.º 47
0
        public void SetValue(string AppKey, string AppValue)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");

            System.Xml.XmlNode xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
            if (xElem1 != null) xElem1.SetAttribute("value", AppValue);
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", AppKey);
                xElem2.SetAttribute("value", AppValue);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }
Ejemplo n.º 48
0
        public RawLayout(StructField[] fields, CreateControlDelegate createControlDelegate)
        {
            this.AutoScroll = true;
            this.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
            this.Dock = System.Windows.Forms.DockStyle.Fill;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            foreach (StructField item in fields)
            {
                System.Windows.Forms.Label lbl = new UI.LynnLabel();
                lbl.Text = string.Format("{0} {1}", item.ID, item.Name);
                lbl.Width = 200;
                this.Controls.Add(lbl);

                System.Xml.XmlElement node = doc.CreateElement("Control");
                node.SetAttribute("ID", item.ID);
                node.SetAttribute("Editor", EditorFactory.CreateFromDefaultValue(item.DefaultValue));

                System.Windows.Forms.Control con = createControlDelegate(node);
                con.Width = 200;
                this.Controls.Add(con);
            }
        }
Ejemplo n.º 49
0
        //Given a DataRow, update or Create the SalesForce Object
        //Assuming that we have just one row, easy to change to handle multiples
        public DataReturn Save(string sObjectName, DataRow dRow)
        {
            DataReturn dr = new DataReturn();

            sObject s = new sObject();
            s.type = sObjectName;
            string id = "";
            List<string> fieldsToNull = new List<string>();

            if (dRow["Id"] == null || dRow["Id"].ToString() == "")
            {
                //new
                int fldCount = dRow.Table.Columns.Count - 1;
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                System.Xml.XmlElement[] o = new System.Xml.XmlElement[fldCount];

                fldCount = 0;
                foreach (DataColumn dc in dRow.Table.Columns)
                {
                    if (dc.ColumnName == "Id")
                    {
                        //Nothing!
                    }
                    else if (dc.ColumnName == "type" || dc.ColumnName == "LastModifiedDate" || dc.ColumnName == "CreatedDate")
                    {
                        //don't do anything - this happens when we have the type field from a join
                    }
                    else
                    {
                        if (dc.ColumnName.Contains("__r_"))
                        {
                            if (dc.ColumnName.EndsWith("Id"))
                            {

                                string tn = dc.ColumnName;
                                tn = tn.Substring(0, tn.IndexOf("__r_"));
                                //Concept__r_Id becomes Concept__c
                                tn += "__c";

                                o[fldCount] = doc.CreateElement(tn);
                                o[fldCount].InnerText = CleanUpXML(dRow[dc.ColumnName].ToString());
                                fldCount++;
                            }
                            //Otherwise do nothing
                        }
                        else
                        {
                            o[fldCount] = doc.CreateElement(dc.ColumnName);
                            o[fldCount].InnerText = CleanUpXML(dRow[dc.ColumnName].ToString());
                            fldCount++;
                        }
                    }
                }

                try
                {

                    s.Any = Utility.SubArray<System.Xml.XmlElement>(o, 0, fldCount);
                    SaveResult[] sr = _binding.create(new sObject[] { s });

                    for (int j = 0; j < sr.Length; j++)
                    {
                        if (sr[j].success)
                        {
                            dr.id = sr[j].id;
                        }
                        else
                        {
                            dr.success = false;
                            for (int i = 0; i < sr[j].errors.Length; i++)
                            {
                                dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i].message;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    dr.success = false;
                    dr.errormessage = ex.Message;
                }
            }
            else
            {
                //update
                int fldCount = dRow.Table.Columns.Count;
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement[] o = new System.Xml.XmlElement[fldCount];

                fldCount = 0;
                foreach (DataColumn dc in dRow.Table.Columns)
                {
                    if (dc.ColumnName == "Id")
                    {
                        s.Id = dRow[dc.ColumnName].ToString();
                    }
                    else if (dc.ColumnName == "type" || dc.ColumnName == "LastModifiedDate" || dc.ColumnName == "CreatedDate")
                    {
                        //don't do anything - this happens when we have the type field from a join
                    }
                    else
                    {
                        //For relations - ignore all the other fields except the _Id one
                        //e.g. "Concept__r_Name" "Concept__r_Id" - ignore all but Id

                        //TODO: won't work Nested! need to try this out with a realation of a relation

                        if (dc.ColumnName.Contains("__r_"))
                        {
                            if (dc.ColumnName.EndsWith("Id"))
                            {

                                string tn = dc.ColumnName;
                                tn = tn.Substring(0, tn.IndexOf("__r_"));
                                //Concept__r_Id becomes Concept__c
                                tn += "__c";

                                string val = CleanUpXML(dRow[dc.ColumnName].ToString());
                                if (val == "")
                                {
                                    fieldsToNull.Add(dc.ColumnName);
                                }
                                else
                                {
                                    o[fldCount] = doc.CreateElement(tn);
                                    o[fldCount].InnerText = val;
                                    fldCount++;
                                }

                            }
                            //Otherwise do nothing
                        }
                        else
                        {
                            string val = CleanUpXML(dRow[dc.ColumnName].ToString());
                            if(val==""){
                                fieldsToNull.Add(dc.ColumnName);
                            } else{
                                o[fldCount] = doc.CreateElement(dc.ColumnName);
                                o[fldCount].InnerText = val;
                                fldCount++;
                            }
                        }

                    }
                }

                try
                {
                    s.fieldsToNull = fieldsToNull.ToArray();
                    s.Any = Utility.SubArray<System.Xml.XmlElement>(o, 0, fldCount);
                    SaveResult[] sr = _binding.update(new sObject[] { s });

                    for (int j = 0; j < sr.Length; j++)
                    {
                        Console.WriteLine("\nItem: " + j);
                        if (sr[j].success)
                        {
                            dr.id = sr[j].id;
                        }
                        else
                        {
                            dr.success = false;
                            for (int i = 0; i < sr[j].errors.Length; i++)
                            {
                                dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i].message;
                            }
                        }
                    }

                }
                catch (Exception ex)
                {
                    dr.success = false;
                    dr.errormessage = ex.Message;
                }

            }
            return dr;
        }
Ejemplo n.º 50
0
        //New PES
        public DataReturn CloneAttachmentFile(string ParentId, string AttachmentName, string Xml)
        {
            DataReturn dr = new DataReturn();

            string id = "";

            String soqlQuery = "SELECT Id FROM Attachment where ParentId='" + ParentId + "' and Name='" + AttachmentName + "' order by LastModifiedDate desc limit 1";
            try
            {
                QueryResult qr = _binding.query(soqlQuery);

                if (qr.size > 0)
                {
                    sObject[] records = qr.records;
                    for (int i = 0; i < qr.records.Length; i++)
                    {
                        id = records[i].Any[0].InnerText;
                    }
                }

            }
            catch (Exception ex)
            {
                dr.success = false;
                dr.errormessage = ex.Message;
            }

            sObject attach = new sObject();
            attach.type = "Attachment";
            System.Xml.XmlElement[] o;
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            SaveResult[] sr;

            if (id == "")
            {
                // Create the attacchments fields
                o = new System.Xml.XmlElement[4];
                doc = new System.Xml.XmlDocument();
                o[0] = doc.CreateElement("Name");
                o[0].InnerText = AttachmentName;

                o[1] = doc.CreateElement("isPrivate");
                o[1].InnerText = "false";

                o[2] = doc.CreateElement("ParentId");
                o[2].InnerText = ParentId;

                o[3] = doc.CreateElement("Body");
                byte[] data = Convert.FromBase64String(Xml);
                o[3].InnerText = Convert.ToBase64String(data);

                attach.Any = o;
                sr = _binding.create(new sObject[] { attach });

                for (int j = 0; j < sr.Length; j++)
                {
                    if (sr[j].success)
                    {
                        id = sr[j].id;
                    }
                    else
                    {
                        for (int i = 0; i < sr[j].errors.Length; i++)
                        {
                            dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i];
                        }
                    }
                }
            }
            else
            {
                // Update the attacchments fields
                doc = new System.Xml.XmlDocument();
                o = new System.Xml.XmlElement[1];
                o[0] = doc.CreateElement("Body");
                //  o[0].InnerText = Convert.ToBase64String(System.Text.Encoding.Unicode.GetBytes(Xml));
                byte[] data = Convert.FromBase64String(Xml);
                o[0].InnerText = Convert.ToBase64String(data);

                attach.Any = o;
                attach.Id = id;
                sr = _binding.update(new sObject[] { attach });

                for (int j = 0; j < sr.Length; j++)
                {
                    if (sr[j].success)
                    {
                        id = sr[j].id;
                    }
                    else
                    {
                        for (int i = 0; i < sr[j].errors.Length; i++)
                        {
                            dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i];
                        }
                    }
                }
            }

            dr.id = id;

            return dr;
        }
Ejemplo n.º 51
0
        public DataReturn UpdateAttachmentFile(string Id,string AttachmentName,string FileName)
        {
            DataReturn dr = new DataReturn();

            byte[] b;

            try
            {
                b = System.IO.File.ReadAllBytes(FileName);
            }
            catch (Exception e)
            {
                dr.errormessage = e.Message;
                dr.success = false;
                return dr;
            }

            sObject attach = new sObject();
            attach.type = "Attachment";
            System.Xml.XmlElement[] o;
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            SaveResult[] sr;

                // Update the attacchments fields
                doc = new System.Xml.XmlDocument();
                o = new System.Xml.XmlElement[AttachmentName==""?1:2];

                o[0] = doc.CreateElement("Body");
                o[0].InnerText = Convert.ToBase64String(b);

                if (AttachmentName != "")
                {
                    o[1] = doc.CreateElement("Name");
                    o[1].InnerText = AttachmentName;
                }

                attach.Any = o;
                attach.Id = Id;
                try
                {
                    sr = _binding.update(new sObject[] { attach });
                    Globals.Ribbons.Ribbon1.SFDebug("Update Attachment");

                    for (int j = 0; j < sr.Length; j++)
                    {
                        if (sr[j].success)
                        {
                            Id = sr[j].id;
                        }
                        else
                        {
                            for (int i = 0; i < sr[j].errors.Length; i++)
                            {
                                dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i];
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    dr.errormessage = e.Message;
                    dr.success = false;
                    return dr;
                }

            dr.id = Id;

            return dr;
        }
Ejemplo n.º 52
0
        //Given a DataRow, update or Create the SalesForce Object
        //Assuming that we have just one row, easy to change to handle multiples
        public DataReturn Save(SForceEdit.SObjectDef sObj, DataRow dRow)
        {
            DataReturn dr = new DataReturn();

            sObject s = new sObject();
            s.type = sObj.Name;
            string id = "";

            if (dRow["Id"] == null || dRow["Id"].ToString() == "")
            {
                //new
                int fldCount = dRow.Table.Columns.Count - 1;
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                System.Xml.XmlElement[] o = new System.Xml.XmlElement[fldCount];

                fldCount = 0;

                List<string> fieldsToNull = new List<string>();

                foreach (DataColumn dc in dRow.Table.Columns)
                {

                    //Get the field definition
                    SForceEdit.SObjectDef.FieldGridCol f = sObj.GetField(dc.ColumnName);

                    // this is a new record so do it even if it says its readonly but exclud any _Name or _Type
                    if (!f.Create)
                    {
                        //nada ...
                    }
                    else if (dc.ColumnName == "Id")
                    {
                        //Nothing!
                    }
                    else if (dc.ColumnName == "type")
                    {
                        //don't do anything - this happens when we have the type field from a join
                    }
                    else
                    {

                        object val = dRow[dc.ColumnName];
                        if (dRow[dc.ColumnName] == DBNull.Value)
                        {
                            fieldsToNull.Add(dc.ColumnName);
                        }
                        else
                        {
                            o[fldCount] = doc.CreateElement(dc.ColumnName);

                            string sval = "";
                            if (f.DataType == "datetime")
                            {
                                sval = ((DateTime)val).ToString("o");
                            }
                            else if (f.DataType == "date")
                            {
                                sval = ((DateTime)val).ToString("yyyy-MM-dd");
                            }
                            else
                            {
                                sval = CleanUpXML(val.ToString());
                            }

                            o[fldCount].InnerText = sval;
                            fldCount++;
                        }

                    }
                }

                try
                {
                    // dont need to set the values to Null! this is a create so just don't tell them
                    // s.fieldsToNull = fieldsToNull.ToArray();
                    s.Any = Utility.SubArray<System.Xml.XmlElement>(o, 0, fldCount);
                    sfPartner.SaveResult[] sr = _binding.create(new sObject[] { s });
                    Globals.Ribbons.Ribbon1.SFDebug("Save>" + s.type);

                    for (int j = 0; j < sr.Length; j++)
                    {
                        if (sr[j].success)
                        {
                            dr.id = sr[j].id;
                        }
                        else
                        {
                            dr.success = false;
                            for (int i = 0; i < sr[j].errors.Length; i++)
                            {
                                dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i].message;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    dr.success = false;
                    dr.errormessage = ex.Message;
                }
            }
            else
            {
                //update
                int fldCount = dRow.Table.Columns.Count;
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                System.Xml.XmlElement[] o = new System.Xml.XmlElement[fldCount];

                fldCount = 0;

                List<string> fieldsToNull = new List<string>();

                foreach (DataColumn dc in dRow.Table.Columns)
                {
                    //Get the field definition
                    SForceEdit.SObjectDef.FieldGridCol f = sObj.GetField(dc.ColumnName);

                    if (dc.ColumnName == "Id")
                    {
                        s.Id = dRow[dc.ColumnName].ToString();
                    }
                    else if (!f.Update)
                    {
                        //not on the list ...
                    }
                    else if (dc.ColumnName == "type")
                    {
                        //don't do anything - this happens when we have the type field from a join
                    }
                    else
                    {

                        object val = dRow[dc.ColumnName];
                        if (dRow[dc.ColumnName] == DBNull.Value ||
                            ((f.DataType != "string") && dRow[dc.ColumnName].ToString() == ""))
                        {
                            fieldsToNull.Add(dc.ColumnName);
                        }
                        else
                        {
                            o[fldCount] = doc.CreateElement(dc.ColumnName);

                            string sval = "";
                            if (f.DataType == "datetime")
                            {
                                sval = ((DateTime)val).ToString("o");
                            }
                            else if (f.DataType == "date")
                            {
                                sval = ((DateTime)val).ToString("yyyy-MM-dd");
                            }
                            else
                            {
                                sval = CleanUpXML(val.ToString());
                            }

                            o[fldCount].InnerText = sval;
                            fldCount++;
                        }
                    }
                }

                try
                {
                    s.fieldsToNull = fieldsToNull.ToArray();
                    s.Any = Utility.SubArray<System.Xml.XmlElement>(o, 0, fldCount);
                    sfPartner.SaveResult[] sr = _binding.update(new sObject[] { s });
                    Globals.Ribbons.Ribbon1.SFDebug("Update>" + s.type);
                    for (int j = 0; j < sr.Length; j++)
                    {
                        Console.WriteLine("\nItem: " + j);
                        if (sr[j].success)
                        {
                            dr.id = sr[j].id;
                        }
                        else
                        {
                            dr.success = false;
                            for (int i = 0; i < sr[j].errors.Length; i++)
                            {
                                dr.errormessage += (dr.errormessage == "" ? "" : ",") + sr[j].errors[i].message;
                            }
                        }
                    }

                }
                catch (Exception ex)
                {
                    dr.success = false;
                    dr.errormessage = ex.Message;
                }

            }
            return dr;
        }
Ejemplo n.º 53
0
 public MyXmlEncoder()
 {
     m_doc = new System.Xml.XmlDocument();
     m_node = m_doc.CreateElement("root");
 }
Ejemplo n.º 54
0
            /// <summary>
            /// Saves the USN data to an XmlDocument
            /// </summary>
            /// <returns>An XmlDocument with the USN data</returns>
            public System.Xml.XmlDocument Save()
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                System.Xml.XmlNode root = doc.AppendChild(doc.CreateElement("usnroot"));
                foreach (KeyValuePair<string, KeyValuePair<long, long>> kv in m_values)
                {
                    System.Xml.XmlNode n = root.AppendChild(doc.CreateElement("usnrecord"));
                    n.Attributes.Append(doc.CreateAttribute("root")).Value = kv.Key;
                    n.Attributes.Append(doc.CreateAttribute("journalid")).Value = kv.Value.Key.ToString();
                    n.Attributes.Append(doc.CreateAttribute("usn")).Value = kv.Value.Value.ToString();
                }

                return doc;
            }
Ejemplo n.º 55
0
        private string EncodeFilterAsXml(List<FilterDialog.FilterEntry> list)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            System.Xml.XmlNode root = doc.AppendChild(doc.CreateElement("root"));

            foreach (FilterDialog.FilterEntry f in list)
            {
                System.Xml.XmlNode filter = root.AppendChild(doc.CreateElement("filter"));
                filter.Attributes.Append(doc.CreateAttribute("include")).Value = f.Include.ToString();
                filter.Attributes.Append(doc.CreateAttribute("filter")).Value = f.Filter;
                filter.Attributes.Append(doc.CreateAttribute("globbing")).Value = f.Globbing;
            }

            return doc.OuterXml;
        }
Ejemplo n.º 56
0
        private void CreatePlist()
        {
            var doc = new System.Xml.XmlDocument();
            // don't resolve any URLs, or if there is no internet, the process will pause for some time
            doc.XmlResolver = null;

            {
                var type = doc.CreateDocumentType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
                doc.AppendChild(type);
            }
            var plistEl = doc.CreateElement("plist");
            {
                var versionAttr = doc.CreateAttribute("version");
                versionAttr.Value = "1.0";
                plistEl.Attributes.Append(versionAttr);
            }

            var dictEl = doc.CreateElement("dict");
            plistEl.AppendChild(dictEl);
            doc.AppendChild(plistEl);

            #if true
            // TODO: this seems to be the only way to get the target settings working
            CreateKeyValuePair(doc, dictEl, "BuildLocationStyle", "UseTargetSettings");
            #else
            // build and intermediate file locations
            CreateKeyValuePair(doc, dictEl, "BuildLocationStyle", "CustomLocation");
            CreateKeyValuePair(doc, dictEl, "CustomBuildIntermediatesPath", "XcodeIntermediates"); // where xxx.build folders are stored
            CreateKeyValuePair(doc, dictEl, "CustomBuildLocationType", "RelativeToWorkspace");
            CreateKeyValuePair(doc, dictEl, "CustomBuildProductsPath", "."); // has to be the workspace folder, in order to write files to expected locations

            // derived data
            CreateKeyValuePair(doc, dictEl, "DerivedDataCustomLocation", "XcodeDerivedData");
            CreateKeyValuePair(doc, dictEl, "DerivedDataLocationStyle", "WorkspaceRelativePath");
            #endif

            this.Document = doc;
        }
Ejemplo n.º 57
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.º 58
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.º 59
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.º 60
0
        internal VerificationFile(IEnumerable<ManifestEntry> parentChain, FilenameStrategy str)
        {
            m_doc = new System.Xml.XmlDocument();
            System.Xml.XmlNode root = m_doc.AppendChild(m_doc.CreateElement("Verify"));
            root.Attributes.Append(m_doc.CreateAttribute("hash-algorithm")).Value = Utility.Utility.HashAlgorithm;
            root.Attributes.Append(m_doc.CreateAttribute("version")).Value = "1";

            m_node = root.AppendChild(m_doc.CreateElement("Files"));

            foreach (ManifestEntry mfe in parentChain)
            {
                System.Xml.XmlNode f = m_node.AppendChild(m_doc.CreateElement("File"));
                f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "manifest";
                f.Attributes.Append(m_doc.CreateAttribute("name")).Value = mfe.Filename;
                f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.Filesize.ToString();
                f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.RemoteHash));

                for (int i = 0; i < mfe.ParsedManifest.SignatureHashes.Count; i++)
                {
                    string sigfilename = mfe.ParsedManifest.SignatureHashes[i].Name;
                    string contentfilename = mfe.ParsedManifest.ContentHashes[i].Name;
                    bool missing = i >= mfe.Volumes.Count;

                    if (string.IsNullOrEmpty(sigfilename) || string.IsNullOrEmpty(contentfilename))
                    {
                        if (missing)
                        {
                            sigfilename = str.GenerateFilename(new SignatureEntry(mfe.Time, mfe.IsFull, i + 1));
                            contentfilename = str.GenerateFilename(new ContentEntry(mfe.Time, mfe.IsFull, i + 1));

                            //Since these files are missing, we have to guess what their real names were
                            string compressionGuess;
                            if (mfe.Volumes.Count <= 0)
                                compressionGuess = ".zip"; //Default if we have no knowledge
                            else
                                compressionGuess = "." + mfe.Volumes[0].Key.Compression; //Most likely the same as all the others

                            //Encryption will likely be the same as the one the manifest uses
                            string encryptionGuess = string.IsNullOrEmpty(mfe.EncryptionMode) ? "" : "." + mfe.EncryptionMode;

                            sigfilename += compressionGuess + encryptionGuess;
                            contentfilename += compressionGuess + encryptionGuess;
                        }
                        else
                        {
                            sigfilename = mfe.Volumes[i].Key.Filename;
                            contentfilename = mfe.Volumes[i].Value.Filename;
                        }
                    }

                    f = m_node.AppendChild(m_doc.CreateElement("File"));
                    f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "signature";
                    f.Attributes.Append(m_doc.CreateAttribute("name")).Value = sigfilename;
                    f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.ParsedManifest.SignatureHashes[i].Size.ToString();
                    if (missing) f.Attributes.Append(m_doc.CreateAttribute("missing")).Value = "true";
                    f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.ParsedManifest.SignatureHashes[i].Hash));

                    f = m_node.AppendChild(m_doc.CreateElement("File"));
                    f.Attributes.Append(m_doc.CreateAttribute("type")).Value = "content";
                    f.Attributes.Append(m_doc.CreateAttribute("name")).Value = contentfilename;
                    f.Attributes.Append(m_doc.CreateAttribute("size")).Value = mfe.ParsedManifest.ContentHashes[i].Size.ToString();
                    if (missing) f.Attributes.Append(m_doc.CreateAttribute("missing")).Value = "true";
                    f.InnerText = Utility.Utility.ByteArrayAsHexString(Convert.FromBase64String(mfe.ParsedManifest.ContentHashes[i].Hash));
                }
            }
        }