public static DatabaseConfiguration Read (string file)
		{
			DatabaseConfiguration config = new DatabaseConfiguration ();
			
			StreamReader s = new StreamReader (file);
			using (s) {
				XmlTextReader tr = new XmlTextReader (s);
				tr.MoveToContent ();
				tr.ReadStartElement ("Configuration");
				tr.MoveToContent ();
				tr.ReadStartElement ("DisabledAddins");
				tr.MoveToContent ();
				if (!tr.IsEmptyElement) {
					while (tr.NodeType != XmlNodeType.EndElement) {
						if (tr.NodeType == XmlNodeType.Element) {
							if (tr.LocalName == "Addin")
								config.DisabledAddins.Add (tr.ReadElementString ());
						}
						else
							tr.Skip ();
						tr.MoveToContent ();
					}
				}
			}
			return config;
		}
Esempio n. 2
0
 public bool cargar()
 {
     XmlTextReader reader = new XmlTextReader(archivoConfig);
     try
     {
         try
         {
             reader.MoveToContent();
         }
         catch (Exception)
         {
             return false;
         }
         if (reader.Name != primerElemento)
             throw new ErrorSokoVen("El archivo " + archivoConfig +
               " debería empezar con: <" + primerElemento + '>');
         while (reader.Read())
         {
             switch (reader.MoveToContent())
             {
                 case XmlNodeType.Element:
                     leeElemento(reader);
                     break;
             }
         }
     }
     finally
     {
         if (reader != null)
             reader.Close();
     }
     return true;
 }
 private ConfigurationContainer ReadConfiguration(string file)
 {
     ConfigurationContainer container = new ConfigurationContainer();
     XmlTextReader reader = null;
     try {
         reader = new XmlTextReader(new StreamReader(file));
         while (!reader.EOF) {
             reader.Read();
             if (reader.IsStartElement()) {
                 if (reader.Name == "WaitTime") {
                     reader.MoveToContent();
                     reader.Read();
                     container.WaitTime = int.Parse(reader.Value);
                 }
                 else if (reader.Name == "AutoStart") {
                     reader.MoveToContent();
                     reader.Read();
                     container.AutoStart = bool.Parse(reader.Value);
                 }
                 else if (reader.Name == "MaxRetryCount") {
                     reader.MoveToContent();
                     reader.Read();
                     container.MaxRetryCount = int.Parse(reader.Value);
                 }
             }
         }
         return container;
     }
     catch { return null; }
     finally { if (reader != null) reader.Close(); }
 }
 /// <summary>
 ///     Reads this instance.
 /// </summary>
 public List<XmlExceptionParser> Read(string exceptionPath)
 {
     var exceptionsList = new List<XmlExceptionParser>();
     var xmlText = new XmlTextReader(exceptionPath);
     while (xmlText.Read())
     {
         var xmlNode = new XmlExceptionParser();
         if (xmlText.MoveToContent() == XmlNodeType.Element && xmlText.Name == "Message")
         {
             xmlNode.Message = xmlText.ReadElementString();
         }
         if (xmlText.MoveToContent() == XmlNodeType.Element && xmlText.Name == "Source")
         {
             xmlNode.Source = xmlText.ReadElementString();
         }
         if (xmlText.MoveToContent() == XmlNodeType.Element && xmlText.Name == "Stack")
         {
             xmlNode.Stack = xmlText.ReadElementString();
         }
         if (xmlText.MoveToContent() == XmlNodeType.Element && xmlText.Name == "Date")
         {
             xmlNode.Date = Convert.ToDateTime(xmlText.ReadElementString());
         }
         if (!string.IsNullOrEmpty(xmlNode.Message) && !string.IsNullOrEmpty(xmlNode.Source) &&
             !string.IsNullOrEmpty(xmlNode.Stack))
         {
             exceptionsList.Add(xmlNode);
         }
     }
     xmlText.Close();
     return exceptionsList;
 }
Esempio n. 5
0
        public static DatabaseConfiguration Read(string file)
        {
            DatabaseConfiguration config = new DatabaseConfiguration ();

            StreamReader s = new StreamReader (file);
            using (s) {
                XmlTextReader tr = new XmlTextReader (s);
                tr.MoveToContent ();
                if (tr.IsEmptyElement)
                    return config;

                tr.ReadStartElement ("Configuration");
                tr.MoveToContent ();

                while (tr.NodeType != XmlNodeType.EndElement) {

                    if (tr.NodeType != XmlNodeType.Element || tr.IsEmptyElement) {
                        tr.Skip ();
                    }
                    else if (tr.LocalName == "DisabledAddins") {
                        // For back compatibility
                        tr.ReadStartElement ();
                        tr.MoveToContent ();
                        while (tr.NodeType != XmlNodeType.EndElement) {
                            if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin")
                                config.addinStatus [tr.ReadElementString ()] = null;
                            else
                                tr.Skip ();
                            tr.MoveToContent ();
                        }
                        tr.ReadEndElement ();
                    }
                    else if (tr.LocalName == "AddinStatus") {
                        tr.ReadStartElement ();
                        tr.MoveToContent ();
                        while (tr.NodeType != XmlNodeType.EndElement) {
                            if (tr.NodeType == XmlNodeType.Element && tr.LocalName == "Addin") {
                                string aid = tr.GetAttribute ("id");
                                string senabled = tr.GetAttribute ("enabled");
                                if (senabled.Length == 0 || senabled == "True")
                                    config.addinStatus [aid] = config;
                                else
                                    config.addinStatus [aid] = null;
                            }
                            tr.Skip ();
                            tr.MoveToContent ();
                        }
                        tr.ReadEndElement ();
                    }
                    tr.MoveToContent ();
                }
            }
            return config;
        }
Esempio n. 6
0
 public bool LoadFromFile(string filename)
 {
     m_FileName = filename;
     bool bRet = false;
     XmlTextReader reader = null;
     try
     {
         reader = new XmlTextReader(m_FileName);
         while (reader.Read())
         {
             switch (reader.NodeType)
             {
                 case XmlNodeType.Element: // The node is an element.
                     switch (reader.Name)
                     {
                         case "name": reader.MoveToContent(); m_name = reader.ReadElementContentAsString(); break;
                         case "pass1": reader.MoveToContent(); m_pass1 = reader.ReadElementContentAsString(); break;
                         case "pass2": reader.MoveToContent(); m_pass2 = reader.ReadElementContentAsString(); break;
                         case "icon": reader.MoveToContent(); m_icon = reader.ReadElementContentAsInt(); break;
                         case "account":
                             {
                                 AccountItem newAccount = new AccountItem();
                                 if (newAccount.AccountXMLLoad(reader))
                                 {
                                     m_Accounts.Add(newAccount);
                                 }
                                 break;
                             }
                     }
                     break;
                 case XmlNodeType.EndElement:
                     break;
             }
         }
     }
     catch (System.IO.FileNotFoundException exception)
     {
         return false;
     }
     catch (Exception exception)
     {
         MessageBox.Show("Error reading " + m_FileName);
     }
     finally
     {
         reader.Close();
     }
     return bRet;
 }
        public Bag Deserialize(TextReader tr) {
            var reader = new XmlTextReader(tr);
            var result = new Bag();

            // ignore root element
            while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == Root) {
                reader.Read();
            }

            while (reader.MoveToContent() == XmlNodeType.Element) {
                ReadElement(reader, result);
            }

            return result;
        }
Esempio n. 8
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);
                        }
                    }
                }
            }
        }
    }
Esempio n. 9
0
        //http request bt GET
        //to get info of a student
        public List<String> getStudentInfoByGet(string URL, string ID_No)
        {
            //Create the URL
            List<String> infos = new List<string>();
            String[] functions = { "GetStudentName", "GetStudentGender", "GetStudentMajor", "GetStudentEmailAddress" };
            string function = "";
            for (int i = 0; i < functions.Length; i++)
            {
                function = functions[i];
                string strURL = URL + function + "?ID_No=" + ID_No;

                //Initiate, DO NOT use constructor of HttwWebRequest
                //DO use constructor of WebRequest
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
                request.Method = "GET";
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    Stream s = response.GetResponseStream();
                    XmlTextReader reader = new XmlTextReader(s);
                    reader.MoveToContent();
                    string xml = reader.ReadInnerXml();
                    ////////
                    xml = xml.Split(new Char[] { '<', '>' })[2];
                    /////////
                    infos.Add(xml);
                }                
            }
            return infos;
        }
Esempio n. 10
0
    public static void Setup()
    {
      System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
      string name = ass.FullName.Substring(0, ass.FullName.IndexOf(','));


      string userFile = string.Format("{0}\\{1}.LiveSchedule.{2}.xml", dir, name, System.Environment.UserName);
      string defaultFile = string.Format("{0}\\{1}.LiveSchedule.{2}.xml", dir, name, "DefaultConfig");

      string useFile = File.Exists(userFile) ? userFile : File.Exists(defaultFile) ? defaultFile : null;

      if (useFile == null)
      {

        Logger.Debug(string.Format("No config found for executable.  Default would be expected @ {0}", defaultFile), typeof(Scheduler));
        return;
      }

      Logger.Debug(string.Format("Reading scheduler config from file: {0}", useFile), typeof(Scheduler));

      XmlDocument doc = new XmlDocument();
      XmlTextReader reader = new XmlTextReader(string.Format(@"file://{0}", useFile.Replace(@"\", "/")));
      reader.MoveToContent();
      doc.Load(reader);
      reader.Close();

      Setup(doc.DocumentElement);
    }
Esempio n. 11
0
        static void evaluate()
        {
            XmlTextReader reader = new XmlTextReader("network.xml");

            reader.MoveToContent();

            RoadNetwork network = new RoadNetwork(reader);

            Console.WriteLine("Dimensions: " + network.Map.Width + " x " + network.Map.Height);
            Console.WriteLine("Start:" + network.Map.Start.X + ", " + network.Map.Start.Y);
            Console.WriteLine("End:" + network.Map.End.X + ", " + network.Map.End.Y);

            for (int i = 0; i < network.Map.TownCount; i++)
            {
                Coordinates town = network.Map.GetTown(i);
                Console.WriteLine("Town:" + town.X + "," + town.Y);
            }

            for (int i = 0; i < network.EdgeCount; i++)
            {
                Edge edge = network.GetEdge(i);
                Console.WriteLine("Edge:" + edge.Start.Coordinates.X + "," + edge.Start.Coordinates.Y + " - " + edge.End.Coordinates.X + "," + edge.End.Coordinates.Y);
            }

            IEvaluator evaluator = new Evaluator(null);

            uint fitness = evaluator.Evaluate(network);
            float v = FitnessConverter.ToFloat(fitness);

            Console.WriteLine("Fitness: " + fitness);
            Console.WriteLine("Floating Point Fitness: " + v + " " + 1 / v);
        }
Esempio n. 12
0
        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;
        }
Esempio n. 13
0
        public static string ExtractQuery(string fileName, TextWriter errorlogger)
        {
            try
            {
                string data = File.ReadAllText(fileName);
                XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.None);
                Stream xmlFragment = new MemoryStream(Encoding.UTF8.GetBytes(data));
                XmlTextReader reader = new XmlTextReader(xmlFragment, XmlNodeType.Element, context);
                reader.MoveToContent();
                if (reader.NodeType == XmlNodeType.Text)
                {
                    return data;
                }
                XmlReader reader2 = reader.ReadSubtree();
                StringBuilder output = new StringBuilder();
                using (XmlWriter writer = XmlWriter.Create(output))
                {
                    writer.WriteNode(reader2, true);
                }

                StringReader reader3 = new StringReader(data);
                for (int i = 0; i < reader.LineNumber; i++)
                {
                    reader3.ReadLine();
                }
                return reader3.ReadToEnd().Trim();
            }
            catch (Exception ex)
            {
                errorlogger.WriteLine(ex.Message);
                errorlogger.WriteLine(ex.StackTrace);
            }

            return string.Format("//Error loading the file - {0} .The the linq file might be a linqpad expression which is not supported in the viewer currently." ,fileName);
        }
Esempio n. 14
0
        private void Listen(object sender, DoWorkEventArgs e)
        {
            string url = @"http://" + _ipAddr.ToString() + "/PSIA/Metadata/stream?AreaControlEvents=true";
            credentialCache.Add(new System.Uri(url), "Basic", _credentials);

            _req = WebRequest.Create(url);
            _req.Credentials = credentialCache;
            _req.PreAuthenticate = true;

            HttpWebResponse response = (HttpWebResponse)_req.GetResponse();
            Stream responseStream = response.GetResponseStream();
            XmlTextReader reader = new XmlTextReader(responseStream);

            while (true)
            {
                reader.MoveToContent();
                string contents = reader.ReadOuterXml();

                if (OnEventRaised != null)
                {
                    BackgroundWorker worker = new BackgroundWorker();
                    worker.DoWork += new DoWorkEventHandler(worker_DoWork);
                    worker.RunWorkerAsync(contents);
                }

                reader.ResetState();
            }
        }
		public XmlNode SerializeAsXmlNode(XmlDocument doc)
		{
			System.IO.MemoryStream ms = new MemoryStream();
			XmlSerializer serializer = new XmlSerializer(typeof(ColumnCollection));
			XmlTextReader xRead = null;
			XmlNode xTable = null;
			try
			{
				xTable = doc.CreateNode(XmlNodeType.Element, "TABLE", doc.NamespaceURI);

				serializer.Serialize(ms, this);
				ms.Position = 0;
				xRead = new XmlTextReader( ms );
				xRead.MoveToContent();
				string test = xRead.ReadInnerXml();
				XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
				docFrag.InnerXml = test;

				xTable.AppendChild(docFrag);
			}
			catch(Exception ex)
			{
				throw new Exception("IdentityCollection Serialization Error.", ex);
			}
			finally
			{
				ms.Close();
				if (xRead != null) xRead.Close();
			}
			return xTable;
		}
Esempio n. 16
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);
    }
        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();
        }
        public static MapLayer LoadTmx(string xmlFile)
        {
            XmlTextReader reader = new XmlTextReader(xmlFile);

            MapLayer map = null;

            while (reader.Read())
            {
                if (reader.Name.Equals("layer"))
                {
                    map = new MapLayer(Int32.Parse(reader.GetAttribute("width")), Int32.Parse(reader.GetAttribute("height")));
                    for (int i = 0; i < map.Height; i++)
                    {
                        for (int j = 0; j < map.Width; j++)
                        {
                            while (reader.Read())
                            {
                                if (reader.Name.Equals("tile"))
                                    break;
                            }
                            reader.MoveToContent();
                            map.SetTile(j, i, new Tile(Int32.Parse(reader.GetAttribute("gid")) - 1, 0));
                        }
                    }

                    break;
                }
            }

            reader.Close();

            return map;
        }
        public object ReadFile(string file, IProgressMonitor monitor)
        {
            XmlTextReader reader = new XmlTextReader (new StreamReader (file));
            reader.MoveToContent ();

            string version = reader.GetAttribute ("version");
            if (version == null) version = reader.GetAttribute ("fileversion");

            DataSerializer serializer = new DataSerializer (Runtime.ProjectService.DataContext, file);
            ICombineReader combineReader = null;

            if (version == "1.0" || version == "1") {
                combineReader = new CombineReaderV1 (serializer, monitor);
                monitor.ReportWarning (string.Format (GettextCatalog.GetString ("The file '{0}' is using an old combine file format. It will be automatically converted to the current format."), file));
            }
            else if (version == "2.0")
                combineReader = new CombineReaderV2 (serializer, monitor);

            try {
                if (combineReader != null)
                    return combineReader.ReadCombine (reader);
                else
                    throw new UnknownProjectVersionException (file, version);
            } finally {
                reader.Close ();
            }
        }
Esempio n. 20
0
        //http request bt POST
        //to add new info of a student
        public String InsertStudentInfoByPost(string URL, String Info)
        {
            string strURL = URL+ "InsertStudentInfo";
            
            Encoding myEncoding = Encoding.GetEncoding("utf-8");
            string param = "Info="+ HttpUtility.UrlEncode(Info, myEncoding);
            
            byte[] bs = Encoding.ASCII.GetBytes(param);
            string result="";

            //Initiate, DO NOT use constructor of HttwWebRequest
            //DO use constructor of WebRequest
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(strURL);
            //POST
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
            request.ContentLength = bs.Length;
            using (Stream reqStream = request.GetRequestStream())
            {
                reqStream.Write(bs, 0, bs.Length);
            }

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                //DEAL with return values here
                Stream s = response.GetResponseStream();
                XmlTextReader reader = new XmlTextReader(s);
                reader.MoveToContent();
                result = reader.ReadInnerXml();
                ////////
                result=result.Split(new Char[] { '<', '>' })[2];
                /////////
            }
            return result;
        }
        protected override void DeserializeElement(XmlReader reader, bool serializeCollectionKey)
        {
            reader.MoveToContent();

            // Check for invalid usage
            if (reader.AttributeCount > 1)
                throw new ConfigurationErrorsException("Only a single type or fileName attribute is allowed.");
            if (reader.AttributeCount == 0)
                throw new ConfigurationErrorsException("A type or fileName attribute is required.");

            // Determine if we need to get the section from the inline XML or from an external file.
            m_FileName = reader.GetAttribute("fileName");
            if (m_FileName == null)
            {
                DeserializeData(reader);
                reader.ReadEndElement();
            }
            else
            {
                if (!reader.IsEmptyElement)
                {
                    throw new ConfigurationErrorsException(
                        "The section element must be empty when using the fileName attribute.");
                }

                using (FileStream file = new FileStream(m_FileName, FileMode.Open, FileAccess.Read))
                {
                    XmlReader rdr = new XmlTextReader(file);
                    rdr.MoveToContent();
                    DeserializeData(rdr);
                    rdr.Close();
                }
            }
        }
Esempio n. 22
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);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Loads this instance.
        /// </summary>
        public void Load()
        {
            try
            {
                XmlTextReader r = new XmlTextReader(File.OpenRead(fileName));

                object key = null;
                while(r.Read())
                {
                    r.MoveToContent();
                    if(r.NodeType == XmlNodeType.Element)
                    {
                        if(r.Name == "Name")
                        {
                            r.MoveToContent();
                            key = Enum.Parse(typeof(System.Windows.Forms.Keys), r.ReadString());
                        }
                        else if(r.Name == "Macro")
                        {
                            r.MoveToContent();
                            keys[key] = r.ReadString();
                        }
                    }
                }
            }
            catch(XmlException)
            {
            }
            catch(FileNotFoundException)
            {
                //this just means this is the first time
                //the list has ever been loaded
            }
        }
Esempio n. 24
0
		/// <summary>
		/// Cache the xmld docs into a hashtable for faster access.
		/// </summary>
		/// <param name="reader">An XMLTextReader containg the docs the cache</param>
		private void CacheDocs(XmlTextReader reader)
		{
			object oMember = reader.NameTable.Add("member");
			reader.MoveToContent();

			while (!reader.EOF) 
			{
				if ((reader.NodeType == XmlNodeType.Element) && (reader.Name.Equals(oMember)))
				{
					string ID = reader.GetAttribute("name");
					string doc = reader.ReadInnerXml().Trim();
					doc = PreprocessDoc(ID, doc);
					if (docs.ContainsKey(ID))
					{
						Trace.WriteLine("Warning: Multiple <member> tags found with id=\"" + ID + "\"");
					}
					else
					{
						docs.Add(ID, doc);
					}
				}
				else
				{
					reader.Read();
				}
			}
		}
Esempio n. 25
0
        /// <summary>
        /// Opens a click through file.
        /// </summary>
        /// <param name="sender">Control that sent the open request.</param>
        internal void Open(object sender)
        {
            DialogResult result = this.openFileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                string filePath = this.openFileDialog.FileName;
                string extensionNamespace;
                try
                {
                    using (XmlTextReader xml = new XmlTextReader(filePath))
                    {
                        xml.MoveToContent();
                        extensionNamespace = xml.NamespaceURI;

                        foreach (ClickThroughUIExtension extension in this.Extensions)
                        {
                            Fabricator f = extension.Fabricator;
                            if (f.Namespace == extensionNamespace)
                            {
                                this.ShowWorkPage(this, extension);
                                f.Open(filePath);
                                break;
                            }
                        }
                    }
                }
                finally
                {
                }
            }
        }
Esempio n. 26
0
        internal static Dictionary<string, string> ReturnGitHubChecksumDictionary()
        {
            Dictionary<string, string> returnValues = new Dictionary<string, string>();

            try
            {
                using (XmlTextReader reader = new XmlTextReader(GitHubProjectUrl))
                {
                    // simply (and easily) skip the junk at the beginning
                    reader.MoveToContent();
                    //reader.ReadToDescendant("FileList");

                    while (reader.Read())
                    {
                        if ((reader.NodeType == XmlNodeType.Element) &&
                              (reader.IsStartElement()) &&
                                reader.HasAttributes)
                        {
                            string fileName = reader.GetAttribute(0);
                            string fileHash = reader.GetAttribute(1);
                            returnValues.Add(fileName, fileHash);
                        }

                    }
                }
            }
            catch (Exception)
            {

            }

            return returnValues;
        }
Esempio n. 27
0
        internal static void LoadConfig(this DatabaseConfig config)
        {
            CheckForConfigFile();

              using (var xmlReader = new XmlTextReader(FilePath))
              {
            while (xmlReader.Read())
            {
              if (xmlReader.NodeType == XmlNodeType.Element)
              {
            switch (xmlReader.Name)
            {
              case "ConnectionString":
                config.ConnectionString = xmlReader.ReadString();
                break;
              case "DatabaseEngine":
                xmlReader.MoveToContent();
                ServiceLocator.DatabaseEngine value;
                Enum.TryParse(xmlReader.ReadString(), out value);
                config.DatabaseEngine = value;
                break;
            }
              }
            }
              }
        }
        /// <summary>
        /// Main function that retrieves the list from API, including paging
        /// </summary>
        /// <param name="url">URL of API request</param>
        /// <param name="haveSoFar">Number of pages already retrieved, for upper limit control</param>
        /// <returns>List of pages</returns>
        public List<Article> ApiMakeList(string url, int haveSoFar)
        {
            // TODO: error handling
            List<Article> list = new List<Article>();
            string postfix = "";

            string newUrl = url;

            while (list.Count + haveSoFar < Limit)
            {
                string text = Tools.GetHTML(newUrl + postfix);

                XmlTextReader xml = new XmlTextReader(new StringReader(text));
                xml.MoveToContent();
                postfix = "";

                while (xml.Read())
                {
                    if (xml.Name == "query-continue")
                    {
                        XmlReader r = xml.ReadSubtree();

                        r.Read();

                        while (r.Read())
                        {
                            if (!r.IsStartElement()) continue;
                            if (!r.MoveToFirstAttribute())
                                throw new FormatException("Malformed element '" + r.Name + "' in <query-continue>");
                            postfix += "&" + r.Name + "=" + HttpUtility.UrlEncode(r.Value);
                        }
                    }
                    else if (PageElements.Contains(xml.Name) && xml.IsStartElement())
                    {
                        if (!EvaluateXmlElement(xml))
                            continue;

                        //int ns = -1;
                        //int.TryParse(xml.GetAttribute("ns"), out ns);
                        string name = xml.GetAttribute("title");

                        if (string.IsNullOrEmpty(name))
                        {
                            System.Windows.Forms.MessageBox.Show(xml.ReadInnerXml());
                            break;
                        }

                        // HACK: commented out until we make AWB always load namespaces from the wiki,
                        // to avoid problems with unknown namespace
                        //if (ns >= 0) list.Add(new Article(name, ns));
                        //else
                        list.Add(new Article(name));
                    }

                }
                if (string.IsNullOrEmpty(postfix)) break;
            }

            return list;
        }
Esempio n. 29
0
        private void ParseXml(Stream input, TextWriter output)
        {
            XmlReader reader = new XmlTextReader(input);

            reader.MoveToContent();
            int previousDepth = reader.Depth;
            int originalDepth = previousDepth;

            PrintNode(reader, output);

            // Walk the document
            while (true)
            {
                reader.Read();
                reader.MoveToContent();

                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        // We are decending the branch
                        while (reader.Depth < previousDepth)
                        {
                            --previousDepth;
                        }

                        // We are accending the branch
                        if (reader.Depth > previousDepth)
                        {
                            ++previousDepth;
                        }

                        PrintNode(reader, output);
                        break;
                    case XmlNodeType.Text:
                        output.WriteLine(new String(' ', reader.Depth * 2) + reader.Value);
                        break;
                    case XmlNodeType.EndElement:
                        output.WriteLine(new String(' ', reader.Depth * 2) + "</" + reader.Name + ">");
                        break;
                }

                if (reader.Depth <= originalDepth)
                    break;
            }

            reader.Close();
        }
Esempio n. 30
0
        /// <summary>
        /// Retrieves and compares the version stored on the server against the current running version.
        /// </summary>
        /// <returns>1 if new updates are found, 0 if no newer version is found. -1 is thrown if there is an error.</returns>
        public int GetNewVersion()
        {
            WebRequest request = WebRequest.Create(XmlUrl);
            request.Timeout = 3000;
            WebResponse response = request.GetResponse();
            Stream responseStream = response.GetResponseStream();

            Version newVersion = null;
            XmlTextReader reader = null;

            try
            {
                reader = new XmlTextReader(responseStream);
                reader.MoveToContent();
                string elementName = string.Empty;

                if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == NodeRootElement))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                            elementName = reader.Name;
                        else
                        {
                            if ((reader.NodeType == XmlNodeType.Text) && (reader.HasValue))
                            {
                                switch (elementName)
                                {
                                    case NodeLatestVersion:
                                        newVersion = new Version(reader.Value);
                                        break;
                                    case NodeUrl:
                                        _updateUrl = reader.Value;
                                        break;
                                }
                            }
                        }
                    }
                }

                if (newVersion == null || string.IsNullOrEmpty(_updateUrl))
                    return -1;
            }
            catch (Exception e)
            {
                return -1;
            }
            finally
            {
                if (reader != null)
                    reader.Close();
            }

            Version curVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            if (curVersion.CompareTo(newVersion) < 0)
                return 1; // Newer version found
            else
                return 0; // Unable to find any updates
        }
Esempio n. 31
0
        public static String CheckForXMLUpdate(String updateXMLURL)
        {
            // this code was borrowed from:
            // http://themech.net/2008/05/adding-check-for-update-option-in-csharp/

            XmlTextReader reader = null;
            Version newVersion = null;
            string url = "";

            try
            {
                reader = new XmlTextReader(updateXMLURL);
                reader.MoveToContent();
                string elementName = "";
                if ((reader.NodeType == XmlNodeType.Element) &&
                    (reader.Name == ProgramName))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                            elementName = reader.Name;
                        else
                        {
                            if ((reader.NodeType == XmlNodeType.Text) &&
                                (reader.HasValue))
                            {
                                switch (elementName)
                                {
                                    case "version":
                                        newVersion = new Version(reader.Value);
                                        break;
                                    case "url":
                                        url = reader.Value;
                                        break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                if (reader != null) reader.Close();
            }

            if(url != null && newVersion != null)
            {
                Version currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                if(currentVersion.CompareTo(newVersion) < 0)
                {
                    return url;
                }
            }

            return String.Empty;
        }
        public Dictionary<string, object> CheckForUpdates(Version currentVersion)
        {
            var results = new Dictionary<string, object> {{"Available", false}, {"DownloadLink", null}};
            var downloalUrl = "";
            Version newVersion = null;
            const string xmlUrl = "C://VebBrowserUpdates//update.xml";
            var reader = new XmlTextReader(xmlUrl);
            try
            {
                reader.MoveToContent();
                var elementName = "";
                if ((reader.NodeType == XmlNodeType.Element) && (reader.Name == "VoiceBrowser"))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                            elementName = reader.Name;
                        else if ((reader.NodeType == XmlNodeType.Text) && (reader.HasValue))
                        {
                            switch (elementName)
                            {
                                case "version":
                                    {
                                        newVersion = new Version(reader.Value);
                                        break;
                                    }
                                case "url":
                                    {
                                        downloalUrl = reader.Value;
                                        break;
                                    }
                            }
                        }
                    }
                }
                // how to get the version of an application
                //Version currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

                if (currentVersion.CompareTo(newVersion) < 0)
                {
                    results["Available"] = true;
                    results["url"] = downloalUrl;
                }
                else
                {
                    results["Available"] = false;
                    results["url"] = "";
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                reader.Close();
            }
            return results;
        }
Esempio n. 33
0
        public bool AccountXMLLoad(XmlTextReader reader)
        {
            string priv = "", pub = "";

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        string name = reader.Name;

                        string value = "";
                        if (name == "transactions" || name=="tx")
                        {

                        }
                        else
                        {
                            reader.MoveToContent();
                            value = reader.ReadElementContentAsString();
                        }

                        //reader.read
                        switch (name)
                        {
                            case "name": m_name = value; break;
                            case "privkey": priv = value; break;
                            case "pubkey": pub = value; break;
                            case "icon": m_icon = Convert.ToInt32(value); break;
                            case "numtx": m_tx = Convert.ToInt32(value); break;
                            case "addressid": m_addressid = Convert.ToUInt32(value); break;
                            case "balance": m_balance = Convert.ToInt64(value); break;
                            case "enabled": m_bEnabled = Convert.ToBoolean(value); break;
                            case "tx":
                                {
                                    AddressHistory tx = new AddressHistory();

                                    tx.hash = reader.GetAttribute("hash");
                                    tx.amount = Convert.ToInt64(reader.GetAttribute("amnt"));
                                    tx.fromto = reader.GetAttribute("from");
                                    tx.info = reader.GetAttribute("info");
                                    tx.type = Convert.ToInt32(reader.GetAttribute("type"));
                                    tx.time = Convert.ToInt64(reader.GetAttribute("time"));
                                    m_txhistory.Add(tx);
                                }
                                break;
                        }
                        break;
                    case XmlNodeType.EndElement:
                        if (reader.Name == "account")
                        {
                            m_Key.SetKeyByString(priv, pub);
                            return true;
                        }
                        break;
                }
            }
            return false;
        }
Esempio n. 34
0
        public static bool VerifyFileFormat(string convertedCadFilePath)
        {
            bool isValid       = true;
            var  xmlTextReader = new System.Xml.XmlTextReader(convertedCadFilePath);

            xmlTextReader.MoveToContent();
            if (!String.Equals(xmlTextReader.LocalName, "Model3DGroup", StringComparison.CurrentCultureIgnoreCase))
            {
                isValid = false;
                throw new Exception("Failed...");
            }
            xmlTextReader.Close();

            return(isValid);
        }
Esempio n. 35
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);
 }
Esempio n. 36
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);
        }
Esempio n. 38
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);
            }
        }
Esempio n. 39
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);
        }
Esempio n. 40
0
        public string TransformModel(string format, int fromItem, int toItem)
        {
            System.Xml.XmlTextReader r = this.RQItems.ConvertTo(format, fromItem, toItem);

            try
            {
                var xTrf    = new System.Xml.Xsl.XslCompiledTransform(true);
                var xTrfArg = new System.Xml.Xsl.XsltArgumentList();
                var xSet    = new System.Xml.Xsl.XsltSettings(true, true);
                var mstr    = new System.Xml.XmlTextWriter(new System.IO.MemoryStream(), System.Text.Encoding.UTF8);
                var doc     = new System.Xml.XmlDocument();

                //TESTDATEI(EZEUGEN)
                //System.Xml.XmlDocument Doc = new System.Xml.XmlDocument();
                //Doc.Load(r);
                //Doc.Save("D:\\Users\\Jorge\\Desktop\\MVCTest.xml");
                //ENDE TESTDATEI
                r.MoveToContent();
                xTrf.Load(HttpContext.Current.Server.MapPath("~/xslt/ViewTransforms/RQResultList2RQSorted_Paging.xslt"), xSet, new System.Xml.XmlUrlResolver());
                xTrfArg.AddParam("ApplPath", "", "http://" + HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST") + (HttpContext.Current.Request.ApplicationPath.Equals("/") ? "" : HttpContext.Current.Request.ApplicationPath));
                xTrfArg.AddParam("MyDocsPath", "", "http://" + HttpContext.Current.Request.ServerVariables.Get("HTTP_HOST") + (HttpContext.Current.Request.ApplicationPath.Equals("/") ? "" : HttpContext.Current.Request.ApplicationPath));
                xTrfArg.AddParam("SortType", "", this.GetListPreprocessor().SortTypeString());
                xTrf.Transform(new System.Xml.XPath.XPathDocument(r), xTrfArg, mstr);
                mstr.BaseStream.Flush();
                mstr.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
                doc.Load(mstr.BaseStream);
                //TESTDATEI EZEUGEN
                //doc.Save("D:\\Users\\Jorge\\Desktop\\MVCTest.xml");
                //mstr.BaseStream.Seek(0, System.IO.SeekOrigin.Begin);
                //ENDE TESTDATEI
                //var rd = new System.Xml.XmlTextReader(mstr.BaseStream);
                return(doc.OuterXml);
            }
            catch
            {
                // RQItemSet ist leer
                throw new NotImplementedException("Could not find a RiQuest item with requested document number.");
            }
        }
Esempio n. 41
0
        private void gridViewFiles_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            try
            {
                row = (vw_Comprobantes_recibidos_Info)gridViewFiles.GetFocusedRow();

                if (e.Column.Name == "colCheked")
                {
                    if ((bool)gridViewFiles.GetFocusedRowCellValue(colCheked))
                    {
                        gridViewFiles.SetFocusedRowCellValue(colCheked, false);
                    }
                    else
                    {
                        gridViewFiles.SetFocusedRowCellValue(colCheked, true);
                    }
                }


                if (e.Column.Name == "colextencion")
                {
                    if (row.extencion == ".pdf")
                    {
                        string RutaFile = Path.GetTempPath();

                        RutaFile = RutaFile + "\\" + row.descripcion_archi;
                        System.IO.File.WriteAllBytes(RutaFile, row.Archivo_adjunto);

                        System.Diagnostics.Process proc = new System.Diagnostics.Process();

                        proc.StartInfo.FileName = RutaFile;
                        proc.Start();
                        proc.Close();
                    }

                    if (row.extencion == ".Xml" || row.extencion == ".xml")
                    {
                        string RutaFile = Path.GetTempPath();

                        RutaFile = RutaFile + "\\" + row.descripcion_archi;

                        XmlDocument doc = new XmlDocument();
                        string      xml = Encoding.UTF8.GetString(row.Archivo_adjunto);
                        doc.LoadXml(xml);


                        doc.Save(RutaFile);


                        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(RutaFile);
                        string contenido = "";
                        while (reader.Read())
                        {
                            reader.MoveToContent();
                            if (reader.NodeType == System.Xml.XmlNodeType.Element)
                            {
                                contenido += "<" + reader.Name + ">\n";
                            }
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                contenido += reader.Value + "\n";
                            }
                        }

                        if (contenido != "")
                        {
                            frmMensaje frmsg = new frmMensaje();
                            frmsg.richTextBoxMensaje.Text = contenido;
                            frmsg.WindowState             = FormWindowState.Maximized;
                            frmsg.ShowDialog();
                        }
                    }
                }


                if (e.Column.Name == "cols_Xml")
                {
                    if (row.s_Xml != "")
                    {
                        frmMensaje frmsg = new frmMensaje();
                        frmsg.richTextBoxMensaje.Text = row.s_Xml;
                        frmsg.WindowState             = FormWindowState.Maximized;
                        frmsg.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 42
0
        static void ReadOption()
        {
            if (System.IO.File.Exists(@".\Options.xml"))
            {
                System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(@".\Options.xml");

                string vContents = "";
                while (reader.Read())
                {
                    reader.MoveToContent();
                    if (reader.NodeType == System.Xml.XmlNodeType.Element && reader.Name != "Options" && reader.Name != "Value")
                    {
                        vContents += reader.Name + ":";
                    }
                    if (reader.NodeType == System.Xml.XmlNodeType.Text)
                    {
                        vContents += reader.Value + "-";
                    }
                }
                string[] vBuffer = vContents.Split('-');
                for (int i = 0; i < 6; i++)
                {
                    string[] vValue = vBuffer[i].Split(':');
                    switch (vValue[0])
                    {
                    case "SCORE":
                        SCORE = Convert.ToInt32(vValue[1]);
                        break;

                    case "MAXX":
                        MAXX = Convert.ToInt32(vValue[1]);
                        break;

                    case "MAXY":
                        MAXY = Convert.ToInt32(vValue[1]);
                        break;

                    case "MINX":
                        MINX = Convert.ToInt32(vValue[1]);
                        break;

                    case "MINY":
                        MINY = Convert.ToInt32(vValue[1]);
                        break;

                    case "vMode":
                        vMode = Convert.ToBoolean(vValue[1]);
                        break;

                    case "vWait":
                        vWait = Convert.ToInt32(vValue[1]);
                        break;

                    default:
                        break;
                    }
                }
                reader.Close();
            }
            else
            {
                CreateOptions();
            }
        }
Esempio n. 43
0
        static void Main(string[] args)
        {
            Stream s;

            if (args.Length == 1)
            {
                s = new FileStream(args[0], FileMode.Open, FileAccess.Read);
            }
            else
            {
                s = Console.OpenStandardInput();
            }

            System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(s);
            xr.MoveToContent();
            if (!xr.LocalName.Equals("packetSequence"))
            {
                throw new System.FormatException("Not a packetSequence");
            }

            int result = nextElement(ref xr);

            UInt32 msg_no = 0;
            Stream outp   = Console.OpenStandardOutput();

            //StreamWriter sw = new StreamWriter(outp);
            while (result == 1)
            {
                if (xr.LocalName.Equals("packetSequence"))
                {
                    break;
                }

                StringWriter  sw  = new StringWriter();
                XmlTextWriter tw  = new XmlTextWriter(sw);
                XmlDocument   doc = new XmlDocument();
                doc.Load(xr.ReadSubtree());
                doc.WriteContentTo(tw);

                LTKD.Message       msg;
                ENUM_LLRP_MSG_TYPE dummy;

                try
                {
                    LLRPXmlParser.ParseXMLToLLRPMessage(sw.ToString(), out msg, out dummy);
                }
                catch (Exception e)
                {
                    String desc = "ParseXMLToLLRPMessage failure on Packet #" + msg_no + ", " + e.Message;
                    Console.Error.WriteLine(desc);
                    String err_msg =
                        "<ERROR_MESSAGE MessageID=\"0\" Version=\"0\">\r\n" +
                        "  <LLRPStatus>\r\n" +
                        "    <StatusCode>M_Success</StatusCode>\r\n" +
                        "    <ErrorDescription>" + desc + "</ErrorDescription>\r\n" +
                        "  </LLRPStatus>\r\n" +
                        "</ERROR_MESSAGE>\r\n";

                    LLRPXmlParser.ParseXMLToLLRPMessage(err_msg, out msg, out dummy);
                }

                byte[] packet = LTKD.Util.ConvertBitArrayToByteArray(msg.ToBitArray());
                outp.Write(packet, 0, packet.Length);

                /* next XML subdocument */
                result = nextElement(ref xr);
                msg_no++;
            }
        }
Esempio n. 44
0
        private void gridView_PDF_XML_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            try
            {
                mail_Mensaje_Archi_Adjunto_Info InfoAdjunto = new mail_Mensaje_Archi_Adjunto_Info();
                InfoAdjunto = (mail_Mensaje_Archi_Adjunto_Info)gridView_PDF_XML.GetFocusedRow();

                if (e.Column.Name == "colCheked")
                {
                    if ((bool)gridView_PDF_XML.GetFocusedRowCellValue(colCheked))
                    {
                        gridView_PDF_XML.SetFocusedRowCellValue(colCheked, false);
                    }
                    else
                    {
                        gridView_PDF_XML.SetFocusedRowCellValue(colCheked, true);
                    }
                }


                if (e.Column.Name == "colMosTrar_icono_Imprimir")
                {
                    if (InfoAdjunto.extensionArchivo == ".pdf")
                    {
                        string RutaFile = Path.GetTempPath();

                        RutaFile = RutaFile + "\\" + InfoAdjunto.descripcion_archi;
                        System.IO.File.WriteAllBytes(RutaFile, InfoAdjunto.Archivo_adjunto);

                        System.Diagnostics.Process proc = new System.Diagnostics.Process();

                        proc.StartInfo.FileName = RutaFile;
                        proc.Start();
                        proc.Close();
                    }

                    if (InfoAdjunto.extensionArchivo == ".Xml" || InfoAdjunto.extensionArchivo == ".xml")
                    {
                        string RutaFile = Path.GetTempPath();

                        RutaFile = RutaFile + "\\" + InfoAdjunto.descripcion_archi;

                        XmlDocument doc = new XmlDocument();
                        string      xml = Encoding.UTF8.GetString(InfoAdjunto.Archivo_adjunto);
                        doc.LoadXml(xml);
                        //doc.InnerXml


                        doc.Save(RutaFile);


                        System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(RutaFile);
                        string contenido = "";
                        while (reader.Read())
                        {
                            reader.MoveToContent();
                            if (reader.NodeType == System.Xml.XmlNodeType.Element)
                            {
                                contenido += "<" + reader.Name + ">\n";
                            }
                            if (reader.NodeType == System.Xml.XmlNodeType.Text)
                            {
                                contenido += reader.Value + "\n";
                            }
                        }

                        if (contenido != "")
                        {
                            frmMensaje_XML frmsg = new frmMensaje_XML();
                            frmsg.richTextBoxMensaje.Text = contenido;
                            frmsg.WindowState             = FormWindowState.Maximized;
                            frmsg.ShowDialog();
                        }
                    }
                }

                //Para Descargar

                if (e.Column.Name == "colMosTrar_icono_Descargar")
                {
                    if (InfoAdjunto.extensionArchivo == ".pdf")
                    {
                        //  Guardar archivo en ubicacion

                        SaveFileDialog sfd = new SaveFileDialog();
                        sfd.Title            = "Save As PDF";
                        sfd.Filter           = "(*.pdf)|*.pdf";
                        sfd.InitialDirectory = @"C:\";
                        sfd.FileName         = InfoAdjunto.descripcion_archi;
                        if (sfd.ShowDialog() == DialogResult.OK)
                        {
                            string RutaFile = "";

                            RutaFile = RutaFile + "\\" + InfoAdjunto.descripcion_archi;
                            System.IO.File.WriteAllBytes(sfd.FileName, InfoAdjunto.Archivo_adjunto);
                        }
                    }

                    if (InfoAdjunto.extensionArchivo == ".xml" || InfoAdjunto.extensionArchivo == ".Xml")
                    {
                        //  Guardar archivo en ubicacion

                        string xml = Encoding.UTF8.GetString(InfoAdjunto.Archivo_adjunto);

                        XmlDocument xmlOrigen = new XmlDocument();
                        xmlOrigen.Load(new StringReader(xml));

                        Stream         myStream;
                        SaveFileDialog saveFileDialog1 = new SaveFileDialog();

                        saveFileDialog1.Filter           = "xml files (*.xml)|*.xml";
                        saveFileDialog1.FilterIndex      = 2;
                        saveFileDialog1.RestoreDirectory = true;
                        saveFileDialog1.FileName         = InfoAdjunto.descripcion_archi;

                        if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            if ((myStream = saveFileDialog1.OpenFile()) != null)
                            {
                                xmlOrigen.Save(myStream);
                                myStream.Close();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                BusSisLog.Log_Error(ex.Message.ToString(), eTipoError.ERROR, this.ToString());
            }
        }