示例#1
0
    public AvailabilityRS GetDataChangedate(string SearchID, string hotelcode, string rooms, string checkin, string checkout, string adult, string children, string childrenage, string gc, string CurrencyCode, string b2c_idn)
    {
        //HotelPropertyAj hpr = null;

        AvailabilityRS objAvailabilityRS = new AvailabilityRS();

        //string filePathContext = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + SearchID + "_ContextChange-RS.xml");
        //if (File.Exists(filePathContext))
        //{
        //    ContextResult = File.ReadAllText(filePathContext);
        //}
        //else
        //{
        //    ContextResult = XMLRead.ContextChange(searchid);
        //}


        try
        {
            searchid    = SearchID;
            objfavicons = new ClsFevicons();
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            TextInfo = cultureInfo.TextInfo;
            //string filePathRQ = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_propertydesc_" + hotelcode + "_" + CurrencyCode + "-RS.xml");
            string          filePathRQ = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_propertydesc_" + hotelcode + "_" + CurrencyCode + "_hotelsAvail-RS.xml");
            XmlDataDocument xmldoc     = new XmlDataDocument();
            if (File.Exists(filePathRQ))
            {
                FileStream fs = new FileStream(filePathRQ, FileMode.Open, FileAccess.Read);
                xmldoc.Load(fs);
                fs.Close();
                XmlNode       xnod         = xmldoc.DocumentElement;
                XmlSerializer deserializer = new XmlSerializer(typeof(AvailabilityRS));
                StreamReader  reader       = new StreamReader(filePathRQ);
                objAvailabilityRS = (AvailabilityRS)deserializer.Deserialize(reader);
            }
            else
            {
                DataTable    dssearch = HotelDBLayer.GetSearch(searchid);
                HPDCondition Hapc     = GetCondition(searchid, hotelcode, CurrencyCode);
                result     = gethdata(Hapc, ContextResult, searchid, CurrencyCode, b2c_idn);
                filePathRQ = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_propertydesc_" + hotelcode + "_" + CurrencyCode + "_hotelsAvail-RS.xml");
                FileStream fs = new FileStream(filePathRQ, FileMode.Open, FileAccess.Read);
                xmldoc.Load(fs);
                fs.Close();
                XmlNode       xnod         = xmldoc.DocumentElement;
                XmlSerializer deserializer = new XmlSerializer(typeof(AvailabilityRS));
                StreamReader  reader       = new StreamReader(filePathRQ);
                objAvailabilityRS = (AvailabilityRS)deserializer.Deserialize(reader);
                if (!File.Exists(filePathRQ))
                {
                    File.WriteAllText(filePathRQ, objAvailabilityRS.Xmlns);
                }
            }
        }
        catch { }
        return(objAvailabilityRS);
    }
        public static string GetDataroom(string SearchID, string hotelcode, string CurrencyCode, string b2c_idn)
        {
            string         filePathRQ        = string.Empty;
            AvailabilityRS objAvailabilityRS = new AvailabilityRS();
            ManageHDetAj   objManageHDetAj   = new ManageHDetAj();
            string         result            = string.Empty;


            try
            {
                string      searchid = SearchID;
                ClsFevicons objfavicons;
                objfavicons = new ClsFevicons();
                CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                // TextInfo = cultureInfo.TextInfo;
                //string filePathRQ = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_propertydesc_" + hotelcode + "_" + CurrencyCode + "-RS.xml");
                filePathRQ = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_" + CurrencyCode + "_hotelsAvail-RS.xml");
                XmlDataDocument xmldoc = new XmlDataDocument();
                if (File.Exists(filePathRQ))
                {
                    FileStream fs = new FileStream(filePathRQ, FileMode.Open, FileAccess.Read);
                    xmldoc.Load(fs);
                    fs.Close();
                    XmlNode       xnod         = xmldoc.DocumentElement;
                    XmlSerializer deserializer = new XmlSerializer(typeof(AvailabilityRS));
                    StreamReader  reader       = new StreamReader(filePathRQ);
                    result            = File.ReadAllText(filePathRQ);
                    objAvailabilityRS = (AvailabilityRS)deserializer.Deserialize(reader);
                }
                else
                {
                    DataTable    dssearch = HotelDBLayer.GetSearch(searchid);
                    HPDCondition Hapc     = objManageHDetAj.GetCondition(searchid, hotelcode, CurrencyCode);
                    result     = objManageHDetAj.gethdata(Hapc, ContextResult, searchid, CurrencyCode, b2c_idn);
                    filePathRQ = Path.Combine(HttpRuntime.AppDomainAppPath, "HotelXML/" + searchid + "_propertydesc_" + hotelcode + "_" + CurrencyCode + "_hotelsAvail-RS.xml");
                    FileStream fs = new FileStream(filePathRQ, FileMode.Open, FileAccess.Read);
                    xmldoc.Load(fs);
                    fs.Close();
                    XmlNode       xnod         = xmldoc.DocumentElement;
                    XmlSerializer deserializer = new XmlSerializer(typeof(AvailabilityRS));
                    StreamReader  reader       = new StreamReader(filePathRQ);
                    objAvailabilityRS = (AvailabilityRS)deserializer.Deserialize(reader);

                    result = File.ReadAllText(filePathRQ);
                    if (!File.Exists(filePathRQ))
                    {
                        File.WriteAllText(filePathRQ, objAvailabilityRS.Xmlns);
                    }
                }
            }
            catch { }
            return(result);
        }
        private void InsertDataToTable(string tableName, string filePath)
        {
            XmlDataDocument xmlDoc = new XmlDataDocument();
            SqlCommand      cmd    = new SqlCommand();

            try
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    if (fs != null)
                    {
                        xmlDoc.Load(fs);
                        XmlNodeList NodeList = xmlDoc.GetElementsByTagName("Item");
                        for (int i = 0; i < NodeList.Count; i++)
                        {
                            //string ID = NodeList[i];
                            cmd = SetParameters(tableName, NodeList[i]);
                            ExecuteInsertSQL(cmd);
                            if (!string.IsNullOrEmpty(this.Error.Text.ToString()))
                            {
                                continue;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.Error.Text = ex.Message;
            }
            finally
            {
                cmd.Dispose();
            }
        }
示例#4
0
        public void EditingXmlTree()
        {
            XmlDataDocument doc = new XmlDataDocument();

            doc.DataSet.ReadXmlSchema("Test/System.Xml/region.xsd");
            doc.Load("Test/System.Xml/region.xml");

            XmlElement Element = doc.GetElementFromRow(doc.DataSet.Tables [0].Rows [1]);

            Element.FirstChild.InnerText = "64";
            Assert.AreEqual("64", doc.DataSet.Tables [0].Rows [1] [0], "test#01");

            DataSet Set = new DataSet();

            Set.ReadXml("Test/System.Xml/region.xml");
            doc = new XmlDataDocument(Set);

            Element = doc.GetElementFromRow(doc.DataSet.Tables [0].Rows [1]);
            Assert.IsNotNull(Element);

            try {
                Element.FirstChild.InnerText = "64";
                Assert.Fail("test#02");
            } catch (InvalidOperationException) {
            }

            Assert.AreEqual("2", doc.DataSet.Tables [0].Rows [1] [0], "test#05");

            Set.EnforceConstraints       = false;
            Element.FirstChild.InnerText = "64";
            Assert.AreEqual("64", doc.DataSet.Tables [0].Rows [1] [0], "test#06");
        }
示例#5
0
    public void loaddata()
    {
        XmlDataDocument xml = new XmlDataDocument();

        xml.Load(Server.MapPath("~/" + "main.xml"));

        XmlNodeList nodes = xml.SelectSingleNode("tss").ChildNodes;

        DataTable dt = new DataTable();

        dt.Columns.Add("index", typeof(string));
        dt.Columns.Add("src", typeof(string));
        dt.Columns.Add("href", typeof(string));
        dt.Columns.Add("target", typeof(string));

        foreach (XmlNode node in nodes)
        {
            DataRow row = dt.NewRow();

            row["index"]  = node.Attributes["index"].Value;
            row["src"]    = node.Attributes["src"].Value;
            row["href"]   = node.Attributes["href"].Value;
            row["target"] = node.Attributes["target"].Value;



            dt.Rows.Add(row);
        }

        GridView1.DataSource = dt;
        GridView1.DataBind();
    }
示例#6
0
        /// <summary>
        /// Khởi tạo file ngôn ngữ xml
        /// </summary>
        /// <param name="FileName">Nhập tên file(ko có đuôi .xml)</param>
        public LanguageXML(String FileName)
        {
            String Name = Globals.GetPhysicalUploadsUrl() + "/LanguageFiles/" + FileName + ".xml";

            X = new XmlDataDocument();
            X.Load(Name);
        }
示例#7
0
        public static Settings ImportSettings()
        {
            string          str             = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TumblRipper"), "Settings.xml");
            ImporterLoading importerLoading = new ImporterLoading();
            Settings        setting         = new Settings();
            XmlDataDocument xmlDataDocument = new XmlDataDocument();
            int             i = 0;

            xmlDataDocument.Load(new FileStream(str, FileMode.Open, FileAccess.Read));
            XmlNodeList elementsByTagName = xmlDataDocument.GetElementsByTagName("string");

            importerLoading.setTotal(elementsByTagName.Count);
            importerLoading.Show();
            for (i = 0; i < elementsByTagName.Count; i++)
            {
                importerLoading.setLoading(elementsByTagName[i].InnerText);
                Website website = ImporterV1.ImportFromTumblr(elementsByTagName[i].InnerText);
                if (website != null)
                {
                    setting.Sites.Add(website);
                }
            }
            importerLoading.Close();
            importerLoading.Dispose();
            setting.SaveSettings();
            return(setting);
        }
示例#8
0
        public ActionResult FactFindData()
        {
            var        xmldoc = new XmlDataDocument();
            string     path   = HttpContext.Server.MapPath("~/App_Data/FactFind.xml");
            FileStream fs     = new FileStream(path, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            fs.Close();
            fs.Dispose();

            var Asset       = xmldoc.GetElementsByTagName("Asset")[0].InnerXml;
            var Expenditure = xmldoc.GetElementsByTagName("Expenditure")[0].InnerXml;
            var Income      = xmldoc.GetElementsByTagName("Income")[0].InnerXml;
            var Liablity    = xmldoc.GetElementsByTagName("Liablity")[0].InnerXml;
            var StudentId   = Guid.Parse(xmldoc.GetElementsByTagName("StudentId")[0].InnerXml);

            var FactFind = new List <object>();

            FactFind.Add(new { y = Asset, legendText = "Asset", indexLabel = "Asset" });
            FactFind.Add(new { y = Expenditure, legendText = "Expenditure", indexLabel = "Expenditure" });
            FactFind.Add(new { y = Income, legendText = "Income", indexLabel = "Income" });
            FactFind.Add(new { y = Liablity, legendText = "Liablity", indexLabel = "Liablity" });

            JavaScriptSerializer jss = new JavaScriptSerializer();

            string output = jss.Serialize(FactFind);

            return(Json(output, JsonRequestBehavior.AllowGet));
        }
示例#9
0
        public void AddLink(string title, string uri)
        {
            XmlDocument doc = new XmlDataDocument();

            doc.Load("RssLinks.xml");
            XmlNode rootNode = doc.SelectSingleNode("links");

            XmlNode linkNode = doc.CreateElement("link");

            XmlNode titleNode = doc.CreateElement("title");
            XmlText titleText = doc.CreateTextNode(title);

            titleNode.AppendChild(titleText);

            XmlNode uriNode = doc.CreateElement("uri");
            XmlText uriText = doc.CreateTextNode(uri);

            uriNode.AppendChild(uriText);

            XmlNode defaultshowNode = doc.CreateElement("defaultshow");
            XmlText defaultshowText = doc.CreateTextNode("false");

            defaultshowNode.AppendChild(defaultshowText);

            linkNode.AppendChild(titleNode);
            linkNode.AppendChild(uriNode);
            linkNode.AppendChild(defaultshowNode);

            rootNode.AppendChild(linkNode);

            doc.Save("RssLinks.xml");
        }
示例#10
0
        private void LoadFSM(string config)
        {
            System.Xml.XmlDataDocument doc = new XmlDataDocument();
            doc.Load(config);

            FSM_State state = new FSM_State();

            foreach (XmlNode node in doc.GetElementsByTagName("State"))
            {
                state.nextPossibleStates = new List <String>();
                foreach (XmlNode child in node.ChildNodes)
                {
                    if (child.Name == "StateName")
                    {
                        state.name = child.InnerText;
                    }
                    else if (child.Name == "NextPossibleState")
                    {
                        state.nextPossibleStates.Add(child.InnerText);
                    }
                }
                statesList.Add(state);
            }
            //states = new AllPosibleStates(this.statesList.ToArray());
        }
示例#11
0
 /// <summary>
 /// 向指定用户发送消息
 /// </summary>
 /// <param name="msg">要发送的消息内容</param>
 /// <param name="ToWho">要发送消息的目标用户</param>
 /// <returns>返回发送结果是成功还是失败</returns>
 private void MessageSend()
 {
     try
     {
         string      TOIpNumber = "";
         CheckOutNum NAN        = new CheckOutNum(ToWho);
         this.ToIpName = NAN.QQname;
         this.MSG      = msg;
         TOIpNumber    = NAN.QQnumber;
         XmlDataDocument Xml = new XmlDataDocument();
         Xml.Load("online.dat");
         XmlNode root = Xml.SelectSingleNode("root");
         for (int i = 0; i < root.ChildNodes.Count; i++)
         {
             if (root.ChildNodes[i].ChildNodes[0].InnerText.Trim() == TOIpNumber.Trim())
             {
                 this.IpEndPoint = root.ChildNodes[i].ChildNodes[1].InnerText.Trim();
                 break;
             }
         }
         CheckOutIpPoint IEP  = new CheckOutIpPoint(IpEndPoint);
         TcpClient       Send = new TcpClient();
         Send.Connect(IEP.IpAdd, 5281);
         Stream       stm  = Send.GetStream();
         UTF8Encoding asen = new UTF8Encoding();
         byte[]       ba   = asen.GetBytes("2;" + ShareDate.ThisUser.Trim() + ";" + MSG);  //参数格式为(标识;原用户;消息内容)
         stm.Write(ba, 0, ba.Length);
         Send.Close();
         result = true;
     }
     catch
     {
         result = false;
     }
 }
示例#12
0
        private void load_xml()
        {
            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList     xmlnode;
            int             i  = 0;
            FileStream      fs = new FileStream(xmlPath, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            xmlnode = xmldoc.GetElementsByTagName("sprite");
            for (i = 0; i <= xmlnode.Count - 1; i++)
            {
                var sprite = new Sprite();

                string n  = xmlnode[i].Attributes.GetNamedItem("n").Value;
                string x  = xmlnode[i].Attributes.GetNamedItem("x").Value;
                string y  = xmlnode[i].Attributes.GetNamedItem("y").Value;
                string w  = xmlnode[i].Attributes.GetNamedItem("w").Value;
                string h  = xmlnode[i].Attributes.GetNamedItem("h").Value;
                string px = xmlnode[i].Attributes.GetNamedItem("pX").Value;
                string py = xmlnode[i].Attributes.GetNamedItem("pY").Value;

                sprite.n  = n;
                sprite.x  = int.Parse(x);
                sprite.y  = int.Parse(y);
                sprite.w  = int.Parse(w);
                sprite.h  = int.Parse(h);
                sprite.px = float.Parse(px);
                sprite.py = float.Parse(py);

                sheet.sprites.Add(sprite);
            }
        }
    private void GetData()
    {
        XmlDataDocument xmlDataDoc = new XmlDataDocument();

        xmlDataDoc.Load(Server.MapPath("~/Files/XMLFile.xml"));
        List <Markers> markers = new List <Markers>();

        foreach (XmlNode n in xmlDataDoc.DocumentElement.GetElementsByTagName("Property"))
        {
            if (n.HasChildNodes)
            {
                foreach (XmlNode childNode in n)
                {
                    if (childNode.Name == "GEOData")
                    {
                        Markers loObj = new Markers();
                        loObj.City      = Convert.ToString(childNode.Attributes["City"].Value);
                        loObj.Longitude = Convert.ToString(childNode.Attributes["Longitude"].Value);
                        loObj.Latitude  = Convert.ToString(childNode.Attributes["Latitude"].Value);
                        markers.Add(loObj);
                    }
                }
            }
        }
        if (markers != null && markers.Count > 0)
        {
            rptMarkers.DataSource = markers;
            rptMarkers.DataBind();
        }
    }
示例#14
0
        static public XmlNode Load(string filename)
        {
            XmlDataDocument doc = new XmlDataDocument();

            doc.Load(filename);
            return(doc);
        }
示例#15
0
        void readData()
        {
            XmlDataDocument xmldoc = new XmlDataDocument();

            FileStream fs = new FileStream("D:/Projects/WFormCP/WFormProjects/WFormP/UserReg/XMLReader/XMLReader/userFile.xml", FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            XmlNodeList xmlnode = xmldoc.GetElementsByTagName("User");

            //User newUser = new User();

            for (int i = 0; i <= xmlnode.Count - 1; i++)
            {
                /*xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                 * str = xmlnode[i].ChildNodes.Item(0).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(1).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(2).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(3).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(4).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(5).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(5).InnerText.Trim() + "  " + xmlnode[i].ChildNodes.Item(6).InnerText.Trim();
                 * MessageBox.Show(str);*/
                User newUser = new User();
                newUser.firstName   = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                newUser.lastName    = xmlnode[i].ChildNodes.Item(1).InnerText.Trim();
                newUser.Gender      = xmlnode[i].ChildNodes.Item(2).InnerText.Trim();
                newUser.EmailID     = xmlnode[i].ChildNodes.Item(3).InnerText.Trim();
                newUser.PhoneNumber = long.Parse(xmlnode[i].ChildNodes.Item(4).InnerText.Trim());
                newUser.State       = xmlnode[i].ChildNodes.Item(5).InnerText.Trim();
                newUser.Country     = xmlnode[i].ChildNodes.Item(6).InnerText.Trim();
                userList.Add(newUser);
            }
        }
        private void ReadDB()
        {
            //for database
            //preparing
            XmlDataDocument xmlDoc = new XmlDataDocument();
            XmlNodeList     xmlNode;

            database = new List <Item>();
            try
            {
                //read
                FileStream fs = new FileStream(@".\database.xml", FileMode.Open, FileAccess.Read);
                xmlDoc.Load(fs);
                xmlNode = xmlDoc.GetElementsByTagName("Item");
                foreach (XmlNode node in xmlNode)                       //parse into list
                {
                    Item item = new Item();
                    item.Id    = XmlConvert.ToInt32(node.ChildNodes.Item(0).InnerText.Trim());
                    item.Type  = node.ChildNodes.Item(1).InnerText.Trim();
                    item.Stock = XmlConvert.ToInt32(node.ChildNodes.Item(2).InnerText.Trim());
                    item.Price = XmlConvert.ToInt32(node.ChildNodes.Item(3).InnerText.Trim());
                }
                Console.WriteLine("Server finised reading database");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("Database not found");
            }
        }
示例#17
0
        public int ReadXMLTime(string putanja)
        {
            bool uspesno = false;

            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList     xmlnode;
            int             i    = 0;
            int             text = 0;
            string          str  = null;
            FileStream      fs   = new FileStream(putanja, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            xmlnode = xmldoc.GetElementsByTagName("note");
            for (i = 0; i <= xmlnode.Count - 1; i++)
            {
                uspesno = true;
                xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                str  = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                text = int.Parse(str);
            }

            fs.Close();

            return(text);
        }
        /// <summary>
        /// Return a list of enrollments from the files
        /// </summary>
        /// <returns>Enrollments</returns>
        public List <Enrollment> Extract_Enrollments()
        {
            this.Enrollments = new List <Enrollment>();
            foreach (var file in Files)
            {
                string filename = file.Substring(file.LastIndexOf(@"\")).Replace(@"\", "");
                filename = filename.Replace("user_", "");
                filename = filename.Replace(".xml", "");
                int             enrollNo = Convert.ToInt32(filename);
                XmlDataDocument xmldoc   = new XmlDataDocument();
                XmlNodeList     xmlnode;
                int             i   = 0;
                string          str = null;
                FileStream      fs  = new FileStream(file, FileMode.Open, FileAccess.Read);
                xmldoc.Load(fs);
                xmlnode = xmldoc.GetElementsByTagName("name");
                string name = "";
                for (i = 0; i <= xmlnode.Count - 1; i++)
                {
                    try
                    {
                        name = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                    }
                    catch (Exception exc)
                    {
                    }
                }

                Enrollments.Add(new Enrollment {
                    Enrollment_No = enrollNo, Name = name, XML_File = file
                });
            }
            return(Enrollments);
        }
示例#19
0
        void get_languages()
        {
            //find and load language files in to menu toolstrip
            ToolStrip language_menu = new ToolStrip();
            var       enviroment    = System.Environment.CurrentDirectory;

            string[] fileEntries = Directory.GetFiles(enviroment + "\\languages");


            ToolStripMenuItem[] items = new ToolStripMenuItem[fileEntries.Length];
            int i = 0;

            foreach (string fileName in fileEntries)
            {
                string          name   = Path.GetFileName(fileName);
                XmlDataDocument xmldoc = new XmlDataDocument();
                XmlNodeList     xmlnode;
                FileStream      fs = new FileStream(enviroment + "\\languages\\" + name, FileMode.Open, FileAccess.Read);
                xmldoc.Load(fs);
                xmlnode = xmldoc.GetElementsByTagName("language");
                string lang_text = xmlnode[0].ChildNodes.Item(0).InnerText.Trim();

                items[i]        = new ToolStripMenuItem();
                items[i].Text   = lang_text + " (" + name.Replace(".xml", "") + ")";
                items[i].Tag    = name.Replace(".xml", "");
                items[i].Click += new EventHandler(LanguageItemClickHandler);
                i++;
            }
            this.mnuLanguage.DropDownItems.AddRange(items);
        }
示例#20
0
        public static void BuildEntryDatabase()
        {
            XmlDataDocument AccessoryTable = new XmlDataDocument();

            AccessoryTable.Load(GlobalSettings.Default.StartupPath + "packingslips\\accessorytable.xml");

            XmlNodeList NodeList = AccessoryTable.GetElementsByTagName("DefineAssetString");

            AccessoryFilter = new Filter <ulong>(NodeList.Count, 0.01f, delegate(ulong Input) { return(0); });

            foreach (XmlNode Node in NodeList)
            {
                ulong ID = Convert.ToUInt64(Node.Attributes["assetID"].Value, 16);
                AccessoryFilter.Add(ID);
            }

            XmlDataDocument AnimTable = new XmlDataDocument();

            AnimTable.Load(GlobalSettings.Default.StartupPath + "packingslips\\animtable.xml");

            NodeList   = AnimTable.GetElementsByTagName("DefineAssetString");
            AnimFilter = new Filter <ulong>(NodeList.Count, 0.01f, delegate(ulong Input) { return(0); });

            foreach (XmlNode Node in NodeList)
            {
                ulong ID = Convert.ToUInt64(Node.Attributes["assetID"].Value, 16);
                AnimFilter.Add(ID);
            }
        }
示例#21
0
        public static XMLFile LoadFile(string filename)
        {
            XmlDataDocument doc = new XmlDataDocument();

            doc.Load(filename);
            return(new XMLFile(doc));
        }
        private void readDB()
        {
            //for database
            //preparing
            XmlDataDocument xmlDoc = new XmlDataDocument();
            XmlNodeList     xmlNode;

            database = new List <Item>();
            //read
            FileStream fs = new FileStream(@".\database.xml", FileMode.Open, FileAccess.Read);

            xmlDoc.Load(fs);
            xmlNode = xmlDoc.GetElementsByTagName("Item");
            foreach (XmlNode node in xmlNode)                   //parse into list
            {
                Item item = new Item();
                item.Id    = XmlConvert.ToInt32(node.ChildNodes.Item(0).InnerText.Trim());
                item.Type  = node.ChildNodes.Item(1).InnerText.Trim();
                item.Stock = XmlConvert.ToInt32(node.ChildNodes.Item(2).InnerText.Trim());
                item.Price = XmlConvert.ToInt32(node.ChildNodes.Item(3).InnerText.Trim());
            }

            //for customer order
            order = new List <Item>();
        }
示例#23
0
        private string TransformXML(string sXML, string XSLPath)
        {
            XmlDataDocument oXML = new XmlDataDocument();
            //XPathDocument oXSL = new XPathDocument(XSLPath);

            XslCompiledTransform oTransform = new XslCompiledTransform();
            XsltArgumentList     xslArg     = new XsltArgumentList();
            string sMessage;

            //oXML.Load(new XmlTextReader(sXML, XmlNodeType.Document, null));
            oXML.Load(sXML);
            XPathNavigator nav = oXML.CreateNavigator();

            oTransform.Load(XSLPath);

            try
            {
                System.IO.MemoryStream oText    = new System.IO.MemoryStream();
                XmlTextWriter          xmlWrite = new XmlTextWriter(oText, System.Text.Encoding.UTF8);
                oTransform.Transform(nav, xmlWrite);
                xmlWrite.Flush();
                oText.Flush();
                oText.Position = 1;
                System.IO.StreamReader sr = new System.IO.StreamReader(oText);
                sMessage = sr.ReadToEnd();
                oText.Close();
                return(sMessage);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#24
0
        public static XmlDataDocument GetXML(string sqlQuery)
        {
            // create a cache key
            StringBuilder cacheKey = new StringBuilder();

            XmlDataDocument xmlDocument   = new XmlDataDocument();                      // xml document to hold return values
            SqlConnection   sqlConnection = new SqlConnection();                        // SQL Connection to retrieve data
            XmlReader       xmlReader;                                                  // xml reader to return data as xml

            // open the connection
            sqlConnection.ConnectionString = ConnectionString;
            sqlConnection.Open();

            // set the command to execute on SQL
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Connection     = sqlConnection;
            sqlCommand.CommandType    = CommandType.Text;
            sqlCommand.CommandText    = sqlQuery;
            sqlCommand.CommandTimeout = _sqlConnTimeout;

            // return the data as XML
            xmlReader = sqlCommand.ExecuteXmlReader();

            // load the data into the xml document
            xmlDocument.Load(xmlReader);

            // close the connection
            sqlConnection.Close();

            // return the retrieved XML
            return(xmlDocument);
        }
示例#25
0
        public static List <string> ReadXml(string TextFile, string Root, string Username = "")
        {
            List <string>   strings = new List <string>();
            XmlDataDocument xmldoc  = new XmlDataDocument();
            XmlNodeList     xmlnode;
            FileStream      fs = new FileStream(TextFile, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            xmlnode = xmldoc.GetElementsByTagName(Root);
            if (Username != "")
            {
                for (int i = 0; i <= xmlnode.Count - 1; i++)
                {
                    string str = null;
                    if (xmlnode[i].ChildNodes.Item(0).InnerText.StartsWith(Username))
                    {
                        for (var j = 0; j < xmlnode[i].ChildNodes.Item(0).ChildNodes.Count; j++)
                        {
                            str += (xmlnode[i].ChildNodes.Item(0).ChildNodes.Item(j).InnerText + "|");
                        }
                        strings.Add(str);
                    }
                }
            }
            return(strings);
        }
示例#26
0
        public ActionResult Index(string type)
        {
            SaveCareerType(type);

            FactFindViewModel model = new FactFindViewModel();

            var         xmldoc = new XmlDataDocument();
            XmlNodeList xmlnode;
            XmlNode     node;

            string     path = HttpContext.Server.MapPath("~/App_Data/FactFind.xml");
            FileStream fs   = new FileStream(path, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            fs.Close();
            fs.Dispose();
            node    = xmldoc.SelectSingleNode("StudentId");
            xmlnode = xmldoc.GetElementsByTagName("StudentId");
            Guid studentId = Guid.Parse(xmlnode[0].InnerText);

            model.Asset       = xmldoc.GetElementsByTagName("Asset")[0].InnerXml;
            model.Expenditure = xmldoc.GetElementsByTagName("Expenditure")[0].InnerXml;
            model.Income      = xmldoc.GetElementsByTagName("Income")[0].InnerXml;
            model.Liablity    = xmldoc.GetElementsByTagName("Liablity")[0].InnerXml;

            return(View(model));
        }
示例#27
0
        // Methods
        public void ExportTOKhai(string template, string fileName)
        {
            XmlDataDocument document = new XmlDataDocument();

            document.Load(template);
            document.Save(fileName);
        }
示例#28
0
        public void loadXmlToDataTable()
        {
            //Instantiate the public datatabe myDate and add its columns
            myData = new DataTable();
            myData.Columns.Add("Error");
            myData.Columns.Add("Solution");
            myData.PrimaryKey = new DataColumn[] { myData.Columns["Error"] };
            //Set path to the XML document = the apps runtime directory so its the same for all users
            string xmlDocPath = AppDomain.CurrentDomain.BaseDirectory + "Ref/ErrorCodes.xml";
            //Create new xmldoc object and parse all of the nodes within it
            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList     xmlnode;

            xmlnode = xmldoc.GetElementsByTagName("ErrorCodes");
            //Setup filestream that will read out the xmldoc and parse out the needed data
            FileStream fs = new FileStream(xmlDocPath, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);

            int i;

            //Loop thorugh each ErrorCodes node in the doc and collect the error code, and the solution/meaning of the error
            for (i = 0; i <= xmlnode.Count - 1; i++)
            {
                //Insert the error code and solution/meaning into the global datatable
                myData.Rows.Add(xmlnode[i].ChildNodes.Item(1).InnerText, xmlnode[i].ChildNodes.Item(2).InnerText);
            }
            //Set the datagridview's datasource to the datatable we just populated
            dgDisplay.DataSource = myData;
            //Aaaaand we're done! (f**k office 365)
        }//End loadXmlToDataTable
示例#29
0
        public void Navigator()
        {
            XmlDataDocument doc = new XmlDataDocument();

            doc.DataSet.ReadXmlSchema("Test/System.Xml/region.xsd");
            doc.Load("Test/System.Xml/region.xml");

            XPathNavigator Nav = doc.CreateNavigator();

            Nav.MoveToRoot();
            Nav.MoveToFirstChild();

            Assert.AreEqual("Root", Nav.Name.ToString(), "test#01");
            Assert.AreEqual(string.Empty, Nav.NamespaceURI.ToString(), "test#02");
            Assert.AreEqual("False", Nav.IsEmptyElement.ToString(), "test#03");
            Assert.AreEqual("Element", Nav.NodeType.ToString(), "test#04");
            Assert.AreEqual(string.Empty, Nav.Prefix, "test#05");

            Nav.MoveToFirstChild();
            Nav.MoveToNext();
            Assert.AreEqual("Region", Nav.Name.ToString(), "test#06");

            Assert.AreEqual("2Western", Nav.Value.Substring(0, Nav.Value.IndexOf("\n") - 1), "test#07");
            Nav.MoveToFirstChild();
            Assert.AreEqual("2", Nav.Value, "test#08");
            Nav.MoveToRoot();
            Assert.AreEqual("Root", Nav.NodeType.ToString(), "test#09");
        }
示例#30
0
        public async Task <Dictionary <string, string> > GetDBCredentials()
        {
            Dictionary <string, string> credentialList = new Dictionary <string, string>();

            try
            {
                XmlDataDocument xmldoc = new XmlDataDocument();
                XmlNodeList     xmlnode;
                string          serverName = null;
                string          dbName     = null;
                string          userId     = null;
                string          filePath   = HttpContext.Current.Server.MapPath("~/Settings/DBServerCredentials.xml");
                FileStream      fs         = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                xmldoc.Load(fs);
                xmlnode = xmldoc.GetElementsByTagName("Credentials");
                for (int i = 0; i <= xmlnode.Count - 1; i++)
                {
                    credentialList.Add("serverName", xmlnode[i].ChildNodes.Item(0).InnerText.Trim());
                    credentialList.Add("dbName", xmlnode[i].ChildNodes.Item(1).InnerText.Trim());
                    credentialList.Add("userId", xmlnode[i].ChildNodes.Item(2).InnerText.Trim());
                    credentialList.Add("password", xmlnode[i].ChildNodes.Item(3).InnerText.Trim());
                }
                fs.Close();
                fs.Dispose();
            }
            catch { }
            return(credentialList);
        }