Пример #1
0
        public static PDDLModel LoadPDDLModelFromXML(string text)
        {
            PDDLModel       pddlModel = new PDDLModel();
            XmlDataDocument doc       = new XmlDataDocument();

            doc.LoadXml(text);

            XmlNodeList sitesNodes = doc.GetElementsByTagName(Parsing.PDDL_MODEL_NODE_NAME);

            pddlModel.SystemName = sitesNodes[0].ChildNodes[0].InnerText;

            sitesNodes = doc.GetElementsByTagName(Parsing.DOMAIN_NODE_NAME);

            if (sitesNodes[0].HasChildNodes)
            {
                var nameNode = ((XmlElement)sitesNodes[0]).GetElementsByTagName(Parsing.PDDL_FILE_NAME_TAG);
                var pathNode = ((XmlElement)sitesNodes[0]).GetElementsByTagName(Parsing.PDDL_FILE_PATH_TAG);
                var content  = ReadFile(pathNode[0].InnerText);
                pddlModel.Domain = new PDDLFile(nameNode[0].InnerText, pathNode[0].InnerText, content);
            }
            //pddlModel.Domain = sitesNodes[0].ChildNodes[0].InnerText;

            sitesNodes = doc.GetElementsByTagName(Parsing.PROBLEM_NAME);

            if (sitesNodes.Count > 0)
            {
                int i = 0;
                foreach (XmlElement component in sitesNodes)
                {
                    i++;
                    string fName, fPath;

                    XmlNodeList problemName = component.GetElementsByTagName(Parsing.PDDL_FILE_NAME_TAG);

                    if (problemName == null || problemName.Count < 1)
                    {
                        fName = "problem" + i;
                    }
                    else
                    {
                        fName = problemName[0].InnerText;
                    }

                    XmlNodeList problemPath = component.GetElementsByTagName(Parsing.PDDL_FILE_PATH_TAG);
                    if (problemPath == null || problemPath.Count < 1)
                    {
                        fPath = "";
                    }
                    else
                    {
                        fPath = problemPath[0].InnerText;
                    }

                    string pddlContent = ReadFile(fPath);
                    pddlModel.AddProblem(new PDDLFile(fName, fPath, pddlContent));
                }
            }

            return(pddlModel);
        }
Пример #2
0
        public IDictionary <String, String> getLatLong(String zipCode)
        {
            XmlDataDocument doc  = new XmlDataDocument();
            List <String>   data = new List <String>();
            String          url  = "http://maps.googleapis.com/maps/api/geocode/xml?address=" + zipCode;

            doc.Load(url);

            XmlNodeList status     = doc.GetElementsByTagName("status");
            String      res_status = status[0].InnerText;

            if (!res_status.Equals("OK"))
            {
                data.Add("No Result");
            }

            XmlNodeList result = doc.GetElementsByTagName("result");
            XmlNodeList list = null, location = null;

            String latitude = null, longitude = null;

            for (int i = 0; i < result.Count; i++)
            {
                list = doc.GetElementsByTagName("geometry");
            }
            for (int i = 0; i < list.Count; i++)
            {
                location = doc.GetElementsByTagName("location");
            }

            latitude  = location[0].SelectSingleNode("lat").InnerText;
            longitude = location[0].SelectSingleNode("lng").InnerText;
            return(getWeatherData(latitude, longitude));
        }
Пример #3
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));
        }
Пример #4
0
        public IDictionary <String, String> getWeatherData(String lat, String lon)
        {
            XmlDataDocument doc = new XmlDataDocument();
            IDictionary <String, String> data = new Dictionary <String, String>();
            String url = "http://api.openweathermap.org/data/2.5/forecast/daily?lat=" + lat + "&lon=" + lon + "&cnt=5&mode=xml";

            doc.Load(url);

            XmlNodeList locationList = doc.GetElementsByTagName("location");
            XmlNodeList foreCastList = doc.GetElementsByTagName("time");

            data["City"]    = locationList[0].SelectSingleNode("name").InnerText;
            data["Country"] = locationList[0].SelectSingleNode("country").InnerText;

            String temperature, wind, clouds;

            for (int i = 0; i < 5; i++)
            {
                temperature = "Temperature : Morn = " + foreCastList[i].SelectSingleNode("temperature").Attributes["morn"].Value +
                              ",Evening = " + foreCastList[i].SelectSingleNode("temperature").Attributes["eve"].Value + ",Night = " + foreCastList[i].SelectSingleNode("temperature").Attributes["night"].Value;
                wind   = "Wind : " + foreCastList[i].SelectSingleNode("windSpeed").Attributes["name"].Value;
                clouds = "Clouds : " + foreCastList[i].SelectSingleNode("clouds").Attributes["value"].Value;

                data[foreCastList[i].Attributes["day"].Value] = temperature + " | " + wind + " | " + clouds;
            }
            return(data);
        }
Пример #5
0
        public static BPELModel LoadLTSFromXML(string text)
        {
            BPELModel       lts = new BPELModel();
            XmlDataDocument doc = new XmlDataDocument();


            doc.LoadXml(text);

            XmlNodeList sitesNodes = doc.GetElementsByTagName(Parsing.ASSERTION_NODE_NAME);

            foreach (XmlElement component in sitesNodes)
            {
                lts.Assertion = component.InnerText;
            }

            sitesNodes = doc.GetElementsByTagName(Parsing.FILE_NODE_NAME);

            if (sitesNodes.Count > 0)
            {
                foreach (XmlElement component in sitesNodes)
                {
                    lts.AddPath(component.GetAttribute(Parsing.PATH_ATTR_NODE_NAME));
                }
            }

            return(lts);
        }
Пример #6
0
        public static ZapReportXml Converter(string CaminhoXml)
        {
            var             zapReportXml = new ZapReportXml();
            XmlDataDocument xmldoc       = new XmlDataDocument();
            XmlNodeList     xmlnode;
            FileStream      fs = new FileStream(CaminhoXml, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);

            xmlnode = xmldoc.GetElementsByTagName("site");
            zapReportXml.NomeSite = xmlnode[0].Attributes["host"].Value;

            xmlnode = xmldoc.GetElementsByTagName("alertitem");
            for (int i = 0; i <= xmlnode.Count - 1; i++)
            {
                var descricaoAlerta = xmlnode[i].ChildNodes.Item(1).InnerText.Trim();
                var qtdeOcorrencias = xmlnode[i].ChildNodes.Item(8).InnerText.Trim();

                zapReportXml.Alertas.Add(new Alerta()
                {
                    NomeAlerta     = descricaoAlerta,
                    QtdOcorrencias = Convert.ToInt32(qtdeOcorrencias)
                });
            }
            fs.Close();
            return(zapReportXml);
        }
Пример #7
0
        public static LTSModel LoadLTSFromXML(string text)
        {
            LTSModel lts = new LTSModel();

            XmlDataDocument doc = new XmlDataDocument();

            doc.LoadXml(text);

            XmlNodeList sitesNodes = doc.GetElementsByTagName(Parsing.DECLARATION_NODE_NAME);

            foreach (XmlElement component in sitesNodes)
            {
                lts.Declaration = component.InnerText;
            }

            sitesNodes = doc.GetElementsByTagName(Parsing.PROCESSES_NODE_NAME);
            if (sitesNodes.Count > 0)
            {
                foreach (XmlElement component in sitesNodes[0].ChildNodes)
                {
                    LTSCanvas canvas = new LTSCanvas();
                    canvas.LoadFromXml(component);

                    lts.Processes.Add(canvas);
                }
            }

            return(lts);
        }
Пример #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 static UMLModel LoadUMLModelFromXML(string text)
        {
            UMLModel        umlModel = new UMLModel();
            XmlDataDocument doc      = new XmlDataDocument();


            doc.LoadXml(text);


            XmlNodeList sitesNodes = doc.GetElementsByTagName(Parsing.UML_MODEL_NODE_NAME);

            umlModel.SystemName = sitesNodes[0].ChildNodes[0].InnerText;

            sitesNodes = doc.GetElementsByTagName(Parsing.ASSERTION_NODE_NAME);

            if (sitesNodes[0].ChildNodes[0] != null)
            {
                umlModel.Assertion = sitesNodes[0].ChildNodes[0].InnerText;
            }

            sitesNodes = doc.GetElementsByTagName(Parsing.DIAGRAMS_NODE_NAME);

            if (sitesNodes.Count > 0)
            {
                int i = 0;
                foreach (XmlElement component in sitesNodes[0].ChildNodes)
                {
                    i++;
                    string      dName, dxmiContent;
                    XmlNodeList diagramName = component.GetElementsByTagName(Parsing.DIAGRAM_NAME);

                    if (diagramName == null || diagramName.Count < 1)
                    {
                        dName = "diagram" + i;
                    }
                    else
                    {
                        dName = diagramName[0].InnerText;
                    }

                    XmlNodeList xmiContent = component.GetElementsByTagName(Parsing.DIAGRAM_XMI_CONTENT);
                    if (xmiContent == null || xmiContent.Count < 1)
                    {
                        dxmiContent = "";
                    }
                    else
                    {
                        dxmiContent = xmiContent[0].InnerText;
                    }


                    umlModel.AddDiagram(new StateDiagram(dName, dxmiContent));
                }
            }

            return(umlModel);
        }
Пример #10
0
        void update_language(string lang_name)
        {
            // Read the XML language files, iterate through menu's & controls and update labels.
            Properties.Settings.Default.language = lang_name;
            Properties.Settings.Default.Save();
            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList     xmlnode;
            int             i             = 0;
            string          control_name  = null;
            string          control_label = null;
            var             enviroment    = System.Environment.CurrentDirectory;
            FileStream      fs            = new FileStream(enviroment + "\\languages\\" + lang_name + ".xml", FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            xmlnode = xmldoc.GetElementsByTagName("item");  //load control texts
            for (i = 0; i <= xmlnode.Count - 1; i++)
            {
                xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                control_label = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                control_name  = xmlnode[i].Attributes["control"].InnerText;

                Control ctn = Controls.Find(control_name, true)[0];
                ctn.Text = control_label;
            }
            xmlnode = xmldoc.GetElementsByTagName("menu");  //load menu texts
            for (i = 0; i <= xmlnode.Count - 1; i++)
            {
                xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                control_label = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                control_name  = xmlnode[i].Attributes["control"].InnerText;

                foreach (ToolStripMenuItem item in menuStrip1.Items)
                {
                    if (item.Name == control_name)
                    {
                        item.Text = control_label;
                    }
                    foreach (ToolStripMenuItem subitem in item.DropDownItems.OfType <ToolStripMenuItem>())
                    {
                        if (subitem.Name == control_name)
                        {
                            subitem.Text = control_label;
                        }
                    }
                }
            }
            xmlnode = xmldoc.GetElementsByTagName("lang");  //load all the program texts
            for (i = 0; i <= xmlnode.Count - 1; i++)
            {
                xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                control_label         = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                control_name          = xmlnode[i].Attributes["control"].InnerText;
                langStr[control_name] = control_label;
            }
            progress_txt.Text = langStr["idle"];
        }
Пример #11
0
        public void writeSAVE(Stream oldsavefile, string @newsavepath, Stream newsavefile)
        {
            //First things first, we create a backup of the old savefile.
            FileStream save_backup;

            save_backup          = File.OpenWrite(@newsavepath + ".backup");
            oldsavefile.Position = 0;
            oldsavefile.CopyTo(save_backup);
            save_backup.Close();

            //Load save file
            //XmlDataDocument xmlsav = new XmlDataDocument();
            //xmlsav.PreserveWhitespace = true;
            oldsavefile.Position = 0; //We have to reset the position to 0 otherwise this fails
            //xmlsav.Load(oldsavefile); //Load the Save file as an XML document
            XmlNode hnSav = xmlsav.GetElementsByTagName("HacknetSave")[0];
            XmlAttributeCollection miscData = hnSav.Attributes;

            hnSav.Attributes.GetNamedItem("Username").InnerText = userNameInput.Text; //set username
            hnSav.Attributes.GetNamedItem("Language").InnerText = textBox1.Text;      //set language
            if (hideMailFlag.Checked)
            {
                hnSav.Attributes.GetNamedItem("DisableMailIcon").InnerText = "true";
            }
            else
            {
                hnSav.Attributes.GetNamedItem("DisableMailIcon").InnerText = "false";
            }
            XmlNode mission = xmlsav.GetElementsByTagName("mission")[0];

            mission.Attributes.GetNamedItem("next").Value  = missionInput.Text;
            mission.Attributes.GetNamedItem("goals").Value = goalInput.Text;



            //===========================================================
            //Now we actually save the values to a file
            //===========================================================

            //xmlsav.PreserveWhitespace = false;
            newsavefile.Close();
            XmlWriterSettings xmlSettings = new XmlWriterSettings();

            xmlSettings.Indent          = false;
            xmlSettings.NewLineHandling = System.Xml.NewLineHandling.None;
            //xmlSettings.
            XmlWriter newsavefile_final = XmlWriter.Create(newsavepath, xmlSettings);

            xmlsav.Normalize();
            xmlsav.Save(newsavefile_final);

            newsavefile_final.Close();

            Console.WriteLine("Saved successfully!");
        }
Пример #12
0
        /// <summary>
        /// Guarda las opciones
        /// </summary>
        /// <param name="b">Bean de opciones</param>
        public void guardaOpciones(BeanOpciones b)
        {
            XmlDataDocument xml = getXML(rutaOpciones);

            xml.GetElementsByTagName("esGorda")[0].InnerText              = b.EsGorda ? "1" : "0";
            xml.GetElementsByTagName("sacaLengua")[0].InnerText           = b.SacaLengua ? "1" : "0";
            xml.GetElementsByTagName("frecuenciaSacaLengua")[0].InnerText = b.FrecuenciaSacaLengua.ToString();
            xml.GetElementsByTagName("indiceManzana")[0].InnerText        = b.IndiceManzana.ToString();

            xml.Save(rutaOpciones);
        }
Пример #13
0
        // Read config file of test project. ("Configuration.xml")
        public void readConfigFile()
        {
            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList     xmlnode;
            FileStream      fs = new FileStream("Configuration.xml", FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            xmlnode       = xmldoc.GetElementsByTagName("InstallerPath");
            installerPath = xmlnode[xmlnode.Count - 1].InnerText;
            xmlnode       = xmldoc.GetElementsByTagName("InstalledPath");
            installedPath = xmlnode[xmlnode.Count - 1].InnerText;
        }
Пример #14
0
        /// <summary>
        /// Devuelve las opciones guardadas
        /// </summary>
        /// <returns>Bean de opciones</returns>
        public BeanOpciones getOpciones()
        {
            XmlDataDocument xml     = getXML(rutaOpciones);
            BeanOpciones    retorna = new BeanOpciones();

            retorna.EsGorda              = xml.GetElementsByTagName("esGorda")[0].InnerText == "1";
            retorna.SacaLengua           = xml.GetElementsByTagName("sacaLengua")[0].InnerText == "1";
            retorna.FrecuenciaSacaLengua = int.Parse(xml.GetElementsByTagName("frecuenciaSacaLengua")[0].InnerText);
            retorna.IndiceManzana        = int.Parse(xml.GetElementsByTagName("indiceManzana")[0].InnerText);

            return(retorna);
        }
Пример #15
0
        public XMLReader(string xmlFile)
        {
            trkObjectList = new List <TrkObject>();

            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList     xmlnode;
            FileStream      fs = new FileStream(xmlFile, FileMode.Open, FileAccess.Read);

            xmldoc.Load(fs);
            xmlnode  = xmldoc.GetElementsByTagName("ZC_NAME");
            ZC_NAME  = xmlnode[0].InnerText.Trim();
            xmlnode  = xmldoc.GetElementsByTagName("SIO_NAME");
            SIO_NAME = xmlnode[0].InnerText.Trim();
            xmlnode  = xmldoc.GetElementsByTagName("SRCADDR");
            SrcAddr  = Convert.ToUInt16(xmlnode[0].InnerText); // There must be only 1! SrdAddr - no verification of consistency performed
            xmlnode  = xmldoc.GetElementsByTagName("DSTADDR");
            DstAddr  = Convert.ToUInt16(xmlnode[0].InnerText); // There must be only 1! DstAddr - no verification of consistency performed
            xmlnode  = xmldoc.GetElementsByTagName("POINT");
            for (int i = 0; i < xmlnode.Count; i++)
            {
                trkObjectList.Add(new TrkObject());
                trkObjectList[trkObjectList.Count - 1].name = xmlnode[i].Attributes["name"].Value;
                int nbObjects = xmlnode[i].ChildNodes.Count;
                for (int j = 0; j < nbObjects; j++)
                {
                    string localName = xmlnode[i].ChildNodes[j].LocalName;
                    if (localName == "PERIOD")
                    {
                        trkObjectList[trkObjectList.Count - 1].period = Convert.ToInt32(xmlnode[i].ChildNodes[j].InnerText);
                    }
                    else if (localName == "OUTPUT")
                    {
                        trkObjectList[trkObjectList.Count - 1].listTrkInterface.Add(new TrkInterface(xmlnode[i].ChildNodes[j].InnerText.Trim()));
                    }
                    else
                    {
                        TrkInterface _trkInterface = trkObjectList[trkObjectList.Count - 1].listTrkInterface[trkObjectList[trkObjectList.Count - 1].listTrkInterface.Count - 1];
                        if (localName == "TIME")
                        {
                            _trkInterface.timeOperate = Convert.ToInt32(xmlnode[i].ChildNodes[j].InnerText);
                        }
                        if (localName == "INPUT")
                        {
                            _trkInterface.inputId = xmlnode[i].ChildNodes[j].InnerText.Trim();
                        }
                    }
                }
            }
        }
Пример #16
0
        private void LoginUsual()
        {
            try
            {
                XmlDataDocument xmldoc = new XmlDataDocument();
                XmlNodeList     xmlnode;
                int             i  = 0;
                FileStream      fs = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\PHS\AgentInteractionDesktop\app_config.xml", FileMode.Open, FileAccess.Read);
                xmldoc.Load(fs);

                xmlnode = xmldoc.GetElementsByTagName("AppSetting");
                for (i = 0; i <= xmlnode[0].ChildNodes.Count - 1; i++)
                {
                    XmlNodeList xmlInnernode = xmldoc.GetElementsByTagName(xmlnode[0].ChildNodes[i].Name.ToString());
                    if (xmlInnernode.Count != 0)
                    {
                        for (int j = 0; j <= xmlInnernode[0].ChildNodes.Count - 1; j++)
                        {
                            if (xmlInnernode[0].ChildNodes[j].ParentNode.Name.ToString().Trim().ToLower() == "runmultipleinstances")
                            {
                                Settings.GetInstance().RunMultipleInstances = Convert.ToBoolean(xmlInnernode[0].ChildNodes[j].InnerText.Trim());
                            }
                        }
                    }
                }
                //System.Windows.MessageBox.Show("Multiple Instance " + (Settings.GetInstance().RunMultipleInstances ? "Enabled." : "Disabled.") );
                if (Settings.GetInstance().RunMultipleInstances)
                {
                    Helpers.IndexPage objIndexPage = new Helpers.IndexPage();
                    objIndexPage.Start();
                }
                else
                {
                    Process thisProcess = Process.GetCurrentProcess();
                    if (Process.GetProcessesByName(thisProcess.ProcessName).Length > 1)
                    {
                        Environment.Exit(0);
                        return;
                    }
                    else
                    {
                        Helpers.IndexPage objIndexPage = new Helpers.IndexPage();
                        objIndexPage.Start();
                    }
                }
            }
            catch { }
        }
Пример #17
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());
        }
Пример #18
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);
        }
Пример #19
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);
        }
        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");
            }
        }
Пример #21
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);
        }
Пример #22
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
        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>();
        }
Пример #24
0
        /// <summary>
        /// Intenta obtener el token del soap header del web service
        /// </summary>
        /// <returns></returns>
        public bool traerDatosToken()
        {
            bool bRta = false;

            try
            {
                byte[] data = new byte[Convert.ToInt32(System.Web.HttpContext.Current.Request.InputStream.Length)];
                System.Web.HttpContext.Current.Request.InputStream.Position = 0;
                System.Web.HttpContext.Current.Request.InputStream.Read(data, 0, Convert.ToInt32(System.Web.HttpContext.Current.Request.InputStream.Length));
                UTF8Encoding encoding      = new UTF8Encoding();
                string       decodedString = encoding.GetString(data);

                // cargo el soap xml
                XmlDataDocument myXmlDocument = new XmlDataDocument();
                myXmlDocument.LoadXml(decodedString);
                XmlNodeList xmlToken = myXmlDocument.GetElementsByTagName("token");

                // genero el token
                SSOEncodedToken encToken = new SSOEncodedToken();
                encToken.Token = xmlToken.Item(0).InnerText;
                token          = Credencial.ObtenerCredencialEnWs(encToken);

                bRta = true;
            }
            catch (Exception ex)
            {
                bRta = false;
            }

            return(bRta);
        }
Пример #25
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);
        }
Пример #26
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);
            }
        }
Пример #27
0
        public void LoadMap(string mapStruct)
        {
            XmlDataDocument xmldoc = new XmlDataDocument();
            XmlNodeList     xmlnode;

            xmldoc.LoadXml(mapStruct);
            xmlnode = xmldoc.GetElementsByTagName("map");
            XmlNode mapNode = xmlnode.Item(0);
            int     cols    = Convert.ToInt32(mapNode.Attributes["cols"].Value);
            int     rows    = Convert.ToInt32(mapNode.Attributes["rows"].Value);

            mapItems = new GameObject[rows, cols];
            for (int i = 0; i <= mapNode.ChildNodes.Count - 1; i++)
            {
                XmlNode itemNode = mapNode.ChildNodes[i];
                int     row      = Convert.ToInt32(itemNode.Attributes["row"].Value);
                int     col      = Convert.ToInt32(itemNode.Attributes["col"].Value);
                mapItems[row, col] = null;

                if (OnProcessXMLMap != null)
                {
                    mapItems[row, col] = OnProcessXMLMap(itemNode.InnerText, row, col);
                }

                if (mapItems[row, col] != null)
                {
                    mapItems[row, col].SetSize(new System.Windows.Size(engine.BlockSize, engine.BlockSize));
                }
            }

            LoadMap(mapItems);
        }
        /// <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);
        }
Пример #29
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);
        }
Пример #30
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);
            }
        }