Пример #1
0
        public List <string> stListSectionNames(string Type)
        {
            if (xmlrdrdoc == null)
            {
                xmlrdrdoc = new XmlDocument();
                xmlrdrdoc.Load(path);
            }

            if (listListSectionNames.Count == 0)
            {
                //StringBuilder temp = new StringBuilder(255);

                XPathNavigator navigator = xmlrdrdoc.CreateNavigator();

                XPathExpression expression = navigator.Compile("/INI/Section[Type=\"" + Type + "\"]/Name");// "//@Name"); //

                //expression.AddSort("Item"
                expression.AddSort("../Type", XmlSortOrder.Descending, XmlCaseOrder.UpperFirst, string.Empty, XmlDataType.Text);
                expression.AddSort("../Name", XmlSortOrder.Ascending, XmlCaseOrder.UpperFirst, string.Empty, XmlDataType.Text);

                XPathNodeIterator iterator = navigator.Select(expression);

                foreach (XPathNavigator item in iterator)
                {
                    listListSectionNames.Add(item.Value.ToString());
                }
            }
            return(listListSectionNames);
        }
Пример #2
0
        private void PopulateNodes()
        {
            XPathNavigator  nav = cvItemXml.CreateNavigator();
            XPathExpression exp = nav.Compile("Items/Item[@Type='Item']");

            exp.AddSort("@Name", XmlSortOrder.Ascending, XmlCaseOrder.UpperFirst, "en-US", XmlDataType.Text);
            XPathNodeIterator nodeIter = nav.Select(exp);

            while (nodeIter.MoveNext())
            {
                treeCompendium.Nodes["nodeItems"].Nodes.Add(nodeIter.Current.SelectSingleNode("@Name").ToString());
            }

            exp = nav.Compile("Items/Item[@Type='Armor']");
            exp.AddSort("@Name", XmlSortOrder.Ascending, XmlCaseOrder.UpperFirst, "en-US", XmlDataType.Text);
            nodeIter = nav.Select(exp);

            while (nodeIter.MoveNext())
            {
                treeCompendium.Nodes["nodeArmor"].Nodes.Add(nodeIter.Current.SelectSingleNode("@Name").ToString());
            }

            exp = nav.Compile("Items/Item[@Type='Weapon']");
            exp.AddSort("@Name", XmlSortOrder.Ascending, XmlCaseOrder.UpperFirst, "en-US", XmlDataType.Text);
            nodeIter = nav.Select(exp);

            while (nodeIter.MoveNext())
            {
                treeCompendium.Nodes["nodeWeapon"].Nodes.Add(nodeIter.Current.SelectSingleNode("@Name").ToString());
            }

            nav = cvVehicleXml.CreateNavigator();
            exp = nav.Compile("Vehicles/Vehicle");
            exp.AddSort("@Name", XmlSortOrder.Ascending, XmlCaseOrder.UpperFirst, "en-US", XmlDataType.Text);
            nodeIter = nav.Select(exp);

            while (nodeIter.MoveNext())
            {
                treeCompendium.Nodes["nodeVehicle"].Nodes.Add(nodeIter.Current.SelectSingleNode("@Name").ToString());
            }

            string[] files = Directory.GetFiles(cvNpcFolder, "*.xml");

            foreach (string lvFile in files)
            {
                treeCompendium.Nodes["nodeNPC"].Nodes.Add(Path.GetFileNameWithoutExtension(lvFile));
            }
        }
Пример #3
0
        private static void PrepareSort(XPathExpression expression, XPathNavigator source,
                                        object sortExpression, IComparer comparer, XmlNamespaceManager context)
        {
            XPathExpression se;

            var s = sortExpression as string;

            if (s != null)
            {
                se = GetCompiledExpression(s, source);
            }
            else
            {
                var pathExpression = sortExpression as XPathExpression;
                if (pathExpression != null)
                {
                    se = pathExpression;
                }
                else
                {
                    throw new XPathException(Resources.XPathCache_BadSortObject, null);
                }
            }

            se.SetContext(context);
            expression.AddSort(se, comparer);
        }
Пример #4
0
        public static SideBarModule[] InitModules()
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(HttpContext.Current.Server.MapPath("/SideBar/SideBar.xml"));
            XPathNavigator nav = xml.CreateNavigator();

            nav.MoveToRoot();
            XPathExpression expr = nav.Compile("/controls/control");

            expr.AddSort("@Order", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);
            XPathNodeIterator it = nav.Select(expr);

            SideBarModule[] Module = new SideBarModule[it.Count];
            int             i      = 0;

            while (it.MoveNext())
            {
                XmlElement xmlEl = ((IHasXmlNode)it.Current).GetNode() as XmlElement;
                Module[i] = new SideBarModule(xmlEl.GetAttribute("ID"), string.Format("~/SideBar/{0}.ascx", xmlEl.GetAttribute("File")));
                i++;
            }
            HttpContext.Current.Application["modules"] = Module;
            return(Module);
        }
Пример #5
0
            public XmlDocument SortXml(XmlDocument XmlDoc, string SelectSingleNode, string SelectNode, string SortNode, SortMode SortMode)
            {
                int mode = (int)SortMode;

                if (XmlDoc != null)
                {
                    XmlSortOrder sort = mode == 0 ? XmlSortOrder.Ascending : XmlSortOrder.Descending;

                    XmlDocument xmlDocCopy = new XmlDocument();
                    xmlDocCopy.LoadXml(XmlDoc.OuterXml);
                    xmlDocCopy.SelectSingleNode("//" + SelectSingleNode).RemoveAll();

                    XmlNode         node             = XmlDoc.SelectSingleNode("//" + SelectSingleNode);
                    XPathNavigator  navigator        = node.CreateNavigator();
                    XPathExpression selectExpression = navigator.Compile(string.Format("{0}/{1}", SelectNode, SortNode));
                    selectExpression.AddSort(".", sort, XmlCaseOrder.None, "", XmlDataType.Text);
                    XPathNodeIterator nodeIterator = navigator.Select(selectExpression);
                    while (nodeIterator.MoveNext())
                    {
                        XmlNode linkNode         = XmlDoc.SelectSingleNode(string.Format("//{0}[{1}=\"{2}\"]", SelectNode, SortNode, nodeIterator.Current.Value));
                        XmlNode importedLinkNode = xmlDocCopy.ImportNode(linkNode, true);
                        xmlDocCopy.SelectSingleNode("//" + SelectSingleNode).AppendChild(importedLinkNode);
                    }
                    XmlDoc = xmlDocCopy;
                }
                return(XmlDoc);
            }
        //Generates files for the specifed CLI XML document
        static private void GenerateFiles(string filePath)
        {
            //Load the ECMA CLI document
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(filePath);

            //Sort the document so we can split the sections into a file per library
            XPathNavigator  navigator  = xmlDoc.CreateNavigator();
            XPathExpression expression = navigator.Compile("//Types");

            expression.AddSort("attribute::Library ", XmlSortOrder.Ascending, XmlCaseOrder.None, String.Empty, XmlDataType.Text);

            XPathNodeIterator nodeIterator = navigator.Select(expression);

            while (nodeIterator.MoveNext())
            {
                string target;
                target = Path.Combine(Directory.GetCurrentDirectory(),
                                      nodeIterator.Current.GetAttribute("Library", String.Empty) + ".txt");

                using (StreamWriter stream = File.CreateText(target))
                {
                    GenerateFileContents(nodeIterator.Current, stream);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// This was the logic to sort before and now lives here just to show the benchmarks tests above.
        /// </summary>
        /// <param name="parentNode"></param>
        private static void LegacySortNodes(ref XmlNode parentNode)
        {
            XmlNode n = parentNode.CloneNode(true);

            // remove all children from original node
            string xpath = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "./node" : "./* [@id]";

            foreach (XmlNode child in parentNode.SelectNodes(xpath))
            {
                parentNode.RemoveChild(child);
            }


            XPathNavigator  nav  = n.CreateNavigator();
            XPathExpression expr = nav.Compile(xpath);

            expr.AddSort("@sortOrder", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);
            XPathNodeIterator iterator = nav.Select(expr);

            while (iterator.MoveNext())
            {
                parentNode.AppendChild(
                    ((IHasXmlNode)iterator.Current).GetNode());
            }
        }
        /// <summary>
        /// Gets all services from the XML
        /// </summary>
        /// <returns></returns>
        public Collection <Service> Services()
        {
            // Select all services
            XPathNavigator  nav  = this.CreateNavigator();
            XPathExpression expr = nav.Compile("/ns:ClosureInfo/ns:Services/ns:Service");

            expr.SetContext(this.NamespaceManager);

            // Sort by name of service
            XPathExpression sortExpr = nav.Compile("ns:Name");

            sortExpr.SetContext(this.NamespaceManager);
            expr.AddSort(sortExpr, XmlSortOrder.Ascending, XmlCaseOrder.None, String.Empty, XmlDataType.Text);

            // Add services to collection and return
            XPathNodeIterator    it       = nav.Select(expr);
            Collection <Service> services = new Collection <Service>();

            while (it.MoveNext())
            {
                // Deserialise the service
                XmlSerializer deserialiser = new XmlSerializer(typeof(Service), this.XmlNamespace);
                XmlTextReader xmlReader    = new XmlTextReader(new StringReader(it.Current.OuterXml));
                services.Add((Service)deserialiser.Deserialize(xmlReader));
                xmlReader.Close();
            }
            return(services);
        }
Пример #9
0
        public void Repro()
        {
            string xml = @"
				<root xmlns='mvp-xml'>
					<item>
						<value>25</value>
					</item>
					<item>
						<value>40</value>
					</item>
					<item>
						<value>10</value>
					</item>
				</root>"                ;

            XPathDocument  doc = new XPathDocument(new StringReader(xml));
            XPathNavigator nav = doc.CreateNavigator();

            // Setup namespace resolution.
            XmlNamespaceManager ctx = new XmlNamespaceManager(nav.NameTable);

            ctx.AddNamespace("mvp", "mvp-xml");

            // Create sort expression.
            XPathExpression sort = nav.Compile("mvp:value");

            sort.SetContext(ctx);

            // Setting the sort *after* the context yields no results at all in .NET 1.X
            // but works in .NET 2.0
            XPathExpression items = nav.Compile("//mvp:item");

            items.AddSort(sort, XmlSortOrder.Ascending, XmlCaseOrder.None, String.Empty, XmlDataType.Number);
            items.SetContext(ctx);

            XPathNodeIterator it = doc.CreateNavigator().Select(items);

            Assert.IsTrue(it.MoveNext());

            // The same code but setting the sort *after* the context works fine.
            items = nav.Compile("//mvp:item");
            items.SetContext(ctx);
            items.AddSort(sort, XmlSortOrder.Ascending, XmlCaseOrder.None, String.Empty, XmlDataType.Number);

            it = doc.CreateNavigator().Select(items);
            Assert.IsTrue(it.MoveNext());
        }
Пример #10
0
 private static void PrepareSort(XPathExpression expression, XPathNavigator source,
                                 object sortExpression, IComparer comparer)
 {
     if (sortExpression is string)
     {
         expression.AddSort(
             GetCompiledExpression((string)sortExpression, source), comparer);
     }
     else if (sortExpression is XPathExpression)
     {
         expression.AddSort(sortExpression, comparer);
     }
     else
     {
         throw new XPathException(Properties.Resources.XPathCache_BadSortObject, null);
     }
 }
Пример #11
0
        public static List <Order> LoadXmlCore(XmlDocument doc, bool sortByPayingTime)
        {
            if (null == doc)
            {
                return(null);
            }

            string          xpath = ".//order";
            XPathNavigator  nav   = doc.CreateNavigator();
            XPathExpression exp   = nav.Compile(xpath);

            exp.AddSort(sortByPayingTime ? "@paying_time" : "@deal_time", new DateTimeComparer());
            XPathNodeIterator iterator = nav.Select(exp);

            List <Order> orders = new List <Order>();

            //iterator.Current.att

            while (iterator.MoveNext())
            {
                string   orderId       = iterator.Current.GetAttribute("order_id", string.Empty);
                DateTime dealTime      = DateTime.Parse(iterator.Current.GetAttribute("deal_time", string.Empty));
                string   buyerAccount  = iterator.Current.GetAttribute("buyer_account", string.Empty);
                string   alipayAccount = iterator.Current.GetAttribute("alipay_account", string.Empty);
                Order    order         = new Order(orderId, buyerAccount, alipayAccount, dealTime);
                orders.Add(order);

                order._payingTime             = DateTime.Parse(iterator.Current.GetAttribute("paying_time", string.Empty));
                order._goodsMoney             = float.Parse(iterator.Current.GetAttribute("goods_money", string.Empty));
                order._freight                = float.Parse(iterator.Current.GetAttribute("freight", string.Empty));
                order._totalMoney             = float.Parse(iterator.Current.GetAttribute("total_money", string.Empty));
                order._realPayMoney           = float.Parse(iterator.Current.GetAttribute("real_pay_money", string.Empty));
                order._orderStatus            = (OrderStatus)Enum.Parse(typeof(OrderStatus), iterator.Current.GetAttribute("status", string.Empty));
                order._buyerRemark            = iterator.Current.GetAttribute("buyer_remark", string.Empty);
                order._recipientName          = iterator.Current.GetAttribute("recipient_name", string.Empty);
                order._recipientAddress       = iterator.Current.GetAttribute("recipient_address", string.Empty);
                order._editedRecipientAddress = iterator.Current.GetAttribute("edited_recipient_address", string.Empty);
                order._phoneNumber            = iterator.Current.GetAttribute("phone_number", string.Empty);
                order._mobileNumber           = iterator.Current.GetAttribute("mobile_number", string.Empty);
                order._shipmentNumber         = iterator.Current.GetAttribute("shipment_number", string.Empty);
                order._shipmentCompany        = iterator.Current.GetAttribute("shipment_company", string.Empty);
                order._itemSubject            = iterator.Current.GetAttribute("item_subject", string.Empty);
                order._itemAmount             = int.Parse(iterator.Current.GetAttribute("item_amount", string.Empty));
                order._remark        = iterator.Current.GetAttribute("remark", string.Empty);
                order._closingReason = iterator.Current.GetAttribute("closing_reason", string.Empty);
                order._isPhoneOrder  = bool.Parse(iterator.Current.GetAttribute("is_phone_order", string.Empty));

                if (null != iterator.Current.GetAttribute("prepared", string.Empty))
                {
                    order._prepared = bool.Parse(iterator.Current.GetAttribute("prepared", string.Empty));
                }

                order._items = iterator.Current.GetAttribute("items", string.Empty);
            }

            return(orders);
        }
Пример #12
0
 private static void PrepareSort(XPathExpression expression, XPathNavigator source,
                                 object sortExpression, XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType)
 {
     if (sortExpression is string)
     {
         expression.AddSort(
             GetCompiledExpression((string)sortExpression, source),
             order, caseOrder, lang, dataType);
     }
     else if (sortExpression is XPathExpression)
     {
         expression.AddSort(sortExpression, order, caseOrder, lang, dataType);
     }
     else
     {
         throw new XPathException(Properties.Resources.XPathCache_BadSortObject, null);
     }
 }
Пример #13
0
        public static void Get_Code_Identification(C1TopicBar tpbar)
        {
            XmlNode        root;
            XPathNavigator IdItem;
            XPathNavigator IntituleItem;
            XPathNavigator InspectItem;

            root = mod_global.Get_Codes_Id_DocElement();

            //On utilise un navigateur pour pouvoir trier les noeuds
            XPathNavigator  nav = root.CreateNavigator();
            XPathExpression exp = nav.Compile("//code");

            exp.AddSort("@position", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);

            foreach (XPathNavigator item in nav.Select(exp))
            {
                IdItem = item.SelectSingleNode("id");

                IntituleItem = item.SelectSingleNode("intitule");
                InspectItem  = item.SelectSingleNode("inspection");

                if (InspectItem.GetAttribute("corresp", "") == "")
                {
                    C1.Win.C1Command.C1TopicLink link = new C1.Win.C1Command.C1TopicLink();
                    if (item.GetAttribute("ajoute", "") == "true")
                    {
                        link.Text = string.Concat("** " + IntituleItem.Value, " - ", IdItem.Value);
                    }
                    else
                    {
                        link.Text = string.Concat(IntituleItem.Value, " - ", IdItem.Value);
                    }
                    link.Tag = IdItem.Value;
                    tpbar.FindPageByTag(item.GetAttribute("parent", "")).Links.Add(link);
                }
            }

            /* ANCIEN CODE DE NS (remplacé par GB le 16/12/2009)
             * XmlNodeList nodeList;
             * XmlNode IdNode;
             * XmlNode IntituleNode;
             *
             * //nodeList = root.SelectNodes(string.Concat("//code"));
             *
             * foreach (XmlNode unNode in nodeList)
             * {
             *  IdNode = unNode.SelectSingleNode("id");
             *  IntituleNode = unNode.SelectSingleNode("intitule");
             *
             *  C1.Win.C1Command.C1TopicLink link = new C1.Win.C1Command.C1TopicLink();
             *  link.Text = string.Concat(IntituleNode.InnerText, " - ", IdNode.InnerText);
             *  link.Tag = IdNode.InnerText;
             *  tpbar.FindPageByTag(unNode.Attributes["parent"].InnerText).Links.Add(link);
             * }*/
        }
Пример #14
0
        public static Int32 getMaximumCellColumn(ExcelWorksheet worksheet)
        {
            XPathNavigator  nav = worksheet.WorksheetXml.CreateNavigator();
            XPathExpression exp = nav.Compile("//*[name()='c']/@colNumber");

            exp.AddSort("../@colNumber", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Number);
            XmlNode node = nav.SelectSingleNode(exp).UnderlyingObject as XmlNode;

            return(Convert.ToInt32(node.InnerText));
        }
Пример #15
0
        private static void PrepareSort(XPathExpression expression, XPathNavigator source,
                                        object sortExpression, IComparer comparer)
        {
            var s = sortExpression as string;

            if (s != null)
            {
                expression.AddSort(
                    GetCompiledExpression(s, source), comparer);
            }
            else if (sortExpression is XPathExpression)
            {
                expression.AddSort(sortExpression, comparer);
            }
            else
            {
                throw new XPathException(Resources.XPathCache_BadSortObject, null);
            }
        }
Пример #16
0
 public void AddToExpr(XPathExpression e, XslTransformProcessor p)
 {
     e.AddSort(
         expr,
         orderAvt == null ? order : ParseOrder(orderAvt.Evaluate(p)),
         caseOrderAvt == null ? caseOrder: ParseCaseOrder(caseOrderAvt.Evaluate(p)),
         langAvt == null ? lang : ParseLang(langAvt.Evaluate(p)),
         dataTypeAvt == null ? dataType : ParseDataType(dataTypeAvt.Evaluate(p))
         );
 }
Пример #17
0
        public static void Get_Code_Observation(C1TopicBar tpbar)
        {
            XmlNode        root;
            XPathNavigator IdItem;
            XPathNavigator IntituleItem;

            root = mod_global.Get_Codes_Obs_DocElement();

            //On utilise un navigateur pour pouvoir trier les noeuds
            XPathNavigator  nav = root.CreateNavigator();
            XPathExpression exp = nav.Compile("//code");

            exp.AddSort("@position", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number);

            foreach (XPathNavigator item in nav.Select(exp))
            {
                string ajout = String.Empty;
                ajout        = item.GetAttribute("ajoute", "");
                IdItem       = item.SelectSingleNode("id");
                IntituleItem = item.SelectSingleNode("intitule");

                C1.Win.C1Command.C1TopicLink link = new C1.Win.C1Command.C1TopicLink();

                if (ajout != "true")
                {
                    link.Text = string.Concat(IntituleItem.Value, " - ", IdItem.Value);
                }
                else
                {
                    link.Text = string.Concat("** ", IntituleItem.Value, " - ", IdItem.Value);
                }

                link.Tag = IdItem.Value;

                tpbar.FindPageByTag(IdItem.Value.Substring(0, 2)).Links.Add(link);
            }

            /*
             * XmlNodeList myChildNode;
             *
             * if (mod_inspection.TYPE_OUVRAGE == "REGARD")
             *  myChildNode = Codes_Obs_Regard_Xml.GetElementsByTagName("code");
             * else
             *  myChildNode = Codes_Obs_Cana_Xml.GetElementsByTagName("code");
             *
             * foreach (XmlNode unNode in myChildNode)
             * {
             *  C1.Win.C1Command.C1TopicLink link = new C1.Win.C1Command.C1TopicLink();
             *  link.Text = string.Concat(unNode.ChildNodes[1].InnerText, " - ", unNode.ChildNodes[0].InnerText);
             *  link.Tag = unNode.ChildNodes[0].InnerText;
             *  tpbar.FindPageByTag(unNode.ChildNodes[0].InnerText.Substring(0,2)).Links.Add(link);
             * }*/
        }
        //Generate a file
        static private void GenerateFileContents(XPathNavigator navigator, StreamWriter stream)
        {
            //Sort the nodes to create an ordered file
            XPathExpression expression = navigator.Compile("child::Type");

            expression.AddSort("attribute::FullName ", XmlSortOrder.Ascending, XmlCaseOrder.None, String.Empty, XmlDataType.Text);
            XPathNodeIterator nodeIterator = navigator.Select(expression);

            while (nodeIterator.MoveNext())
            {
                stream.WriteLine(nodeIterator.Current.GetAttribute("FullName", String.Empty));
            }
        }
Пример #19
0
    static void Main(string[] args)
    {
        XPathDocument   saleResults      = new XPathDocument(@"salesData.xml");
        XPathNavigator  navigator        = saleResults.CreateNavigator( );
        XPathExpression selectExpression = navigator.Compile("sales/item");
        XPathExpression sortExpr         = navigator.Compile("@sTime");

        selectExpression.AddSort(sortExpr, new DateTimeComparer());
        XPathNodeIterator nodeIterator = navigator.Select(selectExpression);

        while (nodeIterator.MoveNext( ))
        {
            string checkMe = nodeIterator.Current.Value;
        }
    }
Пример #20
0
        public static int GetRowCount(ExcelWorksheet worksheet)
        {
            var count = 0;

            try
            {
                XPathNavigator  nav = worksheet.WorksheetXml.CreateNavigator();
                XPathExpression exp = nav.Compile("//*[name()='row']/@r");
                exp.AddSort("../@r", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Number);
                XmlNode node = nav.SelectSingleNode(exp).UnderlyingObject as XmlNode;
                int.TryParse(node.InnerText, out count);
            }
            catch { }
            return(count);
        }
        public void Process(ClientContext context, bool add, string path)
        {
            XmlDocument seq = new XmlDocument();

            seq.Load(HostingEnvironment.MapPath("~/" + path));
            XPathNavigator  nav = seq.CreateNavigator();
            XPathExpression exp = nav.Compile(@"/Sequence/Item");

            exp.AddSort("@Order", add ? XmlSortOrder.Ascending : XmlSortOrder.Descending, XmlCaseOrder.None, string.Empty, XmlDataType.Number);
            //XmlNodeList items = seq.SelectNodes("/Sequence/Item");
            foreach (XPathNavigator navItem in nav.Select(exp))
            {
                XmlNode     item = (XmlNode)navItem.UnderlyingObject;
                BaseManager itemManager;
                switch ((Constants.RemoteProvisioningType)Enum.Parse(typeof(Constants.RemoteProvisioningType), item.Attributes[Constants.SequenceItemAttributes.Type].Value))
                {
                case Constants.RemoteProvisioningType.List:
                    itemManager = new ListManager();
                    break;

                case Constants.RemoteProvisioningType.File:
                    itemManager = new FileManager();
                    break;

                case Constants.RemoteProvisioningType.CustomAction:
                    itemManager = new CustomActionsManager();
                    break;

                case Constants.RemoteProvisioningType.Page:
                    itemManager = new PageManager();
                    break;

                case Constants.RemoteProvisioningType.View:
                    itemManager = new ViewManager();
                    break;

                case Constants.RemoteProvisioningType.Theme:
                    itemManager = new ThemeManager();
                    break;

                default:
                    throw new Exception("Not Supported Remote Provisioning Type");
                }
                //process the item according to the type
                itemManager.Process(context, add, HostingEnvironment.MapPath(item.Attributes[Constants.SequenceItemAttributes.Path].Value));
            }
        }
Пример #22
0
        private void OnReload(object sender, EventArgs e)
        {
            trayMenu.Items.Remove(stations);
            stations       = null;
            stations       = new ToolStripMenuItem("Stations");
            stations.Image = Properties.Resources.icons8_radio_2;
            XPathNavigator nav;
            XPathDocument  doc;

            bookmarkList.Clear();
            urlList.Clear();
            groupList.Clear();
            doc = new XPathDocument(path + "\\bookmarks.xml");
            nav = doc.CreateNavigator();
            XPathExpression exp = nav.Compile("bookmarks/group");

            exp.AddSort("@name", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text);
            XPathNodeIterator nodeIterator = nav.Select(exp);

            while (nodeIterator.MoveNext())
            {
                ToolStripMenuItem tmp  = new ToolStripMenuItem(nodeIterator.Current.GetAttribute("name", ""));
                XPathExpression   exp2 = nav.Compile("bookmarks/group[@name='" + nodeIterator.Current.GetAttribute("name", "") + "']/bookmark");
                exp2.AddSort("@name", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Text);
                nav = doc.CreateNavigator();
                XPathNodeIterator nodeIterator2 = nav.Select(exp2);
                while (nodeIterator2.MoveNext())
                {
                    ToolStripMenuItem tmpStation = new ToolStripMenuItem(nodeIterator2.Current.GetAttribute("name", ""), null, new EventHandler(station_click));
                    tmpStation.Tag   = nodeIterator2.Current.GetAttribute("url", "");
                    tmpStation.Image = (nodeIterator2.Current.SelectSingleNode("@img") != null) ? thumb(nodeIterator2.Current.GetAttribute("name", ""), nodeIterator2.Current.GetAttribute("img", ""), "station") : Properties.Resources.icons8_speaker;
                    tmp.DropDownItems.Add(tmpStation);
                    tmp.DropDownDirection = ToolStripDropDownDirection.Left;
                    bookmarkList.Add(nodeIterator2.Current.GetAttribute("name", ""));
                    urlList.Add(nodeIterator2.Current.GetAttribute("url", ""));
                }
                tmp.Image = (nodeIterator.Current.SelectSingleNode("@img") != null) ? thumb(nodeIterator.Current.GetAttribute("name", ""), nodeIterator.Current.GetAttribute("img", ""), "group") : Properties.Resources.icons8_radio_station;
                stations.DropDownItems.Add(tmp);
                groupList.Add(nodeIterator.Current.GetAttribute("name", ""));
            }
            trayMenu.Items.Insert(0, stations);
            addCustom.Visible = (urlList.Contains(currentURL)) ? false : true;
        }
Пример #23
0
        public void Sorted1()
        {
            string expr = "//mvp:titles";

            XPathNavigator      docnav = Document.CreateNavigator();
            XPathExpression     xpath  = docnav.Compile(expr);
            XmlNamespaceManager mgr    = new XmlNamespaceManager(docnav.NameTable);

            mgr.AddNamespace(Globals.MvpPrefix, Globals.MvpNamespace);
            xpath.SetContext(mgr);
            XPathExpression sort = docnav.Compile("mvp:price");

            sort.SetContext(mgr);
            xpath.AddSort(sort, XmlSortOrder.Ascending, XmlCaseOrder.LowerFirst, String.Empty, XmlDataType.Number);

            XPathNodeIterator it = Document.CreateNavigator().Select(xpath);

            DebugUtils.XPathNodeIteratorToConsole(it);

            it = Document.CreateNavigator().Select(xpath);

            it.MoveNext();
            it.Current.MoveToFirstChild();
            string id1 = it.Current.Value;

            XPathNodeIterator cached = XPathCache.SelectSorted(
                expr, Document.CreateNavigator(),
                "mvp:price", XmlSortOrder.Ascending, XmlCaseOrder.LowerFirst, String.Empty, XmlDataType.Number,
                new XmlPrefix(Globals.MvpPrefix, Globals.MvpNamespace, Document.CreateNavigator().NameTable));

            DebugUtils.XPathNodeIteratorToConsole(cached);

            cached = XPathCache.SelectSorted(
                expr, Document.CreateNavigator(),
                "mvp:price", XmlSortOrder.Ascending, XmlCaseOrder.LowerFirst, String.Empty, XmlDataType.Number,
                new XmlPrefix(Globals.MvpPrefix, Globals.MvpNamespace, Document.CreateNavigator().NameTable));

            cached.MoveNext();
            cached.Current.MoveToFirstChild();
            string id2 = cached.Current.Value;

            Assert.AreEqual(id1, id2);
        }
Пример #24
0
    public IList <BLAutot> GetAll()
    {
        try
        {
            if (File.Exists(strFileName))
            {
                // Loading the file into XPath document
                XPathDocument  doc = new XPathDocument(strFileName);
                XPathNavigator nav = doc.CreateNavigator();

                XPathExpression exp = nav.Compile("/Wanhatautot/Auto"); // Getting all autot

                // Sorting the records by aid
                exp.AddSort("aid", System.Xml.XPath.XmlSortOrder.Ascending, System.Xml.XPath.XmlCaseOrder.None, "", System.Xml.XPath.XmlDataType.Text);

                XPathNodeIterator iterator = nav.Select(exp);
                IList <BLAutot>   objAutot = new List <BLAutot>();

                while (iterator.MoveNext())
                {
                    XPathNavigator nav2 = iterator.Current.Clone();

                    BLAutot objAuto = new BLAutot();
                    objAuto.aid             = Convert.ToInt64(nav2.Select("//Auto").Current.SelectSingleNode("aid").InnerXml);
                    objAuto.rekkari         = nav2.Select("//Auto").Current.SelectSingleNode("rekkari").InnerXml;
                    objAuto.merkki          = nav2.Select("//Auto").Current.SelectSingleNode("merkki").InnerXml;
                    objAuto.malli           = nav2.Select("//Auto").Current.SelectSingleNode("malli").InnerXml;
                    objAuto.vm              = Convert.ToInt32(nav2.Select("//Auto").Current.SelectSingleNode("vm").InnerXml);
                    objAuto.myyntiHinta     = Convert.ToInt64(nav2.Select("//Auto").Current.SelectSingleNode("myyntiHinta").InnerXml);
                    objAuto.sisaanOstoHinta = Convert.ToInt64(nav2.Select("//Auto").Current.SelectSingleNode("sisaanOstoHinta").InnerXml);

                    objAutot.Add(objAuto);
                }
                return(objAutot);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        return(null);
    }
Пример #25
0
        /// <summary>
        /// Generate script for recreating objects and return
        /// it to the caller.
        /// </summary>
        /// <returns>Script</returns>
        public static string GetObjectLoadScript()
        {
            string          path   = Path.Combine(UserSettings.GetUpdatePath, "Objects.xml");
            XPathDocument   xmldoc = new XPathDocument(path);
            XPathNavigator  nav    = xmldoc.CreateNavigator();
            XPathExpression expr   = nav.Compile("/database/object");

            expr.AddSort("@priority", XmlSortOrder.Ascending, XmlCaseOrder.None, null, XmlDataType.Number);
            XPathNodeIterator iterator = nav.Select(expr);

            string retval = string.Empty;

            while (iterator.MoveNext())
            {
                XPathNavigator create = iterator.Current.SelectSingleNode("create");
                XPathNavigator drop   = iterator.Current.SelectSingleNode("drop");
                retval += string.Format("{0}\r\nGO\r\n\r\n{1}\r\nGO\r\n\r\n", drop.Value, create.Value);
            }
            return(retval);
        }
Пример #26
0
        private static void PrepareSort(XPathExpression expression, XPathNavigator source,
                                        object sortExpression, IComparer comparer, XmlNamespaceManager context)
        {
            XPathExpression se;

            if (sortExpression is string)
            {
                se = GetCompiledExpression((string)sortExpression, source);
            }
            else if (sortExpression is XPathExpression)
            {
                se = (XPathExpression)sortExpression;
            }
            else
            {
                throw new XPathException(Properties.Resources.XPathCache_BadSortObject, null);
            }

            se.SetContext(context);
            expression.AddSort(se, comparer);
        }
Пример #27
0
        private static string GetObjectLoadScript()
        {
            Assembly        a      = Assembly.GetExecutingAssembly();
            string          path   = Path.Combine(a.Location, "Objects.xml");
            Stream          stream = a.GetManifestResourceStream("OpenCBS.Test._Sql.Objects.xml");
            XPathDocument   xmldoc = new XPathDocument(stream);
            XPathNavigator  nav    = xmldoc.CreateNavigator();
            XPathExpression expr   = nav.Compile("/database/object");

            expr.AddSort("@priority", XmlSortOrder.Ascending, XmlCaseOrder.None, null, XmlDataType.Number);
            XPathNodeIterator iterator = nav.Select(expr);

            string retval = string.Empty;

            while (iterator.MoveNext())
            {
                XPathNavigator create = iterator.Current.SelectSingleNode("create");
                XPathNavigator drop   = iterator.Current.SelectSingleNode("drop");
                retval += string.Format("{0}\r\nGO\r\n\r\n{1}\r\nGO\r\n\r\n", drop.Value, create.Value);
            }
            return(retval);
        }
Пример #28
0
        public static string XMLReportQuery(string className, string ApplicationPath)
        {
            string PathFile   = string.Empty;
            string NameOfFile = string.Empty;
            string strXML     = string.Empty;
            string lClassName = "ClassName";

            System.Configuration.AppSettingsReader appconfig = new System.Configuration.AppSettingsReader();
            NameOfFile = appconfig.GetValue("ConfigurationOfReports", typeof(string)) as string;

            PathFile = Path.GetFullPath(NameOfFile);
            if (!File.Exists(PathFile))
            {
                if (!File.Exists(PathFile))
                {
                    throw (new ArgumentException("File not found: " + PathFile));
                }
            }

            XmlDocument lxmlDoc = new XmlDocument();

            lxmlDoc.Load(PathFile);

            //Open the document and associate a navigator.
            XPathNavigator navXPath = lxmlDoc.CreateNavigator();

            string xpathQuery;             //@"XMLReportQuery/@Name[text() = '" +XMLReportQueryName + "']";

            //Select nodes with the same class name.
            xpathQuery = @"/XMLReportsQuery/XMLReportQuery[@" + lClassName + " = '" + className.Trim() + "']";

            XPathExpression expXPath = navXPath.Compile(xpathQuery);

            //Order the reports by the type of report.
            expXPath.AddSort("@Type", XmlSortOrder.Ascending, XmlCaseOrder.None, string.Empty, XmlDataType.Text);
            XPathNodeIterator itNodes = navXPath.Select(expXPath);

            return(XMLReportsQueryHandler.GetOutXML(itNodes.Clone()));
        }
Пример #29
0
        private static void PrepareSort(XPathExpression expression, XPathNavigator source, object sortExpression,
                                        XmlSortOrder order, XmlCaseOrder caseOrder, string lang, XmlDataType dataType,
                                        XmlNamespaceManager context)
        {
            XPathExpression se;

            if (sortExpression is string s)
            {
                se = GetCompiledExpression(s, source);
            }
            else if (sortExpression is XPathExpression)
            {
                se = (XPathExpression)sortExpression;
            }
            else
            {
                throw new XPathException(Properties.Resources.XPathCache_BadSortObject, null);
            }

            se.SetContext(context);
            expression.AddSort(se, order, caseOrder, lang, dataType);
        }
Пример #30
0
        public void RollbackDependencies()
        {
            XmlDocument manifest = new XmlDocument();

            manifest.Load(FullFileName);

            //emtpy output tags

            foreach (XmlNode oNode in  manifest.SelectNodes("/Skin/Dependencies/Dependency/Properties/Output"))
            {
                oNode.RemoveAll();
            }

            //execute rollback tasks
            XmlNode hNode = manifest.SelectSingleNode("/Skin/History");

            if (!(hNode == null || hNode.SelectNodes("Task").Count == 0))
            {
                XPathNavigator  navigator  = manifest.CreateNavigator();
                XPathExpression expression = navigator.Compile("/Skin/History/Task");

                expression.AddSort("@executed", XmlSortOrder.Descending, XmlCaseOrder.UpperFirst,
                                   string.Empty, XmlDataType.Text);

                XPathNodeIterator iterator = navigator.Select(expression);

                foreach (XPathNavigator item in iterator)
                {
                    Task t = Task.CreateFromXmlNode(((System.Xml.IHasXmlNode)item).GetNode());
                    t.TaskType.RollBack(((System.Xml.IHasXmlNode)item).GetNode().SelectSingleNode("OriginalValue").InnerText);
                }

                hNode.RemoveAll();
            }

            manifest.Save(FullFileName);
        }