Ejemplo n.º 1
0
            /// <summary>
            /// This is the worker thread.
            /// </summary>
            /// <param name="stateInfo">Not used.</param>
            void ProcessFiles(object stateInfo)
            {
                System.Text.StringBuilder stb = null;

                while (_filesToProcess.Count > 0)
                {
                    string fullfilename = _filesToProcess.Dequeue();
                    try
                    {
                        string   category     = null;
                        string   name         = null;
                        DateTime creationTime = DateTime.MinValue;
                        string   description  = string.Empty;

                        System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(fullfilename);
                        xmlReader.MoveToContent();
                        while (xmlReader.Read())
                        {
                            if (xmlReader.NodeType == System.Xml.XmlNodeType.Element && xmlReader.LocalName == "Category")
                            {
                                category     = xmlReader.ReadElementString();
                                name         = xmlReader.ReadElementString("Name");
                                creationTime = System.Xml.XmlConvert.ToDateTime(xmlReader.ReadElementString("CreationTime"), System.Xml.XmlDateTimeSerializationMode.Local);
                                if (xmlReader.LocalName == "Description")
                                {
                                    description = xmlReader.ReadElementString("Description");
                                }
                                break;
                            }
                        }
                        xmlReader.Close();

                        AddFitFunctionEntry(category, name, creationTime, description, fullfilename);
                    }
                    catch (Exception ex)
                    {
                        if (stb == null)
                        {
                            stb = new StringBuilder();
                        }

                        stb.AppendLine(ex.ToString());
                    }
                }

                if (stb != null)
                {
                    Current.Console.WriteLine("Exception(s) thrown in " + this.GetType().ToString() + " during parsing of fit functions, details will follow:");
                    Current.Console.WriteLine(stb.ToString());
                }
                _threadIsWorking = false;
            }
Ejemplo n.º 2
0
        private static PackageMatch ParseMatch(System.Xml.XmlTextReader reader)
        {
            // Make sure we're in right position
            reader.ReadStartElement("match");

            PackageMatch match = new PackageMatch();

            if (reader.LocalName == "channel")
            {
                match.ChannelId = reader.ReadElementString();
            }

            if (reader.LocalName == "dep")
            {
                PackageDep dep = new PackageDep(reader);
                match.Dep = dep;
                //dep.Unref ();

                // Move reader to start of next element
                while (reader.Read())
                {
                    if (reader.NodeType == System.Xml.XmlNodeType.Element)
                    {
                        break;
                    }
                }
            }

            if (reader.LocalName == "glob")
            {
                match.Glob = reader.ReadElementString();
            }

            if (reader.LocalName == "importance")
            {
                int    gteq     = 0;
                string gteq_str = reader["gteq"];
                if (gteq_str != null)
                {
                    gteq = System.Xml.XmlConvert.ToInt32(gteq_str);
                }

                PackageImportance imp = RC.Global.PackageImportanceFromString(reader.ReadElementString());
                match.SetImportance(imp, Convert.ToBoolean(gteq));
            }

            return(match);
        }
Ejemplo n.º 3
0
        public static string Get_Definephrase(string tag)
        {
            try
            {
                string ffile = "/cmm/xhtml/Definephrase.xml";
                string fpath = HttpContext.Current.Server.MapPath(ffile);
                if (!System.IO.File.Exists(fpath)) return "";

                string vlreturn = "";
                System.Xml.XmlTextReader rdr = new System.Xml.XmlTextReader(fpath);
                while (rdr.Read())
                {
                    switch (rdr.NodeType)
                    {
                        case System.Xml.XmlNodeType.Element:
                            if (rdr.Name == LANG + tag)
                            {
                                vlreturn = rdr.ReadElementString();
                                goto lexit;
                            }
                            else if (rdr.Name != "phrase")
                                rdr.Skip();
                            break;
                        default:
                            break;
                    }
                }
            lexit:
                rdr.Close();
                return vlreturn;
            }
            catch
            {
                return "Cannot get phrase";
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This event occurs when the output to print for the current page is needed, and
        /// contains the logic to handle the content and layout of the printed page.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A PrintPageEventArgs that contains the event data.</param>
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            // Determine the height of the header, based on the selected font.
            float headerHeight = headerFont.GetHeight(e.Graphics);

            // Determine the number of lines of body text that can be printed per page, taking
            // into account the presence of the header and the size of the selected body font.
            float linesPerPage = (e.MarginBounds.Height - headerHeight) / bodyFont.GetHeight(e.Graphics);

            // Used to store the position at which the next body line
            // should be printed.
            float yPosition = 0;

            // Used to store the number of lines printed so far on the
            // current page.
            int count = 0;

            // User to store the text of the current line.
            string line = null;

            // Print the page header, as specified by the user in the form.
            // Use the header font for this line only.
            e.Graphics.DrawString(companyName.Text.Trim(), headerFont, Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top, new StringFormat());

            // Print each line of the data file, but don't exceed the maximum allowable
            // number of lines per page.  Also, stop when the end of the data file is
            // reached.  This event is called once per page, so if the data exceeds a single
            // page, the XmlTextReader will pick up where it left off on the previous page.
            while (count < linesPerPage && !xmlReader.EOF)
            {
                // Move the pointer to the next "context" line in the Xml data file.
                // If the line is not an XML element, then it can be skipped.
                // Because the initial Read() call made when the xmlReader was opened
                // positioned the file to the first element (<Customers>) the following
                // call actually moves to the first <Customer> tag the first time through.
                if (xmlReader.MoveToContent() == System.Xml.XmlNodeType.Element)
                {
                    // Based on the element, determine what to print and where to print it.
                    switch (xmlReader.Name)
                    {
                    case "Customers":
                    {
                        // This is not really required, since the initial Read() call
                        // when the xmlReader is loaded effectively bypasses the opening element
                        // as described in the comments above.  Included here for explanation only.

                        // If a <Customers> tag is encountered, just print a blank line.
                        line = "";

                        // Tell the XmlTextReader to move on to the next element.
                        xmlReader.Read();

                        break;
                    }

                    case "Customer":
                    {
                        // Hitting a new <Customer> tag indicates the beginning of a
                        // new customer record.  Take this opportunity to print a blank line,
                        // adding spacing between customer records in the report.
                        line = "";

                        // Tell the XmlTextReader to move on to the next element.
                        xmlReader.Read();

                        break;
                    }

                    default:
                    {
                        // All other elements in the sample XML file are actual data
                        // fields pertaining to a customer record.  Print the field name
                        // and value.  The ReadElementString retrieves the value and
                        // automatically forces the XmlTextReader to move on to the
                        // next element.  Because this is handled generically, any additional
                        // customer fields added inside the <Customer> tag in the xml file will
                        // automatically be shown in the printed report.
                        line = xmlReader.Name + ": " + xmlReader.ReadElementString();
                        break;
                    }
                    }

                    // Determine the position at which to print.  Since this report prints one line
                    // at a time, only the height (or Y coordinate) needs to be calculated, because
                    // every line will begin at the far left.  The Y coordinate must take into
                    // consideration the header, the height of each line of body text, and the
                    // number of body lines printed so far on this page.
                    yPosition = e.MarginBounds.Top + headerHeight + (count * bodyFont.GetHeight(e.Graphics));

                    // Draw the line of text on the page using the body font specified by the user.
                    e.Graphics.DrawString(line, bodyFont, Brushes.Black, e.MarginBounds.Left, yPosition, new StringFormat());

                    // Increment the counter to show that another line has been printed.
                    // This is used in the positioning of future lines of text on the current page.
                    count++;
                }
                else
                {
                    // If the XmlTextReader is positioned on a line that is NOT an
                    // Element, then just go on to the next line.
                    xmlReader.Read();
                }
            }

            // If more data exists, print another page.  If not stop this event from firing
            // again by setting the HasMorePages property to false.
            if (xmlReader.EOF)
            {
                e.HasMorePages = false;
            }
            else
            {
                e.HasMorePages = true;
            }
        }
Ejemplo n.º 5
0
 public FilterItem(System.Xml.XmlTextReader tr)
 {
     _action      = (FilterAction)System.Enum.Parse(typeof(FilterAction), tr.ReadElementString("Action"));
     _matchString = tr.ReadElementString("Match");
     _matcher     = GetMatcher(_matchString);
 }
Ejemplo n.º 6
0
      /// <summary>
      /// This is the worker thread.
      /// </summary>
      /// <param name="stateInfo">Not used.</param>
      void ProcessFiles(object stateInfo)
      {

        System.Text.StringBuilder stb = null;

        while (_filesToProcess.Count > 0)
        {
          string fullfilename = _filesToProcess.Dequeue();
          try
          {
            string category = null;
            string name = null;
            DateTime creationTime = DateTime.MinValue;
            string description = string.Empty;

            System.Xml.XmlTextReader xmlReader = new System.Xml.XmlTextReader(fullfilename);
            xmlReader.MoveToContent();
            while (xmlReader.Read())
            {
              if (xmlReader.NodeType == System.Xml.XmlNodeType.Element && xmlReader.LocalName == "Category")
              {
                category = xmlReader.ReadElementString();
                name = xmlReader.ReadElementString("Name");
                creationTime = System.Xml.XmlConvert.ToDateTime(xmlReader.ReadElementString("CreationTime"), System.Xml.XmlDateTimeSerializationMode.Local);
                if (xmlReader.LocalName == "Description")
                  description = xmlReader.ReadElementString("Description");
                break;
              }
            }
            xmlReader.Close();

            AddFitFunctionEntry(category, name, creationTime, description, fullfilename);

          }
          catch (Exception ex)
          {
            if (stb == null)
              stb = new StringBuilder();

            stb.AppendLine(ex.ToString());
          }
        }

        if (stb != null)
        {
          Current.Console.WriteLine("Exception(s) thrown in " + this.GetType().ToString() + " during parsing of fit functions, details will follow:");
          Current.Console.WriteLine(stb.ToString());
        }
        _threadIsWorking = false;
      }