Пример #1
0
        /// <summary>
        /// Build a string from data
        /// </summary>
        /// <param name="output">Allows for method to call itself</param>
        /// <param name="node">The data object</param>
        /// <param name="indent">Current indent</param>
        /// <returns></returns>
        private string BuildDataString(string output, ufDateNode node, int indent)
        {
            string sIndent = string.Empty;

            if (indent == 1)
            {
                output += "\n";
            }

            for (int i = 0; i < indent; i++)
            {
                sIndent += " ";
            }

            // Json data structure
            if (m_bHierarchalTree)
            {
                if (node.ValueArray.Count > 0)
                {
                    output += sIndent + node.Name + ": " + "\n";
                    for (int i = 0; i < node.ValueArray.Count; i++)
                    {
                        output += sIndent + "[" + i.ToString() + "]: " + node.ValueArray[i] + "\n";
                    }
                }
                else
                {
                    output += sIndent + node.Name + ": " + node.Value + "\n";
                }
            }
            // Standard data structure
            else
            {
                if (node.Name != string.Empty)
                {
                    output += sIndent + node.Name + ": " + node.Value + "\n";

                    if (node.RepresentativeNode)
                    {
                        output += sIndent + " " + "representative-hcard: true\n";
                    }

                    if (node.SourceUrl != string.Empty)
                    {
                        output += sIndent + " " + "source-url: " + node.SourceUrl + "\n";
                    }
                }
            }

            //if (m_bReporting && node.OuterHtml != string.Empty)
            //    output += sIndent + "OuterHtml: " + sIndent + HttpUtility.HtmlEncode(node.OuterHtml) + "\n";


            foreach (ufDateNode childNode in node.Nodes)
            {
                output += BuildDataString("", childNode, indent + 1);
            }

            return(output);
        }
Пример #2
0
 public void Convert(ufDateNode node, Stream stream, bool multiples, Urls urls, Errors errors, bool reporting)
 {
     m_bReporting = reporting;
     m_oErrors    = errors;
     m_oUrls      = urls;
     Convert(node, stream, multiples);
 }
Пример #3
0
 public void Convert(ufDateNode node, Stream stream, bool multiples, Urls urls, Errors errors, bool reporting)
 {
     m_bReporting = reporting;
     m_oErrors = errors;
     m_oUrls = urls;
     Convert(node, stream, multiples);
 }
Пример #4
0
 /// <summary>
 /// Provides string version of data object
 /// </summary>
 /// <param name="node">The data object</param>
 /// <param name="urls">The Urls object created by spider</param>
 /// <returns></returns>
 public string Convert(ufDateNode node, bool multiples, Urls urls, Errors errors, bool reporting)
 {
     m_bReporting = reporting;
     m_oErrors    = errors;
     m_oUrls      = urls;
     return(Convert(node, multiples));
 }
Пример #5
0
 public string Convert(ufDateNode node, 
     ufFormatDescriber ufFormat,
     bool multiplesFormats,
     Urls urls)
 {
     m_oUrls = urls;
     return Convert(node, ufFormat, multiplesFormats);
 }
Пример #6
0
 public string Convert(ufDateNode node,
                       ufFormatDescriber ufFormat,
                       bool multiplesFormats,
                       Urls urls)
 {
     m_oUrls = urls;
     return(Convert(node, ufFormat, multiplesFormats));
 }
Пример #7
0
 public string Convert(ufDateNode node, 
     ufFormatDescriber ufFormat,
     bool multiplesFormats,
     string callBack)
 {
     m_sCallBack = callBack;
     m_sCallBack = m_sCallBack.Replace("(", "").Replace(")", "").Trim();
     return Convert(node, ufFormat, multiplesFormats);
 }
Пример #8
0
 public string Convert(ufDateNode node,
                       ufFormatDescriber ufFormat,
                       bool multiplesFormats,
                       string callBack)
 {
     m_sCallBack = callBack;
     m_sCallBack = m_sCallBack.Replace("(", "").Replace(")", "").Trim();
     return(Convert(node, ufFormat, multiplesFormats));
 }
Пример #9
0
 public string Convert(ufDateNode node, 
     ufFormatDescriber ufFormat,
     bool multiplesFormats,
     string callBack,
     Urls urls,
     Errors errors)
 {
     m_oErrors = errors;
     m_sCallBack = callBack;
     m_sCallBack = m_sCallBack.Replace("(", "").Replace(")", "").Trim();
     m_oUrls = urls;
     return Convert(node, ufFormat, multiplesFormats);
 }
Пример #10
0
 public string Convert(ufDateNode node,
                       ufFormatDescriber ufFormat,
                       bool multiplesFormats,
                       string callBack,
                       Urls urls,
                       Errors errors)
 {
     m_oErrors   = errors;
     m_sCallBack = callBack;
     m_sCallBack = m_sCallBack.Replace("(", "").Replace(")", "").Trim();
     m_oUrls     = urls;
     return(Convert(node, ufFormat, multiplesFormats));
 }
Пример #11
0
        /// <summary>
        /// Provides string version of data object
        /// </summary>
        /// /// <param name="node">The data object</param>
        public string Convert(ufDateNode node, bool multiples)
        {
            m_bMultiples = multiples;

            string output = "ufxtract\n";

            output = BuildDataString(output, node, 0);


            //Find errors
            // -------------------------------------------------
            if (m_oErrors != null)
            {
                if (m_oErrors.Count != 0)
                {
                    output += "\n\nerrors" + "\n";
                    if (m_oErrors != null)
                    {
                        foreach (Error error in m_oErrors)
                        {
                            output += "msg: " + error.Message + "\n";
                            output += "url: " + error.Address + "\n";
                            if (error.Status != 0)
                            {
                                output += "status: " + error.Status.ToString() + "\n";
                            }
                        }
                    }
                }
            }

            // Write report if a Urls object is provided
            // -------------------------------------------------
            if (m_bReporting && m_oUrls != null)
            {
                output += "\n\nreport" + "\n";
                foreach (Url url in m_oUrls)
                {
                    output += "url: " + url.Address + "\n";
                    output += "status: " + url.Status.ToString() + "\n";
                    output += "millisec: " + url.LoadTime.Milliseconds.ToString() + "\n\n";
                }
                output += "found: " + node.Nodes.Count.ToString();
            }


            return(output);
        }
Пример #12
0
        public string Convert(ufDateNode node, ufFormatDescriber ufFormat, bool multiplesFormats)
        {
            m_bMultiplesFormats = multiplesFormats;
            foreach (ufDateNode childNode in node.Nodes)
            {
                if (childNode.Name == ufFormat.BaseElement.Name)
                {
                    ufDateNode xChild = xTree.Nodes.Append(childNode.Name, childNode.Value, childNode.SourceUrl, childNode.RepresentativeNode);
                    if (childNode.Nodes.Count > 0)
                    {
                        AddChildNodes(xChild, childNode, ufFormat.BaseElement);
                    }
                }
            }

            string output = "// ufXtract \n";

            if (m_sCallBack != string.Empty)
            {
                output += m_sCallBack + "( ";
            }

            output += "{";

            foreach (ufDateNode childNode in xTree.Nodes)
            {
                output += BuildDataString(childNode, true, false);
            }

            if (xTree.Nodes.Count > 0)
            {
                output = output.Substring(0, output.Length - 2);
            }

            output += AddErrors();
            output += AddReporting(node);

            // End whole block
            output += "}";

            if (m_sCallBack != string.Empty)
            {
                output += " )";
            }

            return(output);
        }
Пример #13
0
        /// <summary>
        /// Provides string version of data object
        /// </summary>
        /// /// <param name="node">The data object</param>
        public string Convert( ufDateNode node, bool multiples )
        {
            m_bMultiples = multiples;

            string output = "ufxtract\n";
            output = BuildDataString(output, node, 0);

            //Find errors
            // -------------------------------------------------
            if (m_oErrors != null)
            {
                if (m_oErrors.Count != 0)
                {
                    output += "\n\nerrors" + "\n";
                    if (m_oErrors != null)
                    {
                        foreach (Error error in m_oErrors)
                        {
                            output += "msg: " + error.Message + "\n";
                            output += "url: " + error.Address + "\n";
                            if (error.Status != 0)
                                output += "status: " + error.Status.ToString() + "\n";
                        }
                    }
                }
            }

            // Write report if a Urls object is provided
            // -------------------------------------------------
            if (m_bReporting && m_oUrls != null)
            {
                output += "\n\nreport" + "\n";
                foreach (Url url in m_oUrls)
                {
                    output += "url: " + url.Address + "\n";
                    output += "status: " + url.Status.ToString() + "\n";
                    output += "millisec: " + url.LoadTime.Milliseconds.ToString() + "\n\n";

                }
                output += "found: " + node.Nodes.Count.ToString();
            }

            return output;
        }
Пример #14
0
        private string AddReporting(ufDateNode node)
        {
            string output = string.Empty;

            if (m_bReporting && m_oUrls != null)
            {
                if (xTree.Nodes.Count > 0 || m_oErrors.Count > 0)
                {
                    output += ", \"report\" : [";
                }
                else
                {
                    output += "\"report\" : [";
                }

                for (int i = 0; i < m_oUrls.Count; i++)
                {
                    output += "{\"url\" : \"" + EncodeJsonText(m_oUrls[i].Address) + "\", ";
                    output += "\"status\" : \"" + m_oUrls[i].Status.ToString() + "\", ";
                    output += "\"millisec\" : \"" + EncodeJsonText(m_oUrls[i].LoadTime.Milliseconds.ToString()) + "\"";

                    if (i != m_oUrls.Count - 1)
                    {
                        output += "}, ";
                    }
                    else
                    {
                        output += "} ";
                    }
                }
                output += "]";

                //output += ", \"found\" : \"" + node.Nodes.Count.ToString() + "\"";
            }

            return(output);
        }
Пример #15
0
 private void AddNode(ufDateNode node, XmlTextWriter writer)
 {
     if (node.Name != string.Empty)
     {
         writer.WriteStartElement(node.Name);
         if (node.SourceUrl != string.Empty)
         {
             writer.WriteAttributeString("sourceurl", node.SourceUrl);
         }
         if (node.RepresentativeNode)
         {
             writer.WriteAttributeString("representativehcard", "true");
         }
         writer.WriteString(node.Value);
     }
     foreach (ufDateNode child in node.Nodes)
     {
         AddNode(child, writer);
     }
     if (node.Name != string.Empty)
     {
         writer.WriteEndElement();
     }
 }
Пример #16
0
        private void AddChildNodes(ufDateNode xNode, ufDateNode node, uFElementDescriber ufElement)
        {
            if (ufElement.AttributeValues.Count > 0)
            {
                // If its a rel or rev uf based on attribute values, just copy it
                //ufDateNode xNodeChild = xNode.Nodes.Append(node.Name, node.Value);
                foreach (ufDateNode childNode in node.Nodes)
                {
                    xNode.Nodes.Add(childNode.Name, childNode.Value, childNode.SourceUrl, childNode.RepresentativeNode);
                }
            }

            foreach (uFElementDescriber childElement in ufElement.Elements)
            {
                // Loop orginal data tree
                foreach (ufDateNode childNode in node.Nodes)
                {
                    // If node name = element describer name
                    if (childNode.Name == childElement.Name)
                    {
                        // If element can have multiples call the AppendArrayList method
                        if (childElement.Multiples)
                        {
                            ufDateNode xChild = xNode.Nodes.Append(childNode.Name, childNode.Value, childNode.SourceUrl, childNode.RepresentativeNode);
                            AddChildNodes(xChild, childNode, childElement);
                        }
                        else
                        {
                            int        index  = xNode.Nodes.Add(childNode.Name, childNode.Value, childNode.SourceUrl, childNode.RepresentativeNode);
                            ufDateNode xChild = xNode.Nodes[index];
                            AddChildNodes(xChild, childNode, childElement);
                        }
                    }
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Build a string from data
        /// </summary>
        /// <param name="output">Allows for method to call itself</param>
        /// <param name="node">The data object</param>
        /// <param name="indent">Current indent</param>
        /// <returns></returns>
        private string BuildDataString(string output, ufDateNode node, int indent)
        {
            string sIndent = string.Empty;

            if( indent == 1 )
                output += "\n";

            for (int i = 0; i < indent; i++)
                sIndent += " ";

            // Json data structure
            if (m_bHierarchalTree)
            {
                if (node.ValueArray.Count > 0)
                {
                    output += sIndent + node.Name + ": " + "\n";
                    for (int i = 0; i < node.ValueArray.Count; i++)
                    {
                        output += sIndent + "[" + i.ToString() + "]: " + node.ValueArray[i] + "\n";
                    }
                }
                else
                {
                    output += sIndent + node.Name + ": " + node.Value + "\n";
                }
            }
            // Standard data structure
            else
            {
                if (node.Name != string.Empty)
                {

                    output += sIndent + node.Name + ": " + node.Value + "\n";

                    if( node.RepresentativeNode )
                        output += sIndent + " " + "representative-hcard: true\n";

                    if (node.SourceUrl != string.Empty)
                        output += sIndent + " " + "source-url: " + node.SourceUrl + "\n";

                }

            }

            //if (m_bReporting && node.OuterHtml != string.Empty)
            //    output += sIndent + "OuterHtml: " + sIndent + HttpUtility.HtmlEncode(node.OuterHtml) + "\n";

            foreach (ufDateNode childNode in node.Nodes)
                output += BuildDataString("", childNode, indent + 1);

            return output;
        }
Пример #18
0
 /// <summary>
 /// Provides string version of data object
 /// </summary>
 /// <param name="node">The data object</param>
 /// <param name="urls">The Urls object created by spider</param>
 /// <returns></returns>
 public string Convert(ufDateNode node, bool multiples, Urls urls, Errors errors, bool reporting)
 {
     m_bReporting = reporting;
     m_oErrors = errors;
     m_oUrls = urls;
     return Convert(node, multiples);
 }
Пример #19
0
        /// <summary>
        /// Provides string version of data object
        /// </summary>
        public void Convert(ufDateNode node, Stream stream, bool multiples)
        {
            string output = string.Empty;
            m_bMultiples = multiples;
            //StringWriter stringwriter = new StringWriter();

            XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);
            writer.Formatting = System.Xml.Formatting.Indented;

            writer.WriteStartDocument(true);
            writer.WriteStartElement("ufxtract");

            foreach (ufDateNode child in node.Nodes)
            {
                AddNode(child, writer);
            }

            //Find errors
            // -------------------------------------------------
            if (m_oErrors != null)
            {
                if (m_oErrors.Count != 0)
                {
                    writer.WriteStartElement("errors");
                    if (m_oErrors != null)
                    {
                        foreach (Error error in m_oErrors)
                        {
                            writer.WriteStartElement("error");
                            writer.WriteElementString("msg", error.Message);
                            writer.WriteStartElement("url");
                            if (error.Status != 0)
                                writer.WriteAttributeString("status", error.Status.ToString());
                            writer.WriteString(error.Address);
                            writer.WriteEndElement();
                            writer.WriteEndElement();
                        }
                    }
                    writer.WriteEndElement();
                }
            }

            // Write report if a Urls object is provided
            // -------------------------------------------------
            if (m_bReporting && m_oUrls != null)
            {
                writer.WriteStartElement("report");
                foreach (Url url in m_oUrls)
                {
                    writer.WriteStartElement("url");
                    writer.WriteAttributeString("status", url.Status.ToString());
                    writer.WriteAttributeString("millisec", url.LoadTime.Milliseconds.ToString());
                    writer.WriteString(url.Address);
                    writer.WriteEndElement();
                }
                writer.WriteElementString("found", node.Nodes.Count.ToString());
                writer.WriteEndElement();
            }

            writer.WriteEndElement();

            writer.WriteEndDocument();
            writer.Flush();
        }
Пример #20
0
        /// <summary>
        /// Build a string from data
        /// </summary>
        private string BuildDataString(ufDateNode node, bool isArrayItem, bool isLastNode)
        {
            string output = string.Empty;

            // Trim just in case
            node.Name      = node.Name.Trim();
            node.Value     = node.Value.Trim();
            node.SourceUrl = node.SourceUrl.Trim();

            ////// Add source here
            //if (node.SourceUrl != string.Empty)
            //    output += "\"sourceurl\": \"" + EncodeJsonText(node.SourceUrl) + "\"";



            if (node.Value == "Array")
            {
                output += "\"" + node.Name + "\": [";
                for (int i = 0; i < node.Nodes.Count; i++)
                {
                    if (i == node.Nodes.Count - 1)
                    {
                        output += BuildDataString(node.Nodes[i], true, true);
                    }
                    else
                    {
                        output += BuildDataString(node.Nodes[i], true, false);
                    }
                }

                if (isLastNode)
                {
                    output += "]";
                }
                else
                {
                    output += "], ";
                }
            }


            if (node.Value != "Array" && node.Nodes.Count > 0)
            {
                if (!IsNumeric(node.Name))
                {
                    output += "\"" + node.Name + "\": {";
                }
                else
                {
                    output += "{";
                }

                if (node.RepresentativeNode)
                {
                    output += "\"representativehcard\": \"true\", ";
                }

                // Add source here
                if (node.SourceUrl != string.Empty)
                {
                    output += "\"sourceurl\": \"" + EncodeJsonText(node.SourceUrl) + "\", ";
                }



                for (int i = 0; i < node.Nodes.Count; i++)
                {
                    if (i == node.Nodes.Count - 1)
                    {
                        output += BuildDataString(node.Nodes[i], false, true);
                    }
                    else
                    {
                        output += BuildDataString(node.Nodes[i], false, false);
                    }
                }

                if (isLastNode)
                {
                    output += "}";
                }
                else
                {
                    output += "}, ";
                }
            }


            if (node.Value != "Array" && node.Nodes.Count == 0)
            {
                // Add source here
                if (node.SourceUrl != string.Empty)
                {
                    output += "\"sourceurl\": \"" + EncodeJsonText(node.SourceUrl) + "\", ";
                }



                if (node.Value != string.Empty)
                {
                    if (isArrayItem)
                    {
                        output += "\"" + EncodeJsonText(node.Value) + "\"";
                    }
                    else
                    {
                        output += "\"" + node.Name + "\": \"" + EncodeJsonText(node.Value) + "\"";
                    }

                    if (isLastNode)
                    {
                        output += " ";
                    }
                    else
                    {
                        output += ", ";
                    }
                }

                for (int i = 0; i < node.Nodes.Count; i++)
                {
                    if (i == node.Nodes.Count - 1)
                    {
                        output += BuildDataString(node.Nodes[i], false, true);
                    }
                    else
                    {
                        output += BuildDataString(node.Nodes[i], false, false);
                    }
                }
            }

            return(output);
        }
Пример #21
0
        private string AddReporting( ufDateNode node )
        {
            string output = string.Empty;
            if (m_bReporting && m_oUrls != null)
            {

                if (xTree.Nodes.Count > 0 || m_oErrors.Count > 0)
                    output += ", \"report\" : [";
                else
                    output += "\"report\" : [";

                for (int i = 0; i < m_oUrls.Count; i++)
                {
                    output += "{\"url\" : \"" + EncodeJsonText(m_oUrls[i].Address) + "\", ";
                    output += "\"status\" : \"" + m_oUrls[i].Status.ToString() + "\", ";
                    output += "\"millisec\" : \"" + EncodeJsonText(m_oUrls[i].LoadTime.Milliseconds.ToString()) + "\"";

                    if (i != m_oUrls.Count - 1)
                        output += "}, ";
                    else
                        output += "} ";
                }
                output += "]";

                //output += ", \"found\" : \"" + node.Nodes.Count.ToString() + "\"";
            }

            return output;
        }
Пример #22
0
        public string Convert(ufDateNode node, ufFormatDescriber ufFormat, bool multiplesFormats)
        {
            m_bMultiplesFormats = multiplesFormats;
            foreach (ufDateNode childNode in node.Nodes)
            {
                if (childNode.Name == ufFormat.BaseElement.Name)
                {
                    ufDateNode xChild = xTree.Nodes.Append(childNode.Name, childNode.Value, childNode.SourceUrl, childNode.RepresentativeNode);
                    if (childNode.Nodes.Count > 0)
                        AddChildNodes(xChild, childNode, ufFormat.BaseElement);

                }
            }

            string output = "// ufXtract \n";
            if( m_sCallBack != string.Empty)
                output += m_sCallBack + "( ";

            output += "{";

            foreach (ufDateNode childNode in xTree.Nodes)
                output += BuildDataString(childNode, true, false);

            if (xTree.Nodes.Count > 0)
                output = output.Substring(0, output.Length - 2);

            output += AddErrors();
            output += AddReporting( node );

            // End whole block
            output += "}";

            if (m_sCallBack != string.Empty)
                output += " )";

            return  output;
        }
Пример #23
0
        /// <summary>
        /// Build a string from data
        /// </summary>
        private string BuildDataString(ufDateNode node, bool isArrayItem, bool isLastNode)
        {
            string output = string.Empty;

            // Trim just in case
            node.Name = node.Name.Trim();
            node.Value = node.Value.Trim();
            node.SourceUrl = node.SourceUrl.Trim();

            ////// Add source here
            //if (node.SourceUrl != string.Empty)
            //    output += "\"sourceurl\": \"" + EncodeJsonText(node.SourceUrl) + "\"";

            if (node.Value == "Array")
            {
                output += "\"" + node.Name + "\": [";
                for (int i = 0; i < node.Nodes.Count; i++)
                {
                    if (i == node.Nodes.Count-1)
                        output += BuildDataString(node.Nodes[i], true, true);
                    else
                        output += BuildDataString(node.Nodes[i], true, false);
                }

                if (isLastNode)
                    output += "]";
                else
                    output += "], ";
            }

            if (node.Value != "Array" && node.Nodes.Count > 0)
            {

                if (!IsNumeric(node.Name))
                    output += "\"" + node.Name + "\": {";
                else
                    output += "{";

                if (node.RepresentativeNode)
                    output += "\"representativehcard\": \"true\", ";

                // Add source here
                if (node.SourceUrl != string.Empty)
                    output += "\"sourceurl\": \"" + EncodeJsonText(node.SourceUrl) + "\", ";

                for (int i = 0; i < node.Nodes.Count; i++)
                    if (i == node.Nodes.Count-1)
                        output += BuildDataString(node.Nodes[i], false, true);
                    else
                        output += BuildDataString(node.Nodes[i], false, false);

                if (isLastNode)
                    output += "}";
                else
                    output += "}, ";

            }

            if (node.Value != "Array" && node.Nodes.Count == 0)
            {

                // Add source here
                if (node.SourceUrl != string.Empty)
                    output += "\"sourceurl\": \"" + EncodeJsonText(node.SourceUrl) + "\", ";

                if (node.Value != string.Empty)
                {
                    if (isArrayItem)
                        output += "\"" + EncodeJsonText(node.Value) + "\"";
                    else
                        output += "\"" + node.Name + "\": \"" + EncodeJsonText(node.Value) + "\"";

                    if (isLastNode)
                        output += " ";
                    else
                        output += ", ";
                }

                for (int i = 0; i < node.Nodes.Count; i++)
                    if (i == node.Nodes.Count-1)
                        output += BuildDataString(node.Nodes[i], false, true);
                    else
                        output += BuildDataString(node.Nodes[i], false, false);
            }

            return output;
        }
Пример #24
0
 public void Convert(ufDateNode node, Stream stream, bool multiples, Urls urls)
 {
     m_oUrls = urls;
     Convert(node, stream, multiples);
 }
Пример #25
0
 private void AddNode(ufDateNode node, XmlTextWriter writer)
 {
     if (node.Name != string.Empty)
     {
         writer.WriteStartElement(node.Name);
         if (node.SourceUrl != string.Empty)
             writer.WriteAttributeString("sourceurl", node.SourceUrl);
         if (node.RepresentativeNode)
             writer.WriteAttributeString("representativehcard", "true");
         writer.WriteString(node.Value);
     }
     foreach (ufDateNode child in node.Nodes)
     {
         AddNode(child, writer);
     }
     if (node.Name != string.Empty)
         writer.WriteEndElement();
 }
Пример #26
0
        private void AddChildNodes(ufDateNode xNode, ufDateNode node, uFElementDescriber ufElement)
        {
            if (ufElement.AttributeValues.Count > 0)
            {
                // If its a rel or rev uf based on attribute values, just copy it
                //ufDateNode xNodeChild = xNode.Nodes.Append(node.Name, node.Value);
                foreach (ufDateNode childNode in node.Nodes)
                    xNode.Nodes.Add(childNode.Name, childNode.Value, childNode.SourceUrl, childNode.RepresentativeNode);

            }

            foreach (uFElementDescriber childElement in ufElement.Elements)
            {
                // Loop orginal data tree
                foreach (ufDateNode childNode in node.Nodes)
                {
                    // If node name = element describer name
                    if (childNode.Name == childElement.Name)
                    {
                        // If element can have multiples call the AppendArrayList method
                        if (childElement.Multiples)
                        {
                            ufDateNode xChild = xNode.Nodes.Append(childNode.Name, childNode.Value, childNode.SourceUrl, childNode.RepresentativeNode);
                            AddChildNodes(xChild, childNode, childElement);
                        }
                        else
                        {
                            int index = xNode.Nodes.Add(childNode.Name, childNode.Value, childNode.SourceUrl, childNode.RepresentativeNode);
                            ufDateNode xChild = xNode.Nodes[index];
                            AddChildNodes(xChild, childNode, childElement);
                        }
                    }
                }
            }
        }
Пример #27
0
 /// <summary>
 /// Provides string version of data object
 /// </summary>
 /// <param name="node">The data object</param>
 /// <param name="urls">The Urls object created by spider</param>
 /// <returns></returns>
 public string Convert(ufDateNode node, bool multiples, Urls urls)
 {
     m_oUrls = urls;
     return(Convert(node, multiples));
 }
Пример #28
0
 /// <summary>
 /// Provides string version of data object
 /// </summary>
 /// <param name="node">The data object</param>
 /// <param name="urls">The Urls object created by spider</param>
 /// <returns></returns>
 public string Convert(ufDateNode node, bool multiples, Urls urls)
 {
     m_oUrls = urls;
     return Convert(node, multiples);
 }
Пример #29
0
        /// <summary>
        /// Provides string version of data object
        /// </summary>
        public void Convert(ufDateNode node, Stream stream, bool multiples)
        {
            string output = string.Empty;

            m_bMultiples = multiples;
            //StringWriter stringwriter = new StringWriter();

            XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8);

            writer.Formatting = System.Xml.Formatting.Indented;

            writer.WriteStartDocument(true);
            writer.WriteStartElement("ufxtract");

            foreach (ufDateNode child in node.Nodes)
            {
                AddNode(child, writer);
            }


            //Find errors
            // -------------------------------------------------
            if (m_oErrors != null)
            {
                if (m_oErrors.Count != 0)
                {
                    writer.WriteStartElement("errors");
                    if (m_oErrors != null)
                    {
                        foreach (Error error in m_oErrors)
                        {
                            writer.WriteStartElement("error");
                            writer.WriteElementString("msg", error.Message);
                            writer.WriteStartElement("url");
                            if (error.Status != 0)
                            {
                                writer.WriteAttributeString("status", error.Status.ToString());
                            }
                            writer.WriteString(error.Address);
                            writer.WriteEndElement();
                            writer.WriteEndElement();
                        }
                    }
                    writer.WriteEndElement();
                }
            }



            // Write report if a Urls object is provided
            // -------------------------------------------------
            if (m_bReporting && m_oUrls != null)
            {
                writer.WriteStartElement("report");
                foreach (Url url in m_oUrls)
                {
                    writer.WriteStartElement("url");
                    writer.WriteAttributeString("status", url.Status.ToString());
                    writer.WriteAttributeString("millisec", url.LoadTime.Milliseconds.ToString());
                    writer.WriteString(url.Address);
                    writer.WriteEndElement();
                }
                writer.WriteElementString("found", node.Nodes.Count.ToString());
                writer.WriteEndElement();
            }


            writer.WriteEndElement();

            writer.WriteEndDocument();
            writer.Flush();
        }
Пример #30
0
 public void Convert(ufDateNode node, Stream stream, bool multiples, Urls urls)
 {
     m_oUrls = urls;
     Convert(node, stream, multiples);
 }
Пример #31
0
        /// <summary>
        /// Takes multiple formatting objects - hAtom
        /// </summary>
        /// <param name="node"></param>
        /// <param name="formatArray"></param>
        /// <param name="multiplesFormats"></param>
        /// <param name="callBack"></param>
        /// <param name="urls"></param>
        /// <param name="errors"></param>
        /// <param name="reporting"></param>
        /// <returns></returns>
        public string Convert(ufDateNode node,
                              ArrayList formatArray,
                              bool multiplesFormats,
                              string callBack,
                              Urls urls,
                              Errors errors,
                              bool reporting)
        {
            m_sCallBack  = callBack;
            m_sCallBack  = m_sCallBack.Replace("(", "").Replace(")", "").Trim();
            m_oUrls      = urls;
            m_oErrors    = errors;
            m_bReporting = reporting;

            foreach (ufFormatDescriber ufFormat in formatArray)
            {
                foreach (ufDateNode childNode in node.Nodes)
                {
                    foreach (ufDateNode grandChildNode in childNode.Nodes)
                    {
                        if (grandChildNode.Name == ufFormat.BaseElement.Name)
                        {
                            ufDateNode xChild = xTree.Nodes.Append(grandChildNode.Name, grandChildNode.Value, grandChildNode.SourceUrl, grandChildNode.RepresentativeNode);
                            if (grandChildNode.Nodes.Count > 0)
                            {
                                AddChildNodes(xChild, grandChildNode, ufFormat.BaseElement);
                            }
                        }
                    }
                }
            }

            string output = "// ufXtract \n";

            if (m_sCallBack != string.Empty)
            {
                output += m_sCallBack + "( ";
            }

            output += "{";

            foreach (ufDateNode childNode in xTree.Nodes)
            {
                output += BuildDataString(childNode, true, false);
            }

            if (xTree.Nodes.Count > 0)
            {
                output = output.Substring(0, output.Length - 2);
            }

            output += AddErrors();
            output += AddReporting(node);

            // End whole block
            output += "}";

            if (m_sCallBack != string.Empty)
            {
                output += " )";
            }

            //return output.Replace(",", ",\n").Replace("}", "}\n").Replace("{", "{\n").Replace("]", "]\n").Replace("[", "[\n"); ;
            return(output);
        }
Пример #32
0
        /// <summary>
        /// Takes multiple formatting objects - hAtom
        /// </summary>
        /// <param name="node"></param>
        /// <param name="formatArray"></param>
        /// <param name="multiplesFormats"></param>
        /// <param name="callBack"></param>
        /// <param name="urls"></param>
        /// <param name="errors"></param>
        /// <param name="reporting"></param>
        /// <returns></returns>
        public string Convert(ufDateNode node,
            ArrayList formatArray,
            bool multiplesFormats,
            string callBack,
            Urls urls,
            Errors errors,
            bool reporting)
        {
            m_sCallBack = callBack;
            m_sCallBack = m_sCallBack.Replace("(", "").Replace(")", "").Trim();
            m_oUrls = urls;
            m_oErrors = errors;
            m_bReporting = reporting;

            foreach (ufFormatDescriber ufFormat in formatArray)
            {
                foreach (ufDateNode childNode in node.Nodes)
                {
                    foreach (ufDateNode grandChildNode in childNode.Nodes)
                    {
                        if (grandChildNode.Name == ufFormat.BaseElement.Name)
                        {
                            ufDateNode xChild = xTree.Nodes.Append(grandChildNode.Name, grandChildNode.Value, grandChildNode.SourceUrl, grandChildNode.RepresentativeNode);
                            if (grandChildNode.Nodes.Count > 0)
                                AddChildNodes(xChild, grandChildNode, ufFormat.BaseElement);

                        }
                    }
                }
            }

            string output = "// ufXtract \n";
            if (m_sCallBack != string.Empty)
                output += m_sCallBack + "( ";

            output += "{";

            foreach (ufDateNode childNode in xTree.Nodes)
                output += BuildDataString(childNode, true, false);

            if (xTree.Nodes.Count > 0)
                output = output.Substring(0, output.Length - 2);

            output += AddErrors();
            output += AddReporting(node);

            // End whole block
            output += "}";

            if (m_sCallBack != string.Empty)
                output += " )";

            //return output.Replace(",", ",\n").Replace("}", "}\n").Replace("{", "{\n").Replace("]", "]\n").Replace("[", "[\n"); ;
            return output;
        }