public Location(CommandLineLogger logger, string dataSectionName, ParseDataItem dataItems)
                {
                    if (dataItems != null && dataItems.HasChildren)
                    {
                        foreach (ParseDataItem dataItem in dataItems.Children)
                        {
                            switch (dataItem.Header.Trim().ToUpper())
                            {
                            case "NAME":
                                Name = dataItem.Value;
                                break;

                            case "ADDRESS":
                                Address = dataItem.Value;
                                break;

                            case "EXTERNAL ID":
                                ExternalId = dataItem.Value;
                                break;

                            default:
                                logger.LogWarning("Unknown Section - \"Photos - Location:" + dataItem.Header + "\".  Please contact NDCAC with section name and test data to improve parsing functionality");
#if DEBUG
                                throw new ApplicationException(dataItem.Header);
#endif
                                break;
                            }
                        }
                    }
                }
        protected override void ProcessHTML()
        {
            if (HtmlDoc != null && HtmlDoc.HasData)
            {
                ParseDataItem header = HtmlDoc.Items.FirstOrDefault();
                if (header != null && header.HasChildren && header.Children.Count() == 1)
                {
                    LinkedMediaFile = header.Children.First().Value;
                }
            }

            if (!HasData)
            {
                throw new SectionEmptyException(DisplaySectionName);
            }
        }
Esempio n. 3
0
        protected override void ProcessHTML()
        {
            if (HtmlDoc != null && HtmlDoc.HasData)
            {
                //IEnumerable<ParseDataItem> htmlItems = HtmlDoc.Items.Where(x => !x.Header.ToUpper().Contains("DEFINITION"));
                //IEnumerable<ParseDataItem> toSearch = htmlItems.Count() > 1 ? htmlItems : htmlItems.ElementAt(0).Children;
                ParseDataItem header = HtmlDoc.Items.FirstOrDefault();
                if (header != null && header.HasChildren && header.Children.Count() == 1)
                {
                    Blocked = header.Children.First().Value;
                }
            }

            if (!HasData)
            {
                throw new SectionEmptyException(DisplaySectionName);
            }
        }
Esempio n. 4
0
                    internal Share(CommandLineLogger logger, string dataSectionName, ParseDataItem shareItem)
                    {
                        if (shareItem != null && shareItem.HasChildren)
                        {
                            foreach (ParseDataItem dataItem in shareItem.Children)
                            {
                                switch (dataItem.Header.ToUpper().Trim())
                                {
                                case "DATE CREATED":
                                    DateCreated = dataItem.Value;
                                    break;

                                case "LINK":
                                    Link = dataItem.Value;
                                    break;

                                case "SUMMARY":
                                    Summary = dataItem.Value;
                                    break;

                                case "TEXT":
                                    Text = dataItem.Value;
                                    break;

                                case "TITLE":
                                    Title = dataItem.Value;
                                    break;

                                case "URL":
                                    URL = dataItem.Value;
                                    break;

                                default:
                                    logger.LogWarning("Unexpected Html Element - \"" + dataSectionName + " - Message - Share: " + dataItem.Header + "\".  Please contact NDCAC with section name and test data to improve parsing functionality");
#if DEBUG
                                    throw new ApplicationException(dataItem.Header);
#endif
                                    // break;
                                }
                            }
                        }
                    }
Esempio n. 5
0
                internal Message(CommandLineLogger logger, string dataSectionName, int msgNum, IEnumerable <ParseDataItem> marketplaceIdItems, IEnumerable <InstagramObject> participants, IEnumerable <ParseDataItem> messageItems)
                {
                    List <InstagramObject> recipientList = new List <InstagramObject>();

                    GUID     = Guid.NewGuid().ToString();
                    Sequence = msgNum;

                    if (marketplaceIdItems != null && marketplaceIdItems.Any())
                    {
                        foreach (ParseDataItem marketplaceIdItem in marketplaceIdItems)
                        {
                            switch (marketplaceIdItem.Header.ToUpper().Trim())
                            {
                            case "MARKETPLACE ID":
                                MarketplaceId = marketplaceIdItem.Value;
                                break;

                            default:
                                logger.LogWarning("Unexpected Html Element - \"" + dataSectionName + " - Message (Marketplace): " + marketplaceIdItem.Header + "\".  Please contact NDCAC with section name and test data to improve parsing functionality");
                                //_log.LogWarning("Unknown Section - \"Message:" + headerNode.InnerText + "\".  Please contact NDCAC with section name and test data to improve parsing functionality");
#if DEBUG
                                throw new ApplicationException(marketplaceIdItem.Header);
#endif
                                // break;
                            }
                        }
                    }

                    foreach (ParseDataItem messageItem in messageItems)
                    {
                        switch (messageItem.Header.ToUpper().Trim())
                        {
                        case "RECIPIENTS":
                            if (messageItem.HasValues)
                            {
                                foreach (string recipient in messageItem.Values)
                                {
                                    InstagramObject fo = new InstagramObject(recipient);
                                    if (fo.HasData)
                                    {
                                        recipientList.Add(fo);
                                    }
                                }
                            }
                            break;

                        case "AUTHOR":
                            Author = new InstagramObject(messageItem.Value);
                            break;

                        case "SENT":
                            Sent = messageItem.Value;
                            break;

                        case "DELETED":
                            IsDeleted = messageItem.Value;
                            break;

                        case "BODY":
                            Body = messageItem.Value;
                            break;

                        case "IP":
                            IPAddress = messageItem.Value;
                            break;

                        case "CALL RECORD":
                            CallRecord cr = new CallRecord(logger, dataSectionName, messageItem.Children);
                            if (cr.HasData)
                            {
                                CallRecords = new List <CallRecord>()
                                {
                                    cr
                                }
                            }
                            ;
                            break;

                        case "ATTACHMENTS":
                            List <Attachment> items = new List <Attachment>();
                            int startIndex          = 0;
                            foreach (ParseDataItem.ValueCount vc in messageItem.ValueCounts)
                            {
                                string value = vc.Val;
                                List <ParseDataItem> components = null;
                                for (int i = startIndex; i < startIndex + vc.AssociatedChildCount; i++)
                                {
                                    if (components == null)
                                    {
                                        components = new List <ParseDataItem>();
                                    }
                                    ParseDataItem childItem = messageItem.Children.ElementAt(i);
                                    if (childItem.HasData)
                                    {
                                        components.Add(childItem);
                                    }
                                }
                                Attachment att = new Attachment(logger, dataSectionName, value, components);
                                if (att.HasData)
                                {
                                    items.Add(att);
                                }
                                startIndex += vc.AssociatedChildCount;
                            }
                            Attachments = items;
                            break;

                        case "SHARE":
                            Share share = new Share(logger, dataSectionName, messageItem);
                            if (share.HasData)
                            {
                                Shares = new List <Share>()
                                {
                                    share
                                }
                            }
                            ;
                            break;

                        case "MARKETPLACE ID":
                            MarketplaceId = messageItem.Value;
                            break;

                        case "SUBSCRIPTION EVENT":
                            if (messageItem.HasChildren)
                            {
                                SubscriptionEvent subscriptionEvent = new SubscriptionEvent(logger, dataSectionName, messageItem.Children);
                                if (subscriptionEvent.HasData)
                                {
                                    SubscriptionEvents = new List <SubscriptionEvent>()
                                    {
                                        subscriptionEvent
                                    }
                                }
                                ;
                            }
                            break;

                        case "REMOVED BY SENDER":
                            RemoveBySender = messageItem.Value;
                            break;

                        default:
                            logger.LogWarning("Unexpected Html Element - \"" + dataSectionName + " - Message: " + messageItem.Header + "\".  Please contact NDCAC with section name and test data to improve parsing functionality");
                            //_log.LogWarning("Unknown Section - \"Message:" + headerNode.InnerText + "\".  Please contact NDCAC with section name and test data to improve parsing functionality");
#if DEBUG
                            throw new ApplicationException(messageItem.Header);
#endif
                            // break;
                        }
                    }

                    if (participants != null && participants.Any(x => x.HasData))
                    {
                        recipientList.AddRange(participants.Where(x => x.HasData));
                    }

                    if (recipientList.Count() > 0)
                    {
                        Recipients = recipientList;
                    }
                }