Exemple #1
0
        public void SetMorefield(string guid, string[] value)
        {
            System.Xml.XmlElement root = xmlDoc.DocumentElement;
            string s = "/root/nodes/node[@" + PazDocumentLegacy.TAG_GUID + "='" + guid + "']/moreinfo";

            System.Xml.XmlNode xMore;

            System.Xml.XmlNodeList xnl = root.SelectNodes(s);
            if (xnl.Count > 0)
            {
                xMore = root.SelectNodes(s).Item(0);
                //root.SelectNodes(s).Item(0).InnerText= value;
            }
            else
            {
                System.Xml.XmlNode node = FindXmlNodeByGuid(guid);
                xMore = xmlDoc.CreateElement("moreinfo");
                //nodemore.InnerText = value;
                //node.AppendChild (nodemore);
                node.AppendChild(xMore);
            }

            xMore.InnerXml = "";

            foreach (string line in value)
            {
                System.Xml.XmlNode xLine = xmlDoc.CreateElement("line");
                xLine.InnerText = line;
                xMore.AppendChild(xLine);
            }
        }
Exemple #2
0
        public string GetMorefield(string guid)
        {
            System.Xml.XmlElement root = xmlDoc.DocumentElement;
            string s = "/root/nodes/node[@" + PazDocumentLegacy.TAG_GUID + "='" + guid + "']/moreinfo";

            if (root.SelectNodes(s).Count > 0)
            {
                //return root.SelectNodes(s).Item(0).InnerText;
                string more = "";
                foreach (System.Xml.XmlNode xLine in root.SelectNodes(s).Item(0).ChildNodes)
                {
                    more += xLine.InnerText;

                    if (xLine != root.SelectNodes(s).Item(0).ChildNodes.Item(root.SelectNodes(s).Item(0).ChildNodes.Count - 1))
                    {
                        more += "\r\n";
                    }
                }

                return(more);
            }
            else
            {
                return("");
            }
        }
Exemple #3
0
            public static ModifierResult CreateFromXml(System.Xml.XmlElement n)
            {
                ModifierResult retval = new ModifierResult();

                System.Xml.XmlNodeList cost_nodes     = n.SelectNodes("./costs/cost");
                System.Xml.XmlNodeList modifier_nodes = n.SelectNodes("./modifiers/modifier");
                retval.AddCostsOrModifiers(cost_nodes);
                retval.AddCostsOrModifiers(modifier_nodes);
                System.Xml.XmlNodeList tag_nodes = n.SelectNodes("./tags/tag");
                foreach (System.Xml.XmlElement tag_node in tag_nodes)
                {
                    retval.tags.Add(tag_node.GetAttribute("value"));
                }
                return(retval);
            }
Exemple #4
0
        private void ReadLoc(System.Xml.XmlElement root, Core.Dependency leaf)
        {
            int loc      = 0;
            var fileName = string.Empty;
            var nodes    = root.SelectNodes("location");

            foreach (var node in nodes)
            {
                if (node.GetType() != typeof(System.Xml.XmlElement))
                {
                    continue;
                }

                var element   = node as System.Xml.XmlElement;
                var bodystart = element.GetAttribute("bodystart");
                var bodyend   = element.GetAttribute("bodyend");
                fileName = element.GetAttribute("bodyfile");
                if (bodyend == "-1" || bodyend.Length == 0 || bodystart.Length == 0)
                {
                    continue;
                }

                loc += 1 + System.Convert.ToInt32(bodyend) - System.Convert.ToInt32(bodystart);
            }

            leaf.LOC = loc;

            fileName = "$(Source)/" + fileName;
            this.parser.Sources.Create(leaf, new DeepEnds.Core.SourceProvider(fileName));
        }
        /// <summary>
        /// 取得現有科目
        /// </summary>
        /// <param name="orgainXml"></param>
        /// <param name="subjectName"></param>
        /// <returns></returns>
        public static int GetSubjectCount(System.Xml.XmlElement orgainXml, string subjectName)
        {
            // 取得所有
            int result = orgainXml.SelectNodes($"//Subject[@SubjectName='{subjectName}']").Count;

            return(result + 1);
        }
Exemple #6
0
            protected override void Run()
            {
                string TableName     = DSpace_ExecArgs[0];
                string ImportDfsFile = DSpace_ExecArgs[1];
                string OutputDfsFile = DSpace_ExecArgs[2]; // Gets combined into DfsTableFile.
                string QlArgDelim    = DSpace_ExecArgs[3];

                if (GetDfsFileRecordLength(ImportDfsFile) > 0)
                {
                    throw new Exception("Import file '" + ImportDfsFile + "' not found or has incorrect type");
                }

                System.Xml.XmlDocument systables;
                using (GlobalCriticalSection.GetLock())
                {
                    systables = LoadSysTables_unlocked();
                }

                System.Xml.XmlElement xeTable = FindTable(systables, TableName);
                if (null == xeTable)
                {
                    throw new Exception("Table '" + TableName + "' does not exist");
                }

                string DfsTableFile = xeTable["file"].InnerText;

                string RowInfo;
                string TypeInfo; // Type
                int    ExpectedImportRowLength = 0;
                int    OutputRowLength         = 0;
                {
                    StringBuilder sbRowInfo  = new StringBuilder();
                    StringBuilder sbTypeInfo = new StringBuilder(); // Type
                    foreach (System.Xml.XmlNode xn in xeTable.SelectNodes("column"))
                    {
                        if (0 != sbRowInfo.Length)
                        {
                            sbRowInfo.Append(',');
                            sbTypeInfo.Append(','); // Type
                        }
                        string stsize = xn["bytes"].InnerText;
                        int    tsize  = int.Parse(stsize);
                        ExpectedImportRowLength += tsize - 1; // Import rows don't include Nullable byte.
                        OutputRowLength         += tsize;
                        sbRowInfo.Append(stsize);
                        sbTypeInfo.Append(xn["type"].InnerText); // Type
                    }
                    RowInfo  = sbRowInfo.ToString();
                    TypeInfo = sbTypeInfo.ToString(); // Type
                }

                string overrideFTE = "";

                if (RDBMS_DBCORE.Qa.FaultTolerantExecution)
                {
                    overrideFTE = " \"//Job[@Name='RDBMS_ImportLines']/FaultTolerantExecution/Mode=enabled\" ";
                }

                DSpace_Log(Shell("dspace exec \"//Job[@Name='RDBMS_ImportLines']/IOSettings/DFSInput=" + ImportDfsFile + "\" \"//Job[@Name='RDBMS_ImportLines']/IOSettings/DFSOutput=" + OutputDfsFile + "@" + OutputRowLength.ToString() + "\" " + overrideFTE + " RDBMS_ImportLines.DBCORE \"" + TableName + "\" \"" + ImportDfsFile + "\" \"" + OutputDfsFile + "\" \"" + DfsTableFile + "\" \"" + RowInfo + "\" \"" + TypeInfo + "\" \"" + QlArgDelim + "\"").Trim());
            }
Exemple #7
0
        private void _Upgrade_1_2()
        {
            // upgrade from version 1 to 2 pazWordFile
            /// il campo more info diventa da una linea ad n lineee
            /// la versione passa da 1 ad 2

            System.Xml.XmlElement root = xmlDoc.DocumentElement;
            string s = "/root/nodes/node/moreinfo";

            foreach (System.Xml.XmlNode xMore in root.SelectNodes(s))
            {
                string   morein = xMore.InnerText;
                string[] linein = morein.Split('\n');

                xMore.InnerXml = "";
                foreach (string line in linein)
                {
                    string[]           line2 = line.Split('\r');
                    System.Xml.XmlNode xLine = xmlDoc.CreateElement("line");
                    xLine.InnerText = line2[0];
                    xMore.AppendChild(xLine);
                }
            }

            s = "/root/info";
            System.Xml.XmlNode node = root.SelectSingleNode(s);
            SetAttributeByName(node, TAG_FILEVERSION, "2");
        }
Exemple #8
0
        /// <summary>
        /// SelectXmlNodes of an item of selected parentguid
        /// </summary>
        /// <param name="guid">parent guid to find</param>
        /// <returns>XmlNodes if exista otherwise null...</returns>
        public System.Xml.XmlNodeList FindXmlNodeByParentGuid(string guid)
        {
            System.Xml.XmlElement root = xmlDoc.DocumentElement;
            string s = "/root/nodes/node[@" + PazDocumentLegacy.TAG_PARENTGUID + "='" + guid + "']";

            return(root.SelectNodes(s));
        }
Exemple #9
0
            public static ItemArchetype CreateFromXml(System.Xml.XmlElement n, Roar.DataConversion.IXCRMParser ixcrm_parser)
            {
                DomainObjects.ItemArchetype retval = new DomainObjects.ItemArchetype();
                retval.id          = n.GetAttributeOrDefault("id", null);
                retval.ikey        = n.GetAttributeOrDefault("ikey", null);
                retval.type        = n.GetAttributeOrDefault("type", null);
                retval.label       = n.GetAttributeOrDefault("label", null);
                retval.description = n.GetAttributeOrDefault("description", null);

                if (n.HasAttribute("consumable"))
                {
                    retval.consumable = n.GetAttribute("consumable").ToLower() == "true";
                }
                if (n.HasAttribute("sellable"))
                {
                    retval.sellable = n.GetAttribute("sellable").ToLower() == "true";
                }
                retval.stats = ixcrm_parser.ParseItemStatList(n.SelectSingleNode("./stats") as System.Xml.XmlElement);
                retval.price = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./price") as System.Xml.XmlElement);
                retval.tags  = ixcrm_parser.ParseTagList(n.SelectSingleNode("./tags") as System.Xml.XmlElement);
                System.Xml.XmlNodeList property_nodes = n.SelectNodes("./properties/property");
                foreach (System.Xml.XmlElement property_node in property_nodes)
                {
                    Roar.DomainObjects.ItemArchetypeProperty property = new Roar.DomainObjects.ItemArchetypeProperty();
                    property.ikey  = property_node.GetAttribute("ikey");
                    property.value = property_node.GetAttribute("value");
                    retval.properties.Add(property);
                }
                return(retval);
            }
Exemple #10
0
        public List <string> ParseTagList(System.Xml.XmlElement n)
        {
            List <string> tags = new List <string>();

            if (n == null)
            {
                return(tags);
            }
            System.Xml.XmlNodeList tag_nodes = n.SelectNodes("./tag");
            foreach (System.Xml.XmlNode tag_node in tag_nodes)
            {
                System.Xml.XmlElement tag_element = tag_node as System.Xml.XmlElement;
                tags.Add(tag_element.GetAttribute("value"));
            }
            return(tags);
        }
        } //  GetSectionNames()

        /// <summary>
        ///   Retrieves the names of all the entries inside a section. </summary>
        /// <param name="section">
        ///   The name of the section holding the entries. </param>
        /// <returns>
        ///   If the section exists, the return value is an array with the names of its entries;
        ///   otherwise it's null. </returns>
        /// <exception cref="InvalidOperationException">
        ///	  <see cref="Profile.Name" /> is null or empty. </exception>
        /// <exception cref="ArgumentNullException">
        ///   section is null. </exception>
        /// <exception cref="XmlException">
        ///	  Parse error in the XML being loaded from the file. </exception>
        /// <seealso cref="Profile.HasEntry" />
        /// <seealso cref="GetSectionNames" />
        public string[] GetEntryNames(string section)
        {
            // Verify the section exists
            if (!UserSectionExists(section))
            {
                return(null);
            }

            VerifyAndAdjustSection(ref section);

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

            if (doc == null)
            {
                return(null);
            }

            // Get the root node, if it exists
            System.Xml.XmlElement root = doc.DocumentElement;
            if (root == null)
            {
                return(null);
            }


            // Get the entry nodes
            System.Xml.XmlNodeList entryNodes = root.SelectNodes(GetSectionsPath(section) + "/entry[@name]");
            if (entryNodes == null)
            {
                return(null);
            }


            // Add all entry names to the string array
            string[] entries = new string[entryNodes.Count];
            int      i       = 0;

            foreach (System.Xml.XmlNode node in entryNodes)
            {
                entries[i++] = node.Attributes["name"].Value;
            }


            //  Return the Array of Entry Names to the calling method.
            return(entries);
        } //  GetEntryNames()
            protected override void Run()
            {
                string TableName     = DSpace_ExecArgs[0];
                string OutputDfsFile = DSpace_ExecArgs[1]; // Gets combined into DfsTableFile.
                string QlArgVals     = DSpace_ExecArgs[2];

                System.Xml.XmlDocument systables;
                using (GlobalCriticalSection.GetLock())
                {
                    systables = LoadSysTables_unlocked();
                }

                System.Xml.XmlElement xeTable = FindTable(systables, TableName);
                if (null == xeTable)
                {
                    throw new Exception("Table '" + TableName + "' does not exist");
                }

                string DfsTableFile = xeTable["file"].InnerText;

                string RowInfo;
                string TypeInfo; // Type
                int    OutputRowLength = 0;

                {
                    StringBuilder sbRowInfo  = new StringBuilder();
                    StringBuilder sbTypeInfo = new StringBuilder(); // Type
                    foreach (System.Xml.XmlNode xn in xeTable.SelectNodes("column"))
                    {
                        if (0 != sbRowInfo.Length)
                        {
                            sbRowInfo.Append(',');
                            sbTypeInfo.Append(','); // Type
                        }
                        string stsize = xn["bytes"].InnerText;
                        int    tsize  = int.Parse(stsize);
                        OutputRowLength += tsize;
                        sbRowInfo.Append(stsize);
                        sbTypeInfo.Append(xn["type"].InnerText); // Type
                    }
                    RowInfo  = sbRowInfo.ToString();
                    TypeInfo = sbTypeInfo.ToString(); // Type
                }

                DSpace_Log(Shell("dspace exec \"//Job[@Name='RDBMS_InsertValues']/IOSettings/DFS_IO/DFSWriter=" + OutputDfsFile + "@" + OutputRowLength.ToString() + "\" RDBMS_InsertValues.DBCORE \"" + TableName + "\" \"" + OutputDfsFile + "\" \"" + QlArgVals + "\" \"" + DfsTableFile + "\" \"" + RowInfo + "\" \"" + TypeInfo + "\"").Trim());
            }
Exemple #13
0
            public static MailPackage CreateFromXml(System.Xml.XmlElement n, Roar.DataConversion.IXCRMParser ixcrm_parser)
            {
                MailPackage retval = new MailPackage();

                retval.id          = n.GetAttribute("id");
                retval.type        = n.GetAttribute("type");
                retval.sender_id   = n.GetAttribute("sender_id");
                retval.sender_name = n.GetAttribute("sender_name");
                retval.message     = n.GetAttribute("message");
                System.Xml.XmlNodeList item_nodes = n.SelectNodes("./item");
                foreach (System.Xml.XmlElement item_node in item_nodes)
                {
                    retval.items.Add(InventoryItem.CreateFromXml(item_node, ixcrm_parser));
                }
                retval.tags      = ixcrm_parser.ParseTagList(n);
                retval.modifiers = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./modifiers") as System.Xml.XmlElement);
                return(retval);
            }
Exemple #14
0
        private void ReadCompoundDef(System.Xml.XmlElement root, System.IO.TextWriter logger)
        {
            Core.Dependency leaf  = null;
            var             nodes = root.SelectNodes("compoundname");

            foreach (var node in nodes)
            {
                if (node.GetType() != typeof(System.Xml.XmlElement))
                {
                    continue;
                }

                var element = node as System.Xml.XmlElement;
                var path    = element.InnerText;
                leaf = this.parser.Dependencies.GetPath(path, "::");
            }

            this.ReadLoc(root, leaf);
            this.ReadReferences(root, leaf, logger);
            this.ReadMembers(root, leaf);
        }
Exemple #15
0
            public static Player CreateFromXml(System.Xml.XmlElement n)
            {
                Player retval = new Player();

                if (n == null)
                {
                    return(retval);
                }
                System.Xml.XmlNodeList attribute_nodes = n.SelectNodes("./attribute");
                foreach (System.Xml.XmlElement nn in attribute_nodes)
                {
                    switch (nn.GetAttribute("ikey"))
                    {
                    case "id":
                        retval.id = nn.GetAttribute("value");
                        break;

                    case "name":
                        retval.name = nn.GetAttribute("value");
                        break;

                    case "level":
                        System.Int32.TryParse(nn.GetAttribute("value"), out retval.level);
                        break;

                    case "xp":
                        System.Int32.TryParse(nn.GetAttribute("value"), out retval.xp.value);
                        System.Int32.TryParse(nn.GetAttribute("level_start"), out retval.xp.level_start);
                        System.Int32.TryParse(nn.GetAttribute("next_level"), out retval.xp.next_level);
                        break;

                    default:
                        Roar.DomainObjects.PlayerAttribute attr = new Roar.DomainObjects.PlayerAttribute();
                        attr.ParseXml(nn);
                        retval.attributes.Add(attr.ikey, attr);
                        break;
                    }
                }
                return(retval);
            }
Exemple #16
0
            public static InventoryItem CreateFromXml(System.Xml.XmlElement n, Roar.DataConversion.IXCRMParser ixcrm_parser)
            {
                DomainObjects.InventoryItem retval = new DomainObjects.InventoryItem();
                retval.id          = n.GetAttribute("id");
                retval.ikey        = n.GetAttribute("ikey");
                retval.type        = n.GetAttribute("type");
                retval.label       = n.GetAttribute("label");
                retval.description = n.GetAttribute("description");

                if (n.HasAttribute("count") && !System.Int32.TryParse(n.GetAttribute("count"), out retval.count))
                {
                    throw new InvalidXMLElementException("Unable to parse count to integer");
                }
                if (n.HasAttribute("consumable"))
                {
                    retval.consumable = n.GetAttribute("consumable").ToLower() == "true";
                }
                if (n.HasAttribute("sellable"))
                {
                    retval.sellable = n.GetAttribute("sellable").ToLower() == "true";
                }
                if (n.HasAttribute("equipped"))
                {
                    retval.equipped = n.GetAttribute("equipped").ToLower() == "true";
                }
                retval.stats = ixcrm_parser.ParseItemStatList(n.SelectSingleNode("./stats") as System.Xml.XmlElement);
                retval.price = ixcrm_parser.ParseModifierList(n.SelectSingleNode("./price") as System.Xml.XmlElement);
                retval.tags  = ixcrm_parser.ParseTagList(n.SelectSingleNode("./tags") as System.Xml.XmlElement);
                System.Xml.XmlNodeList property_nodes = n.SelectNodes("./properties/property");
                foreach (System.Xml.XmlElement property_node in property_nodes)
                {
                    Roar.DomainObjects.ItemArchetypeProperty property = new Roar.DomainObjects.ItemArchetypeProperty();
                    property.ikey  = property_node.GetAttribute("ikey");
                    property.value = property_node.GetAttribute("value");
                    retval.properties.Add(property);
                }
                return(retval);
            }
Exemple #17
0
            public static FacebookShopEntry CreateFromXml(System.Xml.XmlElement n, Roar.DataConversion.IXCRMParser ixcrm_parser)
            {
                FacebookShopEntry retval = new FacebookShopEntry();

                retval.ikey        = n.GetAttribute("ikey");
                retval.description = n.GetAttribute("description");
                retval.label       = n.GetAttribute("label");
                retval.price       = n.GetAttribute("price");
                retval.product_url = n.GetAttribute("product_url");
                retval.image_url   = n.GetAttribute("image_url");

                System.Xml.XmlNodeList modifier_nodes = n.SelectNodes("./modifiers");
                if (modifier_nodes.Count > 0)
                {
                    retval.modifiers = ixcrm_parser.ParseModifierList(modifier_nodes[0] as System.Xml.XmlElement);
                }
                else
                {
                    retval.modifiers = new List <Modifier>();
                }

                return(retval);
            }
        } //  UserSettingExists

        /// <summary>
        ///   Retrieves the names of all the sections. </summary>
        /// <returns>
        ///   If the XML file exists, the return value is an array with the names of all the sections;
        ///   otherwise it's null. </returns>
        /// <exception cref="InvalidOperationException">
        ///	  <see cref="Profile.Name" /> is null or empty. </exception>
        /// <exception cref="XmlException">
        ///	  Parse error in the XML being loaded from the file. </exception>
        /// <seealso cref="Profile.HasSection" />
        /// <seealso cref="GetEntryNames" />
        public string[] GetSectionNames()
        {
            // Verify the document exists
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(_filePath);

            if (doc == null)
            {
                return(null);
            }

            // Get the root node, if it exists
            System.Xml.XmlElement root = doc.DocumentElement;
            if (root == null)
            {
                return(null);
            }

            // Get the section nodes
            System.Xml.XmlNodeList sectionNodes = root.SelectNodes("section[@name]");
            if (sectionNodes == null)
            {
                return(null);
            }

            // Add all section names to the string array
            string[] sections = new string[sectionNodes.Count];
            int      i        = 0;

            foreach (System.Xml.XmlNode node in sectionNodes)
            {
                sections[i++] = node.Attributes["name"].Value;
            }

            //  Return the Array of Section Names to the calling method.
            return(sections);
        } //  GetSectionNames()
Exemple #19
0
        /// <summary> Load meta attributes from jdom element into a MultiMap.
        ///
        /// </summary>
        /// <returns> MultiMap
        /// </returns>
        protected internal static MultiMap loadMetaMap(Element element)
        {
            MultiMap result = new MultiHashMap();

            SupportClass.ListCollectionSupport metaAttributeList = new SupportClass.ListCollectionSupport();
            metaAttributeList.AddAll(element.SelectNodes("urn:meta", CodeGenerator.nsmgr));

            for (IEnumerator iter = metaAttributeList.GetEnumerator(); iter.MoveNext();)
            {
                Element metaAttrib = (Element)iter.Current;
                // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs.
                string attribute = (metaAttrib.Attributes["attribute"] == null
                                                        ? string.Empty : metaAttrib.Attributes["attribute"].Value);
                string value_Renamed = metaAttrib.InnerText;
                string inheritStr    = (metaAttrib.Attributes["inherit"] == null ? null : metaAttrib.Attributes["inherit"].Value);
                bool   inherit       = true;
                if ((Object)inheritStr != null)
                {
                    try
                    {
                        inherit = Boolean.Parse(inheritStr);
                    }
                    catch
                    {
                    }
                }

                MetaAttribute ma = new MetaAttribute(value_Renamed, inherit);
                if (result[attribute] == null)
                {
                    result[attribute] = new SupportClass.ListCollectionSupport();
                }

                ((SupportClass.ListCollectionSupport)result[attribute]).Add(ma);
            }
            return(result);
        }
Exemple #20
0
        private void _Upgrade_2_3()
        {
            // upgrade from version 2 to 3 pazWordFile
            /// il campo used count diventa "000000000000" (spazi!)
            /// la versione passa da 2 a 3

            System.Xml.XmlElement root = xmlDoc.DocumentElement;
            string s = "/root/nodes/node";

            foreach (System.Xml.XmlNode xNode in root.SelectNodes(s))
            {
                String uc = GetAttributeByName(xNode, PazDocumentLegacy.TAG_USEDCOUNTER);

                if (uc != "")
                {
                    uc = String.Format("{0,10}", uc);
                    SetAttributeByName(xNode, PazDocumentLegacy.TAG_USEDCOUNTER, uc);
                }
            }

            s = "/root/info";
            System.Xml.XmlNode node = root.SelectSingleNode(s);
            SetAttributeByName(node, TAG_FILEVERSION, "3");
        }
Exemple #21
0
            public static ShopEntry CreateFromXml(System.Xml.XmlElement n, IXCRMParser xcrm_parser)
            {
                ShopEntry retval = new ShopEntry();

                retval.ikey        = n.GetAttribute("ikey");
                retval.label       = n.GetAttribute("label");
                retval.description = n.GetAttribute("description");


                System.Xml.XmlElement costs_node = n.SelectSingleNode("./costs") as System.Xml.XmlElement;
                if (costs_node != null)
                {
                    retval.costs = xcrm_parser.ParseCostList(costs_node);
                }
                // else branches not necessary as costs, modifiers and requirements are INITIALISED by definition

                System.Xml.XmlElement modifiers_node = n.SelectSingleNode("./modifiers") as System.Xml.XmlElement;
                if (modifiers_node != null)
                {
                    retval.modifiers = xcrm_parser.ParseModifierList(modifiers_node);
                }

                System.Xml.XmlElement requirements_node = n.SelectSingleNode("./requirements") as System.Xml.XmlElement;
                if (requirements_node != null)
                {
                    retval.requirements = xcrm_parser.ParseRequirementList(requirements_node);
                }

                System.Xml.XmlNodeList tag_nodes = n.SelectNodes("./tags/tag");
                foreach (System.Xml.XmlElement tag_node in tag_nodes)
                {
                    retval.tags.Add(tag_node.GetAttribute("value"));
                }

                return(retval);
            }
Exemple #22
0
        void _OpenRIndex()
        {
            try
            {
                if (state == ConnectionState.Open)
                {
                    throw new Exception("Connnection is already open.");
                }

                if (connstr.RIndex == QaConnectionString.RIndexType.POOLED)
                {
                    string[] hosts = connstr.DataSource;
                    Random   rnd   = new Random(unchecked (System.DateTime.Now.Millisecond + System.Threading.Thread.CurrentThread.ManagedThreadId));
                    for (int hi = 0; hi < hosts.Length; hi++)
                    {
                        int    swapindex = rnd.Next() % hosts.Length;
                        string oval      = hosts[hi];
                        hosts[hi]        = hosts[swapindex];
                        hosts[swapindex] = oval;
                    }
                    for (int hi = 0; hi < hosts.Length; hi++)
                    {
                        _OpenSocketRIndex(hosts[hi]);
                    }
                }
                else
                {
                    _OpenSocketRIndex(null);
                }

                netstm.WriteByte((byte)'i'); //get all master indexes.

                sysindexes = new Dictionary <string, Index>();
                {
                    string xml = XContent.ReceiveXString(netstm, buf);
                    if (xml.Length > 0)
                    {
                        System.Xml.XmlDocument xi = new System.Xml.XmlDocument();
                        xi.LoadXml(xml);
                        System.Xml.XmlNodeList xnIndexes = xi.SelectNodes("/indexes/index");
                        foreach (System.Xml.XmlNode xnIndex in xnIndexes)
                        {
                            string                 indName            = xnIndex["name"].InnerText;
                            System.Xml.XmlNode     xnUpdatememoryonly = xnIndex.SelectSingleNode("updatememoryonly");
                            System.Xml.XmlElement  xePinHash          = xnIndex["pinHash"];
                            System.Xml.XmlElement  xeTable            = xnIndex["table"];
                            System.Xml.XmlNodeList xnCols             = xeTable.SelectNodes("column");

                            Column[] cols = new Column[xnCols.Count];
                            for (int ci = 0; ci < xnCols.Count; ci++)
                            {
                                System.Xml.XmlNode xnCol = xnCols[ci];
                                cols[ci].Name  = xnCol["name"].InnerText;
                                cols[ci].Type  = xnCol["type"].InnerText;
                                cols[ci].Bytes = Int32.Parse(xnCol["bytes"].InnerText);
                            }

                            Table tab;
                            tab.Name    = xeTable["name"].InnerText;
                            tab.Columns = cols;

                            Index ind;
                            ind.Name             = indName;
                            ind.Ordinal          = Int32.Parse(xnIndex["ordinal"].InnerText);
                            ind.Table            = tab;
                            ind.UpdateMemoryOnly = (xnUpdatememoryonly != null && xnUpdatememoryonly.InnerText == "1");
                            ind.PinHash          = (xePinHash != null && xePinHash.InnerText == "1");
                            ind.Hash             = ind.PinHash ? new Position[256 * 256] : null;
                            ind.MaxKey           = new byte[tab.Columns[ind.Ordinal].Bytes];
                            sysindexes.Add(indName.ToLower(), ind);
                        }
                    }
                }

                int micnt = 0;
                XContent.ReceiveXBytes(netstm, out micnt, buf);
                micnt    = Utils.BytesToInt(buf, 0);
                mindexes = new Dictionary <string, List <KeyValuePair <byte[], string> > >(micnt);
                for (int mi = 0; mi < micnt; mi++)
                {
                    string indexname = XContent.ReceiveXString(netstm, buf).ToLower();
                    List <KeyValuePair <byte[], string> > lines = new List <KeyValuePair <byte[], string> >();
                    int        keylen  = 9;
                    bool       pinhash = false;
                    Position[] hash    = null;
                    byte[]     maxkey  = null;
                    if (sysindexes.ContainsKey(indexname))
                    {
                        Index thisindex = sysindexes[indexname];
                        int   ordinal   = thisindex.Ordinal;
                        keylen  = thisindex.Table.Columns[ordinal].Bytes;
                        pinhash = thisindex.PinHash;
                        hash    = thisindex.Hash;
                        maxkey  = thisindex.MaxKey;
                    }
                    else
                    {
                        throw new Exception("Index version conflict, need to recreate indexes");
                    }

                    byte[] lastkeybuf = new byte[3];
                    int    filelen    = 0;
                    XContent.ReceiveXBytesNoCap(netstm, out filelen, ref buf);
                    if (filelen > 0)
                    {
                        int pos     = 0;
                        int hoffset = 0;
                        int hlen    = 0;

                        for (int ki = 0; ki < keylen; ki++)
                        {
                            maxkey[ki] = buf[pos++];
                        }

                        while (pos < filelen)
                        {
                            byte[] keybuf = new byte[keylen];
                            for (int ki = 0; ki < keylen; ki++)
                            {
                                keybuf[ki] = buf[pos++];
                            }

                            /*bool samekey = true;
                             * for (int ki = 0; ki < keybuf.Length; ki++)
                             * {
                             *  if (lastkeybuf[ki] != keybuf[ki])
                             *  {
                             *      samekey = false;
                             *      break;
                             *  }
                             * }*/

                            int chunknamestartpos = pos;
                            while (buf[pos++] != (byte)'\0')
                            {
                            }

                            //samekey = false;
                            //if (!samekey)
                            {
                                string chunkname = System.Text.Encoding.UTF8.GetString(buf, chunknamestartpos, pos - chunknamestartpos - 1);

                                if (pinhash)
                                {
                                    if (lines.Count > 0)
                                    {
                                        if (keybuf[1] != lastkeybuf[1] || keybuf[2] != lastkeybuf[2])
                                        {
                                            int shortkey = TwoBytesToInt(lastkeybuf[1], lastkeybuf[2]);
                                            hash[shortkey].Offset = hoffset;
                                            hash[shortkey].Length = hlen;
                                            hoffset = lines.Count;
                                            hlen    = 0;
                                        }
                                    }
                                    hlen++;
                                }

                                lines.Add(new KeyValuePair <byte[], string>(keybuf, chunkname));
                                Buffer.BlockCopy(keybuf, 0, lastkeybuf, 0, 3);
                            }
                        }

                        if (pinhash)
                        {
                            //last flush
                            if (hlen > 0)
                            {
                                int shortkey = TwoBytesToInt(lastkeybuf[1], lastkeybuf[2]);
                                hash[shortkey].Offset = hoffset;
                                hash[shortkey].Length = hlen;
                            }

                            //fill in the gap
                            int prevoffset = 0;
                            int prevlen    = 0;
                            for (int hi = 0; hi < hash.Length; hi++)
                            {
                                Position thispos = hash[hi];
                                if (thispos.Length == 0)
                                {
                                    thispos.Length = prevlen;
                                    thispos.Offset = prevoffset;
                                    hash[hi]       = thispos;
                                }
                                else
                                {
                                    prevoffset = thispos.Offset;
                                    prevlen    = thispos.Length;
                                }
                            }
                        }
                    }
                    mindexes.Add(indexname, lines);
                }

                if (connstr.RIndex == QaConnectionString.RIndexType.NOPOOL)
                {
                    _CloseSocketRIndex();
                }
                state = ConnectionState.Open;
            }
            catch
            {
                Cleanup();
                throw;
            }
        }
Exemple #23
0
        static void OldMain()
        {
            bool b = false; // Remove "Unreachable Code" warning

            if (b)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            } // End if (false)


            string strPath = @"S:\StefanSteiger\COR_Basic\";

            //string strReport = "GM_Gebaeudestammdaten.rdl";
            string strReport = "GM_Gebaeudestammdaten_ML.rdl";

            strReport = "AL_Anlageninventar_ML.rdl";
            strReport = "FM_NutzungsartenDIN_277_Wincasa_ML.rdl";
            strReport = "FM_NutzungsartenDIN_277_Wincasa_ML.rdl";
            strReport = "KU_Kunstinventar_ML.rdl";

            string FILE_NAME = System.IO.Path.Combine(strPath, strReport);

            // AddProc(FILE_NAME);
            // AddMandant(FILE_NAME);

            // ReadUsingReportViewer(FILE_NAME);
            //Select the cd node with the matching title
            System.Xml.XmlDocument doc = XmlTools.File2XmlDocument(FILE_NAME);



            string strXML = @"
<result>
    <relatedProducts>
        <item>
            <id>123foo</id>
            <name>foo</name>
            <text>Foobar</text>
        </item>
        <item>
            <id>hello</id>
            <name>bye</name>
            <text>ciao</text>
        </item>
        <item>
            <id></id>
            <name></name>
            <text></text>
        </item>
    </relatedProducts>
</result>
";

            System.Xml.XmlDocument mydoc = new System.Xml.XmlDocument();
            mydoc.LoadXml(strXML);

            //System.Xml.XmlNodeList x = mydoc.SelectNodes("//*[text()"); // Should be: mydoc.SelectNodes("//*/*[text()");
            //System.Xml.XmlNodeList x = mydoc.SelectNodes("//*[contains(text(), 'foo')]");
            System.Xml.XmlNodeList x = mydoc.SelectNodes("//*[contains(translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉÈÊÀÁÂÒÓÔÙÚÛÇÅÏÕÑŒ', 'abcdefghijklmnopqrstuvwxyzäöüéèêàáâòóôùúûçåïõñœ'),'foo')]"); // Should be: mydoc.SelectNodes("//*/*[text()");
            Console.WriteLine(x.Count);



            //Select the cd node with the matching title
            System.Xml.XmlElement          root  = doc.DocumentElement;
            System.Xml.XmlNamespaceManager nsmgr = ReportServerTools.GetReportNamespaceManager(doc);


            //System.Xml.XmlNodeList xxx = oldCd.SelectNodes("xpath");

            //System.Xml.XmlNodeList xxx = root.SelectNodes("//*/dft:*[text()=\"String\"]", nsmgr);
            System.Xml.XmlNodeList xxx = root.SelectNodes("//*/dft:*[text()]", nsmgr);
            Console.WriteLine(xxx.Count);



            System.Xml.XmlNode oldCd = root.SelectSingleNode("/dft:Report/dft:DataSources/dft:DataSource[@Name=\"COR_Basic\"]", nsmgr);


            // System.Xml.XmlNode RepParams = root.SelectSingleNode("/dft:Report/dft:ReportParameters", nsmgr);
            // System.Xml.XmlNodeList AllParams = RepParams.SelectNodes("//dft:ReportParameter", nsmgr);



            // http://stackoverflow.com/questions/3655549/xpath-containstext-some-string-doesnt-work-when-used-with-node-with-more
            //System.Xml.XmlNodeList AllParams = root.SelectNodes("/dft:Report/dft:ReportParameters/dft:ReportParameter", nsmgr);
            System.Xml.XmlNodeList AllParams = root.SelectNodes("/dft:Report/dft:ReportParameters/dft:ReportParameter/dft:Prompt[contains(text(),\"Liegenschaft\")]", nsmgr);
            Console.WriteLine(AllParams.Count);



            Console.WriteLine(" ----------------------------------------- ");


            foreach (System.Xml.XmlNode ThisParameter in AllParams)
            {
                // XmlAttribute a = doc.SelectSingleNode("/reply/@success");
                Console.WriteLine(ThisParameter.Attributes["Name"].Value);

                System.Xml.XmlNode ParamDataType = ThisParameter.SelectSingleNode("//dft:DataType", nsmgr);
                Console.WriteLine(ParamDataType.FirstChild.Value);
            } // Next ThisParameter

            System.Xml.XmlNodeList stichtage = root.SelectNodes("/dft:Report/dft:ReportParameters/dft:ReportParameter[@Name=\"in_stichtag\"]", nsmgr);
            System.Xml.XmlNode     stichtag  = root.SelectSingleNode("/dft:Report/dft:ReportParameters/dft:ReportParameter[@Name=\"in_stichtag\"]", nsmgr);

            System.Xml.XmlNode stichtagvalue = root.SelectSingleNode("/dft:Report/dft:ReportParameters/dft:ReportParameter[@Name=\"in_stichtag\"]/dft:DefaultValue/dft:Values/dft:Value", nsmgr);

            Console.WriteLine(stichtagvalue.FirstChild.Value);


            // /dft:Report/dft:ReportParameters/dft:ReportParameter[@Name="in_gebaeude"]



            System.Xml.XmlNode datasetname = root.SelectSingleNode("/dft:Report/dft:ReportParameters/dft:ReportParameter[@Name=\"in_gebaeude\"]/dft:DefaultValue/dft:DataSetReference/dft:DataSetName", nsmgr);
            string             dataset     = datasetname.FirstChild.Value;

            System.Xml.XmlNode dsn = root.SelectSingleNode("/dft:Report/dft:DataSets/dft:DataSet[@Name=\"SEL_Gebaeude\"]", nsmgr);


            System.Xml.XmlNode dsn3 = root.SelectSingleNode("/dft:Report/dft:DataSets/dft:DataSet[@Name=\"SEL_Gebaeude\"]/dft:Query", nsmgr);

            System.Xml.XmlNode commandtextnode = root.SelectSingleNode("/dft:Report/dft:DataSets/dft:DataSet[@Name=\"SEL_Gebaeude\"]/dft:Query/dft:CommandText", nsmgr);
            string             commandText     = commandtextnode.FirstChild.Value;

            Console.WriteLine(commandText);


            System.Xml.XmlNodeList AllDatasetParams = root.SelectNodes("/dft:Report/dft:DataSets/dft:DataSet[@Name=\"SEL_Gebaeude\"]/dft:Query/dft:QueryParameters/dft:QueryParameter", nsmgr);
            Console.WriteLine(AllDatasetParams.Count);

            Console.WriteLine(" ----------------------------------------- ");
            foreach (System.Xml.XmlNode DataSetParameter in AllDatasetParams)
            {
                string strName = DataSetParameter.Attributes["Name"].Value;
                string lala    = DataSetParameter.FirstChild.FirstChild.Value;
                Console.WriteLine(lala);

                Console.WriteLine(strName);
            } // Next DataSetParameter


            System.Xml.XmlNode dsn5 = root.SelectSingleNode("/dft:Report/dft:DataSets/dft:DataSet[@Name=\"SEL_Gebaeude\"]/dft:Query/dft:QueryParameters", nsmgr);
            System.Xml.XmlNode dsn6 = root.SelectSingleNode("/dft:Report/dft:DataSets/dft:DataSet[@Name=\"SEL_Gebaeude\"]/dft:Query/dft:QueryParameters/dft:QueryParameter", nsmgr);


            System.Xml.XmlNodeList embeddedImages = root.SelectNodes("/dft:Report/dft:EmbeddedImages/dft:EmbeddedImage", nsmgr);


            System.Xml.XmlNode stao = root.SelectSingleNode("/dft:Report/dft:ReportParameters/dft:ReportParameter[@Name=\"in_standort\"]", nsmgr);
            if (stao != null)
            {
                Console.WriteLine("Has stao");
            }


            Console.WriteLine(stichtag);

            // /dft:Report/dft:PageHeader/dft:ReportItems/dft:Image/dft:Value[text()="=Convert.FromBase64String(Parameters!def_logo.Value)"]
            // /dft:Report/dft:PageHeader/dft:ReportItems/dft:Image/dft:Visibility/dft:Hidden[text()="=CBool(Parameters!def_HideLogo.Value)"]



            // System.Xml.XmlElement newCd = doc.CreateElement("cd");
            // newCd.SetAttribute("country", "country.Text");

            // newCd.InnerXml = "<title>" + this.comboBox1.Text + "</title>" + "<artist>" + artist.Text + "</artist>" + "<price>" + price.Text + "</price>";

            // root.ReplaceChild(newCd, oldCd);

            //save the output to a file
            //doc.Save(FILE_NAME);


            Console.WriteLine(Environment.NewLine);
            Console.WriteLine(" --- Press any key to continue --- ");
            Console.ReadKey();
        } // End Sub Main
Exemple #24
0
        private SyncNode(Microsoft.Samples.FeedSync.FeedItemNode i_FeedItemNode, System.Xml.XmlElement i_SyncNodeXmlElement)
        {
            m_FeedItemNode = i_FeedItemNode;
            m_XmlElement = i_SyncNodeXmlElement;

            m_ID = m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.ID_ATTRIBUTE);
            m_Updates = System.Convert.ToInt32(m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.UPDATES_ATTRIBUTE));

            if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.DELETED_ATTRIBUTE))
                m_Deleted = (m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.DELETED_ATTRIBUTE) == "true");

            if (m_XmlElement.HasAttribute(Microsoft.Samples.FeedSync.Constants.NO_CONFLICTS_ATTRIBUTE))
                m_NoConflicts = (m_XmlElement.GetAttribute(Microsoft.Samples.FeedSync.Constants.NO_CONFLICTS_ATTRIBUTE) == "true");

            string XPathQuery = System.String.Format
                (
                "{0}:{1}",
                m_FeedItemNode.Feed.FeedSyncNamespacePrefix,
                Microsoft.Samples.FeedSync.Constants.HISTORY_ELEMENT_NAME
                );

            System.Xml.XmlNodeList HistoryNodeList = i_SyncNodeXmlElement.SelectNodes
                (
                XPathQuery, 
                i_FeedItemNode.Feed.XmlNamespaceManager
                );

            foreach (System.Xml.XmlElement HistoryNodeXmlElement in HistoryNodeList)
            {
                Microsoft.Samples.FeedSync.HistoryNode HistoryNode = Microsoft.Samples.FeedSync.HistoryNode.CreateFromXmlElement
                    (
                    this,
                    HistoryNodeXmlElement
                    );

                m_HistoryNodeList.Add(HistoryNode);
            }

            if (!m_NoConflicts)
            {
                XPathQuery = System.String.Format
                    (
                    "{0}:{1}",
                    m_FeedItemNode.Feed.FeedSyncNamespacePrefix,
                    Microsoft.Samples.FeedSync.Constants.CONFLICTS_ELEMENT_NAME
                    );

                m_ConflictsNodeXmlElement = (System.Xml.XmlElement)i_SyncNodeXmlElement.SelectSingleNode
                    (
                    XPathQuery,
                    m_FeedItemNode.Feed.XmlNamespaceManager
                    );

                if (m_ConflictsNodeXmlElement != null)
                {
                    System.Xml.XmlNodeList FeedItemXmlNodeList = m_ConflictsNodeXmlElement.SelectNodes
                        (
                        m_FeedItemNode.Feed.FeedItemXPathQuery,
                        m_FeedItemNode.Feed.XmlNamespaceManager
                        );

                    foreach (System.Xml.XmlElement ConflictFeedItemNodeXmlElement in FeedItemXmlNodeList)
                    {
                        Microsoft.Samples.FeedSync.FeedItemNode ConflictFeedItemNode = this.CreateConflictItemNodeFromXmlElement(ConflictFeedItemNodeXmlElement);

                        string Key = System.String.Format
                            (
                            "{0}{1}{2}",
                            ConflictFeedItemNode.SyncNode.Updates,
                            ConflictFeedItemNode.SyncNode.TopMostHistoryNode.Sequence,
                            ConflictFeedItemNode.SyncNode.TopMostHistoryNode.By
                            );

                        if (ConflictFeedItemNode.SyncNode.TopMostHistoryNode.WhenDateTime != null)
                            Key += ((System.DateTime)ConflictFeedItemNode.SyncNode.TopMostHistoryNode.WhenDateTime);

                        if (!m_ConflictNodeList.ContainsKey(Key))
                            m_ConflictNodeList.Add(Key, ConflictFeedItemNode);
                    }
                }
            }
        }
        /// <summary> Constructs a new Generator, configured from XML.</summary>
        public Generator(DirectoryInfo workingDirectory, Element generateElement)
            : this(workingDirectory)
        {
            string value_Renamed = null;

            // set rendererClass field
            if (
                (Object)
                (this.rendererClass =
                 (generateElement.Attributes["renderer"] == null ? null : generateElement.Attributes["renderer"].Value)) == null)
            {
                throw new Exception("attribute renderer is required.");
            }

            // set dirName field
            if (
                (Object)
                (value_Renamed = (generateElement.Attributes["dir"] == null ? null : generateElement.Attributes["dir"].Value)) !=
                null)
            {
                this.baseDirName = value_Renamed;
            }

            // set packageName field
            this.packageName = (generateElement.Attributes["package"] == null
                                    ? string.Empty : generateElement.Attributes["package"].Value);

            // set prefix
            if (
                (Object)
                (value_Renamed = (generateElement.Attributes["prefix"] == null ? null : generateElement.Attributes["prefix"].Value)) !=
                null)
            {
                this.prefix = value_Renamed;
            }

            // set suffix
            if (
                (Object)
                (value_Renamed = (generateElement.Attributes["suffix"] == null ? null : generateElement.Attributes["suffix"].Value)) !=
                null)
            {
                this.suffix = value_Renamed;
            }

            // set extension
            if (
                (Object)
                (value_Renamed =
                 (generateElement.Attributes["extension"] == null ? null : generateElement.Attributes["extension"].Value)) != null)
            {
                this.extension = value_Renamed;
            }

            // set lowerFirstLetter
            value_Renamed = (generateElement.Attributes["lowerFirstLetter"] == null
                             	? null : generateElement.Attributes["lowerFirstLetter"].Value);
            try
            {
                this.lowerFirstLetter = Boolean.Parse(value_Renamed);
            }
            catch
            {
            }

            IEnumerator iter = generateElement.SelectNodes("param").GetEnumerator();
            while (iter.MoveNext())
            {
                Element childNode = (Element) iter.Current;
                params_Renamed[childNode.Attributes["name"].Value] = childNode.InnerText;
            }
        }
        /// <summary> Load meta attributes from jdom element into a MultiMap.
        /// 
        /// </summary>
        /// <returns> MultiMap
        /// </returns>
        protected internal static MultiMap loadMetaMap(Element element)
        {
            MultiMap result = new MultiHashMap();
            SupportClass.ListCollectionSupport metaAttributeList = new SupportClass.ListCollectionSupport();
            metaAttributeList.AddAll(element.SelectNodes("urn:meta", CodeGenerator.nsmgr));

            for (IEnumerator iter = metaAttributeList.GetEnumerator(); iter.MoveNext();)
            {
                Element metaAttrib = (Element) iter.Current;
                // does not use getTextNormalize() or getTextTrim() as that would remove the formatting in new lines in items like description for javadocs.
                string attribute = (metaAttrib.Attributes["attribute"] == null
                                        ? string.Empty : metaAttrib.Attributes["attribute"].Value);
                string value_Renamed = metaAttrib.InnerText;
                string inheritStr = (metaAttrib.Attributes["inherit"] == null ? null : metaAttrib.Attributes["inherit"].Value);
                bool inherit = true;
                if ((Object) inheritStr != null)
                {
                    try
                    {
                        inherit = Boolean.Parse(inheritStr);
                    }
                    catch
                    {
                    }
                }

                MetaAttribute ma = new MetaAttribute(value_Renamed, inherit);
                if (result[attribute] == null)
                    result[attribute] = new SupportClass.ListCollectionSupport();

                ((SupportClass.ListCollectionSupport) result[attribute]).Add(ma);
            }
            return result;
        }
        /// <summary>
        /// CheckTheApplicationForUpdates
        /// </summary>
        private bool CheckTheApplicationForUpdates()
        {
            bool    rc             = false;
            Version currentVersion = Version.Parse(System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Version remoteVersion  = new Version();
            string  strXmlDoc      = "";

            try
            {
                System.Net.HttpWebRequest wr = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(@"https://uhwgmxorg.com/getDownLoadUrl.php");;
                using (System.Net.HttpWebResponse resp = (System.Net.HttpWebResponse)wr.GetResponse())
                {
                    try
                    {
                        StreamReader sr = new StreamReader(resp.GetResponseStream());
                        strXmlDoc = sr.ReadToEnd();
                        Debug.WriteLine(strXmlDoc);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                        return(false);
                    }

                    try
                    {
                        System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
                        xdoc.LoadXml(strXmlDoc);
                        System.Xml.XmlElement  xelRoot  = xdoc.DocumentElement;
                        System.Xml.XmlNodeList xnlNodes = xelRoot.SelectNodes("/GUP/Version");

                        foreach (System.Xml.XmlNode xndNode in xnlNodes)
                        {
                            remoteVersion = Version.Parse(xndNode.InnerText);
                            Debug.WriteLine(xndNode.Name + " : " + xndNode.InnerText);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex);
                        return(false);
                    }

                    if (remoteVersion > currentVersion)
                    {
                        rc = true;
                    }
                    else
                    {
                        MessageBox.Show(String.Format("Current Version is {0}.{1} Remote Version is {2} no update is necessary!", currentVersion.Major, currentVersion.Minor, remoteVersion), "ComMonitor update", MessageBoxButton.OK);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("No connection to update source!"), "ComMonitor update", MessageBoxButton.OK);
                Debug.WriteLine(ex);
                return(false);
            }

            _logger.Info(String.Format("CheckTheApplicationForUpdates rc={0}", rc));

            return(rc);
        }
        public void TestParseFacebookShopListResponse()
        {
            string xml =
                @"<roar tick=""130695522924"">
				<facebook>\
					<shop_list>
						<fbshopitem
							ikey=""shop_item_ikey1""
							description=""Blah Blah""
							label=""label""
							price=""2""
							product_url=""http://foo.bar""
							image_url=""http://foo.bar/baz.png""
						>
							<modifiers>
								<grant_item ikey=""item_ikey_1""/>
							</modifiers>
						</fbshopitem>
						<fbshopitem
							ikey=""shop_item_ikey2""
							description=""Blah Boo""
							label=""item2""
							price=""4""
							product_url=""ABC""
							image_url=""...""
						>
							<modifiers>
								<grant_item ikey=""item_ikey_2""/>
							</modifiers>
						</fbshopitem>
					</shop_list>
				</facebook>
			</roar>"            ;

            System.Xml.XmlElement nn = RoarExtensions.CreateXmlElement(xml);
            Assert.IsNotNull(nn);

            Assert.AreEqual(2, nn.SelectNodes("./facebook/shop_list/fbshopitem").Count);

            Mockery mockery = new Mockery();

            Roar.DataConversion.IXCRMParser    ixcrm_parser   = mockery.NewMock <Roar.DataConversion.IXCRMParser>();
            List <Roar.DomainObjects.Modifier> modifier_list  = new List <Roar.DomainObjects.Modifier>();
            List <Roar.DomainObjects.Modifier> modifier_list1 = new List <Roar.DomainObjects.Modifier>();

            System.Xml.XmlNode modifier_node0 = nn.SelectSingleNode("./facebook/shop_list/fbshopitem[1]/modifiers");
            Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(modifier_node0).Will(Return.Value(modifier_list));

            System.Xml.XmlNode modifier_node1 = nn.SelectSingleNode("./facebook/shop_list/fbshopitem[2]/modifiers");
            Expect.Once.On(ixcrm_parser).Method("ParseModifierList").With(modifier_node1).Will(Return.Value(modifier_list1));

            Roar.DataConversion.Responses.Facebook.ShopList shoplist_response_parser = new Roar.DataConversion.Responses.Facebook.ShopList();
            shoplist_response_parser.ixcrm_parser = ixcrm_parser;

            Roar.WebObjects.Facebook.ShopListResponse response = shoplist_response_parser.Build(nn);

            Assert.IsNotNull(response);
            Assert.AreEqual(2, response.shop_list.Count);
            Roar.DomainObjects.FacebookShopEntry e0 = response.shop_list[0];
            Assert.AreEqual("shop_item_ikey1", e0.ikey);
            Assert.AreEqual("Blah Blah", e0.description);
            Assert.AreEqual("label", e0.label);
            Assert.AreEqual("2", e0.price);
            Assert.AreEqual("http://foo.bar", e0.product_url);
            Assert.AreEqual("http://foo.bar/baz.png", e0.image_url);
            Assert.AreSame(modifier_list, e0.modifiers);

            Roar.DomainObjects.FacebookShopEntry e1 = response.shop_list[1];
            Assert.AreEqual("shop_item_ikey2", e1.ikey);
            Assert.AreEqual("Blah Boo", e1.description);
            Assert.AreEqual("item2", e1.label);
            Assert.AreEqual("4", e1.price);
            Assert.AreEqual("ABC", e1.product_url);
            Assert.AreEqual("...", e1.image_url);
            Assert.AreSame(modifier_list1, e1.modifiers);

            mockery.VerifyAllExpectationsHaveBeenMet();
        }
Exemple #29
0
        /// <summary> Constructs a new Generator, configured from XML.</summary>
        public Generator(DirectoryInfo workingDirectory, Element generateElement) : this(workingDirectory)
        {
            string value_Renamed = null;

            // set rendererClass field
            if (
                (Object)
                (this.rendererClass =
                     (generateElement.Attributes["renderer"] == null ? null : generateElement.Attributes["renderer"].Value)) == null)
            {
                throw new Exception("attribute renderer is required.");
            }

            // set dirName field
            if (
                (Object)
                (value_Renamed = (generateElement.Attributes["dir"] == null ? null : generateElement.Attributes["dir"].Value)) !=
                null)
            {
                this.baseDirName = value_Renamed;
            }

            // set packageName field
            this.packageName = (generateElement.Attributes["package"] == null
                                    ? string.Empty : generateElement.Attributes["package"].Value);

            // set prefix
            if (
                (Object)
                (value_Renamed = (generateElement.Attributes["prefix"] == null ? null : generateElement.Attributes["prefix"].Value)) !=
                null)
            {
                this.prefix = value_Renamed;
            }

            // set suffix
            if (
                (Object)
                (value_Renamed = (generateElement.Attributes["suffix"] == null ? null : generateElement.Attributes["suffix"].Value)) !=
                null)
            {
                this.suffix = value_Renamed;
            }

            // set extension
            if (
                (Object)
                (value_Renamed =
                     (generateElement.Attributes["extension"] == null ? null : generateElement.Attributes["extension"].Value)) != null)
            {
                this.extension = value_Renamed;
            }

            // set lowerFirstLetter
            value_Renamed = (generateElement.Attributes["lowerFirstLetter"] == null
                                                ? null : generateElement.Attributes["lowerFirstLetter"].Value);
            try
            {
                this.lowerFirstLetter = Boolean.Parse(value_Renamed);
            }
            catch
            {
            }

            IEnumerator iter = generateElement.SelectNodes("param").GetEnumerator();
            while (iter.MoveNext())
            {
                Element childNode = (Element)iter.Current;
                params_Renamed[childNode.Attributes["name"].Value] = childNode.InnerText;
            }
        }
Exemple #30
0
            protected override void Run()
            {
                string QlLeftTableName  = DSpace_ExecArgs[0];
                string LeftTableName    = QlArgsUnescape(QlLeftTableName);
                string stype            = DSpace_ExecArgs[1];
                string QlRightTableName = DSpace_ExecArgs[2];
                string RightTableName   = QlArgsUnescape(QlRightTableName);
                string QlOn             = DSpace_ExecArgs[3];
                string On = QlArgsUnescape(QlOn);

                if (-1 != LeftTableName.IndexOf('\0'))
                {
                    throw new NotSupportedException("Cannot JOIN with multiple left tables: " + LeftTableName);
                }

                if (-1 != RightTableName.IndexOf('\0'))
                {
                    throw new NotSupportedException("Cannot JOIN with multiple right tables: " + RightTableName);
                }

                System.Xml.XmlDocument systables;
                using (GlobalCriticalSection.GetLock())
                {
                    systables = LoadSysTables_unlocked();
                }

                System.Xml.XmlElement xeLeftTable = FindTable(systables, LeftTableName);
                if (null == xeLeftTable)
                {
                    throw new Exception("Table (left) '" + LeftTableName + "' does not exist");
                }
                string sLeftRowSize           = xeLeftTable["size"].InnerText;
                int    LeftRowSize            = int.Parse(sLeftRowSize);
                string LeftDfsTableFilesInput = xeLeftTable["file"].InnerText + "@" + sLeftRowSize;

                if (LeftDfsTableFilesInput.StartsWith("qa://", true, null))
                {
                    throw new Exception("Cannot JOIN with system tables (left)");
                }

                System.Xml.XmlElement xeRightTable = FindTable(systables, RightTableName);
                if (null == xeRightTable)
                {
                    throw new Exception("Table (right) '" + RightTableName + "' does not exist");
                }
                string sRightRowSize           = xeRightTable["size"].InnerText;
                int    RightRowSize            = int.Parse(sRightRowSize);
                string RightDfsTableFilesInput = xeRightTable["file"].InnerText + "@" + sRightRowSize;

                if (RightDfsTableFilesInput.StartsWith("qa://", true, null))
                {
                    throw new Exception("Cannot JOIN with system tables (right)");
                }

                string DfsTableFilesInput = LeftDfsTableFilesInput + ";" + RightDfsTableFilesInput;

                string DfsOutputName = "dfs://RDBMS_JoinOn_" + Guid.NewGuid().ToString() + Qa.DFS_TEMP_FILE_MARKER;

                int DfsOutputRowSize = LeftRowSize + RightRowSize;

                string          LeftRowInfo;
                string          LeftDisplayInfo; // Display
                List <DbColumn> LeftCols       = new List <DbColumn>();
                List <string>   LeftColsWidths = new List <string>();
                {
                    StringBuilder sbRowInfo     = new StringBuilder();
                    StringBuilder sbDisplayInfo = new StringBuilder(); // Display
                    int           totsize       = 0;
                    string        xtablename    = xeLeftTable["name"].InnerText;
                    foreach (System.Xml.XmlNode xn in xeLeftTable.SelectNodes("column"))
                    {
                        if (0 != sbRowInfo.Length)
                        {
                            sbRowInfo.Append('\0');
                            sbDisplayInfo.Append(','); // Display
                        }
                        string stsize      = xn["bytes"].InnerText;
                        int    tsize       = int.Parse(stsize);
                        string RealColName = xn["name"].InnerText;
                        string UserColName = RealColName;
                        string xcolname;
                        if (-1 == UserColName.IndexOf('.'))
                        {
                            xcolname = xtablename + "." + UserColName;
                        }
                        else
                        {
                            xcolname = UserColName;
                        }
                        sbRowInfo.Append(xcolname); // Note: doesn't consider sub-select.
                        sbRowInfo.Append('=');
                        sbRowInfo.Append(stsize);
                        sbDisplayInfo.Append(xn["type"].InnerText); // Display
                        sbDisplayInfo.Append('=');                  // Display
                        sbDisplayInfo.Append(xn["dw"].InnerText);   // Display
                        LeftColsWidths.Add(xn["dw"].InnerText);
                        {
                            DbColumn c;
                            c.Type       = DbType.Prepare(xn["type"].InnerText, tsize);
                            c.RowOffset  = totsize;
                            c.ColumnName = xcolname;
                            LeftCols.Add(c);
                        }
                        totsize += tsize;
                    }
                    LeftRowInfo     = sbRowInfo.ToString();
                    LeftDisplayInfo = sbDisplayInfo.ToString(); // Display
                }

                string          RightRowInfo;
                string          RightDisplayInfo; // Display
                List <DbColumn> RightCols       = new List <DbColumn>();
                List <string>   RightColsWidths = new List <string>();
                {
                    StringBuilder sbRowInfo     = new StringBuilder();
                    StringBuilder sbDisplayInfo = new StringBuilder(); // Display
                    int           totsize       = 0;
                    string        xtablename    = xeRightTable["name"].InnerText;
                    foreach (System.Xml.XmlNode xn in xeRightTable.SelectNodes("column"))
                    {
                        if (0 != sbRowInfo.Length)
                        {
                            sbRowInfo.Append('\0');
                            sbDisplayInfo.Append(','); // Display
                        }
                        string stsize      = xn["bytes"].InnerText;
                        int    tsize       = int.Parse(stsize);
                        string RealColName = xn["name"].InnerText;
                        string UserColName = RealColName;
                        string xcolname;
                        if (-1 == UserColName.IndexOf('.'))
                        {
                            xcolname = xtablename + "." + UserColName;
                        }
                        else
                        {
                            xcolname = UserColName;
                        }
                        sbRowInfo.Append(xcolname); // Note: doesn't consider sub-select.
                        sbRowInfo.Append('=');
                        sbRowInfo.Append(stsize);
                        sbDisplayInfo.Append(xn["type"].InnerText); // Display
                        sbDisplayInfo.Append('=');                  // Display
                        sbDisplayInfo.Append(xn["dw"].InnerText);   // Display
                        RightColsWidths.Add(xn["dw"].InnerText);
                        {
                            DbColumn c;
                            c.Type       = DbType.Prepare(xn["type"].InnerText, tsize);
                            c.RowOffset  = totsize;
                            c.ColumnName = xcolname;
                            RightCols.Add(c);
                        }
                        totsize += tsize;
                    }
                    RightRowInfo     = sbRowInfo.ToString();
                    RightDisplayInfo = sbDisplayInfo.ToString(); // Display
                }

                string on1, onop, on2;
                {
                    string onargs = On;
                    on1  = Qa.NextPart(ref onargs);
                    onop = Qa.NextPart(ref onargs);
                    on2  = Qa.NextPart(ref onargs);
                    if (0 == on1.Length ||
                        0 == onop.Length ||
                        0 == on2.Length ||
                        0 != onargs.Trim().Length)
                    {
                        throw new Exception("Invalid ON expression for JOIN: " + On);
                    }
                }

                bool on1left;
                int  on1colindex;
                {
                    int on1colindexother;
                    on1colindex      = DbColumn.IndexOf(LeftCols, on1);
                    on1colindexother = DbColumn.IndexOf(RightCols, on1);
                    if (-1 != on1colindex)
                    {
                        if (-1 != on1colindexother)
                        {
                            throw new Exception("Column name " + on1 + " does not resolve to a single column (in left and right tables)");
                        }
                        else
                        {
                            on1left = true;
                        }
                    }
                    else
                    {
                        if (-1 != on1colindexother)
                        {
                            on1colindex = on1colindexother;
                            on1left     = false;
                        }
                        else
                        {
                            throw new Exception("No such column named " + on1);
                        }
                    }
                }

                bool on2left;
                int  on2colindex;

                {
                    int on2colindexother;
                    on2colindex      = DbColumn.IndexOf(LeftCols, on2);
                    on2colindexother = DbColumn.IndexOf(RightCols, on2);
                    if (-1 != on2colindex)
                    {
                        if (-1 != on2colindexother)
                        {
                            throw new Exception("Column name " + on2 + " does not resolve to a single column (in left and right tables)");
                        }
                        else
                        {
                            on2left = true;
                        }
                    }
                    else
                    {
                        if (-1 != on2colindexother)
                        {
                            on2colindex = on2colindexother;
                            on2left     = false;
                        }
                        else
                        {
                            throw new Exception("No such column named " + on2);
                        }
                    }
                }

                if ((on1left && on2left) ||
                    (!on1left && !on2left))
                {
                    string whicht;
                    if (on1left)
                    {
                        whicht = "(left) " + LeftTableName;
                    }
                    else
                    {
                        whicht = "(right) " + RightTableName;
                    }
                    throw new Exception("ON expression is comparing columns from the same table: "
                                        + on1 + " and " + on2 + " are both part of " + whicht);
                }

                // Order ON columns:
                if (!on1left)
                {
                    {
                        string onx = on1;
                        on1 = on2;
                        on2 = onx;
                    }
                    {
                        int onxcolindex = on1colindex;
                        on1colindex = on2colindex;
                        on2colindex = onxcolindex;
                    }
                    {
                        on1left = true;
                        on2left = false;
                    }
                    // Invert the operator..
                    switch (onop)
                    {
                    case "=":
                        //onop = "=";
                        break;

                    case "!=":
                        //onop = "!=";
                        break;

                    case "<":
                        onop = ">";
                        break;

                    case "<=":
                        onop = ">=";
                        break;

                    case ">":
                        onop = "<";
                        break;

                    case ">=":
                        onop = "<=";
                        break;

                    default:
                        throw new Exception("Unhandled ON operation: " + onop);
                    }
                    On   = on1 + " " + onop + " " + on2;
                    QlOn = QlArgsEscape(On);
                }

                DbColumn on1col;

                if (on1left)
                {
                    on1col = LeftCols[on1colindex];
                }
                else
                {
                    //on1col = RightCols[on1colindex];
                    throw new Exception("DEBUG:  PrepareJoinOn: (!on1left)");
                }
                if (on1col.Type.Size == 0 || on1col.Type.ID == DbTypeID.NULL)
                {
                    throw new Exception("Invalid column for ON expression: " + on1);
                }

                DbColumn on2col;

                if (on2left)
                {
                    //on2col = LeftCols[on2colindex];
                    throw new Exception("DEBUG:  PrepareJoinOn: (on2left)");
                }
                else
                {
                    on2col = RightCols[on2colindex];
                }
                if (on2col.Type.Size == 0 || on2col.Type.ID == DbTypeID.NULL)
                {
                    throw new Exception("Invalid column for ON expression: " + on2);
                }

                int KeyLength = on1col.Type.Size;

                if (on2col.Type.Size > KeyLength)
                {
                    KeyLength = on2col.Type.Size;
                }

                {
                    MapReduceCall mrc = GetMapReduceCallJoinOn(DfsTableFilesInput);
                    mrc.OverrideOutputMethod = "grouped";
                    mrc.OverrideInput        = DfsTableFilesInput;
                    mrc.OverrideOutput       = DfsOutputName + "@" + DfsOutputRowSize;
                    mrc.OverrideKeyLength    = KeyLength;
                    if (RDBMS_DBCORE.Qa.FaultTolerantExecution)
                    {
                        mrc.OverrideFaultTolerantExecutionMode = "enabled";
                    }
                    mrc.Call("\"" + QlLeftTableName + "\" " + stype + " \"" + QlRightTableName
                             + "\" \"" + QlOn
                             + "\" \"" + on1col.RowOffset + "," + on1col.Type.Size + "=" + QlArgsEscape(on1col.Type.Name)
                             + "\" \"" + on2col.RowOffset + "," + on2col.Type.Size + "=" + QlArgsEscape(on2col.Type.Name)
                             + "\" \"" + DfsTableFilesInput
                             + "\"");
                }

                {
                    PrepareSelect.queryresults qr      = new PrepareSelect.queryresults();
                    List <DbColumn>            AllCols = new List <DbColumn>(LeftCols.Count + RightCols.Count);
                    AllCols.AddRange(LeftCols);
                    AllCols.AddRange(RightCols);
                    qr.SetFields(AllCols);
                    qr.temptable  = DfsOutputName;
                    qr.recordsize = LeftRowSize + RightRowSize;
                    string sPartCount = Shell("dspace countparts \"" + DfsOutputName + "\"").Split('\n')[0].Trim();
                    qr.parts = int.Parse(sPartCount);
                    string sDfsOutputSize = Shell("dspace filesize \"" + DfsOutputName + "\"").Split('\n')[0].Trim();
                    long   DfsOutputSize  = long.Parse(sDfsOutputSize);
                    long   NumRowsOutput  = DfsOutputSize / qr.recordsize;
                    qr.recordcount = NumRowsOutput;

                    DSpace_Log(PrepareSelect.SetQueryResults(qr));
                }
            }