Exemplo n.º 1
0
        public bool MoveNext()
        {
            bool bResult = true;

            if (OnixDoc == null)
            {
                this.OnixDoc = new XmlDocument();
                this.OnixDoc.Load(this.OnixReader);

                this.ProductList = this.OnixDoc.GetElementsByTagName(this.ProductXmlTag);
            }

            if (++CurrentIndex < this.ProductList.Count)
            {
                string sInputXml = this.ProductList[CurrentIndex].OuterXml;

                try
                {
                    CurrentRecord =
                        this.ProductSerializer.Deserialize(new StringReader(sInputXml)) as OnixLegacyProduct;

                    if ((CurrentRecord != null) && OnixParser.AlwaysReturnInputXml)
                    {
                        CurrentRecord.SetInputXml(sInputXml);
                    }

                    if ((CurrentRecord != null) &&
                        (CurrentRecord.OnixOtherTextList != null) &&
                        (CurrentRecord.OnixOtherTextList.Length > 0))
                    {
                        int nOTCount = CurrentRecord.OnixOtherTextList.Length;

                        for (int nIdx = 0; nIdx < OtherTextList.Count; ++nIdx)
                        {
                            if (nIdx < nOTCount)
                            {
                                OnixLegacyOtherText TempText = CurrentRecord.OnixOtherTextList[nIdx];
                                TempText.Text = OtherTextList[nIdx];
                            }
                        }
                    }

                    OtherTextList.Clear();
                }
                catch (Exception ex)
                {
                    CurrentRecord = new OnixLegacyProduct();

                    CurrentRecord.SetParsingError(ex);
                    CurrentRecord.SetInputXml(sInputXml);
                }
            }
            else
            {
                bResult = false;
            }

            return(bResult);
        }
Exemplo n.º 2
0
        public static bool HasValidEAN(this OnixLegacyProduct TargetProduct)
        {
            bool   IsValid = false;
            string EAN     = TargetProduct.EAN;

            if (!String.IsNullOrEmpty(EAN))
            {
                IsValid = EAN.IsValidEAN();
            }

            return(IsValid);
        }
Exemplo n.º 3
0
        public static bool HasValidISBN(this OnixLegacyProduct TargetProduct)
        {
            bool IsValid = false;

            string ISBN = TargetProduct.ISBN;

            if (!String.IsNullOrEmpty(ISBN))
            {
                IsValid = ISBN.IsISBNValid();
            }

            return(IsValid);
        }
Exemplo n.º 4
0
        public bool MoveNext()
        {
            bool   bResult      = false;
            string sProductBody = null;

            while (this.OnixReader.Read())
            {
                if ((this.OnixReader.NodeType == XmlNodeType.Element) && (this.OnixReader.Name == this.ProductXmlTag))
                {
                    // XElement product = XElement.ReadFrom(reader) as XElement;

                    sProductBody = this.OnixReader.ReadOuterXml();
                    break;
                }
            }

            if (!String.IsNullOrEmpty(sProductBody))
            {
                try
                {
                    CurrentRecord =
                        this.ProductSerializer.Deserialize(new StringReader(sProductBody)) as OnixLegacyProduct;

                    bResult = true;
                }
                catch (Exception ex)
                {
                    CurrentRecord = new OnixLegacyProduct();

                    CurrentRecord.SetParsingError(ex);
                    CurrentRecord.SetInputXml(sProductBody);
                }
            }

            return(bResult);
        }