Read() public méthode

public Read ( ) : bool
Résultat bool
        public static IncomingTransportMessage Deserialize(string messageId, Stream inputStream)
        {
            var headers = new Dictionary<string, string>();
            var serializedMessageData = "";
            using (var reader = new XmlTextReader(inputStream))
            {
                reader.WhitespaceHandling = WhitespaceHandling.None;
                reader.Read(); // read <root>
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        var elementName = reader.Name;
                        reader.Read(); // read the child;
                        while (reader.NodeType == XmlNodeType.Element)
                        {
                            // likely an empty header element node
                            headers.Add(elementName, reader.Value);

                            elementName = reader.Name;
                            reader.Read(); // read the child;
                        }
                        if (string.Equals(elementName, "body", StringComparison.InvariantCultureIgnoreCase) && reader.NodeType == XmlNodeType.CDATA)
                        {
                            serializedMessageData = reader.Value;
                        }
                        else if (reader.NodeType == XmlNodeType.Text)
                        {
                            headers.Add(elementName, reader.Value);
                        }
                    }
                }
            }
            return new IncomingTransportMessage(messageId, headers, serializedMessageData);
        }
Exemple #2
0
        public String[] GetVersion(List<String> application)
        {
            String[] versionList = new String[5];
            String URLString = "http://www.gamerzzheaven.be/applications.xml";
            
            XmlTextReader reader = new XmlTextReader(URLString);

            while (reader.Read())
            {
                if (reader.NodeType.Equals(XmlNodeType.Element))
                {
                    if (reader.Name.Equals("Application"))
                    {
                        while (reader.MoveToNextAttribute()) // Read the attributes.
                            if (reader.Name == "name")
                            {
                                if (reader.Value.Equals("x264")) //change the z264 string value to the enum once tested
                                {
                                    reader.Read();
                                    if(reader.Name.Equals("Version"))
                                    {
                                        versionList[0] = reader.ReadString();
                                    }
                                }
                            }
                    }
                }
            }
            return versionList; //return curerent application version
        }
Exemple #3
0
        private void FlashMovieFlashCall(object sender, _IShockwaveFlashEvents_FlashCallEvent e)
        {
            try
            {
                XmlTextReader reader = new XmlTextReader(new StringReader(e.request));
                reader.WhitespaceHandling = WhitespaceHandling.Significant;
                reader.MoveToContent();

                if (reader.Name == "invoke" && reader.GetAttribute("name") == "trace")
                {
                    reader.Read();
                    if (reader.Name == "arguments")
                    {
                        reader.Read();
                        if (reader.Name == "string")
                        {
                            reader.Read();
                            TraceManager.Add(reader.Value, 1);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }
Exemple #4
0
        /// <summary>
        /// Constructs the Arcs using Xml
        /// </summary>
        /// <param name="vsXml">Xml data</param>
        public Arcs(string vsXml)
        {
            XmlTextReader reader = new XmlTextReader(new StringReader(vsXml));
            reader.Read();

            ArcType = (EnumArcType)Enum.Parse(typeof(EnumArcType), reader.GetAttribute("arctype"));

            moArcList = new List<Arc>();

            while (reader.Read())
            {
                switch (reader.Name)
                {
                    case "Arcs" :
                        if (reader.NodeType != XmlNodeType.EndElement)
                        {
                            if (moInnerArcs == null)
                            {
                                moInnerArcs = new List<Arcs>();
                            }
                            moInnerArcs.Add(new Arcs(reader.ReadOuterXml()));
                        }
                        break;
                    case "Arc" :
                        moArcList.Add(new Arc(reader.ReadOuterXml()));
                        break;
                }
            }
        }
        /// <summary>
        /// Generates the function list...
        /// </summary>
        /// <returns></returns>
        public static String GenerateFunctionList( bool bIsHeader )
        {
            // EXAMPLE of what we want to generate...
            // bSuccess *= printFunctionResult( My_HeapValidate( ), "HeapValidate" );

            String functionListResults = null;

            XmlTextReader xr = new XmlTextReader( functionXMLFile );

            while ( xr.Read( ) )
            {
                // Find out what type of node we are looking at. The XR reader will read one
                // XML element/value at a time (NOT one line at time)...
                if ( xr.NodeType == XmlNodeType.Element )
                {
                    if ( xr.Name == "FunctionName" )
                    {
                        if ( !xr.Read( ) )
                            break;

                        Console.WriteLine( "Writing Function: " + xr.Value );
                        if ( !bIsHeader )
                            functionListResults += "    bSuccess *= printFunctionResult( My_" + xr.Value + "( ), \"" + xr.Value + "\" );\r\n";
                        else
                            functionListResults += "    BOOL My_" + xr.Value + "( )" + ";\r\n";

                    }
                }
            }

            Exception e;
            xr.Close( );

            return functionListResults;
        }
Exemple #6
0
        public bool exists(string server, string db)
        {
            bool rez = false;
            XmlTextReader reader = new XmlTextReader(dbConf);
            try
            {
                while (reader.Read())
                {
                    if (reader.Value == server)
                    {
                        reader.Read();
                        while (reader.Read() && reader.Name != srvTag)
                        {
                            if (reader.Value == db)
                            {
                                rez = true;
                            }
                        }
                    }
                }
                reader.Close();
            }
            catch (Exception e)
            {

            }

            return rez;
        }
Exemple #7
0
        protected override void specialLoad(ref System.Xml.XmlTextReader reader, string type)
        {
            if (reader.Name == "materials" && reader.NodeType != XmlNodeType.EndElement)
            {
                reader.Read();
                Materials = GenericMethods.StringListFromString(reader.Value);
            }

            if (reader.Name == "meshes" && reader.NodeType != XmlNodeType.EndElement)
            {
                reader.Read();
                Meshes = GenericMethods.StringListFromString(reader.Value);
            }

            if (reader.Name == "pboxes" && reader.NodeType != XmlNodeType.EndElement)
            {
                reader.Read();
                PhysBoxes = GenericMethods.StringListFromString(reader.Value);
            }

            if (reader.Name == "isstatic")
            {
                IsStatic = true;
            }
        }
        private void local(string s)
        {
            try
            {
                String sFilename = Directory.GetCurrentDirectory() + "/" + s;
                XmlTextReader reader = new XmlTextReader(sFilename);
                reader.Read();
                reader.Read();
                String[] t = new String[6];
                String[] t2 = new String[6];
                for (int i = 0; i < 6; i++)
                {
                    reader.Read();
                    reader.Read();
                    t[i] = reader.Name;
                    reader.MoveToNextAttribute();
                    t2[i] = reader.Value;
                }
                gb1.Header = t2[5];

            }
            catch (IndexOutOfRangeException) { }
            catch (FileNotFoundException) { }
            catch (XmlException) { }
        }
        public static string[] GetWeather(string zipCode)
        {
            XmlTextReader textReader = new XmlTextReader("http://weather.yahooapis.com/forecastrss?p=" + zipCode + "&u=f");
            string City = "", State = "", Code = "", URL = "", Temperature = "", Condition = "";
            string High = "", Low = "";

            textReader.MoveToContent();
            string temp = textReader.Name;
            do
            {
                textReader.Read();
                temp = textReader.Name;
            }
            while (temp != "channel");

            while (temp == "channel")
            {
                textReader.Read();

                if (textReader.Name == "yweather:location")
                {
                    City = textReader.GetAttribute("city");
                    State = textReader.GetAttribute("region");
                }
                else if (textReader.Name == "item")
                {
                    do
                    {
                        textReader.Read();
                        if (textReader.Name == "yweather:condition")
                        {
                            Condition = textReader.GetAttribute("text");
                            Temperature = textReader.GetAttribute("temp");
                            Code = textReader.GetAttribute("code");
                        }
                        else if (textReader.Name == "yweather:forecast")
                        {
                            if (Convert.ToInt32(textReader.GetAttribute("date").Substring(0, 2)) == System.DateTime.Now.Day)
                            {
                                High = textReader.GetAttribute("high");
                                Low = textReader.GetAttribute("low");
                            }
                        }
                    }
                    while (textReader.Name != "item");
                    temp = "";
                }
            }
            textReader.Close();
            URL = "http://us.i1.yimg.com/us.yimg.com/i/us/we/52/" + Code + ".gif";
            string[] value = new string[7];
            value[0] = City;
            value[1] = State;
            value[2] = Temperature;
            value[3] = Condition;
            value[4] = Code;
            value[5] = High;
            value[6] = Low;
            return value;
        }
Exemple #10
0
        public static List<int> CheckStatusRowErrors(string errorInfo)
        {
            List<int> errorList = new List<int>();
            bool containsError = false;

            XmlTextReader xReader = new XmlTextReader(new System.IO.StringReader(errorInfo));
            while (xReader.Read())
            {
                if (xReader.Name == "errinfo" && xReader.NodeType == XmlNodeType.Element)
                {
                    xReader.Read();
                    if (xReader.Value != string.Empty)
                    {
                        containsError = true;
                    }
                }
                if (containsError && xReader.Name == "error" && xReader.NodeType == XmlNodeType.Element)
                {
                    while (xReader.Read())
                    {
                        if (xReader.Name == "id" && xReader.NodeType == XmlNodeType.Attribute)
                        {
                            errorList.Add(Convert.ToInt32(xReader.Value));
                        }
                    }
                }
            }
            return errorList;
        }
Exemple #11
0
        public void Deserialize(string input, out int pageCount, out char[] charSet)
        {
            CharSetMapping = new Dictionary<char, FontGlyph>();
            var charSetList = new List<char>();
            pageCount = 0;

            XmlTextReader r = new XmlTextReader(new StringReader(input));

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element && r.Name == "FontData")
                {
                    pageCount = int.Parse(r.GetAttribute("Pages"));
                    int glyphCount = int.Parse(r.GetAttribute("CharSetLen"));

                    while (r.Read() && r.NodeType == XmlNodeType.Element && r.Name == "Glyph")
                    {
                        if (CharSetMapping.Count < glyphCount)
                        {
                            char c = r.GetAttribute("char")[0];
                            var vals = r.GetAttribute("rect").Split(' ');
                            var glyph = new FontGlyph(int.Parse(r.GetAttribute("page")),
                                new Rectangle(int.Parse(vals[0]), int.Parse(vals[1]), int.Parse(vals[2]), int.Parse(vals[3])),
                                int.Parse(r.GetAttribute("yoffset")), c);

                            CharSetMapping.Add(c, glyph);
                            charSetList.Add(c);
                        }
                    }
                }
            }
            charSet = charSetList.ToArray();
        }
Exemple #12
0
        /// <summary>
        ///   Parser recursiv de elemente XML.
        /// </summary>
        /// <param name="reader">Cititorul secvenţial care a deschis fişierul XML</param>
        /// <returns>Elementul XML parsat care conţine toate atributele şi subelementele sale</returns>
        private static XMLElement readCurrentElement(XmlTextReader reader)
        {
            if (!reader.IsStartElement()) {

                return null;
            }

            bool hasChildren = !reader.IsEmptyElement;

            XMLElement result = new XMLElement();

            for (int i = 0; i < reader.AttributeCount; ++i) {

                reader.MoveToAttribute(i);
                result.addAttribute(reader.Name, reader.Value);
            }

            if (hasChildren) {

                while (reader.Read() && reader.NodeType != XmlNodeType.EndElement) {

                    if (reader.IsStartElement()) {

                        result.addElement(reader.Name, readCurrentElement(reader));
                    }
                }
            }

            reader.Read();

            return result;
        }
Exemple #13
0
        public static Hashtable GetSettings()
        {
            Hashtable hash = new Hashtable();

            hash.Add("ip", DEFAULT_IP);
            hash.Add("port", DEFAULT_PORT);

            try
            {
                XmlTextReader xml = new XmlTextReader(CONFIG_FILE_NAME);
                while (xml.Read())
                {
                    switch (xml.NodeType)
                    {
                        case XmlNodeType.Element:
                            if (xml.Name.ToUpper() == "IP")
                                if (xml.Read() && xml.NodeType == XmlNodeType.Text)
                                    hash["ip"] = xml.Value;
                            if (xml.Name.ToUpper() == "PORT")
                                if (xml.Read() && xml.NodeType == XmlNodeType.Text)
                                    hash["port"] = xml.Value;
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in Service: " + ex.Message);
                Console.WriteLine("Process started with default values.");
            }

            return hash;
        }
Exemple #14
0
        public void getData(ref SortedDictionary<string,string> data, ref List<string> localizations)
        {
            XmlTextReader reader = new XmlTextReader (fileName);

            string currentLocal=GameConfig.Localization;
            string key;
            string value;

                reader.Read();

                while (reader.Read()) {

                    if (reader.Name.Equals(LOCALIZATION_NAME)) {
                        currentLocal = reader.GetAttribute(LOCALIZATION_ATTRIBUTE);

                        if (!localizations.Contains(currentLocal))
                            localizations.Add(currentLocal);

                    }

                    if(reader.Name.Equals(ITEM_NAME)){

                        key = reader.GetAttribute(ITEM_ATTRIBUTE);
                        value = reader.ReadElementString();

                        if (key!=null)
                            data.Add(currentLocal+key, value);

                    }
                }

            reader.Close();
            reader  = null;
        }
        private static Dictionary<string, string> GetResources(string content)
        {
            Dictionary<string, string> resources = new Dictionary<string, string>();

            StringReader _sr = new StringReader(content);
            XmlTextReader _xtr = new XmlTextReader(_sr);
            _xtr.XmlResolver = null;
            _xtr.WhitespaceHandling = WhitespaceHandling.None;
            _xtr.Read();

            if ((_xtr.NodeType == XmlNodeType.Element) && (_xtr.Name == "Language"))
            {
                while (_xtr.Read())
                {
                    if ((_xtr.NodeType == XmlNodeType.Element) && (_xtr.Name == "LocaleResource"))
                    {
                        string resourceName = _xtr["Name"];

                        _xtr.Read();
                        if ((_xtr.NodeType == XmlNodeType.Element) && (_xtr.Name == "Value"))
                        {
                            _xtr.Read();
                            if (_xtr.NodeType == XmlNodeType.Text)
                            {
                                string resourceValue = _xtr.Value;
                                resources.Add(resourceName, resourceValue);
                            }
                        }
                    }
                }
            }

            return resources;
        }
Exemple #16
0
 static FileParser()
 {
     s_extensions.Add("");
     //s_extensions.Add(".lua");
     try
     {
         XmlTextReader reader = new XmlTextReader(AppDomain.CurrentDomain.BaseDirectory + "intelluaconfig.xml");
         while (reader.Read())
         {
             if (reader.NodeType == XmlNodeType.Element)
             {
                 if (reader.Name == "path")
                 {
                     reader.Read();
                     s_includePaths.Add(reader.Value);
                 }
                 else if (reader.Name == "ext")
                 {
                     reader.Read();
                     s_extensions.Add(reader.Value);
                 }
             }
         }
     }
     catch
     {
     }
 }
        /// <summary> Reads the inner data from the Template XML format </summary>
        /// <param name="XMLReader"> Current template xml configuration reader </param>
        /// <remarks> This reads the possible values for the combo box from an <i>options</i> subelement.  The default value for the combo box is from a <i>code</i> subelement and the default value for the text box is from a <i>statement</i> subelement. </remarks>
        protected override void Inner_Read_Data(XmlTextReader XMLReader)
        {
            while (XMLReader.Read())
            {
                if ((XMLReader.NodeType == XmlNodeType.Element) && (XMLReader.Name.ToLower() == "options"))
                {
                    XMLReader.Read();
                    string options = XMLReader.Value.Trim();
                    possible_select_items.Clear();
                    if (options.Length > 0)
                    {
                        SortedList<string, string> sorted_codes = new SortedList<string, string>();
                        string[] options_parsed = options.Split(",".ToCharArray());
                        foreach (string thisOption in options_parsed.Where(thisOption => !sorted_codes.ContainsKey(thisOption.Trim())))
                        {
                            sorted_codes.Add(thisOption.Trim(), thisOption.Trim());
                        }

                        possible_select_items.AddRange(sorted_codes.Values);
                    }
                }

                if ((XMLReader.NodeType == XmlNodeType.Element) && (XMLReader.Name.ToLower() == "code"))
                {
                    XMLReader.Read();
                    default_codes.Add(XMLReader.Value.Trim());
                }

                if ((XMLReader.NodeType == XmlNodeType.Element) && (XMLReader.Name.ToLower() == "statement"))
                {
                    XMLReader.Read();
                    default_values.Add(XMLReader.Value.Trim());
                }
            }
        }
        /// <summary> Reads the inner data from the CompleteTemplate XML format </summary>
        /// <param name="XMLReader"> Current template xml configuration reader </param>
        /// <remarks> This reads the possible values for the combo box from a <i>options</i> subelement </remarks>
        protected override void Inner_Read_Data(XmlTextReader XMLReader)
        {
            while (XMLReader.Read())
            {
                if ((XMLReader.NodeType == XmlNodeType.Element) && (XMLReader.Name.ToLower() == "options"))
                {
                    XMLReader.Read();
                    string options = XMLReader.Value.Trim();
                    possible_select_items_text.Clear();
                    possible_select_items_value.Clear();
                    if (options.Length > 0)
                    {
                        string[] options_parsed = options.Split(",".ToCharArray());
                        foreach (string thisOption in options_parsed)
                        {
                            if (!possible_select_items_text.Contains(thisOption.Trim()))
                            {
                                possible_select_items_text.Add(thisOption.Trim());

                            }
                        }
                    }
                }
            }
        }
        public static void loadXML()
        {
            if (pointers.Count <= 0)  {
                reader = new XmlTextReader("RocketLeague.CT");

                while (reader.ReadToFollowing("CheatEntry"))
                {
                    reader.ReadToFollowing("Description");
                    string name = reader.ReadElementContentAsString().Trim('"');

                    reader.ReadToFollowing("Address");
                    string adress = reader.ReadElementContentAsString();
                    string offsets = "";

                    reader.ReadToFollowing("Offsets");
                    reader.Read();
                    while (reader.Read() && reader.NodeType != XmlNodeType.EndElement)
                    {
                        offsets = "+" + reader.ReadElementContentAsString() + offsets;
                    }

                    pointers.Add(name, adress + offsets);
                }
                reader.Close();
            }
        }
Exemple #20
0
		void ReadDefects (string filename)
		{
			using (XmlTextReader reader = new XmlTextReader (filename)) {
				Dictionary<string, string> full_names = new Dictionary<string, string> ();
				// look for 'gendarme-output/rules/rule/'
				while (reader.Read () && (reader.Name != "rule"));
				do {
					full_names.Add (reader ["Name"], "R: " + reader.ReadInnerXml ());
				} while (reader.Read () && reader.HasAttributes);

				// look for 'gendarme-output/results/
				while (reader.Read () && (reader.Name != "results"));

				HashSet<string> defects = null;
				while (reader.Read ()) {
					if (!reader.HasAttributes)
						continue;

					switch (reader.Name) {
					case "rule":
						defects = new HashSet<string> ();
						ignore_list.Add (full_names [reader ["Name"]], defects);
						break;
					case "target":
						string target = reader ["Name"];
						if (target.IndexOf (' ') != -1)
							defects.Add ("M: " + target);
						else
							defects.Add ("T: " + target);
						break;
					}
				}
			}
		}
        public override void Initialize(ESRI.ArcLogistics.App.Pages.Page page)
        {
            label1.Content = "Data unavailable.";
            try
            {
                string URLString = @"http://www.weather.gov/xml/current_obs/KRAL.xml";
                XmlTextReader reader = new XmlTextReader(URLString);

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "temperature_string")
                    {
                        if (reader.Read())
                            label1.Content = "Riverside, CA: " + reader.Value;

                        reader.Close();
                        break;
                    }
                }
            }

            finally
            {

            }
        }
        public static void read(string strXMLPath)
        {
            XmlTextReader textReader = new XmlTextReader(strXMLPath);

            textReader.Read();

            // If the node has value

            while (textReader.Read())
            {

                textReader.MoveToElement(); // Move to 1st element
                if (textReader.NodeType.ToString() != "Whitespace" && textReader.NodeType.ToString() != "Element" && textReader.NodeType.ToString() != "EndElement")
                {
                    Console.WriteLine("════════════════════════════════");

             //   Console.WriteLine("Name:" + textReader.Name);
             //   Console.WriteLine("Base URI:" + textReader.BaseURI);
             //   Console.WriteLine("Local Name:" + textReader.LocalName);
             //   Console.WriteLine("Attribute Count:" + textReader.AttributeCount.ToString());
             //   Console.WriteLine("Depth:" + textReader.Depth.ToString());
             //   Console.WriteLine("Line Number:" + textReader.LineNumber.ToString());
             //   Console.WriteLine("Node Type:" + textReader.NodeType.ToString());

                    Console.WriteLine(textReader.Value.ToString());
             }

            }
            Console.Read();
        }
Exemple #23
0
        public override void Deserialize(Node node, string data)
        {
            TextReader tr = new StringReader(data);
            Dictionary<string, object> properties = new Dictionary<string, object>();

            using(XmlReader xmlReader = new XmlTextReader(tr))
            {
                xmlReader.ReadStartElement("root");
                do {
                    if (xmlReader.NodeType == XmlNodeType.Element) {
                        string name = xmlReader.Name;
                        if (xmlReader.Read()) {
                            switch (xmlReader.NodeType) {
                            case XmlNodeType.Text:
                                properties.Add(name, xmlReader.ReadContentAs(xmlReader.ValueType, null));
                                break;
                            case XmlNodeType.Element:
                                List<object> objs = new List<object>();
                                while(xmlReader.Read() && xmlReader.NodeType != XmlNodeType.EndElement) {
                                    if (xmlReader.Name == "item")
                                        objs.Add(xmlReader.ReadElementContentAs(xmlReader.ValueType, null));
                                }
                                properties.Add(name, objs.ToArray());
                                break;
                            }

                        }

                    }
                } while(xmlReader.Read());
            }

            UpdateNode (node, properties);
        }
Exemple #24
0
        public void ReadXMLPatientFile(string filePath)
        {
            // Read a document
            XmlTextReader textReader = new XmlTextReader(filePath);
            textReader.WhitespaceHandling = WhitespaceHandling.None;

            textReader.Read();
            // If the node has value

            while (textReader.Read())
            {
                if (textReader.NodeType.Equals(XmlNodeType.Element))
                {
                    switch (textReader.LocalName)
                    {
                        case "greenCCD":
                            patientForm.clinicData.xmlns = textReader.GetAttribute(0);
                            patientForm.clinicData.xmlns_xsi = textReader.GetAttribute(1);
                            patientForm.clinicData.xmlns_hr4e = textReader.GetAttribute(2);
                            patientForm.clinicData.xsi_schemaLocation = textReader.GetAttribute(3);
                            break;
                        case "header":
                            ReadHeader(textReader);
                            break;
                        case "body":
                            ReadBody(textReader);
                            break;
                    }
                }
            }

            textReader.Close();
        }
        /* Attempts to open the file at filepath and read the XML */
        public WatchedPath ReadFile(string filepath)
        {
            XmlTextReader textReader = new XmlTextReader(filepath);
            WatchedPath path = new WatchedPath();

            // Read in the data
            while (textReader.Read())
            {
                if (textReader.NodeType == XmlNodeType.Element && textReader.Name == "Start")
                {
                    path.Path = textReader.GetAttribute("path");

                    while (textReader.NodeType != XmlNodeType.EndElement)
                    {
                        textReader.Read();
                        if (textReader.Name == "Destination")
                        {
                            path.Destinations.Add(textReader.GetAttribute("path"));
                        }
                    }
                }
            }
            // Close the reader
            textReader.Close();

            return path;
        }
        private static volatile Dictionary<String, Individual> _users; // = new Dictionary<string, Individual>();

        #endregion Fields

        #region Constructors

        private UserLoad()
        {
            //if (_users != null) return;
            _users = new Dictionary<string, Individual>();
            Environment.CurrentDirectory = HttpContext.Current.Server.MapPath("/");
            XmlTextReader  xmlFile = new XmlTextReader (_filePath);

             xmlFile.Read();
             while (xmlFile.Read())
             {
                 xmlFile.MoveToElement();
                 if (xmlFile.NodeType == XmlNodeType.Element && xmlFile.Name.Equals("user")){
                     Individual user = new Individual();
                     user.IndividualId = Int16.Parse(xmlFile.GetAttribute("IndividualId"));
                     user.FullName = xmlFile.GetAttribute("FullName").Trim();
                     user.UserName = xmlFile.GetAttribute("UserName").Trim();
                     user.Password = xmlFile.GetAttribute("Password").Trim();
                     user.Email = xmlFile.GetAttribute("Email").Trim();
                     user.PhotoName = xmlFile.GetAttribute("PhotoName").Trim();
                     user.SecurityAnswer = xmlFile.GetAttribute("SecurityAnswer").Trim();
                     user.SecurityQuestion = xmlFile.GetAttribute("SecurityQuestion").Trim();

                     foreach (string s in xmlFile.GetAttribute("Roles").Split(','))
                     {
                         user.addRole(s.Trim());
                     }
                     _users.Add(user.UserName, user);
                 }

             }
             xmlFile.Close();
        }
Exemple #27
0
        public static void ReadFromXml(string fileName)
        {
            using (XmlTextReader reader = new XmlTextReader(fileName))
            {
                reader.WhitespaceHandling = WhitespaceHandling.None;
                Console.WriteLine("Array of sides:");
                int i = 1;
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                        case "Length":
                            if (reader.NodeType != XmlNodeType.EndElement)
                            {
                                if (reader.Name.Length < 8)
                                    Console.Write(reader.Name + " "+ i + ":\t\t");
                                else
                                    Console.Write(reader.Name + " " + i + ":\t");
                                reader.Read();
                                Console.WriteLine(reader.Value);
                                ++i;
                            }
                            break;
                    }
                }

            }
        }
Exemple #28
0
 /// <summary> Loads any XML case file with it's Elements, Attributes and Values. </summary>
 /// <param name="fileURL"> Which file to load. </param>
 /// <returns> Load succeeded? </returns>
 bool LoadXML(string fileURL)
 {
     reader = new XmlTextReader(fileURL);
     if (reader.Read() && reader.NodeType == XmlNodeType.XmlDeclaration)
     {
         reader.Skip();
         while (reader.Read())
         {
             switch (reader.NodeType)
             {
                 case XmlNodeType.Element:
                     Program.form1.labelTest.Text += "+"+reader.Name;
                     Program.form1.labelTest.Text += reader.AttributeCount;
                     //Program.form1.labelTest.Text += "-"+reader.Value;
                     for (int i = 0; i < reader.AttributeCount; i++)
                         Program.form1.labelTest.Text += "#" + reader.GetAttribute(i);
                     break;
                 case XmlNodeType.Text:
                     //Program.form1.labelTest.Text += " TEXT  " + reader.Name;
                     Program.form1.labelTest.Text += " TEXT  " + reader.Value;
                     break;
                 case XmlNodeType.EndElement:
                     Program.form1.labelTest.Text += ">" + reader.Name;
                     //Program.form1.labelTest.Text += ">" + reader.Value;
                     break;
                 default:
                     if (reader.NodeType != XmlNodeType.Whitespace)
                         Program.form1.labelTest.Text += "     F A L S E ! ! ! ! !     ";
                     break;
             }
         }
     }
     return true;
 }
Exemple #29
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Decimal getItemPrice(String name)
        {
            XmlConfigurator.Configure(new FileInfo("config/log4net.properties"));
            Decimal result = new Decimal(-1);

            try
            {
                XmlTextReader reader = new XmlTextReader("config/prices.xml");

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "entry" && reader.HasAttributes && reader.GetAttribute("key") == name)
                    {
                        dLog.Debug("Got " + reader.NodeType + " node | Name: " + reader.Name + " | HasAttributes: " + reader.HasAttributes);
                        // move one to read element value
                        reader.Read();
                        dLog.Debug("Node Value: " + reader.Value);
                        result = Decimal.Parse(reader.Value);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                dLog.Debug("Exception in getItemPrice: " + e.Message + "\n" + e.StackTrace);
                result = new Decimal(-1);
            }

            return result;
        }
 /// <summary> Reads the inner data from the CompleteTemplate XML format </summary>
 /// <param name="XMLReader"> Current template xml configuration reader </param>
 /// <remarks> This reads the default value from a <i>value</i> subelement </remarks>
 protected override void Inner_Read_Data(XmlTextReader XMLReader)
 {
     while ( XMLReader.Read() )
     {
         if ( XMLReader.NodeType == XmlNodeType.Element )
         {
             if (XMLReader.Name.ToLower() == "value")
             {
                 XMLReader.Read();
                 items.Add(XMLReader.Value.Trim());
             }
             if (XMLReader.Name.ToLower() == "options")
             {
                 XMLReader.Read();
                 string options = XMLReader.Value.Trim();
                 items.Clear();
                 if (options.Length > 0)
                 {
                     string[] options_parsed = options.Split(",".ToCharArray());
                     foreach (string thisOption in options_parsed.Where(thisOption => !items.Contains(thisOption.Trim())))
                     {
                         items.Add(thisOption.Trim());
                     }
                 }
             }
         }
     }
 }
        ///// <summary>
        ///// Listener for data Binding
        ///// </summary>
        //private void ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        //{
        //    uperBorder = (float)uper.Value;
        //}
        ///// <summary>
        ///// Sets the Slider of the Properties Views
        ///// </summary>
        //public void changeValue(double noise){
        //    uper.Value =noise;
        //    this.ValueChanged(this,null);
        //}
        ///// <summary>
        ///// Gets the Slider of the Properties Views
        ///// </summary>
        //public float getValue(){
        //    return uperBorder;
        //}
        /// <summary>
        /// Sets the Language Content and reads it from an XML File.
        /// </summary>
        public void local(String s)
        {
            try{
                String sFilename = Directory.GetCurrentDirectory() + "/" + s;
                XmlTextReader reader = new XmlTextReader(sFilename);
                reader.Read();
                reader.Read();
                String[] t = new String[1];
                String[] t2 = new String[1];

                    reader.Read();
                    reader.Read();
                    t[0] = reader.Name;
                    reader.MoveToNextAttribute();
                    t2[0] = reader.Value;
                    if (t2[0] == "")
                    {
                        throw new XmlException("datei nicht lang genug");
                    }

                label1.Content = t2[0];
               }
               catch (IndexOutOfRangeException) { }
               catch (FileNotFoundException) { }
               catch (XmlException) { }
        }
Exemple #32
0
 protected override void Inner_Read_Data(System.Xml.XmlTextReader XMLReader)
 {
     while (XMLReader.Read())
     {
         if ((XMLReader.NodeType == XmlNodeType.Element) && (XMLReader.Name.ToLower() == "value"))
         {
             XMLReader.Read();
             html_text = XMLReader.Value.Trim();
         }
     }
 }
        public void LeerFile()
        {
            string Ruta = @"F:\Proyecto-Curso\Proyecto-Curso\ArchivoXML\ArchivoXML.xml";

            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Ruta);
            string contents = "";

            while (reader.Read())
            {
                reader.MoveToContent();

                switch (reader.NodeType)
                {
                //case XmlNodeType.Element: // The node is an element.
                //Console.Write("<" + reader.Name);       Console.WriteLine(">");     break;
                case XmlNodeType.Text: //Display the text in each element.
                    Console.WriteLine(reader.Value);
                    break;
                    //case XmlNodeType. EndElement: //Display the end of the element.
                    //Console.Write("</" + reader.Name);
                    //Console.WriteLine(">"); break;
                }
            }
            reader.Close();
        }
Exemple #34
0
        public bool Instell(bool ignoreExists)
        {
            string databaseFile = Path.Combine(_binPath, "Database.Config");


            Properties dict = new Properties();

            if (File.Exists(databaseFile))
            {
                if (ignoreExists)
                {
                    return(true);
                }

                using (System.Xml.XmlReader reader = new System.Xml.XmlTextReader(databaseFile))
                {
                    while (reader.Read())
                    {
                        if (reader.Name == "add")
                        {
                            string key = reader.GetAttribute("key");
                            if (string.IsNullOrEmpty(key))
                            {
                                continue;
                            }

                            dict[key] = reader.GetAttribute("value");
                        }
                    }
                }
            }

            _form = new DbForm(dict, this.OnTestDB, this.OnGenerateTable, this.OnSaveDB);
            return(_form.ShowDialog( ) == System.Windows.Forms.DialogResult.OK);
        }
Exemple #35
0
    protected void btn_install_Click(object sender, EventArgs e)
    {
        bool go = true;

        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Server.MapPath("DesktopModules/AIS/Installer/Modules.xml"));
        while (reader.Read())
        {
            if (reader.Name == "module" && reader.HasAttributes)
            {
                if (DesktopModuleController.GetDesktopModuleByFriendlyName(reader.GetAttribute("friendlyName")) == null)
                {
                    go = false;
                    break;
                }
            }
        }
        if (go)
        {
            procede();
        }
        else
        {
            pnl_friendly.Visible = false;
            pnl_install.Visible  = false;
            pnl_install_missing_files.Visible = true;
        }
    }
Exemple #36
0
    protected void fillList()
    {
        list = new List <DesktopModuleInfo>();
        DesktopModuleController dmc = new DesktopModuleController();

        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Server.MapPath("DesktopModules/AIS/Installer/Modules.xml") /*Modules"C:\\inetpub\\wwwroot\\DNN\\DesktopModules\\AIS\\Installer\\Modules.xml"*/);
        while (reader.Read())
        {
            reader.MoveToContent();
            if (reader.Name == "module")
            {
                if (reader.HasAttributes)
                {
                    DesktopModuleInfo dmi = dmc.GetDesktopModuleByName(reader.GetAttribute("friendlyName"));
                    //We check if the module is already activated. If it is, there's no need to reinstall it
                    if (dmi != null)
                    {
                        if (!IsInPage(dmi))
                        {
                            list.Add(dmi);
                        }
                    }
                }
            }
        }
    }
Exemple #37
0
    //send alerts at a particular time. this method reads details from xml file in a list and calls a method to send mail to all subscribers
    public void sendAlerts(string path)
    {
        //string path = System.Web.HttpContext.Current.Server.MapPath("~/StoreUserInfo.xml");
        //System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader("C:\\Users\\Latika\\Desktop\\DSOD-Assignment 3\\StoreUserInfo.xml");
        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(path);

        List <string> cont     = new List <string>();
        string        contents = "";

        while (reader.Read())
        {
            reader.MoveToContent();
            if (reader.NodeType == System.Xml.XmlNodeType.Element)
            {
                contents += "<" + reader.Name + ">\n";
            }

            if (reader.NodeType == System.Xml.XmlNodeType.Text)
            {
                contents += reader.Value + "\n";
                cont.Add(reader.Value);
            }
        }

        sendMail(cont);
    }
Exemple #38
0
        static void Main()
        {
            WriteHeader();
            Utils.Log.Debug("XmlReader", "Reading configuration file");
            Xml.XmlReader ConfigurationFileReader = new Xml.XmlTextReader("configuration.xml");
            string        ParentTab = null;

            while (ConfigurationFileReader.Read())
            {
                switch (ConfigurationFileReader.NodeType)
                {
                case Xml.XmlNodeType.Element:
                    ParentTab = ConfigurationFileReader.Name;
                    break;

                case Xml.XmlNodeType.Text:
                    switch (ParentTab)
                    {
                    case "server_id":
                        ServerID = int.Parse(ConfigurationFileReader.Value);
                        break;

                    case "server_address":
                        ServerAddress = ConfigurationFileReader.Value;
                        break;

                    case "server_port":
                        ServerPort = int.Parse(ConfigurationFileReader.Value);
                        break;

                    case "mysql_host":
                        MySQLHost = ConfigurationFileReader.Value;
                        break;

                    case "mysql_port":
                        MySQLPort = int.Parse(ConfigurationFileReader.Value);
                        break;

                    case "mysql_user":
                        MySQLUser = ConfigurationFileReader.Value;
                        break;

                    case "mysql_password":
                        MySQLPassword = ConfigurationFileReader.Value;
                        break;

                    case "debug":
                        Debug = ConfigurationFileReader.Value.ToLower() == "true" ? true : false;
                        break;
                    }
                    break;
                }
            }
            ConfigurationFileReader.Close();
            IServer Server = new IServer(ServerID, ServerAddress, ServerPort, MySQLHost, MySQLPort, new string[] { MySQLUser, MySQLPassword });

            Server.Run();
            System.Console.Read();
        }
Exemple #39
0
        /// <summary>
        /// Leser navn og beskrivelser av funksjonen og alle dens variable, fra en C# xml fil.
        /// Dobbelarrayen har to kolonner. Første kolonne er navn, mens andre kolonne er beskrivelser. Rad en inneholder info om funksjonen, mens resten av radene er info om variablene.
        /// </summary>
        /// <param name="funkNavn">Navnet på funksjonen man vil ha info om.</param>
        /// <param name="fil">Full path med filnavn til xml filen.</param>
        /// <returns>Dobbelarrayen har to kolonner. Første kolonne er navn, mens andre kolonne er beskrivelser. Rad en inneholder info om funksjonen, mens resten av radene er info om variablene.</returns>
        public static string[,] XmlLesVarBeskFraFunk(string funkNavn, string fil)
        {
            Xml.XmlTextReader rd = new Xml.XmlTextReader(fil);
            System.Collections.Generic.List <string> funkVarBeskLi = new System.Collections.Generic.List <string>();
            System.Collections.Generic.List <string> funkVarNavnLi = new System.Collections.Generic.List <string>();
            bool   iFunk = false;
            string reg   = "([.]" + funkNavn + "+([(]))"; //matcher punktum, etterfulgt av funksjonsnavnet, etterfulgt av parentesstart.

            while (rd.Read())
            {
                if (rd.Name == "member")
                { //Funksjonsnavn
                    if (iFunk)
                    {
                        break;        //Ferdig med funksjonen.
                    }
                    string attr = "";
                    for (int j = 0; j < rd.AttributeCount; j++)
                    {
                        attr = rd.GetAttribute(0);                                         //Hvis jeg ikke har med for-løkken, så får jeg en feilmelding.
                    }
                    if (RegExp.Regex.Match(attr, reg).Success)
                    {
                        iFunk = true;
                        funkVarNavnLi.Add(funkNavn);
                    }
                }
                else if (iFunk && rd.Name == "param")
                { //Variabelnavn og beskrivelse
                    funkVarNavnLi.Add(rd.GetAttribute(0).Trim());
                    funkVarBeskLi.Add(rd.ReadString().Trim());
                }
                else if (iFunk && rd.Name == "summary")
                { //Funksjonsbeskrivelse
                    string        attr       = rd.ReadString();
                    Parser.Parser p          = new Parser.Parser(attr);
                    string[]      funkBeskLi = p.ReadStrings('\n'); //Kvitter meg med whitespace etter linjeskift.
                    attr = "";
                    foreach (string s in funkBeskLi)
                    {
                        attr += s.Trim() + " ";                              //Erstatter linjeskift+whitespace med et mellomrom. Kan alternativt erstatte det med et linjeskift uten whitespace.
                    }
                    funkVarBeskLi.Add(attr.Trim());
                }
            }
            rd.Close();
            if (!iFunk)
            {
                Console.WriteLine("Fant ikke funksjonen " + funkVarNavnLi[0] + " i xmlfilen.");
                return(null);
            }
            string[,] funkVarNavnBeskLi = new string[funkVarBeskLi.Count, 2];
            for (int i = 0; i < funkVarNavnBeskLi.GetLength(0); i++)
            {
                funkVarNavnBeskLi[i, 0] = funkVarNavnLi[i];
                funkVarNavnBeskLi[i, 1] = funkVarBeskLi[i];
            }
            return(funkVarNavnBeskLi);
        }
Exemple #40
0
 protected override void specialLoad(ref System.Xml.XmlTextReader reader, string type)
 {
     if (reader.Name == "texture" && reader.NodeType != XmlNodeType.EndElement)
     {
         reader.Read();
         Texture = reader.Value;
     }
 }
Exemple #41
0
        protected override void specialLoad(ref System.Xml.XmlTextReader reader, string type)
        {
            base.specialLoad(ref reader, type);

            if (reader.Name == "vradius" && reader.NodeType != XmlNodeType.EndElement)
            {
                reader.Read();
                volume.AffectionRadius = GenericMethods.FloatFromString(reader.Value);
            }
        }
Exemple #42
0
        public bool parseXMLAsDelimited(string sSource,
                                        string sDest,
                                        string record_node,
                                        T_Fields[] arr_args,
                                        string filing_file = null,
                                        bool bSort         = false)
        {
            System.Collections.ArrayList filing_values = null;
            string tmpDest = System.IO.Path.GetTempFileName();

            System.IO.FileStream   xmlStream = new System.IO.FileStream(sSource, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            System.IO.StreamWriter writer    = new System.IO.StreamWriter(tmpDest, false, new System.Text.UTF8Encoding(false));
            System.Xml.XmlReader   rd        = new System.Xml.XmlTextReader(xmlStream, System.Xml.XmlNodeType.Document, null);
            string sreturn = "";

            try
            {
                while (rd.Read())
                {
                    if (rd.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        if (rd.LocalName == record_node ||
                            rd.Name == record_node)
                        {
                            sreturn = rd.ReadOuterXml();

                            writer.WriteLine(parseNode(sreturn));
                        }
                    }
                }
                if (rd != null)
                {
                    rd.Close();
                }
                if (writer != null)
                {
                    writer.Close();
                }

                return(processFile2MARC(tmpDest, sDest, arr_args, filing_file, bSort));
            }
            catch (System.Exception pp)
            {
                LastError = "Unable to process XML File.\n\nFull Exception:\n" + pp.ToString();
                if (rd != null)
                {
                    rd.Close();
                }
                if (writer != null)
                {
                    writer.Close();
                }
                return(false);
            }
        }
Exemple #43
0
        /// <summary>
        /// Extracts workspace settings from an XML Fragment and puts them into a hashtable:
        /// </summary>
        /// <param name="xmlFrag">The XML frag.</param>
        /// <returns>
        /// hashtable of the geodatabase workspace parameters
        /// </returns>
        private Hashtable WrkspcXMLFrag2Hash(string xmlFrag)
        {
            Trace.WriteLine("Start WrkspcXMLFrag2Hash");
            Hashtable hash = new Hashtable();

            try
            {
                NameTable           nameTable        = new NameTable();
                XmlNamespaceManager namespaceManager = new XmlNamespaceManager(new NameTable());
                namespaceManager.AddNamespace("rk", "urn:store-items");

                XmlParserContext     parserContext = new XmlParserContext(null, namespaceManager, null, XmlSpace.None);
                System.Xml.XmlReader xmlReader     = new System.Xml.XmlTextReader(xmlFrag, XmlNodeType.Element, parserContext);

                // iterate through the attributes of the <WORKSPACE> XML fragment and load into hashtable:
                try
                {
                    while (xmlReader.Read())
                    {
                        if (xmlReader.NodeType == XmlNodeType.Element)
                        {
                            if (xmlReader.HasAttributes == true)
                            {
                                try
                                {
                                    while (xmlReader.MoveToNextAttribute())
                                    {
                                        hash.Add(xmlReader.Name.ToUpper(), xmlReader.Value);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Trace.WriteLine("ArcZonaWorkspace.WrkspcXMLFrag2Hash Exception  Inside While: " + ex.Message + "\n\nStackTrace: " + ex.StackTrace);
                                    throw;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine("ArcZonaWorkspace.WrkspcXMLFrag2Hash Exception: " + ex.Message + "\n\nStackTrace: " + ex.StackTrace);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("ArcZonaWorkspace.WrkspcXMLFrag2Hash Exception: " + ex.Message + "\n\nStackTrace: " + ex.StackTrace);
                throw;
            }

            Trace.WriteLine("End WrkspcXMLFrag2Hash");

            return(hash);
        }
Exemple #44
0
        private void Conectar()
        {
            Connected = false;
            try
            {
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader("c:\\Terminal.xml");
                IDTerminal = 0;
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                    case "Mensaje":
                        IDTerminal = Convert.ToInt16(reader.ReadString());
                        break;

                    case "IP":
                        IP = reader.ReadString();
                        break;

                    case "PUERTO":
                        Port = Convert.ToInt32(reader.ReadString());
                        break;
                    }
                }
                msj                = new Mensaje();
                Cliente            = new TcpClient(this.IP, this.Port);
                StreamCliente      = Cliente.GetStream();
                msj.NombreTerminal = "Terminal";
                msj.Prioridad      = IDTerminal;
                msj.op             = 4;
                Send s = Send.GetSend();
                s.StreamCliente = this.StreamCliente;
                s.Cliente       = this.Cliente;
                s.EnviarMensaje(serial.SerializarObj(msj));
                Connected = true;
                this.Hilo = new Thread(SubProceso);
                this.Hilo.IsBackground = true;
                this.Hilo.Start();
            }
            catch
            {
                DialogResult dialogResult = MessageBox.Show("Error 100 - Sin conexion al servidor ¿Intentar Reconectar?", "Sin conexion a el servidor", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    Conectar();
                }
                else if (dialogResult == DialogResult.No)
                {
                    Connected = false;
                    Application.Exit();
                }
            }
        }
Exemple #45
0
        void ReadXMLFile(string filename)
        {
            //load the xml file into the XmlTextReader object.
            XmlTextReader XmlRdr = new System.Xml.XmlTextReader(filename);

            //while moving through the xml document.
            bool ListIsReady = false;

            LyricObject myLyric = new LyricObject();

            while (XmlRdr.Read())
            {
                ListIsReady = true; // guard to make sure we have font objects to fill with data..


                if (ListIsReady)
                {
                    //check the node type and look for the elements desired.
                    if (XmlRdr.NodeType == XmlNodeType.Element && XmlRdr.Name == "Artist")
                    {
                        myLyric.Artist = XmlRdr.ReadElementContentAsString();
                    }

                    if (XmlRdr.NodeType == XmlNodeType.Element && XmlRdr.Name == "Title")
                    {
                        myLyric.Title = XmlRdr.ReadElementContentAsString();
                    }

                    if (XmlRdr.NodeType == XmlNodeType.Element && XmlRdr.Name == "S1")
                    {
                        myLyric.S1 = XmlRdr.ReadElementContentAsString();
                    }

                    if (XmlRdr.NodeType == XmlNodeType.Element && XmlRdr.Name == "S2")
                    {
                        myLyric.S2 = XmlRdr.ReadElementContentAsString();
                    }

                    if (XmlRdr.NodeType == XmlNodeType.Element && XmlRdr.Name == "S3")
                    {
                        myLyric.S3 = XmlRdr.ReadElementContentAsString();
                    }

                    if (XmlRdr.NodeType == XmlNodeType.Element && XmlRdr.Name == "S4")
                    {
                        myLyric.S4 = XmlRdr.ReadElementContentAsString();

                        m_LyricObject.Add(myLyric);
                        myLyric = new LyricObject();
                    }
                }
            } //endwhile
        }
Exemple #46
0
    protected void btnXMLImport_Click(object sender, EventArgs e)
    {
        //  string xmlfilename =
        //"D:\\LAVC computer Science\\CSIT 870Exercise\\Final Project\\Survey Prj\\Survey_Questions_e.xml";
        // "D:\\LAVC computer Science\\CSIT 870Exercise\\XMLFile_and_Templates\\XMLFile.xml";


        System.Xml.XmlTextReader xmlreader = new System.Xml.XmlTextReader
                                                 (Server.MapPath("~/App_Data/Survey_Questions_e.xml"));

        SqlConnection connection = new System.Data.SqlClient.SqlConnection();
        string        con_string = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

        connection.ConnectionString = con_string;


        //string cmd_string = "DELETE FROM Question";   // remove all records from the REGIONS table
        // System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(cmd_string, connection);

        /*    command.Connection.Open();
         *  command.ExecuteNonQuery();                  // execute the delete command
         *
         *  xmlreader.MoveToContent();   */// skip over the XML header stuff
        while (xmlreader.Read())
        {
            if (xmlreader.NodeType == System.Xml.XmlNodeType.Element) // only process the start tag of the element
            {
                string tag = xmlreader.Name;                          // get the tag name for the element
                if (tag == "Question")
                {
                    string Focus_Group = xmlreader.GetAttribute("Focus_Group"); // get the Attribute values
                    string Catagory    = xmlreader.GetAttribute("Catagory");
                    string Questiontxt = xmlreader.ReadInnerXml();

                    // Build and execute the INSERT command

                    string cmd_string = "INSERT INTO Question(Focus_Group,Catagory,Question) VALUES ('"
                                        + Focus_Group + "', '" + Catagory + "', '" + Questiontxt + "')";
                    System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand(cmd_string, connection);

                    command.CommandText = cmd_string;
                    command.Connection.Open();
                    command.ExecuteNonQuery();            // execute the insert command
                    command.Connection.Close();
                }
            }
        }



        GridView1.Visible = true;
    }
        private void IniciarServidor()
        {
            int    Port = 0;
            string IP   = "";

            try
            {
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader("c:\\Servidor.xml");
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                    case "IP":
                        IP = reader.ReadString();
                        break;

                    case "PUERTO":
                        Port = Convert.ToInt32(reader.ReadString());
                        break;
                    }
                }
            }
            catch
            {
                MessageBox.Show("Error al cargar configuracion de conexion");
            }
            try
            {
                IPEndPoint ipend = new IPEndPoint(IPAddress.Parse(IP), Port);
                Server = new TcpListener(ipend);
                Server.Start();
            }
            catch
            {
                DialogResult dialogResult = MessageBox.Show("Error al iniciar servidor ¿Intentar denuevo?", "Alerta", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    IniciarServidor();
                }
                else if (dialogResult == DialogResult.No)
                {
                    Application.Exit();
                }
            }
            hs = new Hashtable();
            datos.setTerminales(hs);
            this.Hilo = new Thread(ServerStart);
            this.Hilo.IsBackground = true;
            this.Hilo.Start();
            datos.Online = true;
        }
Exemple #48
0
        /// <summary>
        /// Finner alle funksjoner som en bestemt variabel inngår i, og variabelens tilhørende beskrivelse. Hentes fra en C# xml fil.
        /// Dobbelarrayen har to kolonner. Første kolonne er funksjonsnavn, mens andre kolonne er variabelbeskrivelsen for hver funksjon.
        /// </summary>
        /// <param name="varNavn">Navnet på variabelen man vil ha info om.</param>
        /// <param name="fil">Full path med filnavn til xml filen.</param>
        /// <returns>Dobbelarrayen har to kolonner. Første kolonne er funksjonsnavn, mens andre kolonne er variabelbeskrivelsen for hver funksjon.</returns>
        public static string[,] XmlLesFunkNavnVarBeskFraVar(string varNavn, string fil)
        {
            Xml.XmlTextReader rd = new Xml.XmlTextReader(fil);
            System.Collections.Generic.List <string> varBeskLi  = new System.Collections.Generic.List <string>();
            System.Collections.Generic.List <string> funkNavnLi = new System.Collections.Generic.List <string>();
            string reg = "([.]\\w+([(]))"; //matcher punktum, etterfulgt av et ord, etterfulgt av parentesstart.

            while (rd.Read())
            {
                if (rd.Name == "member")
                { //Funksjonsnavn
                    string attr = "";
                    for (int j = 0; j < rd.AttributeCount; j++)
                    {
                        attr = rd.GetAttribute(0);                                         //Hvis jeg ikke har med for-løkken, så får jeg en feilmelding.
                    }
                    RegExp.Match m = RegExp.Regex.Match(attr, reg);
                    if (m.Success)
                    {
                        attr = m.ToString();
                        funkNavnLi.Add(attr.Remove(attr.Length - 1).Remove(0, 1)); //Fjerner punktum og parentes
                    }
                }
                else if (rd.Name == "param")
                { //Variabelbeskrivelse
                    string attr = "";
                    if (rd.AttributeCount > 0)
                    {
                        attr = rd.GetAttribute(0).Trim();                        //Det hender at rd ikke har noen attributes.
                    }
                    if (attr == varNavn)
                    {
                        varBeskLi.Add(rd.ReadString().Trim());
                    }
                }
            }
            rd.Close();
            if (string.IsNullOrEmpty(funkNavnLi[0]))
            {
                Console.WriteLine("Fant ikke variabelen " + varNavn + " i xmlfilen.");
                return(null);
            }
            string[,] funkNavnVarBeskLi = new string[funkNavnLi.Count, 2];
            for (int i = 0; i < funkNavnVarBeskLi.GetLength(0); i++)
            {
                funkNavnVarBeskLi[i, 0] = funkNavnLi[i];
                funkNavnVarBeskLi[i, 1] = varBeskLi[i];
            }
            return(funkNavnVarBeskLi);
        }
Exemple #49
0
 public bool XMLTagExists(string FilePath, string SearchTag)
 {
     System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(FilePath);
     while (reader.Read())
     {
         reader.MoveToContent();
         if (reader.NodeType == System.Xml.XmlNodeType.Element)
         {
             if (reader.Name == SearchTag)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemple #50
0
    /// <summary>
    /// Here we create the roles written in the xml file
    /// </summary>
    protected void CreateRoles()
    {
        try
        {
            PortalSettings portalSettings = new PortalSettings();
            int            portalId       = portalSettings.PortalId;
            RoleController rc             = new RoleController();

            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Server.MapPath("DesktopModules/AIS/Installer/Modules.xml") /*"C:\\inetpub\\wwwroot\\DNN\\DesktopModules\\AIS\\ListeInterventions\\Roles.xml"*/);
            while (reader.Read())
            {
                reader.MoveToContent();
                if (reader.Name == "role")
                {
                    RoleInfo ri = new RoleInfo();
                    ri.PortalID       = portalId;
                    ri.AutoAssignment = false;
                    ri.Status         = RoleStatus.Approved;
                    if (reader.HasAttributes)
                    {
                        if (reader.GetAttribute("name") != "")
                        {
                            ri.RoleName = reader.GetAttribute("name");
                        }
                        if (reader.GetAttribute("groupID") != "")
                        {
                            ri.RoleGroupID = int.Parse(reader.GetAttribute("groupID"));
                        }
                        if (reader.GetAttribute("public") != "")
                        {
                            ri.IsPublic = bool.Parse(reader.GetAttribute("public"));
                        }
                    }
                    //Don't add existing roles
                    if (!RoleExists(ri))
                    {
                        rc.AddRole(ri);
                    }
                }
            }
        }
        catch (Exception exc)
        {
            //superlabel.Text += "An error occured, please see the event log or contact an administrator for more informations";
        }
    }
        internal static void Open(string path, Scene scene, TextureManager textureManager, Layers layers)
        {
            XmlTextReader xmlReader = new System.Xml.XmlTextReader(path);

            xmlReader.MoveToContent();  // Jumps into top level header
            while (xmlReader.Read())
            {
                if ("texturedata" == xmlReader.Name)
                {
                    LoadTextureData(xmlReader, textureManager);
                }
                else if ("scenedata" == xmlReader.Name)
                {
                    LoadSceneData(xmlReader, scene, textureManager);
                }
            }
            layers.RefreshLayerContent(scene.Layers);
        }
Exemple #52
0
        private bool ReadXMLFile(string fileName)
        {
            try
            {
                Logger.MajorDebug("Reading XML configuration...");
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(fileName);
                reader.WhitespaceHandling = System.Xml.WhitespaceHandling.None;
                reader.MoveToContent();
                reader.Read();

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

                doc.Load(reader);

                port                   = Convert.ToInt32(GetParameterValue(doc, "Port"));
                consolePort            = Convert.ToInt32(GetParameterValue(doc, "ConsolePort"));
                maxCons                = Convert.ToInt32(GetParameterValue(doc, "MaxConnections"));
                LMKFile                = Convert.ToString(GetParameterValue(doc, "LMKStorageFile"));
                VBsources              = Convert.ToString(GetParameterValue(doc, "VBSourceDirectory"));
                Logger.CurrentLogLevel = (Log.Logger.LogLevel)(Enum.Parse(typeof(Logger.LogLevel), Convert.ToString(GetParameterValue(doc, "LogLevel")), true));
                CheckLMKParity         = Convert.ToBoolean(GetParameterValue(doc, "CheckLMKParity"));
                HostDefsDir            = Convert.ToString(GetParameterValue(doc, "XMLHostDefinitionsDirectory"));
                DoubleLengthZMKs       = Convert.ToBoolean(GetParameterValue(doc, "DoubleLengthZMKs"));
                LegacyMode             = Convert.ToBoolean(GetParameterValue(doc, "LegacyMode"));
                ExpectTrailers         = Convert.ToBoolean(GetParameterValue(doc, "ExpectTrailers"));
                HeaderLength           = Convert.ToInt32(GetParameterValue(doc, "HeaderLength"));
                EBCDIC                 = Convert.ToBoolean(GetParameterValue(doc, "EBCDIC"));

                StartUpCore(Convert.ToString(GetParameterValue(doc, "FirmwareNumber")), Convert.ToString(GetParameterValue(doc, "DSPFirmwareNumber")),
                            Convert.ToBoolean(GetParameterValue(doc, "StartInAuthorizedState")), Convert.ToInt32(GetParameterValue(doc, "ClearPINLength")));

                reader.Close();
                reader = null;

                return(true);
            }
            catch (Exception ex)
            {
                Logger.MajorError("Error loading the configuration file");
                Logger.MajorError(ex.ToString());
                return(true);
            }
        }
Exemple #53
0
        public bool get(string filePath)
        {
            bool status = false;

            System.Xml.XmlTextReader reader;

            try
            {
                reader = new System.Xml.XmlTextReader(filePath);

                //string contents = "";

                string keyName = "";

                string keyVal = "";

                while (reader.Read())
                {
                    reader.MoveToContent();
                    if (reader.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        keyName = reader.Name;
                    }
                    //contents += "<" + reader.Name + ">\n";

                    if (reader.NodeType == System.Xml.XmlNodeType.Text)
                    {
                        keyVal = reader.Value;
                    }
                    //contents += reader.Value + "\n";
                }

                status = true;
            }
            catch (Exception ex)
            {
                message = ex.Message;
                status  = false;
            }

            return(status);
        }
Exemple #54
0
        /// <summary>
        /// Read config from configuration file.
        /// </summary>
        /// <returns>If no errors occurred true, otherwise false.</returns>
        public Boolean readConfig()
        {
            Boolean result = true;

            try {
                XmlTextReader xtr = new System.Xml.XmlTextReader("radixpro.config");
                while (xtr.Read())
                {
                    if (xtr.NodeType == XmlNodeType.Element)
                    {
                        parseXmlTag(xtr.Name, xtr.ReadString());
                    }
                }
                xtr.Close();
            }
            catch {
                result = false;
                // todo handle exception message
            }
            return(result);
        }
Exemple #55
0
    private List <TabPermissionInfo> getListPermissionsTab(string tabName)
    {
        PortalSettings           ps          = new PortalSettings();
        int                      portalId    = ps.PortalId;
        RoleController           rc          = new RoleController();
        List <TabPermissionInfo> permissions = new List <TabPermissionInfo>();

        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Server.MapPath("DesktopModules/AIS/Installer/Modules.xml") /*"C:\\inetpub\\wwwroot\\DNN\\DesktopModules\\AIS\\Installer\\Modules.xml"*/);
        while (reader.Read())
        {
            if (reader.Name == "permission" && reader.HasAttributes && reader.GetAttribute("tab") == tabName)
            {
                RoleInfo ri = rc.GetRoleByName(portalId, reader.GetAttribute("role"));
                foreach (PermissionInfo p in PermissionController.GetPermissionsByTab())
                {
                    if (p.PermissionKey == "VIEW")
                    {
                        TabPermissionInfo tpi = new TabPermissionInfo();
                        tpi.PermissionID   = p.PermissionID;
                        tpi.PermissionKey  = p.PermissionKey;
                        tpi.PermissionName = p.PermissionName;
                        tpi.AllowAccess    = bool.Parse(reader.GetAttribute("View"));;
                        tpi.RoleID         = ri.RoleID;
                        permissions.Add(tpi);
                    }
                    if (p.PermissionKey == "EDIT")
                    {
                        TabPermissionInfo tpi = new TabPermissionInfo();
                        tpi.PermissionID   = p.PermissionID;
                        tpi.PermissionKey  = p.PermissionKey;
                        tpi.PermissionName = p.PermissionName;
                        tpi.AllowAccess    = bool.Parse(reader.GetAttribute("Edit"));;
                        tpi.RoleID         = ri.RoleID;
                        permissions.Add(tpi);
                    }
                }
            }
        }
        return(permissions);
    }
Exemple #56
0
    // Get the recording details from the XML file returned by the web request
    RecordingDetails GetRecordingDetails()
    {
        WWW www = new WWW(GetRecordingDetailsURL);

        while (!www.isDone)
        {
        }
        if (debugActive)
        {
            Debug.Log(www.text);
        }
        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(new System.IO.StringReader(www.text));
        string newestID        = "";
        string newestStartTime = "";
        string newestStopTime  = "";

        while (reader.Read())
        {
            string newID        = reader.GetAttribute("recordingid");
            string newStartTime = reader.GetAttribute("starttime");
            string newStopTime  = reader.GetAttribute("stoptime");

            if (newID != null)
            {
                newestStartTime = newStartTime;
                newestStopTime  = newStopTime;
                newestID        = newID;
            }
        }

        RecordingDetails output = new RecordingDetails();

        output.recordingID = newestID;
        output.startTime   = newestStartTime;
        output.stopTime    = newestStopTime;

        details.collected = true;
        return(output);
    }
Exemple #57
0
        public static TNfeProc GetTNFeProc(string content)
        {
            TNfeProc nfeProc = null;

            try
            {
                XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
                namespaces.Add("NFe", "http://www.portalfiscal.inf.br/nfe");
                XmlSerializer serializer = new XmlSerializer(typeof(TNfeProc));
                serializer.Serialize(Console.Out, new TNfeProc(), namespaces);
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(new System.IO.StringReader(content));
                reader.Read();
                nfeProc = (TNfeProc)serializer.Deserialize(reader);
                reader.Close();
            }
            catch
            {
                nfeProc = null;
                throw;
            }
            return(nfeProc);
        }
Exemple #58
0
        /// <summary>
        /// Reads the substrate list out of the xml file
        /// </summary>
        /// <param name="XMLfile">a xml file</param>
        public substrates(string XMLfile)
        {
            XmlTextReader reader = new System.Xml.XmlTextReader(XMLfile);

            string xml_tag      = "";
            string substrate_id = "";

            // go through the file
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case System.Xml.XmlNodeType.Element: // this knot is an element
                    xml_tag = reader.Name;

                    while (reader.MoveToNextAttribute())
                    { // read the attributes, here only the attribute of digester
                      // is of interest, all other attributes are ignored,
                      // actually there usally are no other attributes
                        if (xml_tag == "substrate" && reader.Name == "id")
                        {
                            // found a new substrate
                            substrate_id = reader.Value;

                            addSubstrate(new biogas.substrate(ref reader, substrate_id));

                            break;
                        }
                    }
                    break;
                } // switch
            }     // while

            //

            reader.Close();
        }
Exemple #59
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            string XmlFile;

            System.IO.DirectoryInfo directoryInfo;
            System.IO.DirectoryInfo directoryXML;

            //Get the applications startup path
            directoryInfo = System.IO.Directory.GetParent(Application.StartupPath);

            //Set the output path
            if (directoryInfo.Name.ToString() == "bin")
            {
                directoryXML = System.IO.Directory.GetParent(directoryInfo.FullName);
                XmlFile      = directoryXML.FullName + "\\customers.xml";
            }
            else
            {
                XmlFile = directoryInfo.FullName + "\\customers.xml";
            }
            fileName.Text = XmlFile;

            //load the xml file into the XmlTextReader object.

            XmlTextReader XmlRdr = new System.Xml.XmlTextReader(XmlFile);

            //while moving through the xml document.
            while (XmlRdr.Read())
            {
                //check the node type and look for the element type
                //whose Name property is equal to name.
                if (XmlRdr.NodeType == XmlNodeType.Element && XmlRdr.Name == "name")
                {
                    XMLOutput.Text += XmlRdr.ReadString() + "\r\n";
                }
            }
        }
Exemple #60
0
        /// <summary>
        /// discover an url endpoint from a wsdl file. only supports anonymous access http gets
        /// </summary>
        /// <param name="URL"></param>
        /// <returns></returns>
        public string[] DiscoverEndpointByWSDL(string URL)
        {
            List <string> urls = new List <string>();

            System.Net.WebClient client = new System.Net.WebClient();
            string res = "";

            try
            {
                res = client.DownloadString(URL);
            }
            catch (Exception ex)
            {
                //todo log warning
                return(null);
            }
            StringReader sw = new StringReader(res);

            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(sw);
            while (reader.Read())
            {
                if (
                    (reader.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/soap/" ||
                     reader.NamespaceURI == "http://www.w3.org/2003/01/wsdl/soap12") &&
                    reader.Name == "address")
                {
                    try
                    {
                        urls.Add(reader.GetAttribute("location"));
                    }
                    catch { }
                }
            }
            sw.Dispose();
            return(urls.ToArray());
        }