示例#1
0
    public static DataSet ToDataSet(DataSetData dsd)
    {
        DataSet ds = new DataSet();
        UTF8Encoding encoding = new UTF8Encoding();
        Byte[] byteArray = encoding.GetBytes(dsd.DataXML);
        MemoryStream stream = new MemoryStream(byteArray);
        XmlReader reader = new XmlTextReader(stream);
        ds.ReadXml(reader);
        XDocument xd = XDocument.Parse(dsd.DataXML);
        foreach (DataTable dt in ds.Tables)
        {						
            var rs = from row in xd.Descendants(dt.TableName)
                     select row;			
 			
            int i = 0;
            foreach (var r in rs)
            {
                DataRowState state = (DataRowState)Enum.Parse(typeof(DataRowState), r.Attribute("RowState").Value);
                DataRow dr = dt.Rows[i];
                dr.AcceptChanges();
                if (state == DataRowState.Deleted)
                    dr.Delete();
                else if (state == DataRowState.Added)
                    dr.SetAdded();
                else if (state == DataRowState.Modified)
                    dr.SetModified();               
                i++;
            }
        }            
        return ds;
    }
示例#2
0
	public static void process(XamlOptions options, string input) {
		if (!input.EndsWith(".xaml")) {
			Console.WriteLine("Input filenames must end in .xaml");
			return;
		}
		if (Environment.Version.Major < 2 && options.Partial) {
			Console.WriteLine("This runtime version does not support partial classes");
			return;
		}
		if (options.OutputFile == null) {
			options.OutputFile = input + ".out";
		}
		ICodeGenerator generator = getGenerator(options.OutputLanguage);
		XmlTextReader xr = new XmlTextReader(input);
		try {
			string result = ParserToCode.Parse(xr, generator, options.Partial);
			TextWriter tw = new StreamWriter(options.OutputFile);
			tw.Write(result);
			tw.Close();
		}
		catch (Exception ex) {
			Console.WriteLine("Line " + xr.LineNumber + ", Column " + xr.LinePosition);
			throw ex;
		}
	}
示例#3
0
  static void Main(string[] args)
  {
    string localURL = @"http://ip-address.domaintools.com/myip.xml";
    XmlTextReader xmlreader = null;
    xmlreader = new XmlTextReader (localURL);

    while (xmlreader.Read())
    {
    
    	if(xmlreader.NodeType == XmlNodeType.Element)
    	{
    	
    			Console.WriteLine("Element : " + xmlreader.Name);
    
    	} 

    	if(xmlreader.NodeType == XmlNodeType.Text)
    	{
    		Console.WriteLine("Value : " +xmlreader.Value);
    	}
    }
    if (xmlreader != null)
      xmlreader.Close();

  }
示例#4
0
    public Mirror(string spec)
    {
        objectStack = new Stack();
        objectStack.Push(null);

        // Register the commands
        commands = new List<Command>();
        commands.Add(new ElementCommand());
        commands.Add(new EndElementCommand());
        commands.Add(new AttributeCommand());

        Reader = new XmlTextReader(spec);
        while (Reader.Read())
        {
            InterpretCommands();

            var b = Reader.IsEmptyElement;
            if (Reader.HasAttributes)
            {
                for (var i = 0; i < Reader.AttributeCount; i++)
                {
                    Reader.MoveToAttribute(i);
                    InterpretCommands();
                }
            }
            if (b) Pop();
        }
    }
示例#5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName = "******";
        string password = "******";

        DataSet ds = new DataSet();

        Twitter twitter = new Twitter();

        XmlDocument xmlDoc = twitter.GetUserTimelineAsXML(userName, password, "simonbegg", Twitter.OutputFormatType.XML);

        var query = (from c in xmlDoc.DocumentElement.ChildNodes.Cast<XmlNode>()
                    select c.SelectSingleNode("text").InnerXml).Take(2);

        XmlTextReader xtr = new XmlTextReader(new StringReader(xmlDoc.OuterXml));

        XElement xe = XElement.Load(xtr);

        string tweets = String.Empty;

        var foo = (from c in xe.Elements("status")
                  select c.Element("text")).First();

        foreach (string tweet in query)
            tweets += tweet + "<br />";

        this.litTweet.Text = foo.ToString();
        this.litTweetHeader.Text = "Latest tweets from talamh";
    }
示例#6
0
 public void LevelDataXML(string pathToXml)
 {
     parseFile = Resources.Load(pathToXml) as TextAsset;
     platforms = new List<PlatformData>();
     metadata = new List<MetaData>();
     portalSpawns = new List<Portal>();
     hazardSpawns = new List<Hazard>();
     playerSpawns = new List<Vector2>();
     enemySpawns = new List<Vector2>();
     items = new List<Vector2>();
     XmlTextReader mapReader = new XmlTextReader(new StringReader(parseFile.text));
     mapReader.Read();
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(mapReader.ReadOuterXml());
     mapSize = new Vector2((float)int.Parse(doc.ChildNodes[0].Attributes[0].Value)/16, (float)int.Parse(doc.ChildNodes[0].Attributes[1].Value)/16);
     for (int x = 0; x < doc.ChildNodes[0].ChildNodes.Count; x++)
     {
         if (doc.ChildNodes[0].ChildNodes[x].Name.ToLower().Equals("frontlayer")) {
             LoadTiles(doc.ChildNodes[0].ChildNodes[x], platforms);
         }
         if (doc.ChildNodes[0].ChildNodes[x].Name.ToLower().Equals("entities"))
         {
             LoadSpawnPoints(doc.ChildNodes[0].ChildNodes[x]);
         }
     }
 }
    public List<string> GetDialogById(string id)
    {
        XmlTextReader reader = new XmlTextReader(XMLFileName);
        List<string> texts   = new List<string>();

        while (reader.Read())
        {
            if (reader.NodeType == XmlNodeType.Element && reader.Name == id)
            {
                int i = 0;
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.EndElement && reader.Name == id)
                    {
                        break;
                    }
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == ("text_" + i))
                    {
                        texts.Add(reader.ReadElementContentAsString());
                        i++;
                    }
                }
            }
        }
        reader.Close();

        return texts;
    }
    public void SetAppTypeProduct()
    {
        try
        {
            XmlDocument doc = new XmlDocument();
            string xpath = Server.MapPath("../data/xml/configproduct.xml");
            XmlTextReader reader = new XmlTextReader(xpath);
            doc.Load(reader);
            reader.Close();
            XmlNodeList nodes = doc.SelectNodes("/root/product");
            int numnodes = nodes.Count;
            for (int i = 0; i < numnodes; i++)
            {
                string nameapp = nodes.Item(i).ChildNodes[0].InnerText;
                string idtype = nodes.Item(i).ChildNodes[1].InnerText;
                string appunit = nodes.Item(i).ChildNodes[2].InnerText;
                string unit = nodes.Item(i).ChildNodes[3].InnerText;
                if (nameapp.Length > 0 && idtype.Length > 0)
                {
                    Application[nameapp] = int.Parse(idtype);
                }
                if (appunit.Length > 0 && unit.Length > 0)
                {
                    Application[appunit] = unit;
                }
            }
        }
        catch
        {

        }
    }
示例#9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AWSAuthConnection conn = new AWSAuthConnection(accessKey, secretKey);

          XmlTextReader r = new XmlTextReader(Request.InputStream);
          r.MoveToContent();
          string xml = r.ReadOuterXml();

          XmlDocument documentToSave = new XmlDocument();
          documentToSave.LoadXml(xml);

          SortedList metadata = new SortedList();
          metadata.Add("title", bucket);
          metadata.Add("Content-Type", "application/xml");
          S3Object titledObject =
           new S3Object(documentToSave.OuterXml, metadata);

          SortedList headers = new SortedList();
          headers.Add("Content-Type", "application/xml");
          headers.Add("x-amz-acl", "public-read");

          conn.put(bucket, documentKey, titledObject, headers);

          Response.Write("saved: " + documentToSave.OuterXml);
    }
示例#10
0
文件: eventdump.cs 项目: nobled/mono
	public void TestOASIS ()
	{
		XmlDocument doc = new XmlDocument ();
		doc.NodeInserting += new XmlNodeChangedEventHandler (OnInserting);
		doc.NodeInserted += new XmlNodeChangedEventHandler (OnInserted);
		doc.NodeChanging += new XmlNodeChangedEventHandler (OnChanging);
		doc.NodeChanged += new XmlNodeChangedEventHandler (OnChanged);
		doc.NodeRemoving += new XmlNodeChangedEventHandler (OnRemoving);
		doc.NodeRemoved += new XmlNodeChangedEventHandler (OnRemoved);

		foreach (FileInfo fi in
			new DirectoryInfo (@"xml-test-suite/xmlconf/oasis").GetFiles ("*.xml")) {
			try {
				if (fi.Name.IndexOf ("fail") >= 0)
					continue;

				Console.WriteLine ("#### File: " + fi.Name);

				XmlTextReader xtr = new XmlTextReader (fi.FullName);
				xtr.Namespaces = false;
				xtr.Normalization = true;
				doc.RemoveAll ();
				doc.Load (xtr);

			} catch (XmlException ex) {
				if (fi.Name.IndexOf ("pass") >= 0)
					Console.WriteLine ("Incorrectly invalid: " + fi.FullName + "\n" + ex.Message);
			}
		}
	}
示例#11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        XmlReader rd = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml");
        string kur="",capraz="";
        if (!this.IsPostBack)
        {

            while (rd.Read())
            {
                if (rd.NodeType == XmlNodeType.Element)
                {
                    if (rd.Name == "Isim")
                    {
                        kur = rd.ReadString();
                    }
                    if (rd.Name == "CrossRateUSD")
                    {
                        capraz = rd.ReadString();
                    }
                    if (kur != "" && capraz != "")
                    {
                kurlar.Items.Add(new ListItem(kur, capraz));
                    kur = "";
                    capraz = "";

                    }

                }

            }

        }
    }
示例#12
0
 public List<MenuItem> GetItems()
 {
     XmlSerializer xs=new XmlSerializer(typeof(INVIMenu));
     XmlTextReader xtr=new XmlTextReader(HttpContext.Current.Server.MapPath("../Web.sitemap"));
     INVIMenu oMenu = xs.Deserialize(xtr) as INVIMenu;
     return oMenu.siteMapNode.Items;
 }
示例#13
0
	static void Main (string[] args)
	{
		if (args.Length < 2) 
		{
			Console.WriteLine("Syntax; VALIDATE xmldoc schemadoc");
			return;
		}
		XmlValidatingReader reader = null;
		try
		 {
			XmlTextReader nvr = new XmlTextReader (args[0]);
			nvr.WhitespaceHandling = WhitespaceHandling.None;
			reader = new XmlValidatingReader (nvr);
			reader.Schemas.Add (GetTargetNamespace (args[1]), args[1]);
            reader.ValidationEventHandler += new ValidationEventHandler(OnValidationError);
			while (reader.Read ());
		}
		catch (Exception ex)
		{
			Console.WriteLine(ex.Message);
		}
		finally
		{
			if (reader != null)
				reader.Close();
		}
	}
示例#14
0
	public static string GetTargetNamespace (string src)
	{
		XmlTextReader reader = null;
		try
		{
			reader = new XmlTextReader (src);
			reader.WhitespaceHandling = WhitespaceHandling.None;
			while (reader.Read())
			{
				if (reader.NodeType == XmlNodeType.Element &&
				reader.LocalName == "schema")
				{
					while (reader.MoveToNextAttribute ())
					{
						if (reader.Name == "targetNamespace")
							return reader.Value;
					}
				}
			}
			return "";
		}	
		finally 
		{
			if (reader != null)
				reader.Close ();
		}
	}
    private static string ReadXml(string filename, int ID)
    {
        string strLastVersion = "";

        XmlTextReader reader = new XmlTextReader(filename);

        while (reader.Read())
        {
            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    if (reader.Name == "id")
                    {
                        if (reader.Value == ID.ToString())
                        {
                            strLastVersion = reader.ReadString();
                            reader.Close();
                            return strLastVersion;
                        }
                    }
                }
            }
        }

        return strLastVersion;
    }
示例#16
0
文件: Xml.cs 项目: walrus7521/code
 public static void Read()
 {
     XmlTextReader reader = new XmlTextReader("books.xml");
     while (reader.Read())
     {
         switch (reader.NodeType)
         {
             case XmlNodeType.Element: // The node is an element.
                 Console.Write("<" + reader.Name);
                 while (reader.MoveToNextAttribute()) // Read the attributes.
                     Console.Write(" " + reader.Name + "='" + reader.Value + "'");
                 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;
         }
     }
     // Do some work here on the data.
     Console.ReadLine();
 }
示例#17
0
文件: test.cs 项目: mono/gert
	static void Main (string [] args)
	{
		string schemaFile = "bug.xsd";
		XmlTextReader treader = new XmlTextReader (schemaFile);

		XmlSchema sc = XmlSchema.Read (treader, null);
		sc.Compile (null);

		string page =
			"<body xmlns=\"" + sc.TargetNamespace + "\">"
			+ "<div>"
			+ "</div>"
			+ "</body>";

		System.Xml.XmlTextReader reader = new XmlTextReader (new StringReader (page));
		try {
			XmlValidatingReader validator = new System.Xml.XmlValidatingReader (reader);
			validator.Schemas.Add (sc);
			validator.ValidationType = ValidationType.Schema;
			validator.EntityHandling = EntityHandling.ExpandCharEntities;
			while (validator.Read ()) {
			}
		} finally {
			reader.Close ();
		}
	}
示例#18
0
文件: test.cs 项目: mono/gert
	static void Main ()
	{
		string dir = AppDomain.CurrentDomain.BaseDirectory;

		XmlTextReader xtr = new XmlTextReader (Path.Combine (dir, "MyTestService.wsdl"));

#if NET_2_0
		XmlReaderSettings settings = new XmlReaderSettings ();
		settings.ValidationType = ValidationType.Schema;
		settings.Schemas.Add ("http://schemas.xmlsoap.org/wsdl/", "http://schemas.xmlsoap.org/wsdl/");
		settings.Schemas.Add ("http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/http/");
		settings.Schemas.Add ("http://schemas.xmlsoap.org/wsdl/soap/", "http://schemas.xmlsoap.org/wsdl/soap/");
		settings.Schemas.Add ("http://schemas.xmlsoap.org/wsdl/soap12/", "http://schemas.xmlsoap.org/wsdl/soap12/wsdl11soap12.xsd");

		XmlReader vr = XmlReader.Create (xtr, settings);
#else
		XmlValidatingReader vr = new XmlValidatingReader (xtr);
		vr.ValidationType = ValidationType.Schema;
		vr.Schemas.Add ("http://schemas.xmlsoap.org/wsdl/", "http://schemas.xmlsoap.org/wsdl/");
		vr.Schemas.Add ("http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/http/");
		vr.Schemas.Add ("http://schemas.xmlsoap.org/wsdl/soap/", "http://schemas.xmlsoap.org/wsdl/soap/");
#endif

		while (vr.Read ()) {
		}
		
	}
示例#19
0
    protected void GetAlbumArt(string albumId, string album, string artist)
    {
        string path = Server.MapPath(@"~/images/cover-art/");

        if(!File.Exists(path + albumId + ".png")){
            string url = "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=b25b959554ed76058ac220b7b2e0a026&artist=" + artist + "&album=" + album;
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method = "GET";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                XmlTextReader reader = new XmlTextReader(response.GetResponseStream());
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "image")
                    {
                        if (reader.GetAttribute("size").Equals("large"))
                        {
                            url = reader.ReadInnerXml();

                            WebClient webClient = new WebClient();
                            webClient.DownloadFile(url, path + albumId + ".png");
                        }
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
    }
示例#20
0
文件: xmltest.cs 项目: nobled/mono
	static void RunNotWellFormedTest (string subdir, bool isSunTest)
	{
		string basePath = @"xml-test-suite/xmlconf/" + subdir + @"/not-wf";
		DirectoryInfo [] dirs = null;
		if (isSunTest)
			dirs =  new DirectoryInfo [] {new DirectoryInfo (basePath)};
		else
			dirs = new DirectoryInfo (basePath).GetDirectories ();

		foreach (DirectoryInfo di in dirs) {
			foreach (FileInfo fi in di.GetFiles ("*.xml")) {
				try {
					XmlTextReader xtr = new XmlTextReader (fi.FullName);
					xtr.Namespaces = false;
					while (!xtr.EOF)
						xtr.Read ();
					Console.WriteLine ("Incorrectly wf: " + subdir + "/" + di.Name + "/" + fi.Name);
				} catch (XmlException) {
					// expected
				} catch (Exception ex) {
					Console.WriteLine ("Unexpected Error: " + subdir + "/" + di.Name + "/" + fi.Name + "\n" + ex.Message);
				}
			}
		}
	}
示例#21
0
    private void readXML()
    {
        string fileName = "/home/nasser/Desktop/ncg/ncg/sampledata.xml";
        if (File.Exists (fileName)) {

            XmlTextReader xreader = new XmlTextReader(fileName);
            label1.Text="";
            while(xreader.Read ())
            {
                if(xreader.NodeType==XmlNodeType.Element)
                {
                    xreader.Read();
                    if(xreader.NodeType==XmlNodeType.Text)
                    {
                    }
                }
                /*label1.Text+="\nnode type :\t"+xreader.NodeType.ToString ();
                label1.Text+="\nname : \t\t"+xreader.Name;
                label1.Text+="\nvalue :\t\t"+xreader.Value;
                label1.Text+="\n-----------------";*/
            }

            //label1.Text+="\n"+xreader.GetAttribute("version").ToString ();
        }
        else
            label1.Text="file not exists";
    }
示例#22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack) //sürekli japon yeni ni ekliyodu butonda bu yüzden bunu ekledik sadece ilk postback olduğunda yapar sonraki postbackları yapmaz
        {
            ListItem aa;
            //ddlKurlar.Items.Add(new ListItem("japon yeni", "2,2")); 7/merkez bankasından xml alıcaz
            XmlTextReader re = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml");
            string txt = "";
            string value = "";
            while (re.Read()) {

             if(re.NodeType==XmlNodeType.Element)

                 if (re.Name == "Isim") {

                     txt = re.ReadString();

                 }
             if (re.Name == "CrossRateUSD")
             {
                 value = re.ReadString();
                 if (value == "")
                     continue;  //boş değerleri böylece götürdük ddl deki
                 aa = new ListItem();
                 aa.Text = txt;
                 aa.Value = value.Replace(".", ",");
                 ddlKurlar.Items.Add(aa);
             }

            }
        }
    }
示例#23
0
    public string[] GetItemsList(string prefixText, int count)
    {
        List<string> suggestions = new List<string>();
            using (XmlTextReader reader = new XmlTextReader(HttpContext.Current.Server.MapPath("flightdata.xml")))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "departurelocation")
                    {
                        string itemName = reader.ReadInnerXml();
                        if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (!suggestions.Contains(itemName))
                            suggestions.Add(itemName);

                            if (suggestions.Count == count) break;
                        }
                    }

                    if (reader.NodeType == XmlNodeType.Element && reader.Name == "destinationlocation")
                    {
                        string itemName = reader.ReadInnerXml();
                        if (itemName.StartsWith(prefixText, StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (!suggestions.Contains(itemName))
                            suggestions.Add(itemName);

                            if (suggestions.Count == count) break;
                        }
                    }

                }
            }
            return suggestions.ToArray();
    }
 protected void Button1_ServerClick(object sender, EventArgs e)
 {
     try
     {
         string currency = idChoice.Value;
         XmlDocument doc = new XmlDocument();
         string url = Server.MapPath("../data/xml/configproduct.xml");
         XmlTextReader reader = new XmlTextReader(url);
         doc.Load(reader);
         reader.Close();
         if (doc.IsReadOnly)
         {
             diverr.Visible = true;
             diverr.InnerHtml = "File XML đã bị khóa. Không thể thay đổi";
             return;
         }
         XmlNode nodeEdit = doc.SelectSingleNode("root/product[nameappunit='currency']/unit");
         string value = nodeEdit.InnerText;
         if (!value.Equals(currency))
         {
             nodeEdit.InnerText = currency;
             doc.Save(url);
             Application["currency"] = currency;
             diverr.Visible = true;
             diverr.InnerHtml = "Đã thay đổi cách hiển thị tiền tệ";
         }
         else
         {
             diverr.Visible = true;
             diverr.InnerHtml = "Hệ thống đang hiển thị kiểu tiền này.";
         }
     }catch
     {}
 }
示例#25
0
    public static List<string> ReadXml(string path, string colum)
    {
        List<string> listOfElements = new List<string>();

        XmlTextReader textReader = new XmlTextReader(path);

        int foundName = 0;

        while (textReader.Read())
        {
            if (foundName > 0 && textReader.Name != string.Empty && !String.Equals(textReader.Name, colum, StringComparison.CurrentCultureIgnoreCase))
                foundName = 0;

            if (foundName == 2 && String.Equals(textReader.Name, colum, StringComparison.CurrentCultureIgnoreCase))
            {
                foundName = 0; continue;
            }

            if (foundName == 0 && String.Equals(textReader.Name, colum, StringComparison.CurrentCultureIgnoreCase))
            {
                foundName = 1; continue;
            }

            if (foundName != 1 || textReader.Name != string.Empty) continue;

            listOfElements.Add(textReader.Value);
        }

        textReader.Close();
        return listOfElements;
    }
示例#26
0
 void ReadOrthographicSize(XmlTextReader textReader, GameObject go)
 {
     ScanToNode(textReader, "OrthographicSize");
     float size = GetFloat(textReader);
     Camera camera = go.GetComponent(typeof(Camera)) as Camera;
     camera.orthographicSize = size;
 }
示例#27
0
    void ReadXML()
    {
        int typesCount = (int)MessageType.Count;
        messages = new List<string>[typesCount];
        for(int i = 0; i < typesCount; i++) {
            messages[i] = new List<string>();
        }

        XmlTextReader reader = new XmlTextReader (file.text, XmlNodeType.Element, null);
        while(reader.Read()) {
            string typeName = reader.Name;
            if(string.IsNullOrEmpty(typeName)) {
                continue;
            }

            string message = reader.ReadString();

            int mTypeIndex = (int)((MessageType)System.Enum.Parse(typeof(MessageType), typeName));
            if(mTypeIndex >= 0 && mTypeIndex < typesCount) {
                messages[mTypeIndex].Add(message);
        //				Debug.Log("Adding message: " + message + " for type " + typeName);
            } else {
                Debug.LogError("Unknown type " + typeName);
            }
        }
    }
示例#28
0
	private void ReadXML()
	{
		string xmlFile = Server.MapPath("DvdList.xml");

		// Create the reader.
		XmlTextReader reader = new XmlTextReader(xmlFile);

		StringBuilder str = new StringBuilder();
		reader.ReadStartElement("DvdList");

		// Read all the <DVD> elements.
		while (reader.Read())
		{
			if ((reader.Name == "DVD") && (reader.NodeType == XmlNodeType.Element))
			{
				reader.ReadStartElement("DVD");
				str.Append("<ul><b>");
				str.Append(reader.ReadElementString("Title"));
				str.Append("</b><li>");
				str.Append(reader.ReadElementString("Director"));
				str.Append("</li><li>");
				str.Append(String.Format("{0:C}",
					Decimal.Parse(reader.ReadElementString("Price"))));
				str.Append("</li></ul>");
			}
		}
		// Close the reader and show the text.
		reader.Close();
		XmlText.Text = str.ToString();
	}
示例#29
0
    protected void btnCheckDevelioperKey_Click(object sender, EventArgs e)
    {
        shiftPlaning objshiftPlaning = new shiftPlaning(txtKey.Text);
        objshiftPlaning.Method = "GET";
        objshiftPlaning.Key = txtKey.Text;
        objshiftPlaning.Username = txtUsername.Text;
        objshiftPlaning.Password = txtPassword.Text;
        objshiftPlaning.OutPut = "xml";
        objshiftPlaning.module = "staff.login";
        string responseXml = objshiftPlaning.doLogin(txtUsername.Text, txtPassword.Text);

        txtResponse.Text = responseXml;
        TextReader txtReader = new StringReader(responseXml);
        XmlReader reader = new XmlTextReader(txtReader);
        DataSet ds = new DataSet();
        ds.ReadXml(reader);

        string myToken = objshiftPlaning.getAppToken();
        Session["myToken"] = myToken;
        if (myToken == null)
        {
            string LoginResponse = objshiftPlaning.doLogin(txtUsername.Text, txtPassword.Text);
            TextReader Reader = new StringReader(LoginResponse);
            DataSet dsResp = new DataSet();
            dsResp.ReadXml(Reader);
            //if (dsResp != null)
            //{
            //    if (dsResp.Tables["response"] != null)
            //    {
            //        if (dsResp.Tables["response"].Rows.Count > 0)
            //        {
            //            if (dsResp.Tables["response"].Rows[0]["status"] == "1")
            //            {
            //                if (dsResp.Tables["employee"] != null)
            //                {
            //                   // Response.Write("Hi, " + dsResp.Tables["employee"].Rows[0]["name"].ToString() + Environment.NewLine);
            //                }
            //            }
            //            else
            //            {

            //            }
            //        }
            //        else
            //        {
            //        }
            //    }
            //}
        }
        else
        {
            DataTable objEmployee = ds.Tables["employee"];
            DataTable objbusiness = ds.Tables["business"];
            if (ds.Tables["employee"] != null)
            {
               // Response.Write("Hi, " + ds.Tables["employee"].Rows[0]["name"].ToString() + Environment.NewLine);
            }
        }
    }
示例#30
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     XmlTextReader reader = new XmlTextReader("http://www.ntvmsnbc.com/id/24928011/device/rss/rss.xml");
     DataSet ds = new DataSet();
     ds.ReadXml(reader);
     DataList1.DataSource = ds.Tables[2];
     DataList1.DataBind();
 }
 /// <summary> Reads the inner data from the Template XML format </summary>
 /// <param name="XMLReader"> Current template xml configuration reader </param>
 /// <remarks> This procedure does not currently read any inner xml (not yet necessary) </remarks>
 protected override void Inner_Read_Data( XmlTextReader XMLReader )
 {
     // Do nothing
 }
示例#32
0
        private static HTML_Based_Content Text_To_HTML_Based_Content(string Display_Text, bool Retain_Entire_Display_Text, string Source)
        {
            // Create the values to hold the information
            string code        = String.Empty;
            string title       = String.Empty;
            string author      = String.Empty;
            string description = String.Empty;
            string thumbnail   = String.Empty;
            string keyword     = String.Empty;
            string banner      = String.Empty;
            string date        = String.Empty;
            string sitemap     = String.Empty;
            string webskin     = String.Empty;

            // StringBuilder keeps track of any other information in the head that should be retained
            StringBuilder headBuilder = new StringBuilder();

            // Try to read the head using XML
            int  head_start  = Display_Text.IndexOf("<head>", StringComparison.OrdinalIgnoreCase);
            int  head_end    = Display_Text.IndexOf("</head>", StringComparison.OrdinalIgnoreCase);
            bool read_as_xml = false;

            if ((head_start >= 0) && (head_end > head_start))
            {
                try
                {
                    string        head_xml  = Display_Text.Substring(head_start, (head_end - head_start) + 7);
                    XmlTextReader xmlReader = new XmlTextReader(new StringReader(head_xml));
                    while (xmlReader.Read())
                    {
                        if (xmlReader.NodeType != XmlNodeType.Element)
                        {
                            continue;
                        }

                        switch (xmlReader.Name.ToUpper())
                        {
                        case "LINK":
                            headBuilder.Append("<link ");
                            int attributeCount = xmlReader.AttributeCount;
                            for (int i = 0; i < attributeCount; i++)
                            {
                                xmlReader.MoveToAttribute(i);
                                headBuilder.Append(xmlReader.Name + "=\"" + xmlReader.Value + "\" ");
                            }
                            headBuilder.AppendLine(" />");
                            break;

                        case "TITLE":
                            xmlReader.Read();
                            title = xmlReader.Value;
                            break;

                        case "CODE":
                            xmlReader.Read();
                            code = xmlReader.Value.ToLower();
                            break;

                        case "META":
                            string name_type    = String.Empty;
                            string content_type = String.Empty;
                            if (xmlReader.MoveToAttribute("name"))
                            {
                                name_type = xmlReader.Value;
                            }
                            if (xmlReader.MoveToAttribute("content"))
                            {
                                content_type = xmlReader.Value;
                            }
                            if ((name_type.Length > 0) && (content_type.Length > 0))
                            {
                                switch (name_type.ToUpper())
                                {
                                case "BANNER":
                                    banner = content_type;
                                    break;

                                case "TITLE":
                                    title = content_type;
                                    break;

                                case "THUMBNAIL":
                                    thumbnail = content_type;
                                    break;

                                case "AUTHOR":
                                    author = content_type;
                                    break;

                                case "DATE":
                                    date = content_type;
                                    break;

                                case "KEYWORDS":
                                    keyword = content_type;
                                    break;

                                case "DESCRIPTION":
                                    description = content_type;
                                    break;

                                case "CODE":
                                    code = content_type.ToLower();
                                    break;

                                case "SITEMAP":
                                    sitemap = content_type;
                                    break;

                                case "WEBSKIN":
                                    webskin = content_type;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    read_as_xml = true;
                }
                catch
                {
                    read_as_xml = false;
                }
            }

            // Read this the old way if unable to read via XML for some reason
            if (!read_as_xml)
            {
                // Get the title and code

                string header_info = Display_Text.Substring(0, Display_Text.IndexOf("<body>"));
                if (header_info.IndexOf("<title>") > 0)
                {
                    string possible_title = header_info.Substring(header_info.IndexOf("<title>"));
                    possible_title = possible_title.Substring(7, possible_title.IndexOf("</title>") - 7);
                    title          = possible_title.Trim();
                }
                if (header_info.IndexOf("<code>") > 0)
                {
                    string possible_code = header_info.Substring(header_info.IndexOf("<code>"));
                    possible_code = possible_code.Substring(6, possible_code.IndexOf("</code>") - 6);
                    code          = possible_code.Trim();
                }

                // See if the banner should be displayed (default is only option righht now)
                if (Display_Text.IndexOf("<meta name=\"banner\" content=\"default\"") > 0)
                {
                    banner = "default";
                }
            }

            // Create return value
            HTML_Based_Content returnValue = new HTML_Based_Content {
                Code = code, Title = title
            };

            if (author.Length > 0)
            {
                returnValue.Author = author;
            }
            if (banner.Length > 0)
            {
                returnValue.Banner = banner;
            }
            if (date.Length > 0)
            {
                returnValue.Date = date;
            }
            if (description.Length > 0)
            {
                returnValue.Description = description;
            }
            if (keyword.Length > 0)
            {
                returnValue.Keywords = keyword;
            }
            if (thumbnail.Length > 0)
            {
                returnValue.Thumbnail = thumbnail;
            }
            if (sitemap.Length > 0)
            {
                returnValue.SiteMap = sitemap;
            }
            if (webskin.Length > 0)
            {
                returnValue.Web_Skin = webskin;
            }
            if (headBuilder.Length > 0)
            {
                returnValue.Extra_Head_Info = headBuilder.ToString();
            }

            // Should the actual display text be retained?
            if (Retain_Entire_Display_Text)
            {
                int start_body = Display_Text.IndexOf("<body>") + 6;
                int end_body   = Display_Text.IndexOf("</body>");
                if ((start_body > 0) && (end_body > start_body))
                {
                    returnValue.Static_Text = Display_Text.Substring(start_body, end_body - start_body) + " ";

                    if ((Source.Length > 0) && (returnValue.Static_Text.IndexOf("<%LASTMODIFIED%>") > 0))
                    {
                        FileInfo fileInfo    = new FileInfo(Source);
                        DateTime lastWritten = fileInfo.LastWriteTime;
                        returnValue.Static_Text = returnValue.Static_Text.Replace("<%LASTMODIFIED%>", lastWritten.ToLongDateString());
                    }
                }
            }

            return(returnValue);
        }
示例#33
0
        public void ReadXmlString_GetScanners(string strXml, Scanner[] arScanner, int nTotal, out int nScannerCount)
        {
            nScannerCount = 0;
            if (1 > nTotal || string.IsNullOrEmpty(strXml))
            {
                return;
            }
            try {
                XmlTextReader xmlRead = new XmlTextReader(new StringReader(strXml));
                // Skip non-significant whitespace
                xmlRead.WhitespaceHandling = WhitespaceHandling.Significant;

                string  sElementName = "", sElmValue = "";
                Scanner scanr    = null;
                int     nIndex   = 0;
                bool    bScanner = false;
                while (xmlRead.Read())
                {
                    switch (xmlRead.NodeType)
                    {
                    case XmlNodeType.Element:
                        sElementName = xmlRead.Name;
                        if (Scanner.TAG_SCANNER == sElementName)
                        {
                            bScanner = false;
                        }

                        string strScannerType = xmlRead.GetAttribute(Scanner.TAG_SCANNER_TYPE);
                        if (xmlRead.HasAttributes && (
                                (Scanner.TAG_SCANNER_SNAPI == strScannerType) ||
                                (Scanner.TAG_SCANNER_SSI == strScannerType) ||
                                (Scanner.TAG_SCANNER_NIXMODB == strScannerType) ||
                                (Scanner.TAG_SCANNER_IBMHID == strScannerType) ||
                                (Scanner.TAG_SCANNER_OPOS == strScannerType) ||
                                (Scanner.TAG_SCANNER_IMBTT == strScannerType) ||
                                (Scanner.TAG_SCALE_IBM == strScannerType) ||
                                (Scanner.SCANNER_SSI_BT == strScannerType) ||
                                (Scanner.TAG_SCANNER_HIDKB == strScannerType)))                                //n = xmlRead.AttributeCount;
                        {
                            if (arScanner.GetLength(0) > nIndex)
                            {
                                bScanner = true;
                                scanr    = (Scanner)arScanner.GetValue(nIndex++);
                                if (null != scanr)
                                {
                                    scanr.ClearValues();
                                    nScannerCount++;
                                    scanr.SCANNERTYPE = strScannerType;
                                }
                            }
                        }
                        break;

                    case XmlNodeType.Text:
                        if (bScanner && (null != scanr))
                        {
                            sElmValue = xmlRead.Value;
                            switch (sElementName)
                            {
                            case Scanner.TAG_SCANNER_ID:
                                scanr.SCANNERID = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_SERIALNUMBER:
                                scanr.SERIALNO = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_MODELNUMBER:
                                scanr.MODELNO = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_GUID:
                                scanr.GUID = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_PORT:
                                scanr.PORT = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_FW:
                                scanr.SCANNERFIRMWARE = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_DOM:
                                scanr.SCANNERMNFDATE = sElmValue;
                                break;
                            }
                        }
                        break;
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }
示例#34
0
 internal override void ReadXml(XmlTextReader reader)
 {
     throw new NotImplementedException();
 }
示例#35
0
        public static instrumentParamsStrt readFitParametersXML(string fileXml, string instrument)
        {
            instrumentParamsStrt parameters = new instrumentParamsStrt();

            //Initialize necessary objets for XML reading
            XmlTextReader reader = new XmlTextReader(fileXml);
            XmlNodeType   nType  = reader.NodeType;
            XmlDocument   xmldoc = new XmlDocument();

            xmldoc.Load(reader);

            //Get the instrument tags
            XmlNodeList xmlnodeInstrument = xmldoc.GetElementsByTagName("instrument");

            //search the correct <instrument> entry
            for (int i = 0; i < xmlnodeInstrument.Count; i++)
            {
                if (xmlnodeInstrument[i].Attributes["id"].Value.Trim() == instrument.Trim())
                {
                    for (int j = 0; j < xmlnodeInstrument[i].ChildNodes.Count; j++)
                    {
                        if (xmlnodeInstrument[i].ChildNodes[j].Name == "resolution")
                        {
                            if (xmlnodeInstrument[i].ChildNodes[j].InnerText.Trim() == "LOW")
                            {
                                parameters.instResolution = Resolution.LOW;
                            }
                            if (xmlnodeInstrument[i].ChildNodes[j].InnerText.Trim() == "HIGH")
                            {
                                parameters.instResolution = Resolution.HIGH;
                            }
                        }

                        if (xmlnodeInstrument[i].ChildNodes[j].Name == "kmax")
                        {
                            parameters.kmax = int.Parse(xmlnodeInstrument[i].ChildNodes[j].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                        }

                        if (xmlnodeInstrument[i].ChildNodes[j].Name == "initialFitParams")
                        {
                            for (int k = 0; k < xmlnodeInstrument[i].ChildNodes[j].ChildNodes.Count; k++)
                            {
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "alpha")
                                {
                                    parameters.alpha = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "sigma")
                                {
                                    parameters.sigma = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "deltaR")
                                {
                                    parameters.deltaR = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "efficiency")
                                {
                                    parameters.f = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "deltaMZ")
                                {
                                    parameters.deltaMz = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "SN_f")
                                {
                                    parameters.sn_f = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                            }
                        }
                        if (xmlnodeInstrument[i].ChildNodes[j].Name == "deltaFitParams")
                        {
                            for (int k = 0; k < xmlnodeInstrument[i].ChildNodes[j].ChildNodes.Count; k++)
                            {
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "A")
                                {
                                    parameters.varA = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "B")
                                {
                                    parameters.varB = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "efficiency")
                                {
                                    parameters.varf = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "sigma")
                                {
                                    parameters.varSigma = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "alpha")
                                {
                                    parameters.varAlpha = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                                if (xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].Name == "SN")
                                {
                                    parameters.varSn = double.Parse(xmlnodeInstrument[i].ChildNodes[j].ChildNodes[k].InnerText.Trim(), System.Globalization.CultureInfo.InvariantCulture);
                                }
                            }
                        }
                    }
                }
            }


            return(parameters);
        }
示例#36
0
 /// <summary>
 /// Wrap an XmlTextReader with state for event-based parsing of an XML stream.
 /// </summary>
 /// <param name="xmlReader"><c>XmlTextReader</c> with the XML from a service response.</param>
 public UnmarshallerContext(XmlTextReader xmlReader)
 {
     this.xmlReader = xmlReader;
     this.xmlReader.WhitespaceHandling = WhitespaceHandling.None;
 }
示例#37
0
        /// <summary>
        /// Scan the WoW Folders Directory for any folder plugins, validate them, and add them to the program.
        /// </summary>
        public void ScanDirectories()
        {
            if (!Directory.Exists("./ClientPlugins/"))
            {
                Directory.CreateDirectory("./ClientPlugins/");
            }

            String[] files = Directory.GetFiles("./ClientPlugins/", "*.xml");
            foreach (String file in files)
            {
                XMLValidator validator = new XMLValidator(file, iswowfolder: true);
                if (validator.ValidateXMLFile())
                {
                    MessageBox.Show(String.Format("Plugin {0} is in an invalid format! Possibly out of date?", file));
                    continue;
                }
                XmlTextReader reader = new XmlTextReader(file);
                String        element = "";
                String        locale = "", client = "", fileLocation = "";
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                    {
                        element = reader.Name;
                        if (String.Compare(element, "WoWDirectory") == 0)
                        {
                            client       = "0.0.0";
                            fileLocation = "";
                            locale       = "";
                        }
                        break;
                    }

                    case XmlNodeType.Text:
                    {
                        switch (element)
                        {
                        case "Client":
                            client = reader.Value;
                            break;

                        case "FileLocation":
                            fileLocation = reader.Value;
                            break;

                        case "Locale":
                            locale = reader.Value;
                            break;
                        }
                        break;
                    }
                    }
                }

                if (Config.wowDirectories.ContainsX(client))
                {
                    throw new Exception(String.Format("You cannot have multiple WoW.exe files for the same client {0}!", client));
                }
                if (Config.ValidateClient(client) && Config.ValidateLocale(locale) && fileLocation != "")
                {
                    Config.wowDirectories.Add(client, locale, fileLocation);
                }
            }
        }
        private void buttonNewExercise_Click(object sender, EventArgs e)
        {
            buttonVerify.Hide();
            buttonVerify2.Show();
            buttonShowAnswer.Hide();
            buttonShowAnswer2.Show();
            buttonNewExercise.Hide();
            buttonVerify2.Enabled = true;
            buttonShowAnswer2.Enabled = true;

            textBox1.Clear();
            textBox1.BackColor = Color.White;
            textBox1.Location = new Point(832, 166);
            textBox2.Clear();
            textBox2.BackColor = Color.White;
            textBox2.Location = new Point(914, 226);
            textBox3.Clear();
            textBox3.BackColor = Color.White;
            textBox3.Location = new Point(848, 290);
            textBox4.Clear();
            textBox4.BackColor = Color.White;
            textBox4.Location = new Point(827, 354);
            textBox5.Clear();
            textBox5.BackColor = Color.White;
            textBox5.Location = new Point(800, 417);
            textBox6.Clear();
            textBox6.BackColor = Color.White;
            textBox7.Clear();
            textBox7.BackColor = Color.White;
            textBox7.Location = new Point(792, 547);
            textBox8.Clear();
            textBox8.BackColor = Color.White;
            textBox8.Location = new Point(906, 617);
            textBox9.Clear();
            textBox9.BackColor = Color.White;
            textBox9.Location = new Point(846, 681);
            textBox10.Clear();
            textBox10.BackColor = Color.White;
            textBox10.Location = new Point(831, 748);

            label21.Location = new Point(932, 166);
            label22.Location = new Point(1012, 226);
            label23.Location = new Point(948, 290);
            label24.Location = new Point(935, 354);
            label25.Location = new Point(906, 417);
            label27.Location = new Point(894, 547);
            label28.Location = new Point(1006, 617);
            label29.Location = new Point(946, 681);
            label30.Location = new Point(931, 748);

            label11.Text = "";
            label12.Text = "";
            label13.Text = "";
            label14.Text = "";
            label15.Text = "";
            label16.Text = "";
            label17.Text = "";
            label18.Text = "";
            label19.Text = "";
            label20.Text = "";

            string fileName = "XMLGerunziuSiInfinitiv.xml";
            string path = Path.Combine(Environment.CurrentDirectory, @"", fileName);

            XmlTextReader xtr = new XmlTextReader(path);
            try
            {
                while (xtr.Read())
                {
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "one")
                    {
                        string s1 = xtr.ReadElementString();
                        label1.Text = ("" + s1);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "two")
                    {
                        string s2 = xtr.ReadElementString();
                        label2.Text = ("" + s2);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "three")
                    {
                        string s3 = xtr.ReadElementString();
                        label3.Text = ("" + s3);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "four")
                    {
                        string s4 = xtr.ReadElementString();
                        label4.Text = ("" + s4);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "five")
                    {
                        string s5 = xtr.ReadElementString();
                        label5.Text = ("" + s5);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "six")
                    {
                        string s6 = xtr.ReadElementString();
                        label6.Text = ("" + s6);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "seven")
                    {
                        string s7 = xtr.ReadElementString();
                        label7.Text = ("" + s7);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "eight")
                    {
                        string s8 = xtr.ReadElementString();
                        label8.Text = ("" + s8);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "nine")
                    {
                        string s9 = xtr.ReadElementString();
                        label9.Text = ("" + s9);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "ten")
                    {
                        string s10 = xtr.ReadElementString();
                        label10.Text = ("" + s10);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentyone")
                    {
                        string s21 = xtr.ReadElementString();
                        label21.Text = ("" + s21);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentytwo")
                    {
                        string s22 = xtr.ReadElementString();
                        label22.Text = ("" + s22);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentythree")
                    {
                        string s23 = xtr.ReadElementString();
                        label23.Text = ("" + s23);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentyfour")
                    {
                        string s24 = xtr.ReadElementString();
                        label24.Text = ("" + s24);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentyfive")
                    {
                        string s25 = xtr.ReadElementString();
                        label25.Text = ("" + s25);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentysix")
                    {
                        string s26 = xtr.ReadElementString();
                        label26.Text = ("" + s26);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentyseven")
                    {
                        string s27 = xtr.ReadElementString();
                        label27.Text = ("" + s27);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentyeight")
                    {
                        string s28 = xtr.ReadElementString();
                        label28.Text = ("" + s28);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "twentynine")
                    {
                        string s29 = xtr.ReadElementString();
                        label29.Text = ("" + s29);
                    }
                    if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "thirty")
                    {
                        string s30 = xtr.ReadElementString();
                        label30.Text = ("" + s30);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 virtual public iCalObject Deserialize(XmlTextReader xtr, Type iCalendarType)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#40
0
        public void             loadFromXML(XmlTextReader aXMLTextReader)
        {
            var lReader = new XMLAttributeReader(aXMLTextReader);

            LabelText = lReader.getAttribute <String>("ToolTip", "");
        }
示例#41
0
    public bool saveXmlToBd(string usuario, string fileName)
    {
        tbl_remesasDTO _remesas = new tbl_remesasDTO();

        //_remesas.UsuarioCarga = ObtenerUsuarioTopaz(usuario.ToLower());
        // string Domain = HttpContext.Current.Request.Url.Authority;

        // XDocument xDoc = XDocument.Parse(strXML);

        //File.WriteAllText("xmlremesa.xml", strXML, Encoding.ASCII);

        try
        {
            if (fileName != null)
            {
                // string archivo = usuario + DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(fileXml.FileName);
                //fileXml.SaveAs(HttpContext.Current.Server.MapPath("~/upload/" + archivo));

                string path = HttpContext.Current.Server.MapPath("~/File/" + fileName);
                //  String path = "~/File/" + fileName;


                String URLString = path;

                XmlTextReader reader = new XmlTextReader(URLString);

                while (reader.Read())
                {
                    switch (reader.Name.ToString())

                    {
                    case "Tipo":
                        _remesas.Tipo = reader.ReadString();
                        break;

                    case "Destinatario1":
                        _remesas.Destinatario1 = reader.ReadString();
                        break;

                    case "Destinatario2":

                        _remesas.Destinatario2 = reader.ReadString();
                        break;

                    case "Destinatario3":

                        _remesas.Destinatario3 = reader.ReadString();
                        break;

                    case "Destinatario4":

                        _remesas.Destinatario4 = reader.ReadString();
                        break;

                    case "Destinatario5":

                        _remesas.Destinatario5 = reader.ReadString();
                        break;

                    case "Direccion1":

                        _remesas.Direccion1 = reader.ReadString();
                        break;

                    case "Direccion2":

                        _remesas.Direccion2 = reader.ReadString();
                        break;

                    case "EstadoBeneficiario":

                        _remesas.EstadoBeneficiario = reader.ReadString();
                        break;

                    case "CiudadBeneficiario":

                        _remesas.CiudadBeneficiario = reader.ReadString();
                        break;

                    case "Telefono":

                        _remesas.Telefono = reader.ReadString();
                        break;

                    case "Identificacion":

                        _remesas.Identificacion = reader.ReadString();
                        break;

                    case "NumeroID":

                        _remesas.NumeroID = reader.ReadString();
                        break;

                    case "EmitidaPor":

                        _remesas.EmitidaPor = reader.ReadString();
                        break;

                    case "FechaEmision":

                        _remesas.FechaEmision = reader.ReadString();
                        break;

                    case "FechaExpiracion":

                        _remesas.FechaExpiracion = reader.ReadString();
                        break;

                    case "FechaNacimiento":

                        _remesas.FechaNacimiento = reader.ReadString();
                        break;

                    case "Ocupacion":

                        _remesas.Ocupacion = reader.ReadString();
                        break;

                    case "Nacionalidad":

                        _remesas.Nacionalidad = reader.ReadString();
                        break;

                    case "Trabajo":

                        _remesas.Trabajo = reader.ReadString();
                        break;

                    case "Sexo":

                        _remesas.Sexo = reader.ReadString();
                        break;

                    case "EstadoCivil":

                        _remesas.EstadoCivil = reader.ReadString();
                        break;

                    case "WUCard":

                        _remesas.WUCard = reader.ReadString();
                        break;

                    case "Remitente1":

                        _remesas.Remitente1 = reader.ReadString();
                        break;

                    case "Remitente2":

                        _remesas.Remitente2 = reader.ReadString();
                        break;

                    case "Remitente3":

                        _remesas.Remitente3 = reader.ReadString();
                        break;

                    case "Remitente4":

                        _remesas.Remitente4 = reader.ReadString();
                        break;

                    case "Remitente5":

                        _remesas.Remitente5 = reader.ReadString();
                        break;

                    case "Origen":

                        _remesas.Origen = reader.ReadString();
                        break;

                    case "EstadoOrigen":

                        _remesas.EstadoOrigen = reader.ReadString();
                        break;

                    case "CiudadOrigen":

                        _remesas.CiudadOrigen = reader.ReadString();
                        break;

                    case "Fecha":

                        _remesas.Fecha = reader.ReadString();
                        break;

                    case "Hora":

                        _remesas.Hora = reader.ReadString();
                        break;

                    case "Operador":

                        _remesas.Operador = reader.ReadString();
                        break;

                    case "MTCN":

                        _remesas.MTCN = reader.ReadString();
                        break;

                    case "Monto":

                        _remesas.Monto = reader.ReadString();

                        break;

                    case "Moneda":

                        _remesas.Moneda = reader.ReadString();
                        break;

                    case "Agente":

                        _remesas.Agente = reader.ReadString();
                        break;

                    case "IDTerminal":

                        _remesas.IDTerminal = reader.ReadString();
                        break;

                    case "ExchangeRate":

                        _remesas.ExchangeRate = reader.ReadString();
                        break;

                    case "TestQuestion":

                        _remesas.TestQuestion = reader.ReadString();
                        break;

                    case "TestAnswer":

                        _remesas.TestAnswer = reader.ReadString();
                        break;

                    case "Mensaje":

                        _remesas.Mensaje = reader.ReadString();
                        break;

                    case "TasaDeCambioFD":

                        _remesas.TasaDeCambioFD = reader.ReadString();
                        break;

                    case "MonedaOriginalTransaccionTL":

                        _remesas.MonedaOriginalTransaccionTL = reader.ReadString();
                        break;

                    case "MontoOriginalTransaccionTL":

                        _remesas.MontoOriginalTransaccionTL = reader.ReadString();
                        break;
                    }
                } //End While



                int    IdResponse  = saveToBD(_remesas);
                string msgResponse = ObtenerMensaje(IdResponse);
            }
            else
            {
                CustomeExeption ce = new CustomeExeption("El xml viene nulo");
                ExceptionLogging.SendErrorToText(ce, true);
            }
        }
        catch (Exception ex)
        {
            ExceptionLogging.SendErrorToText(ex, false);
        }


        return(true);
    }
        //=====================================================================

        /// <summary>
        /// This is used to perform the actual conversion
        /// </summary>
        /// <returns>The new project filename on success.  An exception is
        /// thrown if the conversion fails.</returns>
        public override string ConvertProject()
        {
            FilePath filePath;
            Version  schemaVersion, lastShfbVersion = new Version(1, 7, 0, 0);
            Dictionary <string, string> renameProps = new Dictionary <string, string>();

            object value;
            string version, deps, propName = null, path, dest, filter, helpFileFormat;

            string[] depList;

            // Create a list of property names that need renaming due to
            // changes from version to version.
            renameProps.Add("showAttributes", "DocumentAttributes");        // v1.0.0.0 name
            renameProps.Add("hhcPath", "HtmlHelp1xCompilerPath");           // v1.3.3.1 and prior
            renameProps.Add("hxcompPath", "HtmlHelp2xCompilerPath");        // v1.3.3.1 and prior
            renameProps.Add("rootNSContainer", "RootNamespaceContainer");   // v1.3.3.1 and prior

            // The HelpFileFormat enum values changed in v1.8.0.3
            Dictionary <string, string> translateFormat = new Dictionary <string, string> {
                { "HTMLHELP1X", "HtmlHelp1" },
                { "HTMLHELP2X", "MSHelp2" },
                { "HELP1XANDHELP2X", "HtmlHelp1, MSHelp2" },
                { "HELP1XANDWEBSITE", "HtmlHelp1, Website" },
                { "HELP2XANDWEBSITE", "MSHelp2, Website" },
                { "HELP1XAND2XANDWEBSITE", "HtmlHelp1, MSHelp2, Website" }
            };

            try
            {
                xr = new XmlTextReader(new StreamReader(base.OldProjectFile));
                xr.MoveToContent();

                if (xr.EOF)
                {
                    base.Project.SaveProject(base.Project.Filename);
                    return(base.Project.Filename);
                }

                version = xr.GetAttribute("schemaVersion");

                if (String.IsNullOrEmpty(version))
                {
                    throw new BuilderException("CVT0003", "Invalid or missing schema version");
                }

                schemaVersion = new Version(version);

                if (schemaVersion > lastShfbVersion)
                {
                    throw new BuilderException("CVT0004", "Unrecognized schema version");
                }

                while (!xr.EOF)
                {
                    if (xr.NodeType == XmlNodeType.Element)
                    {
                        propName = xr.Name;

                        switch (propName)
                        {
                        case "project":         // Ignore the main project node
                            break;

                        case "PurgeDuplicateTopics":
                        case "ShowFeedbackControl":
                        case "ProjectLinkType":
                        case "projectLinks":        // ProjectLinkType in v1.3.3.1 and prior
                        case "SandcastlePath":
                            // PurgeDuplicateTopics was removed in v1.6.0.7
                            // ShowFeedbackControl was removed in v1.8.0.3
                            // ProjectLinkType was removed in v1.9.0.0
                            // SandcastlePath was removed in v2014.1.26.0
                            break;

                        case "sdkLinks":            // SdkLinkType in v1.3.3.1 and prior
                        case "SdkLinkType":
                            switch (xr.ReadString().ToLowerInvariant())
                            {
                            case "none":
                            case "index":
                            case "local":
                                base.Project.HtmlSdkLinkType = base.Project.WebsiteSdkLinkType =
                                    HtmlSdkLinkType.None;
                                base.Project.MSHelp2SdkLinkType      = MSHelp2SdkLinkType.Index;
                                base.Project.MSHelpViewerSdkLinkType = MSHelpViewerSdkLinkType.Id;
                                break;

                            default:            // MSDN links
                                break;
                            }
                            break;

                        case "additionalContent":
                            this.ConvertAdditionalContent();
                            break;

                        case "conceptualContent":
                            contentConverter.ConvertContent();
                            break;

                        case "assemblies":
                            this.ConvertAssemblies();
                            break;

                        case "componentConfigurations":
                            this.ConvertComponentConfigs();
                            break;

                        case "plugInConfigurations":
                            this.ConvertPlugInConfigs();
                            break;

                        case "namespaceSummaries":
                            this.ConvertNamespaceSummaries();
                            break;

                        case "apiFilter":
                            this.ConvertApiFilter();
                            break;

                        case "helpAttributes":
                            this.ConvertHelpAttributes();
                            break;

                        case "dependencies":
                            // The first version used a comma-separated
                            // string of dependencies.
                            if (schemaVersion.Major == 1 && schemaVersion.Minor == 0)
                            {
                                deps = xr.ReadString();

                                if (deps.Length != 0)
                                {
                                    depList = deps.Split(new char[] { ',' });

                                    foreach (string s in depList)
                                    {
                                        base.Project.References.AddReference(
                                            Path.GetFileNameWithoutExtension(s),
                                            base.FullPath(s));
                                    }
                                }
                            }
                            else
                            {
                                this.ConvertDependencies();
                            }
                            break;

                        case "SyntaxFilters":
                            // 1.6.0.4 used ScriptSharp but 1.6.0.5 renamed
                            // it to JavaScript which is more generic as it
                            // can apply to other projects too.
                            filter = xr.ReadString();

                            if (schemaVersion.Major == 1 &&
                                schemaVersion.Minor == 6 &&
                                schemaVersion.Build == 0 &&
                                schemaVersion.Revision < 5)
                            {
                                filter = filter.Replace("ScriptSharp",
                                                        "JavaScript");
                            }

                            base.SetProperty(xr.Name, filter);
                            break;

                        case "ContentSiteMap":
                            // In 1.6.0.7, this became a sub-property
                            // of the additional content collection.
                            path = xr.GetAttribute("path");

                            if (path != null && path.Trim().Length > 0)
                            {
                                dest = Path.Combine(base.ProjectFolder,
                                                    Path.GetFileName(path));
                                dest = Path.ChangeExtension(dest,
                                                            ".sitemap");

                                base.Project.AddFileToProject(
                                    base.FullPath(path), dest);
                                this.UpdateSiteMap(dest);
                            }
                            break;

                        case "TopicFileTransform":
                            // In 1.6.0.7, this became a sub-property
                            // of the additional content collection.
                            path = xr.GetAttribute("path");

                            if (path != null && path.Trim().Length > 0)
                            {
                                dest = Path.Combine(base.ProjectFolder,
                                                    Path.GetFileName(path));
                                dest = Path.ChangeExtension(dest, ".xsl");
                                base.Project.AddFileToProject(
                                    base.FullPath(path), dest);
                            }
                            break;

                        case "HelpFileFormat":
                            // The enum value names changed in v1.8.0.3
                            helpFileFormat = xr.ReadString().ToUpper(CultureInfo.InvariantCulture);

                            foreach (string key in translateFormat.Keys)
                            {
                                helpFileFormat = helpFileFormat.Replace(key, translateFormat[key]);
                            }

                            base.SetProperty(propName, helpFileFormat);
                            break;

                        default:
                            if (renameProps.ContainsKey(propName))
                            {
                                propName = renameProps[propName];
                            }

                            value = base.SetProperty(propName, xr.ReadString());

                            filePath = value as FilePath;

                            // For file and folder paths, set the value
                            // from the attribute if present.
                            path = xr.GetAttribute("path");

                            if (filePath != null && !String.IsNullOrEmpty(path))
                            {
                                // Adjust relative paths for the new location
                                if (Path.IsPathRooted(path))
                                {
                                    filePath.Path        = path;
                                    filePath.IsFixedPath = true;
                                }
                                else
                                {
                                    filePath.Path = base.FullPath(path);
                                }
                            }
                            break;
                        }
                    }

                    xr.Read();
                }

                // The default for SealedProtected changed to true in v1.3.1.1
                Version changeVer = new Version(1, 3, 1, 1);

                if (schemaVersion < changeVer)
                {
                    base.Project.DocumentSealedProtected = true;
                }

                // Missing namespaces were always indicated prior to v1.4.0.2
                changeVer = new Version(1, 4, 0, 2);

                if (schemaVersion < changeVer)
                {
                    base.Project.ShowMissingNamespaces = true;
                }

                // The missing type parameters option was added in 1.6.0.7
                changeVer = new Version(1, 6, 0, 7);

                if (schemaVersion < changeVer)
                {
                    base.Project.ShowMissingTypeParams = true;
                }

                base.CreateFolderItems();
                base.Project.SaveProject(base.Project.Filename);
            }
            catch (Exception ex)
            {
                throw new BuilderException("CVT0005", String.Format(
                                               CultureInfo.CurrentCulture, "Error reading project " +
                                               "from '{0}' (last property = {1}):\r\n{2}",
                                               base.OldProjectFile, propName, ex.Message), ex);
            }
            finally
            {
                if (xr != null)
                {
                    xr.Close();
                }
            }

            return(base.Project.Filename);
        }
示例#43
0
        public static void AddXml(Glyph.Name glyphName, String assetName, Texture.Name textName)
        {
            System.Xml.XmlTextReader reader = new XmlTextReader(assetName);

            int key    = -1;
            int x      = -1;
            int y      = -1;
            int width  = -1;
            int height = -1;

            // I'm sure there is a better way to do this... but this works for now
            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:     // The node is an element.
                    if (reader.GetAttribute("key") != null)
                    {
                        key = Convert.ToInt32(reader.GetAttribute("key"));
                    }
                    else if (reader.Name == "x")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                x = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "y")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                y = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "width")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                width = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    else if (reader.Name == "height")
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Text)
                            {
                                height = Convert.ToInt32(reader.Value);
                                break;
                            }
                        }
                    }
                    break;

                case XmlNodeType.EndElement:     //Display the end of the element
                    if (reader.Name == "character")
                    {
                        // have all the data... so now create a glyph
                        //Debug.WriteLine("key:{0} x:{1} y:{2} w:{3} h:{4}", key, x, y, width, height);
                        GlyphMan.Add(glyphName, key, textName, x, y, width, height);
                    }
                    break;
                }
            }
        }
示例#44
0
        public void ReadXmlString_RsmAttr(string strXml, Scanner[] arScanner, out Scanner scanr, out int nIndex, out int nAttrCount, out int nOpCode)
        {
            nIndex     = -1;
            nAttrCount = 0;
            scanr      = null;
            nOpCode    = -1;
            if (string.IsNullOrEmpty(strXml))
            {
                return;
            }

            try {
                XmlTextReader xmlRead = new XmlTextReader(new StringReader(strXml));
                // Skip non-significant whitespace
                xmlRead.WhitespaceHandling = WhitespaceHandling.Significant;

                string sElementName = "", sElmValue = "";
                bool   bValid = false, bFirst = false;
                while (xmlRead.Read())
                {
                    switch (xmlRead.NodeType)
                    {
                    case XmlNodeType.Element:
                        sElementName = xmlRead.Name;
                        if (Scanner.TAG_SCANNER_ID == sElementName)
                        {
                            bValid = true;
                            bFirst = true;
                        }
                        // for old att_getall.xml ....since name is not used(user can refer data-dictionary)
                        else if (bValid && Scanner.TAG_ATTRIBUTE == sElementName && xmlRead.HasAttributes && (1 == xmlRead.AttributeCount))
                        {
                            sElmValue = xmlRead.GetAttribute("name");
                            if (null != scanr)
                            {
                                scanr.m_arAttributes.SetValue(sElmValue, nAttrCount, Scanner.POS_ATTR_NAME);
                            }
                        }
                        break;

                    case XmlNodeType.Text:
                        if (bValid)
                        {
                            sElmValue = xmlRead.Value;
                            if (bFirst && Scanner.TAG_SCANNER_ID == sElementName)
                            {
                                bFirst = false;
                                foreach (Scanner scanrTmp in arScanner)
                                {
                                    if ((null != scanrTmp) &&
                                        (sElmValue == scanrTmp.SCANNERID))
                                    {
                                        scanr = scanrTmp;
                                        break;
                                    }
                                }
                            }
                            else if (null != scanr)
                            {
                                switch (sElementName)
                                {
                                case Scanner.TAG_OPCODE:
                                    nOpCode = int.Parse(sElmValue);
                                    if (!(MainWindow.RSM_ATTR_GETALL == nOpCode ||
                                          MainWindow.RSM_ATTR_GET == nOpCode ||
                                          MainWindow.RSM_ATTR_GETNEXT == nOpCode))
                                    {
                                        return;
                                    }
                                    break;

                                case Scanner.TAG_ATTRIBUTE:
                                    if (MainWindow.RSM_ATTR_GETALL == nOpCode)
                                    {
                                        scanr.m_arAttributes.SetValue(sElmValue, nAttrCount, Scanner.POS_ATTR_ID);
                                        nAttrCount++;
                                    }
                                    break;

                                case Scanner.TAG_ATTR_ID:
                                    nIndex = -1;
                                    GetAttributePos(sElmValue, scanr, out nIndex);
                                    break;

                                case Scanner.TAG_ATTR_NAME:
                                    if (-1 != nIndex)
                                    {
                                        scanr.m_arAttributes.SetValue(sElmValue, nIndex, Scanner.POS_ATTR_NAME);
                                    }
                                    break;

                                case Scanner.TAG_ATTR_TYPE:
                                    if (-1 != nIndex)
                                    {
                                        scanr.m_arAttributes.SetValue(sElmValue, nIndex, Scanner.POS_ATTR_TYPE);
                                    }
                                    break;

                                case Scanner.TAG_ATTR_PROPERTY:
                                    if (-1 != nIndex)
                                    {
                                        scanr.m_arAttributes.SetValue(sElmValue, nIndex, Scanner.POS_ATTR_PROPERTY);
                                    }
                                    break;

                                case Scanner.TAG_ATTR_VALUE:
                                    if (-1 != nIndex)
                                    {
                                        scanr.m_arAttributes.SetValue(sElmValue, nIndex, Scanner.POS_ATTR_VALUE);
                                    }
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }
示例#45
0
        private bool ParseInternal(DTypeDesc caller, NamingContext context, string xml, PhpArray values, PhpArray indices)
        {
            StringReader          stringReader = new StringReader(xml);
            XmlTextReader         reader       = new XmlTextReader(stringReader);
            Stack <ElementRecord> elementStack = new Stack <ElementRecord>();
            TextRecord            textChunk    = null;

            _startElementHandler.BindOrBiteMyLegsOff(caller, context);
            _endElementHandler.BindOrBiteMyLegsOff(caller, context);
            _defaultHandler.BindOrBiteMyLegsOff(caller, context);
            _startNamespaceDeclHandler.BindOrBiteMyLegsOff(caller, context);
            _endNamespaceDeclHandler.BindOrBiteMyLegsOff(caller, context);
            _characterDataHandler.BindOrBiteMyLegsOff(caller, context);
            _processingInstructionHandler.BindOrBiteMyLegsOff(caller, context);

            while (reader.ReadState == ReadState.Initial || reader.ReadState == ReadState.Interactive)
            {
                try
                {
                    reader.Read();
                }
                catch (XmlException)
                {
                    _lastLineNumber   = reader.LineNumber;
                    _lastColumnNumber = reader.LinePosition;
                    _lastByteIndex    = -1;
                    _errorCode        = (int)XmlParserError.XML_ERROR_GENERIC;
                    return(false);
                }

                //these are usually required
                _lastLineNumber   = reader.LineNumber;
                _lastColumnNumber = reader.LinePosition;

                // we cannot do this - we could if we had underlying stream, but that would require
                // encoding string -> byte[] which is pointless


                switch (reader.ReadState)
                {
                case ReadState.Error:
                    //report error
                    break;

                case ReadState.EndOfFile:
                    //end of file
                    break;

                case ReadState.Closed:
                case ReadState.Initial:
                    //nonsense
                    Debug.Fail(null);
                    break;

                case ReadState.Interactive:
                    //debug step, that prints out the current state of the parser (pretty printed)
                    //Debug_ParseStep(reader);
                    ParseStep(reader, elementStack, ref textChunk, values, indices);
                    break;
                }

                if (reader.ReadState == ReadState.Error || reader.ReadState == ReadState.EndOfFile || reader.ReadState == ReadState.Closed)
                {
                    break;
                }
            }

            return(true);
        }
示例#46
0
 internal GiftCard(XmlTextReader xmlReader)
 {
     ReadXml(xmlReader);
 }
示例#47
0
 protected DataProviderBase()
 {
     xmlSerializer = new XmlSerializer(typeof(List <TEntity>));
     xmlReader     = new XmlTextReader(GetDataFilePath());
 }
示例#48
0
        internal override void ReadXml(XmlTextReader reader)
        {
            while (reader.Read())
            {
                if (reader.Name == "gift_card" && reader.NodeType == XmlNodeType.EndElement)
                {
                    break;
                }

                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                DateTime dateVal;

                switch (reader.Name)
                {
                case "id":
                    long id;
                    if (long.TryParse(reader.ReadElementContentAsString(), out id))
                    {
                        Id = id;
                    }
                    break;

                case "product_code":
                    ProductCode = reader.ReadElementContentAsString();
                    break;

                case "currency":
                    Currency = reader.ReadElementContentAsString();
                    break;

                case "redemption_code":
                    RedemptionCode = reader.ReadElementContentAsString();
                    break;

                case "unit_amount_in_cents":
                    int amount;
                    if (Int32.TryParse(reader.ReadElementContentAsString(), out amount))
                    {
                        UnitAmountInCents = amount;
                    }
                    break;

                case "balance_in_cents":
                    int balance;
                    if (Int32.TryParse(reader.ReadElementContentAsString(), out balance))
                    {
                        BalanceInCents = balance;
                    }
                    break;

                case "redemption_invoice":
                    string redemptionUrl = reader.GetAttribute("href");
                    if (redemptionUrl != null)
                    {
                        _redemptionInvoiceId = Uri.UnescapeDataString(redemptionUrl.Substring(redemptionUrl.LastIndexOf("/") + 1));
                    }
                    break;

                case "purchase_invoice":
                    string purchaseUrl = reader.GetAttribute("href");
                    if (purchaseUrl != null)
                    {
                        _purchaseInvoiceId = Uri.UnescapeDataString(purchaseUrl.Substring(purchaseUrl.LastIndexOf("/") + 1));
                    }
                    break;

                case "gifter_account":
                    string href = reader.GetAttribute("href");
                    if (null != href)
                    {
                        _accountCode = Uri.UnescapeDataString(href.Substring(href.LastIndexOf("/") + 1));
                    }
                    else
                    {
                        GifterAccount = new Account(reader, "gifter_account");
                    }
                    break;

                case "delivery":
                    Delivery = new Delivery(reader);
                    break;

                case "created_at":
                    if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                    {
                        CreatedAt = dateVal;
                    }
                    break;

                case "updated_at":
                    if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                    {
                        UpdatedAt = dateVal;
                    }
                    break;

                case "redeemed_at":
                    if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                    {
                        RedeemedAt = dateVal;
                    }
                    break;

                case "delivered_at":
                    if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                    {
                        DeliveredAt = dateVal;
                    }
                    break;
                }
            }
        }
示例#49
0
        /// <summary>
        /// Scan the Plugins Directory for any plugins, validate them, and add them to the program.
        /// </summary>
        public void ScanPlugins()
        {
            if (!Directory.Exists("./Plugins/"))
            {
                Directory.CreateDirectory("./Plugins/");
            }
            String[] files = Directory.GetFiles("./Plugins/", "*.xml");
            foreach (String sFile in files)
            {
                XMLValidator validator = new XMLValidator(sFile, isplugin: true);
                if (validator.ValidateXMLFile())
                {
                    MessageBox.Show(String.Format("Plugin {0} is in an invalid format! Possibly out of date?", sFile));
                    continue;
                }
                XmlTextReader reader = new XmlTextReader(sFile);
                String        element = "";
                String        name = "", client = "", realmlist = "";
                SArray3       realmOptions = new SArray3();
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                    {
                        element = reader.Name;
                        if (String.Compare(element, "Realm") == 0)
                        {
                            if (realmOptions.ContainsX(name))
                            {
                                continue;
                            }
                            if (name != "" && Config.ValidateClient(client))
                            {
                                realmOptions.Add(name, realmlist, client);
                            }
                            client    = "0.0.0";
                            name      = "";
                            realmlist = "";
                        }
                        break;
                    }

                    case XmlNodeType.Text:
                    {
                        switch (element)
                        {
                        case "RealmName":
                            name = reader.Value;
                            break;

                        case "RealmList":
                            realmlist = reader.Value;
                            break;

                        case "RealmClient":
                            client = reader.Value;
                            break;
                        }
                        break;
                    }
                    }
                }

                if (realmOptions.ContainsX(name))
                {
                    throw new Exception(String.Format("Realm id {0} used more than once!", name));
                }
                if (Config.ValidateClient(client))
                {
                    realmOptions.Add(name, realmlist, client);
                }

                foreach (Vector3 <String> vector in realmOptions)
                {
                    Config.realmOptions.Add(vector);
                }

                ListView box = (ListView)m_masterForm.Controls["chosenRealm"];
                foreach (Vector3 <String> kvp in realmOptions)
                {
                    ListViewItem itemToAdd = new ListViewItem(kvp.X);
                    itemToAdd.Name = kvp.X;
                    box.Items.Add(itemToAdd);
                }
            }
        }
示例#50
0
        public ParentNode(XmlTextReader xml, ParentNode parent)
        {
            m_Parent = parent;

            Parse(xml);
        }
示例#51
0
        /// <summary>
        /// It creates a SVG document reading from a file.
        /// If a current document exists, it is destroyed.
        /// </summary>
        /// <param name="sFilename">The complete path of a valid SVG file.</param>
        /// <returns>
        /// true if the file is loaded successfully and it is a valid SVG document, false if the file cannot be open or if it is not
        /// a valid SVG document.
        /// </returns>
        public bool LoadFromFile(string sFilename)
        {
            ErrH err = new ErrH("SvgDoc", "LoadFromFile");

            err.LogParameter("sFilename", sFilename);

            if (m_root != null)
            {
                m_root    = null;
                m_nNextId = 1;
                m_elements.Clear();
            }

            bool bResult = true;

            try
            {
                XmlTextReader reader;
                reader = new XmlTextReader(sFilename);
                reader.WhitespaceHandling = WhitespaceHandling.None;
                reader.Normalization      = false;
                reader.XmlResolver        = null;
                reader.Namespaces         = false;

                string     tmp;
                SvgElement eleParent = null;

                try
                {
                    // parse the file and display each of the nodes.
                    while (reader.Read() && bResult)
                    {
                        switch (reader.NodeType)
                        {
                        case XmlNodeType.Attribute:
                            tmp = reader.Name;
                            tmp = reader.Value;
                            break;

                        case XmlNodeType.Element:
                        {
                            SvgElement ele = AddElement(eleParent, reader.Name);

                            if (ele == null)
                            {
                                err.Log("Svg element cannot be added. Name: " + reader.Name, ErrH._LogPriority.Warning);
                                bResult = false;
                            }
                            else
                            {
                                eleParent = ele;

                                if (reader.IsEmptyElement)
                                {
                                    if (eleParent != null)
                                    {
                                        eleParent = eleParent.getParent();
                                    }
                                }

                                bool bLoop = reader.MoveToFirstAttribute();
                                while (bLoop)
                                {
                                    ele.SetAttributeValue(reader.Name, reader.Value);

                                    bLoop = reader.MoveToNextAttribute();
                                }
                            }
                        }
                        break;

                        case XmlNodeType.Text:
                            if (eleParent != null)
                            {
                                eleParent.setElementValue(reader.Value);
                            }
                            break;

                        case XmlNodeType.CDATA:

                            err.Log("Unexpected item: " + reader.Value, ErrH._LogPriority.Warning);
                            break;

                        case XmlNodeType.ProcessingInstruction:
                            switch (reader.Name)
                            {
                            case "xml-stylesheet":
                                this.StyleSheets.Add(reader.Value);
                                break;

                            default:
                                err.Log("Unexpected item: " + reader.Value, ErrH._LogPriority.Warning);
                                break;
                            }
                            break;

                        case XmlNodeType.Comment:

                            err.Log("Unexpected item: " + reader.Value, ErrH._LogPriority.Warning);
                            break;

                        case XmlNodeType.XmlDeclaration:
                            m_sXmlDeclaration = "<?xml " + reader.Value + "?>";
                            break;

                        case XmlNodeType.Document:
                            err.Log("Unexpected item: " + reader.Value, ErrH._LogPriority.Warning);
                            break;

                        case XmlNodeType.DocumentType:
                        {
                            string sDTD1;
                            string sDTD2;

                            sDTD1 = reader.GetAttribute("PUBLIC");
                            sDTD2 = reader.GetAttribute("SYSTEM");

                            m_sXmlDocType = "<!DOCTYPE svg PUBLIC \"" + sDTD1 + "\" \"" + sDTD2 + "\">";
                        }
                        break;

                        case XmlNodeType.EntityReference:
                            err.Log("Unexpected item: " + reader.Value, ErrH._LogPriority.Warning);
                            break;

                        case XmlNodeType.EndElement:
                            if (eleParent != null)
                            {
                                eleParent = eleParent.getParent();
                            }
                            break;
                        } // switch
                    }     // while
                }         // read try
                catch (XmlException xmle)
                {
                    err.LogException(xmle);
                    err.LogParameter("Line Number", xmle.LineNumber.ToString());
                    err.LogParameter("Line Position", xmle.LinePosition.ToString());

                    bResult = false;
                }
                catch (Exception e)
                {
                    err.LogException(e);
                    bResult = false;
                }
                finally
                {
                    reader.Close();
                }
            }
            catch
            {
                err.LogUnhandledException();
                bResult = false;
            }

            err.LogEnd(bResult);

            return(bResult);
        }
示例#52
0
    // This method reads a config.xml file at the given path and fills the
    // ConfigData object with the data.
    public bool fileToStruct(string configXMLPath, ConfigData configData)
    {
        if (!File.Exists(configXMLPath))
        {
            return(false);
        }

        using (XmlTextReader configReader = new XmlTextReader(configXMLPath))
        {
            while (configReader.Read())
            {
                if (configReader.NodeType == XmlNodeType.Element)
                {
                    // "Global" Attributes
                    string itNameAttr = "";

                    switch (configReader.Name)
                    {
                    case "ImageTarget":

                        // Parse name from config file
                        itNameAttr = configReader.GetAttribute("name");
                        if (itNameAttr == null)
                        {
                            Debug.LogWarning("Found ImageTarget without " +
                                             "name attribute in " +
                                             "config.xml. Image Target " +
                                             "will be ignored.");
                            continue;
                        }

                        // Parse itSize from config file
                        Vector2  itSize     = Vector2.zero;
                        string[] itSizeAttr =
                            configReader.GetAttribute("size").Split(' ');
                        if (itSizeAttr != null)
                        {
                            if (!QCARUtilities.SizeFromStringArray(
                                    out itSize, itSizeAttr))
                            {
                                Debug.LogWarning("Found illegal itSize " +
                                                 "attribute for Image " +
                                                 "Target " + itNameAttr +
                                                 " in config.xml. " +
                                                 "Image Target will be " +
                                                 "ignored.");
                                continue;
                            }
                        }
                        else
                        {
                            Debug.LogWarning("Image Target " + itNameAttr +
                                             " is missing a itSize " +
                                             "attribut in config.xml. " +
                                             "Image Target will be " +
                                             "ignored.");
                            continue;
                        }
                        configReader.MoveToElement();

                        ConfigData.ImageTargetData imageTarget =
                            new ConfigData.ImageTargetData();

                        imageTarget.size           = itSize;
                        imageTarget.virtualButtons =
                            new List <ConfigData.VirtualButtonData>();

                        configData.SetImageTarget(imageTarget, itNameAttr);

                        break;


                    case "VirtualButton":

                        // Parse name from config file
                        string vbNameAttr =
                            configReader.GetAttribute("name");
                        if (vbNameAttr == null)
                        {
                            Debug.LogWarning("Found VirtualButton " +
                                             "without name attribute in " +
                                             "config.xml. Virtual Button " +
                                             "will be ignored.");
                            continue;
                        }

                        // Parse rectangle from config file
                        Vector4  vbRectangle     = Vector4.zero;
                        string[] vbRectangleAttr =
                            configReader.GetAttribute("rectangle").Split(' ');
                        if (vbRectangleAttr != null)
                        {
                            if (!QCARUtilities.RectangleFromStringArray(
                                    out vbRectangle, vbRectangleAttr))
                            {
                                Debug.LogWarning("Found invalid " +
                                                 "rectangle attribute " +
                                                 "for Virtual Button " +
                                                 vbNameAttr +
                                                 " in config.xml. " +
                                                 "Virtual Button will " +
                                                 "be ignored.");
                                continue;
                            }
                        }
                        else
                        {
                            Debug.LogWarning("Virtual Button " +
                                             vbNameAttr +
                                             " has no rectangle " +
                                             "attribute in config.xml. " +
                                             "Virtual Button will be " +
                                             "ignored.");
                            continue;
                        }

                        // Parse enabled boolean from config file
                        bool   vbEnabled   = true;
                        string enabledAttr =
                            configReader.GetAttribute("enabled");
                        if (enabledAttr != null)
                        {
                            if (string.Compare(enabledAttr,
                                               "true", true) == 0)
                            {
                                vbEnabled = true;
                            }
                            else if (string.Compare(enabledAttr,
                                                    "false", true) == 0)
                            {
                                vbEnabled = false;
                            }
                            else
                            {
                                Debug.LogWarning("Found invalid enabled " +
                                                 "attribute for Virtual " +
                                                 "Button " + vbNameAttr +
                                                 " in config.xml. " +
                                                 "Default setting will " +
                                                 "be used.");
                            }
                        }

                        // Parse sensitivity from config file
                        VirtualButton.Sensitivity vbSensitivity =
                            VirtualButton.DEFAULT_SENSITIVITY;
                        string vbSensitivityAttr =
                            configReader.GetAttribute("sensitivity");
                        if (vbSensitivityAttr != null)
                        {
                            if (string.Compare(vbSensitivityAttr,
                                               "low", true) == 0)
                            {
                                vbSensitivity =
                                    VirtualButton.Sensitivity.LOW;
                            }
                            else if (string.Compare(vbSensitivityAttr,
                                                    "medium", true) == 0)
                            {
                                vbSensitivity =
                                    VirtualButton.Sensitivity.MEDIUM;
                            }
                            else if (string.Compare(vbSensitivityAttr,
                                                    "high", true) == 0)
                            {
                                vbSensitivity =
                                    VirtualButton.Sensitivity.HIGH;
                            }
                            else
                            {
                                Debug.LogWarning("Found illegal " +
                                                 "sensitivity attribute " +
                                                 "for Virtual Button " +
                                                 vbNameAttr +
                                                 " in config.xml. " +
                                                 "Default setting will " +
                                                 "be used.");
                            }
                        }

                        configReader.MoveToElement();

                        ConfigData.VirtualButtonData virtualButton =
                            new ConfigData.VirtualButtonData();

                        string latestITName = GetLatestITName(configData);

                        virtualButton.name        = vbNameAttr;
                        virtualButton.rectangle   = vbRectangle;
                        virtualButton.enabled     = vbEnabled;
                        virtualButton.sensitivity = vbSensitivity;

                        // Since the XML Reader runs top down we can assume
                        // that the Virtual Button that has been found is
                        // part of the latest Image Target.
                        if (configData.ImageTargetExists(latestITName))
                        {
                            configData.AddVirtualButton(virtualButton,
                                                        latestITName);
                        }
                        else
                        {
                            Debug.LogWarning("Image Target with name " +
                                             latestITName +
                                             " could not be found. " +
                                             "Virtual Button " +
                                             vbNameAttr +
                                             "will not be added.");
                        }
                        break;

                    case "MultiTarget":

                        // Parse name from config file
                        string mtNameAttr =
                            configReader.GetAttribute("name");
                        if (mtNameAttr == null)
                        {
                            Debug.LogWarning("Found Multi Target without " +
                                             "name attribute in " +
                                             "config.xml. Multi Target " +
                                             "will be ignored.");
                            continue;
                        }
                        configReader.MoveToElement();

                        ConfigData.MultiTargetData multiTarget =
                            new ConfigData.MultiTargetData();

                        multiTarget.parts =
                            new List <ConfigData.MultiTargetPartData>();

                        configData.SetMultiTarget(multiTarget, mtNameAttr);
                        break;


                    case "Part":

                        // Parse name from config file
                        string prtNameAttr =
                            configReader.GetAttribute("name");
                        if (prtNameAttr == null)
                        {
                            Debug.LogWarning("Found Multi Target Part " +
                                             "without name attribute in " +
                                             "config.xml. Part will be " +
                                             "ignored.");
                            continue;
                        }

                        // Parse translations from config file
                        Vector3  prtTranslation     = Vector3.zero;
                        string[] prtTranslationAttr =
                            configReader.GetAttribute("translation").Split(' ');
                        if (prtTranslationAttr != null)
                        {
                            if (!QCARUtilities.TransformFromStringArray(
                                    out prtTranslation, prtTranslationAttr))
                            {
                                Debug.LogWarning("Found illegal " +
                                                 "transform attribute " +
                                                 "for Part " + prtNameAttr +
                                                 " in config.xml. Part " +
                                                 "will be ignored.");
                                continue;
                            }
                        }
                        else
                        {
                            Debug.LogWarning("Multi Target Part " +
                                             prtNameAttr + " has no " +
                                             "translation attribute in " +
                                             "config.xml. Part will be " +
                                             "ignored.");
                            continue;
                        }

                        // Parse rotations from config file
                        Quaternion prtRotation     = Quaternion.identity;
                        string[]   prtRotationAttr =
                            configReader.GetAttribute("rotation").Split(' ');
                        if (prtRotationAttr != null)
                        {
                            if (!QCARUtilities.OrientationFromStringArray(
                                    out prtRotation, prtRotationAttr))
                            {
                                Debug.LogWarning("Found illegal rotation " +
                                                 "attribute for Part " +
                                                 prtNameAttr +
                                                 " in config.xml. Part " +
                                                 "will be ignored.");
                                continue;
                            }
                        }
                        else
                        {
                            Debug.LogWarning("Multi Target Part " +
                                             prtNameAttr + " has no " +
                                             "rotation attribute in " +
                                             "config.xml. Part will be " +
                                             "ignored.");
                            continue;
                        }

                        configReader.MoveToElement();

                        ConfigData.MultiTargetPartData multiTargetPart =
                            new ConfigData.MultiTargetPartData();

                        string latestMTName = GetLatestMTName(configData);

                        multiTargetPart.name        = prtNameAttr;
                        multiTargetPart.rotation    = prtRotation;
                        multiTargetPart.translation = prtTranslation;

                        // Since the XML Reader runs top down we can assume
                        // that the Virtual Button that has been found is
                        // part of the latest Image Target.
                        if (configData.MultiTargetExists(latestMTName))
                        {
                            configData.AddMultiTargetPart(multiTargetPart,
                                                          latestMTName);
                        }
                        else
                        {
                            Debug.LogWarning("Multi Target with name " +
                                             latestMTName +
                                             " could not be found. " +
                                             "Multi Target Part " +
                                             prtNameAttr +
                                             "will not be added.");
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }

        return(true);
    }
示例#53
0
 internal Purchase(XmlTextReader xmlReader)
 {
     ReadXml(xmlReader);
 }
示例#54
0
    /// <summary>
    /// Loads the trained Eigen Recogniser from specified location
    /// </summary>
    /// <param name="filename"></param>
    public void Load_Eigen_Recogniser(string filename)
    {
        //Lets get the recogniser type from the file extension
        string ext = Path.GetExtension(filename);

        //switch (ext)
        //{
        //    case (".LBPH"):
        //        Recognizer_Type = "EMGU.CV.LBPHFaceRecognizer";
        //        recognizer = new LBPHFaceRecognizer(1, 8, 8, 8, 100);//50
        //        break;
        //    case (".FFR"):
        Recognizer_Type = "EMGU.CV.FisherFaceRecognizer";
        recognizer      = new FisherFaceRecognizer(0, 3500);//4000
        //        break;
        //    case (".EFR"):
        //        Recognizer_Type = "EMGU.CV.EigenFaceRecognizer";
        //        recognizer = new EigenFaceRecognizer(80, double.PositiveInfinity);
        //        break;
        //}

        //introduce error checking
        recognizer.Load(filename);

        //Now load the labels
        string direct = Path.GetDirectoryName(filename);

        Names_List.Clear();
        if (File.Exists(direct + "/Labels.xml"))
        {
            FileStream filestream = File.OpenRead(direct + "/Labels.xml");
            long       filelength = filestream.Length;
            byte[]     xmlBytes   = new byte[filelength];
            filestream.Read(xmlBytes, 0, (int)filelength);
            filestream.Close();

            MemoryStream xmlStream = new MemoryStream(xmlBytes);

            using (XmlReader xmlreader = XmlTextReader.Create(xmlStream))
            {
                while (xmlreader.Read())
                {
                    if (xmlreader.IsStartElement())
                    {
                        switch (xmlreader.Name)
                        {
                        case "NAME":
                            if (xmlreader.Read())
                            {
                                Names_List.Add(xmlreader.Value.Trim());
                            }
                            break;
                        }
                    }
                }
            }
            ContTrain = NumLabels;
        }
        //Console.WriteLine("load");

        _IsTrained = true;
    }
示例#55
0
        /// <summary> Reads metadata from an open stream and saves to the provided item/package </summary>
        /// <param name="Input_Stream"> Open stream to read metadata from </param>
        /// <param name="Return_Package"> Package into which to read the metadata </param>
        /// <param name="Options"> Dictionary of any options which this metadata reader/writer may utilize </param>
        /// <param name="Error_Message">[OUTPUT] Explanation of the error, if an error occurs during reading </param>
        /// <returns>TRUE if successful, otherwise FALSE </returns>
        /// <remarks>This reader accepts two option values.  'EAD_File_ReaderWriter:XSL_Location' gives the location of a XSL
        /// file, which can be used to transform the description XML read from this EAD into HTML (or another format of XML).
        /// 'EAD_File_ReaderWriter:Analyze_Description' indicates whether to analyze the description section of the EAD and
        /// read it into the item. (Default is TRUE).</remarks>
        public bool Read_Metadata(Stream Input_Stream, SobekCM_Item Return_Package, Dictionary <string, object> Options, out string Error_Message)
        {
            // Ensure this metadata module extension exists
            EAD_Info eadInfo = Return_Package.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY) as EAD_Info;

            if (eadInfo == null)
            {
                eadInfo = new EAD_Info();
                Return_Package.Add_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY, eadInfo);
            }

            // Set a couple defaults first
            Return_Package.Bib_Info.SobekCM_Type    = TypeOfResource_SobekCM_Enum.Archival;
            Return_Package.Bib_Info.Type.Collection = true;
            Error_Message = String.Empty;

            // Check for some options
            string XSL_Location        = String.Empty;
            bool   Analyze_Description = true;

            if (Options != null)
            {
                if (Options.ContainsKey("EAD_File_ReaderWriter:XSL_Location"))
                {
                    XSL_Location = Options["EAD_File_ReaderWriter:XSL_Location"].ToString();
                }
                if (Options.ContainsKey("EAD_File_ReaderWriter:Analyze_Description"))
                {
                    bool.TryParse(Options["EAD_File_ReaderWriter:Analyze_Description"].ToString(), out Analyze_Description);
                }
            }


            // Use a string builder to seperate the description and container sections
            StringBuilder description_builder = new StringBuilder(20000);
            StringBuilder container_builder   = new StringBuilder(20000);

            // Read through with a simple stream reader first
            StreamReader reader            = new StreamReader(Input_Stream);
            string       line              = reader.ReadLine();
            bool         in_container_list = false;

            // Step through each line
            while (line != null)
            {
                if (!in_container_list)
                {
                    // Do not import the XML stylesheet portion
                    if ((line.IndexOf("xml-stylesheet") < 0) && (line.IndexOf("<!DOCTYPE ") < 0))
                    {
                        // Does the start a DSC section?
                        if ((line.IndexOf("<dsc ") >= 0) || (line.IndexOf("<dsc>") > 0))
                        {
                            in_container_list = true;
                            container_builder.AppendLine(line);
                        }
                        else
                        {
                            description_builder.AppendLine(line);
                        }
                    }
                }
                else
                {
                    // Add this to the container builder
                    container_builder.AppendLine(line);

                    // Does this end the container list section?
                    if (line.IndexOf("</dsc>") >= 0)
                    {
                        in_container_list = false;
                    }
                }

                // Get the next line
                line = reader.ReadLine();
            }

            // Close the reader
            reader.Close();

            // Just assign all the description section first
            eadInfo.Full_Description = description_builder.ToString();

            // Should the decrpition additionally be analyzed?
            if (Analyze_Description)
            {
                // Try to read the XML
                try
                {
                    XmlTextReader reader2 = new XmlTextReader(description_builder.ToString());

                    // Initial doctype declaration sometimes throws an error for a missing EAD.dtd.
                    bool ead_start_found = false;
                    int  error           = 0;
                    while ((!ead_start_found) && (error < 5))
                    {
                        try
                        {
                            reader2.Read();
                            if ((reader2.NodeType == XmlNodeType.Element) && (reader2.Name.ToLower() == GlobalVar.EAD_METADATA_MODULE_KEY))
                            {
                                ead_start_found = true;
                            }
                        }
                        catch
                        {
                            error++;
                        }
                    }

                    // Now read the body of the EAD
                    while (reader2.Read())
                    {
                        if (reader2.NodeType == XmlNodeType.Element)
                        {
                            string nodeName = reader2.Name.ToLower();
                            switch (nodeName)
                            {
                            case "descrules":
                                string descrules_text = reader2.ReadInnerXml().ToUpper();
                                if (descrules_text.IndexOf("FINDING AID PREPARED USING ") == 0)
                                {
                                    Return_Package.Bib_Info.Record.Description_Standard = descrules_text.Replace("FINDING AID PREPARED USING ", "");
                                }
                                else
                                {
                                    string[] likely_description_standards = { "DACS", "APPM", "AACR2", "RDA", "ISADG", "ISAD", "MAD", "RAD" };
                                    foreach (string likely_standard in likely_description_standards)
                                    {
                                        if (descrules_text.IndexOf(likely_standard) >= 0)
                                        {
                                            Return_Package.Bib_Info.Record.Description_Standard = likely_standard;
                                            break;
                                        }
                                    }
                                }
                                break;

                            case "unittitle":
                                while (reader2.Read())
                                {
                                    if (reader2.NodeType == XmlNodeType.Text)
                                    {
                                        Return_Package.Bib_Info.Main_Title.Title = reader2.Value;
                                        break;
                                    }
                                    else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("unittitle"))
                                    {
                                        break;
                                    }
                                }
                                while (!(reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("unittitle")))
                                {
                                    reader2.Read();
                                }
                                break;

                            case "unitid":
                                while (reader2.Read())
                                {
                                    if (reader2.NodeType == XmlNodeType.Text)
                                    {
                                        Return_Package.Bib_Info.Add_Identifier(reader2.Value, "Main Identifier");
                                    }
                                    if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName))
                                    {
                                        break;
                                    }
                                }
                                break;

                            case "origination":
                                while (reader2.Read())
                                {
                                    if (reader2.NodeType == XmlNodeType.Element && reader2.Name.Equals("persname"))
                                    {
                                        while (reader2.Read())
                                        {
                                            if (reader2.NodeType == XmlNodeType.Text)
                                            {
                                                Return_Package.Bib_Info.Main_Entity_Name.Full_Name = Trim_Final_Punctuation(reader2.Value);
                                                Return_Package.Bib_Info.Main_Entity_Name.Name_Type = Name_Info_Type_Enum.personal;
                                            }
                                            else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName))
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName))
                                    {
                                        break;
                                    }
                                }
                                break;

                            case "physdesc":
                                while (reader2.Read())
                                {
                                    if (reader2.NodeType == XmlNodeType.Element && reader2.Name.Equals("extent"))
                                    {
                                        while (reader2.Read())
                                        {
                                            if (reader2.NodeType == XmlNodeType.Text)
                                            {
                                                Return_Package.Bib_Info.Original_Description.Extent = reader2.Value;
                                            }
                                            else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("extent"))
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals("physdesc"))
                                    {
                                        break;
                                    }
                                }
                                break;

                            case "abstract":
                                while (reader2.Read())
                                {
                                    if (reader2.NodeType == XmlNodeType.Text)
                                    {
                                        Return_Package.Bib_Info.Add_Abstract(reader2.Value);
                                    }
                                    else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName))
                                    {
                                        break;
                                    }
                                }
                                break;

                            case "repository":
                                while (reader2.Read())
                                {
                                    if (reader2.NodeType == XmlNodeType.Element && reader2.Name.Equals("corpname"))
                                    {
                                        while (reader2.Read())
                                        {
                                            if (reader2.NodeType == XmlNodeType.Text)
                                            {
                                                Return_Package.Bib_Info.Location.Holding_Name = reader2.Value;
                                            }
                                            else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName))
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName))
                                    {
                                        break;
                                    }
                                }
                                break;

                            case "accessrestrict":
                                Return_Package.Bib_Info.Add_Note(Clean_Text_Block(reader2.ReadInnerXml()), Note_Type_Enum.restriction);
                                break;

                            case "userestrict":
                                Return_Package.Bib_Info.Access_Condition.Text = Clean_Text_Block(reader2.ReadInnerXml());
                                break;

                            case "acqinfo":
                                Return_Package.Bib_Info.Add_Note(Clean_Text_Block(reader2.ReadInnerXml()), Note_Type_Enum.acquisition);
                                break;

                            case "bioghist":
                                Return_Package.Bib_Info.Add_Note(Clean_Text_Block(reader2.ReadInnerXml()), Note_Type_Enum.biographical);
                                break;

                            case "scopecontent":
                                Return_Package.Bib_Info.Add_Abstract(Clean_Text_Block(reader2.ReadInnerXml()), "", "summary", "Summary");
                                break;

                            case "controlaccess":
                                while (reader2.Read())
                                {
                                    if (reader2.NodeType == XmlNodeType.Element && (reader2.Name.Equals("corpname") || reader2.Name.Equals("persname")))
                                    {
                                        string tagnamei = reader2.Name;
                                        string source   = "";
                                        if (reader2.MoveToAttribute("source"))
                                        {
                                            source = reader2.Value;
                                        }
                                        while (reader2.Read())
                                        {
                                            if (reader2.NodeType == XmlNodeType.Text)
                                            {
                                                Subject_Info_Name newName = new Subject_Info_Name();
                                                //ToSee: where to add name? and ehat types
                                                //ToDo: Type
                                                newName.Full_Name = Trim_Final_Punctuation(reader2.Value);
                                                newName.Authority = source;
                                                Return_Package.Bib_Info.Add_Subject(newName);
                                                if (tagnamei.StartsWith("corp"))
                                                {
                                                    newName.Name_Type = Name_Info_Type_Enum.corporate;
                                                }
                                                else if (tagnamei.StartsWith("pers"))
                                                {
                                                    newName.Name_Type = Name_Info_Type_Enum.personal;
                                                }
                                                else
                                                {
                                                    newName.Name_Type = Name_Info_Type_Enum.UNKNOWN;
                                                }
                                            }
                                            else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals(tagnamei))
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    else if (reader2.NodeType == XmlNodeType.Element && (reader2.Name.Equals("subject")))
                                    {
                                        string tagnamei = reader2.Name;
                                        string source   = "";
                                        if (reader2.MoveToAttribute("source"))
                                        {
                                            source = reader2.Value;
                                        }
                                        while (reader2.Read())
                                        {
                                            if (reader2.NodeType == XmlNodeType.Text)
                                            {
                                                string subjectTerm = Trim_Final_Punctuation(reader2.Value.Trim());
                                                if (subjectTerm.Length > 1)
                                                {
                                                    Subject_Info_Standard subject = Return_Package.Bib_Info.Add_Subject();
                                                    subject.Authority = source;
                                                    if (subjectTerm.IndexOf("--") == 0)
                                                    {
                                                        subject.Add_Topic(subjectTerm);
                                                    }
                                                    else
                                                    {
                                                        while (subjectTerm.IndexOf("--") > 0)
                                                        {
                                                            string fragment = subjectTerm.Substring(0, subjectTerm.IndexOf("--")).Trim();
                                                            if (fragment.ToLower() == "florida")
                                                            {
                                                                subject.Add_Geographic(fragment);
                                                            }
                                                            else
                                                            {
                                                                subject.Add_Topic(fragment);
                                                            }

                                                            if (subjectTerm.Length > subjectTerm.IndexOf("--") + 3)
                                                            {
                                                                subjectTerm = subjectTerm.Substring(subjectTerm.IndexOf("--") + 2);
                                                            }
                                                            else
                                                            {
                                                                subjectTerm = String.Empty;
                                                            }
                                                        }
                                                        if (subjectTerm.Trim().Length > 0)
                                                        {
                                                            string fragment = subjectTerm.Trim();
                                                            if (fragment.ToLower() == "florida")
                                                            {
                                                                subject.Add_Geographic(fragment);
                                                            }
                                                            else
                                                            {
                                                                subject.Add_Topic(fragment);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            else if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals(tagnamei))
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.ToLower().Equals(nodeName))
                                    {
                                        break;
                                    }
                                }
                                break;

                            case "dsc":
                                eadInfo.Container_Hierarchy.Read(reader2);
                                break;
                            }
                        }


                        if (reader2.NodeType == XmlNodeType.EndElement && reader2.Name.Equals(GlobalVar.EAD_METADATA_MODULE_KEY))
                        {
                            break;
                        }
                    }

                    reader2.Close();
                }
                catch (Exception ee)
                {
                    Error_Message = "Error caught in EAD_reader2_Writer: " + ee.Message;
                    return(false);
                }
            }


            // If there is a XSL, apply it to the description stored in the EAD sub-section of the item id
            if (XSL_Location.Length > 0)
            {
                try
                {
                    // Create the transform and load the XSL indicated
                    XslCompiledTransform transform = new XslCompiledTransform();
                    transform.Load(XSL_Location);

                    // Apply the transform to convert the XML into HTML
                    StringWriter      results  = new StringWriter();
                    XmlReaderSettings settings = new XmlReaderSettings();
                    settings.ProhibitDtd = false;
                    using (XmlReader transformreader = XmlReader.Create(new StringReader(eadInfo.Full_Description), settings))
                    {
                        transform.Transform(transformreader, null, results);
                    }
                    eadInfo.Full_Description = results.ToString();

                    // Get rid of the <?xml header
                    if (eadInfo.Full_Description.IndexOf("<?xml") >= 0)
                    {
                        int xml_end_index = eadInfo.Full_Description.IndexOf("?>");
                        eadInfo.Full_Description = eadInfo.Full_Description.Substring(xml_end_index + 2);
                    }

                    // Since this was successful, try to build the TOC list of included sections
                    SortedList <int, string> toc_sorter = new SortedList <int, string>();
                    string description     = eadInfo.Full_Description;
                    int    did             = description.IndexOf("<a name=\"did\"");
                    int    bioghist        = description.IndexOf("<a name=\"bioghist\"");
                    int    scopecontent    = description.IndexOf("<a name=\"scopecontent\"");
                    int    organization    = description.IndexOf("<a name=\"organization\"");
                    int    arrangement     = description.IndexOf("<a name=\"arrangement\"");
                    int    relatedmaterial = description.IndexOf("<a name=\"relatedmaterial\"");
                    int    otherfindaid    = description.IndexOf("<a name=\"otherfindaid\"");
                    int    index           = description.IndexOf("<a name=\"index\">");
                    int    bibliography    = description.IndexOf("<a name=\"bibliography\"");
                    int    odd             = description.IndexOf("<a name=\"odd\"");
                    int    controlaccess   = description.IndexOf("<a name=\"controlaccess\"");
                    int    accruals        = description.IndexOf("<a name=\"accruals\"");
                    int    appraisal       = description.IndexOf("<a name=\"appraisal\"");
                    int    processinfo     = description.IndexOf("<a name=\"processinfo\"");
                    int    acqinfo         = description.IndexOf("<a name=\"acqinfo\"");
                    int    prefercite      = description.IndexOf("<a name=\"prefercite\"");
                    int    altformavail    = description.IndexOf("<a name=\"altformavail\"");
                    int    custodhist      = description.IndexOf("<a name=\"custodhist\"");
                    int    accessrestrict  = description.IndexOf("<a name=\"accessrestrict\"");
                    int    admininfo       = description.IndexOf("<a name=\"admininfo\"");

                    if (did >= 0)
                    {
                        toc_sorter[did] = "did";
                    }
                    if (bioghist >= 0)
                    {
                        toc_sorter[bioghist] = "bioghist";
                    }
                    if (scopecontent >= 0)
                    {
                        toc_sorter[scopecontent] = "scopecontent";
                    }
                    if (organization >= 0)
                    {
                        toc_sorter[organization] = "organization";
                    }
                    if (arrangement >= 0)
                    {
                        toc_sorter[arrangement] = "arrangement";
                    }
                    if (relatedmaterial >= 0)
                    {
                        toc_sorter[relatedmaterial] = "relatedmaterial";
                    }
                    if (otherfindaid >= 0)
                    {
                        toc_sorter[otherfindaid] = "otherfindaid";
                    }
                    if (index >= 0)
                    {
                        toc_sorter[index] = "index";
                    }
                    if (bibliography >= 0)
                    {
                        toc_sorter[bibliography] = "bibliography";
                    }
                    if (odd >= 0)
                    {
                        toc_sorter[odd] = "odd";
                    }
                    if (controlaccess >= 0)
                    {
                        toc_sorter[controlaccess] = "controlaccess";
                    }
                    if (accruals >= 0)
                    {
                        toc_sorter[accruals] = "accruals";
                    }
                    if (appraisal >= 0)
                    {
                        toc_sorter[appraisal] = "appraisal";
                    }
                    if (processinfo >= 0)
                    {
                        toc_sorter[processinfo] = "processinfo";
                    }
                    if (acqinfo >= 0)
                    {
                        toc_sorter[acqinfo] = "acqinfo";
                    }
                    if (prefercite >= 0)
                    {
                        toc_sorter[prefercite] = "prefercite";
                    }
                    if (altformavail >= 0)
                    {
                        toc_sorter[altformavail] = "altformavail";
                    }
                    if (custodhist >= 0)
                    {
                        toc_sorter[custodhist] = "custodhist";
                    }
                    if (accessrestrict >= 0)
                    {
                        toc_sorter[accessrestrict] = "accessrestrict";
                    }
                    if (admininfo >= 0)
                    {
                        toc_sorter[admininfo] = "admininfo";
                    }

                    // Now, add each section back to the TOC list
                    foreach (string thisEadSection in toc_sorter.Values)
                    {
                        // Index needs to have its head looked up, everything else adds simply
                        if (thisEadSection != "index")
                        {
                            switch (thisEadSection)
                            {
                            case "did":
                                eadInfo.Add_TOC_Included_Section("did", "Descriptive Summary");
                                break;

                            case "bioghist":
                                eadInfo.Add_TOC_Included_Section("bioghist", "Biographical / Historical Note");
                                break;

                            case "scopecontent":
                                eadInfo.Add_TOC_Included_Section("scopecontent", "Scope and Content");
                                break;

                            case "accessrestrict":
                                eadInfo.Add_TOC_Included_Section("accessrestrict", "Access or Use Restrictions");
                                break;

                            case "relatedmaterial":
                                eadInfo.Add_TOC_Included_Section("relatedmaterial", "Related or Separated Material");
                                break;

                            case "admininfo":
                                eadInfo.Add_TOC_Included_Section("admininfo", "Administrative Information");
                                break;

                            case "altformavail":
                                eadInfo.Add_TOC_Included_Section("altformavail", " &nbsp; &nbsp; Alternate Format Available");
                                break;

                            case "prefercite":
                                eadInfo.Add_TOC_Included_Section("prefercite", " &nbsp; &nbsp; Preferred Citation");
                                break;

                            case "acqinfo":
                                eadInfo.Add_TOC_Included_Section("acqinfo", " &nbsp; &nbsp; Acquisition Information");
                                break;

                            case "processinfo":
                                eadInfo.Add_TOC_Included_Section("processinfo", " &nbsp; &nbsp; Processing Information");
                                break;

                            case "custodhist":
                                eadInfo.Add_TOC_Included_Section("custodhist", " &nbsp; &nbsp; Custodial Work_History");
                                break;

                            case "controlaccess":
                                eadInfo.Add_TOC_Included_Section("controlaccess", "Selected Subjects");
                                break;

                            case "otherfindaid":
                                eadInfo.Add_TOC_Included_Section("otherfindaid", "Alternate Form of Finding Aid");
                                break;
                            }
                        }
                        else
                        {
                            int    end_link    = eadInfo.Full_Description.IndexOf("</a>", index);
                            string index_title = eadInfo.Full_Description.Substring(index + 16, end_link - index - 16);
                            if (index_title.Length > 38)
                            {
                                index_title = index_title.Substring(0, 32) + "...";
                            }
                            eadInfo.Add_TOC_Included_Section("index", index_title);
                        }
                    }
                }
                catch (Exception ee)
                {
                    bool error = false;
                }
            }

            // Now, parse the container section as XML
            if (container_builder.Length > 0)
            {
                StringReader  containerReader = new StringReader(container_builder.ToString());
                XmlTextReader xml_reader      = new XmlTextReader(containerReader);
                xml_reader.Read();
                eadInfo.Container_Hierarchy.Read(xml_reader);
            }

            return(true);
        }
示例#56
0
    /// <summary>
    /// Loads the traing data given a (string) folder location
    /// </summary>
    /// <param name="Folder_location"></param>
    /// <returns></returns>
    private bool LoadTrainingData(string Folder_location)
    {
        if (File.Exists(Folder_location + "\\TrainedLabels.xml"))
        {
            try
            {
                //message_bar.Text = "";
                Names_List.Clear();
                Names_List_ID.Clear();
                trainingImages.Clear();
                FileStream filestream = File.OpenRead(Folder_location + "\\TrainedLabels.xml");
                long       filelength = filestream.Length;

                byte[] xmlBytes = new byte[filelength];
                filestream.Read(xmlBytes, 0, (int)filelength);
                filestream.Close();

                MemoryStream xmlStream = new MemoryStream(xmlBytes);

                using (XmlReader xmlreader = XmlTextReader.Create(xmlStream))
                {
                    while (xmlreader.Read())
                    {
                        if (xmlreader.IsStartElement())
                        {
                            switch (xmlreader.Name)
                            {
                            case "NAME":
                                if (xmlreader.Read())
                                {
                                    Names_List_ID.Add(Names_List.Count);     //0, 1, 2, 3....
                                    Names_List.Add(xmlreader.Value.Trim());
                                    NumLabels += 1;
                                }
                                break;

                            case "FILE":
                                if (xmlreader.Read())
                                {
                                    //PROBLEM HERE IF TRAININGG MOVED
                                    trainingImages.Add(new Image <Gray, byte>(Application.StartupPath + "\\TrainedFaces\\" + xmlreader.Value.Trim()));
                                }
                                break;
                            }
                        }
                    }
                }
                ContTrain = NumLabels;

                if (trainingImages.ToArray().Length != 0)
                {
                    //Eigen face recognizer
                    //Parameters:
                    //      num_components – The number of components (read: Eigenfaces) kept for this Prinicpal
                    //          Component Analysis. As a hint: There’s no rule how many components (read: Eigenfaces)
                    //          should be kept for good reconstruction capabilities. It is based on your input data,
                    //          so experiment with the number. Keeping 80 components should almost always be sufficient.
                    //
                    //      threshold – The threshold applied in the prediciton. This still has issues as it work inversly to LBH and Fisher Methods.
                    //          if you use 0.0 recognizer.Predict will always return -1 or unknown if you use 5000 for example unknow won't be reconised.
                    //          As in previous versions I ignore the built in threhold methods and allow a match to be found i.e. double.PositiveInfinity
                    //          and then use the eigen distance threshold that is return to elliminate unknowns.
                    //
                    //NOTE: The following causes the confusion, sinc two rules are used.
                    //--------------------------------------------------------------------------------------------------------------------------------------
                    //Eigen Uses
                    //          0 - X = unknown
                    //          > X = Recognised
                    //
                    //Fisher and LBPH Use
                    //          0 - X = Recognised
                    //          > X = Unknown
                    //
                    // Where X = Threshold value


                    //switch (Recognizer_Type)
                    //{
                    //    case ("EMGU.CV.LBPHFaceRecognizer"):
                    recognizer = new LBPHFaceRecognizer(1, 8, 8, 8, 100); //50
                                                                          //        break;
                                                                          //    case ("EMGU.CV.FisherFaceRecognizer"):
                                                                          //recognizer = new FisherFaceRecognizer(0, 3500);//4000
                                                                          //        break;
                                                                          //    case("EMGU.CV.EigenFaceRecognizer"):
                                                                          //    default:
                                                                          //        recognizer = new EigenFaceRecognizer(80, double.PositiveInfinity);
                                                                          //        break;
                                                                          //}
                                                                          //Console.WriteLine(trainingImages);
                    try
                    {
                        recognizer.Train(trainingImages.ToArray(), Names_List_ID.ToArray());
                    }
                    catch (System.AccessViolationException)
                    {
                        //Console.WriteLine("test");
                    }
                    // Recognizer_Type = recognizer.GetType();
                    // string v = recognizer.ToString(); //EMGU.CV.FisherFaceRecognizer || EMGU.CV.EigenFaceRecognizer || EMGU.CV.LBPHFaceRecognizer
                    //Console.WriteLine("test");

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Error = ex.ToString();
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }
示例#57
0
        public void ReadXmlString_FW(string strXml, out int nMax, out int nProgress, out string sStatus, out string csScannerID)
        {
            nMax        = 0;
            nProgress   = 0;
            sStatus     = "";
            csScannerID = "";
            if (string.IsNullOrEmpty(strXml))
            {
                return;
            }

            string csSerial = "", csModel = "", csGuid = "";

            try {
                XmlTextReader xmlRead = new XmlTextReader(new StringReader(strXml));
                // Skip non-significant whitespace
                xmlRead.WhitespaceHandling = WhitespaceHandling.Significant;

                string sElementName = "", sElmValue = "";
                bool   bScanner = false;
                while (xmlRead.Read())
                {
                    switch (xmlRead.NodeType)
                    {
                    case XmlNodeType.Element:
                        sElementName = xmlRead.Name;
                        if (Scanner.TAG_SCANNER_ID == sElementName)
                        {
                            bScanner = true;
                        }
                        break;

                    case XmlNodeType.Text:
                        if (bScanner)
                        {
                            sElmValue = xmlRead.Value;
                            switch (sElementName)
                            {
                            case Scanner.TAG_SCANNER_ID:
                                csScannerID = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_SERIALNUMBER:
                                csSerial = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_MODELNUMBER:
                                csModel = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_GUID:
                                csGuid = sElmValue;
                                break;

                            case Scanner.TAG_STATUS:
                                sStatus = sElmValue;
                                break;

                            case TAG_MAXCOUNT:
                                nMax = int.Parse(sElmValue);
                                break;

                            case TAG_PROGRESS:
                                nProgress = int.Parse(sElmValue);
                                break;
                            }
                        }
                        break;
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>
        /// Returns a page of errors from the folder in descending order
        /// of logged time as defined by the sortable filenames.
        /// </summary>

        public override int GetErrors(int pageIndex, int pageSize, IList errorEntryList)
        {
            if (pageIndex < 0)
            {
                throw new ArgumentOutOfRangeException("pageIndex", pageIndex, null);
            }

            if (pageSize < 0)
            {
                throw new ArgumentOutOfRangeException("pageSize", pageSize, null);
            }

            /* Get all files in directory */
            string        logPath = LogPath;
            DirectoryInfo dir     = new DirectoryInfo(logPath);

            if (!dir.Exists)
            {
                return(0);
            }

            FileSystemInfo[] infos = dir.GetFiles("error-*.xml");

            if (infos.Length < 1)
            {
                return(0);
            }

            string[] files = new string[infos.Length];
            int      count = 0;

            /* Get files that are not marked with system and hidden attributes */
            foreach (FileSystemInfo info in infos)
            {
                if (IsUserFile(info.Attributes))
                {
                    files[count++] = Path.Combine(logPath, info.Name);
                }
            }

            InvariantStringArray.Sort(files, 0, count);
            Array.Reverse(files, 0, count);

            if (errorEntryList != null)
            {
                /* Find the proper page */
                int firstIndex = pageIndex * pageSize;
                int lastIndex  = (firstIndex + pageSize < count) ? firstIndex + pageSize : count;

                /* Open them up and rehydrate the list */
                for (int i = firstIndex; i < lastIndex; i++)
                {
                    XmlTextReader reader = new XmlTextReader(files[i]);

                    try
                    {
                        while (reader.IsStartElement("error"))
                        {
                            string id    = reader.GetAttribute("errorId");
                            Error  error = ErrorXml.Decode(reader);
                            errorEntryList.Add(new ErrorLogEntry(this, id, error));
                        }
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
            }

            /* Return how many are total */
            return(count);
        }
示例#59
0
        public void ReadXmlString_AttachDetachMulti(string strXml, out Scanner[] arScanr, out string sStatus)
        {
            arScanr = new Scanner[8];
            for (int index = 0; index < 5; index++)
            {
                arScanr.SetValue(null, index);
            }

            sStatus = "";
            if (string.IsNullOrEmpty(strXml))
            {
                return;
            }

            try {
                XmlTextReader xmlRead = new XmlTextReader(new StringReader(strXml));
                // Skip non-significant whitespace
                xmlRead.WhitespaceHandling = WhitespaceHandling.Significant;

                string sElementName = "", sElmValue = "";
                bool   bScanner      = false;
                int    nScannerCount = 0;             //for multiple scanners as in cradle+cascaded
                int    nIndex        = 0;
                while (xmlRead.Read())
                {
                    switch (xmlRead.NodeType)
                    {
                    case XmlNodeType.Element:
                        sElementName = xmlRead.Name;
                        string strScannerType = xmlRead.GetAttribute(Scanner.TAG_SCANNER_TYPE);
                        if (xmlRead.HasAttributes && (
                                (Scanner.TAG_SCANNER_SNAPI == strScannerType) ||
                                (Scanner.TAG_SCANNER_SSI == strScannerType) ||
                                (Scanner.TAG_SCANNER_IBMHID == strScannerType) ||
                                (Scanner.TAG_SCANNER_OPOS == strScannerType) ||
                                (Scanner.TAG_SCANNER_IMBTT == strScannerType) ||
                                (Scanner.TAG_SCALE_IBM == strScannerType) ||
                                (Scanner.SCANNER_SSI_BT == strScannerType) ||
                                (Scanner.TAG_SCANNER_HIDKB == strScannerType)))                                //n = xmlRead.AttributeCount;
                        {
                            nIndex = nScannerCount;
                            arScanr.SetValue(new Scanner(), nIndex);
                            nScannerCount++;
                            arScanr[nIndex].SCANNERTYPE = strScannerType;
                        }
                        if ((null != arScanr[nIndex]) && Scanner.TAG_SCANNER_ID == sElementName)
                        {
                            bScanner = true;
                        }
                        break;

                    case XmlNodeType.Text:
                        if (bScanner && (null != arScanr[nIndex]))
                        {
                            sElmValue = xmlRead.Value;
                            switch (sElementName)
                            {
                            case Scanner.TAG_SCANNER_ID:
                                arScanr[nIndex].SCANNERID = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_SERIALNUMBER:
                                arScanr[nIndex].SERIALNO = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_MODELNUMBER:
                                arScanr[nIndex].MODELNO = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_GUID:
                                arScanr[nIndex].GUID = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_TYPE:
                                arScanr[nIndex].SCANNERTYPE = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_FW:
                                arScanr[nIndex].SCANNERFIRMWARE = sElmValue;
                                break;

                            case Scanner.TAG_SCANNER_DOM:
                                arScanr[nIndex].SCANNERMNFDATE = sElmValue;
                                break;

                            case Scanner.TAG_STATUS:
                                sStatus = sElmValue;
                                break;

                            case TAG_PNP:
                                if ("0" == sElmValue)
                                {
                                    arScanr[nIndex] = null;
                                    nScannerCount--;
                                }
                                break;
                            }
                        }
                        break;
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }
示例#60
0
        public void ReadXmlString_Scale(string strXml, out string weight, out string weightMode, out int Scalestatus)
        {
            weight      = "";
            weightMode  = "";
            Scalestatus = 0;
            if (string.IsNullOrEmpty(strXml))
            {
                return;
            }

            try {
                XmlTextReader xmlRead = new XmlTextReader(new StringReader(strXml));
                // Skip non-significant whitespace
                xmlRead.WhitespaceHandling = WhitespaceHandling.Significant;

                string sElementName = "", sElmValue = "";
                bool   bScanner = false;
                while (xmlRead.Read())
                {
                    switch (xmlRead.NodeType)
                    {
                    case XmlNodeType.Element:
                        sElementName = xmlRead.Name;
                        if (Scanner.TAG_SCANNER_ID == sElementName)
                        {
                            bScanner = true;
                        }
                        break;

                    case XmlNodeType.Text:
                        if (bScanner)
                        {
                            sElmValue = xmlRead.Value;
                            switch (sElementName)
                            {
                            case Scanner.TAG_SCALE_WEIGHT:
                                weight = sElmValue;
                                break;

                            case Scanner.TAG_SCALE_WEIGHT_MODE:
                                weightMode = sElmValue;
                                break;

                            case Scanner.TAG_SCALE_STATUS:
                                Scalestatus = int.Parse(sElmValue);
                                break;


                                //case Scanner.TAG_SCANNER_GUID:
                                //    csGuid = sElmValue;
                                //    break;
                                //case Scanner.TAG_STATUS:
                                //    sStatus = sElmValue;
                                //    break;
                                //case TAG_MAXCOUNT:
                                //    nMax = Int32.Parse(sElmValue);
                                //    break;
                                //case TAG_PROGRESS:
                                //    nProgress = Int32.Parse(sElmValue);
                                //    break;
                            }
                        }
                        break;
                    }
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }