Beispiel #1
0
        /**************************************************************************/

        public void RenderListViewSearchTargetUrls(
            MacroscopeDocumentCollection DocCollection,
            string UrlFragment
            )
        {
            List <ListViewItem> ListViewItems = new List <ListViewItem>(DocCollection.CountDocuments());

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count     = 0;
            decimal TotalDocs = (decimal)DocCollection.CountDocuments();

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Displaying Links",
                    Message: "Processing links in document collection for display:",
                    MajorPercentage: ((decimal)100 / TotalDocs) * Count,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                string Url = msDoc.GetUrl();

                if (msDoc != null)
                {
                    this.RenderListViewSearchTargetUrls(
                        ListViewItems: ListViewItems,
                        msDoc: msDoc,
                        Url: Url,
                        UrlFragment: UrlFragment
                        );
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: ((decimal)100 / TotalDocs) * Count,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
Beispiel #2
0
        /**************************************************************************/

        public void RenderListView(MacroscopeJobMaster JobMaster)
        {
            Dictionary <String, bool> Blocked = JobMaster.GetBlockedByRobotsList();

            if (Blocked.Count == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem>(1);

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = (decimal)Blocked.Count;
            decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (string Url in Blocked.Keys)
            {
                bool IsInternal = JobMaster.GetAllowedHosts().IsInternalUrl(Url);

                this.RenderListView(
                    ListViewItems: ListViewItems,
                    Url: Url,
                    IsBlocked: Blocked[Url],
                    IsInternal: IsInternal
                    );

                Count++;
                MajorPercentage = ((decimal)100 / TotalDocs) * Count;

                ProgressForm.UpdatePercentages(
                    Title: null,
                    Message: null,
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
        /** Render Entire DocCollection *******************************************/

        public void RenderTreeView(MacroscopeDocumentCollection DocCollection)
        {
            if (DocCollection.CountDocuments() == 0)
            {
                return;
            }

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = ( decimal )DocCollection.CountDocuments();
            decimal MajorPercentage = (( decimal )100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                Application.DoEvents();

                if (msDoc == null)
                {
                    continue;
                }

                string Url = msDoc.GetUrl();

                this.RenderTreeView(msDoc, Url);

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    MajorPercentage = (( decimal )100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
        /** Render One Document *******************************************/

        public virtual void RenderListView(MacroscopeDocument msDoc, string Url)
        {
            if (msDoc == null)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem> (1);

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = ( decimal )1;
            decimal MajorPercentage = (( decimal )100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.ControlBox = false;

                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            Application.DoEvents();

            if (msDoc != null)
            {
                this.RenderListView(
                    ListViewItems: ListViewItems,
                    msDoc: msDoc,
                    Url: msDoc.GetUrl()
                    );
            }

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                Count++;
                MajorPercentage = (( decimal )100 / TotalDocs) * Count;

                ProgressForm.UpdatePercentages(
                    Title: null,
                    Message: null,
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            ProgressForm.Dispose();
        }
Beispiel #5
0
        /**************************************************************************/

        public void RenderListViewSearchSourceUrls(
            MacroscopeDocumentCollection DocCollection,
            string UrlFragment
            )
        {
            List <ListViewItem> ListViewItems = new List <ListViewItem>(DocCollection.CountDocuments());

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count     = 0;
            decimal TotalDocs = (decimal)DocCollection.CountDocuments();

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Displaying Links",
                    Message: "Processing links in document collection for display:",
                    MajorPercentage: ((decimal)100 / TotalDocs) * Count,
                    ProgressLabelMajor: "Documents Processed"
                    );
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                string Url = msDoc.GetUrl();

                if (Url.IndexOf(UrlFragment, StringComparison.CurrentCulture) >= 0)
                {
                    this.RenderListView(
                        ListViewItems: ListViewItems,
                        DocCollection: DocCollection,
                        msDoc: msDoc,
                        Url: Url
                        );
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    TotalDocs = (decimal)DocCollection.CountDocuments();

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: ((decimal)100 / TotalDocs) * Count,
                        ProgressLabelMajor: null
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            ProgressForm.Dispose();
        }
        /**************************************************************************/

        private void RenderTreeView(
            MacroscopeDocumentCollection DocCollection,
            List <string> UrlList
            )
        {
            if (DocCollection.CountDocuments() == 0)
            {
                return;
            }

            if (UrlList.Count == 0)
            {
                return;
            }

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = ( decimal )UrlList.Count;
            decimal MajorPercentage = (( decimal )100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            this.tvTreeView.BeginUpdate();

            DebugMsg(string.Format("HIERARCHY: {0}", "BASE"));

            foreach (string Url in UrlList)
            {
                MacroscopeDocument msDoc = DocCollection.GetDocumentByUrl(Url: Url);

                if (msDoc != null)
                {
                    this.RenderTreeView(msDoc, Url);
                }

                Count++;
                MajorPercentage = (( decimal )100 / TotalDocs) * Count;

                ProgressForm.UpdatePercentages(
                    Title: null,
                    Message: null,
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            this.tvTreeView.ExpandAll();

            this.tvTreeView.EndUpdate();

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
Beispiel #7
0
        /**************************************************************************/

        private void RenderListView(
            MacroscopeDocumentCollection DocCollection,
            List <string> UrlList,
            MacroscopeCustomFilters CustomFilter
            )
        {
            if (this.FilterColOffset == -1)
            {
                throw (new Exception("this.FilterColOffset invalid"));
            }

            if (DocCollection.CountDocuments() == 0)
            {
                return;
            }

            MacroscopeAllowedHosts   AllowedHosts    = this.MainForm.GetJobMaster().GetAllowedHosts();
            Dictionary <string, int> FilterColsTable = new Dictionary <string, int>(CustomFilter.GetSize());
            List <ListViewItem>      ListViewItems   = new List <ListViewItem>();

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = (decimal)DocCollection.CountDocuments();
            decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            for (int Slot = 0; Slot < CustomFilter.GetSize(); Slot++)
            {
                string FilterPattern = CustomFilter.GetPattern(Slot).Key;

                if (FilterColsTable.ContainsKey(FilterPattern))
                {
                    FilterColsTable.Add(string.Format("EMPTY{0}", Slot + 1), Slot + 1);
                }
                else
                {
                    FilterColsTable.Add(FilterPattern, Slot + 1);
                }
            }

            foreach (string Url in UrlList)
            {
                MacroscopeDocument msDoc  = DocCollection.GetDocumentByUrl(Url: Url);
                ListViewItem       lvItem = null;
                string             DocUrl;
                string             PairKey;
                string             StatusCode;
                string             Status;
                string             MimeType;

                if (msDoc == null)
                {
                    continue;
                }
                else
                {
                    DocUrl     = msDoc.GetUrl();
                    PairKey    = DocUrl;
                    StatusCode = ((int)msDoc.GetStatusCode()).ToString();
                    Status     = msDoc.GetStatusCode().ToString();
                    MimeType   = msDoc.GetMimeType();
                }

                if (!CustomFilter.CanApplyCustomFiltersToDocument(msDoc: msDoc))
                {
                    continue;
                }

                if (this.DisplayListView.Items.ContainsKey(PairKey))
                {
                    lvItem = this.DisplayListView.Items[PairKey];
                }
                else
                {
                    lvItem = new ListViewItem(PairKey);
                    lvItem.UseItemStyleForSubItems = false;
                    lvItem.Name = PairKey;

                    lvItem.SubItems.Add("");
                    lvItem.SubItems.Add("");
                    lvItem.SubItems.Add("");
                    lvItem.SubItems.Add("");

                    for (int Slot = 0; Slot < CustomFilter.GetSize(); Slot++)
                    {
                        lvItem.SubItems.Add("");
                    }

                    ListViewItems.Add(lvItem);
                }

                if (lvItem != null)
                {
                    try
                    {
                        lvItem.SubItems[ColUrl].Text        = DocUrl;
                        lvItem.SubItems[ColStatusCode].Text = StatusCode;
                        lvItem.SubItems[ColStatus].Text     = Status;
                        lvItem.SubItems[ColMimeType].Text   = MimeType;

                        for (int Slot = 0; Slot < CustomFilter.GetSize(); Slot++)
                        {
                            string FilterPattern = CustomFilter.GetPattern(Slot: Slot).Key;
                            KeyValuePair <string, MacroscopeConstants.TextPresence> Pair = msDoc.GetCustomFilteredItem(Text: FilterPattern);
                            int ColOffset = this.FilterColOffset + FilterColsTable[FilterPattern];

                            if ((Pair.Key != null) && (Pair.Value != MacroscopeConstants.TextPresence.UNDEFINED))
                            {
                                lvItem.SubItems[ColOffset].Text = MacroscopeConstants.TextPresenceLabels[Pair.Value];

                                switch (Pair.Value)
                                {
                                case MacroscopeConstants.TextPresence.CONTAINS_STRING:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Green;
                                    break;

                                case MacroscopeConstants.TextPresence.NOT_CONTAINS_STRING:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Green;
                                    break;

                                case MacroscopeConstants.TextPresence.MUST_CONTAIN_STRING:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Red;
                                    break;

                                case MacroscopeConstants.TextPresence.SHOULD_NOT_CONTAIN_STRING:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Red;
                                    break;

                                case MacroscopeConstants.TextPresence.CONTAINS_REGEX:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Green;
                                    break;

                                case MacroscopeConstants.TextPresence.NOT_CONTAINS_REGEX:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Green;
                                    break;

                                case MacroscopeConstants.TextPresence.MUST_CONTAIN_REGEX:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Red;
                                    break;

                                case MacroscopeConstants.TextPresence.SHOULD_NOT_CONTAIN_REGEX:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Red;
                                    break;

                                default:
                                    lvItem.SubItems[ColOffset].ForeColor = Color.Gray;
                                    break;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        DebugMsg(string.Format("MacroscopeDisplayCustomFilters: {0}", ex.Message));
                        DebugMsg(string.Format("MacroscopeDisplayCustomFilters: {0}", ex.StackTrace));
                    }
                }
                else
                {
                    DebugMsg(string.Format("MacroscopeDisplayCustomFilters MISSING: {0}", PairKey));
                }

                if (msDoc.GetIsInternal())
                {
                    lvItem.SubItems[ColUrl].ForeColor = Color.Green;
                }
                else
                {
                    lvItem.SubItems[ColUrl].ForeColor = Color.Gray;
                }

                if (Regex.IsMatch(StatusCode, "^[2]"))
                {
                    lvItem.SubItems[ColStatusCode].ForeColor = Color.Green;
                    lvItem.SubItems[ColStatus].ForeColor     = Color.Green;
                }
                else
                if (Regex.IsMatch(StatusCode, "^[3]"))
                {
                    lvItem.SubItems[ColStatusCode].ForeColor = Color.Goldenrod;
                    lvItem.SubItems[ColStatus].ForeColor     = Color.Goldenrod;
                }
                else
                if (Regex.IsMatch(StatusCode, "^[45]"))
                {
                    lvItem.SubItems[ColStatusCode].ForeColor = Color.Red;
                    lvItem.SubItems[ColStatus].ForeColor     = Color.Red;
                }
                else
                {
                    lvItem.SubItems[ColStatusCode].ForeColor = Color.Blue;
                    lvItem.SubItems[ColStatus].ForeColor     = Color.Blue;
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;

                    MajorPercentage = ((decimal)100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            this.DisplayListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            this.DisplayListView.Columns[ColUrl].Width        = 300;
            this.DisplayListView.Columns[ColStatusCode].Width = 100;
            this.DisplayListView.Columns[ColStatus].Width     = 100;
            this.DisplayListView.Columns[ColMimeType].Width   = 100;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
        /**************************************************************************/

        private void RenderListView(
            MacroscopeDocumentCollection DocCollection,
            Dictionary <string, string> LocalesList
            )
        {
            MacroscopeAllowedHosts AllowedHosts = this.MainForm.GetJobMaster().GetAllowedHosts();

            SortedDictionary <string, int> LocaleColsTable = new SortedDictionary <string, int> ();

            if (DocCollection.CountDocuments() == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem> ();

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = ( decimal )DocCollection.CountDocuments();
            decimal MajorPercentage = (( decimal )100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            this.DisplayListView.Items.Clear();
            this.DisplayListView.Columns.Clear();

            {
                int LocaleColCount = 5;

                this.DisplayListView.Columns.Add("URL", "URL");
                this.DisplayListView.Columns.Add("Status Code", "Status Code");
                this.DisplayListView.Columns.Add("Site Locale", "Site Locale");
                this.DisplayListView.Columns.Add("HrefLang Present", "HrefLang Present");
                this.DisplayListView.Columns.Add("Title", "Title");

                foreach (string Locale in LocalesList.Keys)
                {
                    string LocaleLabel       = Locale.ToUpper();
                    string DateServerLabel   = string.Format("{0} Date Server", Locale.ToUpper());
                    string DateModifiedLabel = string.Format("{0} Date Modified", Locale.ToUpper());

                    this.DisplayListView.Columns.Add(LocaleLabel, LocaleLabel);
                    this.DisplayListView.Columns.Add(DateServerLabel, DateServerLabel);
                    this.DisplayListView.Columns.Add(DateModifiedLabel, DateModifiedLabel);

                    LocaleColsTable[Locale] = LocaleColCount;
                    LocaleColCount++;

                    LocaleColsTable[DateServerLabel] = LocaleColCount;
                    LocaleColCount++;

                    LocaleColsTable[DateModifiedLabel] = LocaleColCount;
                    LocaleColCount++;
                }
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                bool Proceed = false;

                if (msDoc.GetIsInternal())
                {
                    Proceed = true;

                    if (msDoc.GetIsRedirect())
                    {
                        Proceed = false;
                    }

                    if (!msDoc.IsDocumentType(Type: MacroscopeConstants.DocumentType.HTML))
                    {
                        Proceed = false;
                    }
                }

                if (Proceed)
                {
                    Dictionary <string, MacroscopeHrefLang> HrefLangsTable = msDoc.GetHrefLangs();
                    string         DocUrl        = msDoc.GetUrl();
                    string         PairKey       = UrlToDigest(DocUrl).ToString();
                    HttpStatusCode StatusCode    = msDoc.GetStatusCode();
                    int            StatusCodeNum = ( int )StatusCode;
                    MacroscopeConstants.Specifiers HrefLangPresent = MacroscopeConstants.Specifiers.UNSPECIFIED;
                    string       DocLocale = msDoc.GetLocale();
                    string       DocTitle  = msDoc.GetTitle();
                    ListViewItem lvItem    = null;

                    if (
                        (HrefLangsTable != null) &&
                        (HrefLangsTable.Count > 1))
                    {
                        HrefLangPresent = MacroscopeConstants.Specifiers.SPECIFIED;
                    }
                    else
                    {
                        HrefLangPresent = MacroscopeConstants.Specifiers.UNSPECIFIED;
                    }

                    if (this.DisplayListView.Items.ContainsKey(PairKey))
                    {
                        lvItem = this.DisplayListView.Items[PairKey];
                    }
                    else
                    {
                        lvItem = new ListViewItem(PairKey);
                        lvItem.UseItemStyleForSubItems = false;
                        lvItem.Name = PairKey;

                        lvItem.SubItems.Add("");
                        lvItem.SubItems.Add("");
                        lvItem.SubItems.Add("");
                        lvItem.SubItems.Add("");
                        lvItem.SubItems.Add("");

                        for (int i = 0; i < LocalesList.Keys.Count; i++)
                        {
                            lvItem.SubItems.Add("");
                            lvItem.SubItems.Add("");
                            lvItem.SubItems.Add("");
                        }

                        ListViewItems.Add(lvItem);
                    }

                    if (lvItem != null)
                    {
                        try
                        {
                            lvItem.SubItems[ColUrl].Text             = DocUrl;
                            lvItem.SubItems[ColStatusCode].Text      = StatusCode.ToString();
                            lvItem.SubItems[ColSiteLocale].Text      = DocLocale;
                            lvItem.SubItems[ColHrefLangPresent].Text = "";
                            lvItem.SubItems[ColTitle].Text           = DocTitle;

                            switch (HrefLangPresent)
                            {
                            case MacroscopeConstants.Specifiers.SPECIFIED:
                                lvItem.SubItems[ColHrefLangPresent].ForeColor = Color.Green;
                                lvItem.SubItems[ColHrefLangPresent].Text      = "SPECIFIED";
                                break;

                            default:
                                lvItem.SubItems[ColHrefLangPresent].ForeColor = Color.Red;
                                lvItem.SubItems[ColHrefLangPresent].Text      = "UNSPECIFIED";
                                break;
                            }

                            if (AllowedHosts.IsInternalUrl(DocUrl))
                            {
                                lvItem.SubItems[ColUrl].ForeColor = Color.Green;
                            }
                            else
                            {
                                lvItem.SubItems[ColUrl].ForeColor = Color.Gray;
                            }

                            if ((StatusCodeNum >= 100) && (StatusCodeNum <= 299))
                            {
                                lvItem.SubItems[ColStatusCode].ForeColor = Color.Green;
                            }
                            else
                            if ((StatusCodeNum >= 300) && (StatusCodeNum <= 399))
                            {
                                lvItem.SubItems[ColStatusCode].ForeColor = Color.Orange;
                            }
                            else
                            if ((StatusCodeNum >= 400) && (StatusCodeNum <= 599))
                            {
                                lvItem.SubItems[ColStatusCode].ForeColor = Color.Red;
                            }
                            else
                            {
                                lvItem.SubItems[ColSiteLocale].ForeColor = Color.Gray;
                            }

                            foreach (string Locale in LocalesList.Keys)
                            {
                                if (!string.IsNullOrEmpty(Locale))
                                {
                                    string   HrefLangUrl          = null;
                                    DateTime HrefLangDateServer   = new DateTime();
                                    DateTime HrefLangDateModified = new DateTime();
                                    int      LocaleCol            = LocaleColsTable[Locale];

                                    if (
                                        (HrefLangsTable != null) &&
                                        (HrefLangsTable.Count > 0))
                                    {
                                        if (HrefLangsTable.ContainsKey(Locale))
                                        {
                                            MacroscopeHrefLang HrefLangAlternate = HrefLangsTable[Locale];

                                            if (HrefLangAlternate != null)
                                            {
                                                HrefLangUrl          = HrefLangAlternate.GetUrl();
                                                HrefLangDateServer   = HrefLangAlternate.GetDateServer();
                                                HrefLangDateModified = HrefLangAlternate.GetDateModified();
                                            }
                                        }
                                    }

                                    if (!string.IsNullOrEmpty(HrefLangUrl))
                                    {
                                        lvItem.SubItems[LocaleCol].ForeColor = Color.Blue;

                                        lvItem.SubItems[LocaleCol].Text = HrefLangUrl;

                                        lvItem.SubItems[LocaleCol + 1].Text = HrefLangDateServer.ToString();
                                        lvItem.SubItems[LocaleCol + 2].Text = HrefLangDateModified.ToString();
                                    }
                                    else
                                    {
                                        lvItem.SubItems[LocaleCol].ForeColor = Color.Red;

                                        lvItem.SubItems[LocaleCol].Text     = "NOT SPECIFIED";
                                        lvItem.SubItems[LocaleCol + 1].Text = "NOT SPECIFIED";
                                        lvItem.SubItems[LocaleCol + 2].Text = "NOT SPECIFIED";
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            DebugMsg(string.Format("MacroscopeDisplayHrefLang: {0}", ex.Message));
                            DebugMsg(string.Format("MacroscopeDisplayHrefLang: {0}", ex.StackTrace));
                        }
                    }
                    else
                    {
                        DebugMsg(string.Format("MacroscopeDisplayHrefLang NOT SPECIFIED: {0}", PairKey));
                    }
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;

                    MajorPercentage = (( decimal )100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            this.DisplayListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            this.DisplayListView.Columns[ColUrl].Width        = 300;
            this.DisplayListView.Columns[ColStatusCode].Width = 80;
            this.DisplayListView.Columns[ColSiteLocale].Width = 100;
            this.DisplayListView.Columns[ColTitle].Width      = 100;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
        /** Render DocCollection Filtered by URL Fragment *************************/

        public void RenderListView(
            MacroscopeDocumentCollection DocCollection,
            string UrlFragment
            )
        {
            if (DocCollection.CountDocuments() == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem>(DocCollection.CountDocuments());

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = (decimal)DocCollection.CountDocuments();
            decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.ControlBox = false;

                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                Application.DoEvents();

                if (msDoc != null)
                {
                    string Url = msDoc.GetUrl();
                    if (Url.IndexOf(UrlFragment, StringComparison.CurrentCulture) >= 0)
                    {
                        this.RenderListView(
                            ListViewItems: ListViewItems,
                            DocCollection: DocCollection,
                            msDoc: msDoc,
                            Url: Url
                            );
                    }
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    MajorPercentage = ((decimal)100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
        /** Render Document List **************************************************/

        public void RenderListView(List <MacroscopeDocument> DocList)
        {
            MacroscopeDocumentCollection DocCollection = this.MainForm.GetJobMaster().GetDocCollection();

            if (DocList.Count == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem>(DocList.Count);

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = (decimal)DocList.Count;
            decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.ControlBox = false;

                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            for (int i = 0; i < DocList.Count; i++)
            {
                MacroscopeDocument msDoc = DocList[i];

                if (msDoc != null)
                {
                    this.RenderListView(
                        ListViewItems: ListViewItems,
                        DocCollection: DocCollection,
                        msDoc: msDoc,
                        Url: msDoc.GetUrl()
                        );
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    MajorPercentage = ((decimal)100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
Beispiel #11
0
        /**************************************************************************/

        private void RenderListViewRedirectChains(MacroscopeDocumentCollection DocCollection)
        {
            List <ListViewItem> ListViewItems = new List <ListViewItem>(DocCollection.CountDocuments());
            List <List <MacroscopeRedirectChainDocStruct> > RedirectChains = DocCollection.GetMacroscopeRedirectChains();

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = (decimal)DocCollection.CountDocuments();
            decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.ControlBox = false;

                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (List <MacroscopeRedirectChainDocStruct> DocList in RedirectChains)
            {
                Application.DoEvents();

                if (DocList.Count > 0)
                {
                    try
                    {
                        this.RenderListViewRedirectChains(
                            ListViewItems: ListViewItems,
                            DocCollection: DocCollection,
                            DocList: DocList
                            );
                    }
                    catch (Exception ex)
                    {
                        this.DebugMsg(string.Format("RenderListViewRedirectChains 1: {0}", ex.Message));
                    }
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    MajorPercentage = ((decimal)100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());
            this.DisplayListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            this.DisplayListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            ProgressForm.Dispose();
        }
Beispiel #12
0
        /**************************************************************************/

        private void RenderListView(Dictionary <ulong, bool> History, MacroscopeDocumentCollection DocCollection)
        {
            if (History.Count == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem>(1);

            MacroscopeAllowedHosts AllowedHosts = this.MainForm.GetJobMaster().GetAllowedHosts();
            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = (decimal)History.Count;
            decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (ulong DocKey in History.Keys)
            {
                ListViewItem       lvItem  = null;
                MacroscopeDocument msDoc   = DocCollection.GetDocumentByDocKey(DocKey: DocKey);
                string             PairKey = DocKey.ToString();

                if (msDoc != null)
                {
                    string Url             = msDoc.GetUrl();
                    string Visited         = "No";
                    string InDocCollection = "No";

                    if (History.ContainsKey(DocKey) && History[DocKey])
                    {
                        Visited = "Yes";
                    }

                    if (DocCollection.ContainsDocument(Url: Url))
                    {
                        InDocCollection = "Yes";
                    }

                    if (this.DisplayListView.Items.ContainsKey(PairKey))
                    {
                        try
                        {
                            lvItem = this.DisplayListView.Items[PairKey];
                            lvItem.SubItems[ColUrl].Text             = Url;
                            lvItem.SubItems[ColVisited].Text         = Visited;
                            lvItem.SubItems[ColInDocCollection].Text = InDocCollection;
                        }
                        catch (Exception ex)
                        {
                            DebugMsg(string.Format("RenderListView 1: {0}", ex.Message));
                        }
                    }
                    else
                    {
                        try
                        {
                            lvItem = new ListViewItem(PairKey);
                            lvItem.UseItemStyleForSubItems = false;

                            lvItem.Name = PairKey;

                            lvItem.SubItems[0].Text = Url;
                            lvItem.SubItems.Add(Visited);
                            lvItem.SubItems.Add(InDocCollection);

                            ListViewItems.Add(lvItem);
                        }
                        catch (Exception ex)
                        {
                            DebugMsg(string.Format("RenderListView 2: {0}", ex.Message));
                        }
                    }

                    if (lvItem != null)
                    {
                        lvItem.ForeColor = Color.Blue;

                        if (AllowedHosts.IsInternalUrl(Url))
                        {
                            lvItem.SubItems[ColUrl].ForeColor = Color.Green;
                            if (History.ContainsKey(DocKey) && History[DocKey])
                            {
                                lvItem.SubItems[ColVisited].ForeColor = Color.Green;
                            }
                            else
                            {
                                lvItem.SubItems[ColVisited].ForeColor = Color.Red;
                            }
                            lvItem.SubItems[ColInDocCollection].ForeColor = Color.Blue;
                        }
                        else
                        {
                            lvItem.SubItems[ColUrl].ForeColor             = Color.Gray;
                            lvItem.SubItems[ColVisited].ForeColor         = Color.Gray;
                            lvItem.SubItems[ColInDocCollection].ForeColor = Color.Gray;
                        }
                    }
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    TotalDocs       = (decimal)History.Count;
                    MajorPercentage = ((decimal)100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
        /**************************************************************************/

        private void RenderListView(Dictionary <string, Boolean> History)
        {
            if (History.Count == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem> (1);

            MacroscopeAllowedHosts AllowedHosts = this.MainForm.GetJobMaster().GetAllowedHosts();
            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = ( decimal )History.Count;
            decimal MajorPercentage = (( decimal )100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (string Url in History.Keys)
            {
                ListViewItem lvItem  = null;
                string       Visited = "No";

                if (History[Url])
                {
                    Visited = "Yes";
                }

                if (this.DisplayListView.Items.ContainsKey(Url))
                {
                    try
                    {
                        lvItem = this.DisplayListView.Items[Url];
                        lvItem.SubItems[1].Text = Visited;
                    }
                    catch (Exception ex)
                    {
                        DebugMsg(string.Format("RenderListView 1: {0}", ex.Message));
                    }
                }
                else
                {
                    try
                    {
                        lvItem = new ListViewItem(Url);
                        lvItem.UseItemStyleForSubItems = false;
                        lvItem.Name = Url;
                        lvItem.SubItems.Add(Visited);

                        ListViewItems.Add(lvItem);
                    }
                    catch (Exception ex)
                    {
                        DebugMsg(string.Format("RenderListView 2: {0}", ex.Message));
                    }
                }

                if (lvItem != null)
                {
                    lvItem.ForeColor = Color.Blue;

                    if (AllowedHosts.IsInternalUrl(Url))
                    {
                        lvItem.SubItems[0].ForeColor = Color.Green;
                        if (History[Url])
                        {
                            lvItem.SubItems[1].ForeColor = Color.Green;
                        }
                        else
                        {
                            lvItem.SubItems[1].ForeColor = Color.Red;
                        }
                    }
                    else
                    {
                        lvItem.SubItems[0].ForeColor = Color.Gray;
                        lvItem.SubItems[1].ForeColor = Color.Gray;
                    }
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    TotalDocs       = ( decimal )History.Count;
                    MajorPercentage = (( decimal )100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            ProgressForm.Dispose();
        }
        /**************************************************************************/

        public override void RenderListView(MacroscopeDocumentCollection DocCollection)
        {
            if (DocCollection.CountDocuments() == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem>(DocCollection.CountDocuments());

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = (decimal)DocCollection.CountDocuments();
            decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                bool Proceed = false;

                if (((int)msDoc.GetStatusCode() >= 400) && ((int)msDoc.GetStatusCode() <= 499))
                {
                    Proceed = true;
                }
                else
                if (((int)msDoc.GetStatusCode() >= 500) && ((int)msDoc.GetStatusCode() <= 599))
                {
                    Proceed = true;
                }

                if (MacroscopePreferencesManager.GetIgnoreErrors410() && ((int)msDoc.GetStatusCode() == 410))
                {
                    Proceed = false;
                }

                if (MacroscopePreferencesManager.GetIgnoreErrors451() && ((int)msDoc.GetStatusCode() == 451))
                {
                    Proceed = false;
                }

                if (Proceed)
                {
                    this.RenderListView(
                        ListViewItems: ListViewItems,
                        DocCollection: DocCollection,
                        msDoc: msDoc,
                        Url: msDoc.GetUrl()
                        );
                }
                else
                {
                    this.RemoveFromListView(Url: msDoc.GetUrl());
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    TotalDocs       = (decimal)DocCollection.CountDocuments();
                    MajorPercentage = ((decimal)100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
Beispiel #15
0
        /**************************************************************************/

        private void RenderListView(MacroscopeJobItem [] UriQueue)
        {
            if (UriQueue.Length == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem> (1);

            MacroscopeAllowedHosts AllowedHosts = this.MainForm.GetJobMaster().GetAllowedHosts();
            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            int     Item            = 1;
            decimal Count           = 0;
            decimal TotalDocs       = ( decimal )UriQueue.Length;
            decimal MajorPercentage = (( decimal )100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing URI Queue for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("URL {0} / {1}", Count, TotalDocs)
                    );
            }

            for (int i = 0; i < UriQueue.Length; i++)
            {
                ListViewItem lvItem = null;
                string       Url    = UriQueue[i].GetItemUrl();

                if (this.DisplayListView.Items.ContainsKey(Url))
                {
                    try
                    {
                        lvItem = this.DisplayListView.Items[Url];
                        lvItem.SubItems[0].Text = Item.ToString();
                    }
                    catch (Exception ex)
                    {
                        DebugMsg(string.Format("RenderListView 1: {0}", ex.Message));
                    }
                }
                else
                {
                    try
                    {
                        lvItem = new ListViewItem(Url);
                        lvItem.UseItemStyleForSubItems = false;
                        lvItem.Name             = Url;
                        lvItem.SubItems[0].Text = Item.ToString();
                        lvItem.SubItems.Add(Url);

                        ListViewItems.Add(lvItem);
                    }
                    catch (Exception ex)
                    {
                        DebugMsg(string.Format("RenderListView 2: {0}", ex.Message));
                    }
                }

                if (lvItem != null)
                {
                    lvItem.ForeColor = Color.Blue;

                    lvItem.SubItems[0].ForeColor = Color.Blue;

                    if (AllowedHosts.IsInternalUrl(Url))
                    {
                        lvItem.SubItems[1].ForeColor = Color.Green;
                    }
                    else
                    {
                        lvItem.SubItems[1].ForeColor = Color.Gray;
                    }
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    TotalDocs       = ( decimal )UriQueue.Length;
                    MajorPercentage = (( decimal )100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("URL {0} / {1}", Count, TotalDocs)
                        );
                }

                Item++;
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            ProgressForm.Dispose();
        }
Beispiel #16
0
        /**************************************************************************/

        private void RenderListView(
            MacroscopeDocumentCollection DocCollection,
            List <string> UrlList,
            MacroscopeDataExtractorCssSelectors DataExtractor
            )
        {
            MacroscopeAllowedHosts AllowedHosts = this.MainForm.GetJobMaster().GetAllowedHosts();

            if (DocCollection.CountDocuments() == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem> ();

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = ( decimal )DocCollection.CountDocuments();
            decimal MajorPercentage = (( decimal )100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (string Url in UrlList)
            {
                MacroscopeDocument msDoc      = DocCollection.GetDocumentByUrl(Url: Url);
                string             DocUrl     = msDoc.GetUrl();
                string             StatusCode = (( int )msDoc.GetStatusCode()).ToString();
                string             Status     = msDoc.GetStatusCode().ToString();
                string             MimeType   = msDoc.GetMimeType();

                if (!DataExtractor.CanApplyDataExtractorsToDocument(msDoc: msDoc))
                {
                    continue;
                }

                foreach (KeyValuePair <string, string> DataExtractedPair in msDoc.IterateDataExtractedCssSelectors())
                {
                    ListViewItem lvItem           = null;
                    string       CssSelectorLabel = DataExtractedPair.Key;
                    string       ExtractedValue   = DataExtractedPair.Value;
                    string       PairKey          = null;

                    if (
                        string.IsNullOrEmpty(CssSelectorLabel) ||
                        string.IsNullOrEmpty(ExtractedValue))
                    {
                        continue;
                    }

                    PairKey = string.Join(
                        ":",
                        UrlToDigest(DocUrl),
                        UrlToDigest(Macroscope.GetStringDigest(Text: CssSelectorLabel)),
                        UrlToDigest(Macroscope.GetStringDigest(Text: ExtractedValue))
                        );

                    if (this.DisplayListView.Items.ContainsKey(PairKey))
                    {
                        lvItem = this.DisplayListView.Items[PairKey];
                    }
                    else
                    {
                        lvItem = new ListViewItem(PairKey);
                        lvItem.UseItemStyleForSubItems = false;
                        lvItem.Name = PairKey;

                        for (int i = 0; i < 6; i++)
                        {
                            lvItem.SubItems.Add("");
                        }

                        ListViewItems.Add(lvItem);
                    }

                    if (lvItem != null)
                    {
                        try
                        {
                            lvItem.SubItems[ColUrl].Text              = DocUrl;
                            lvItem.SubItems[ColStatusCode].Text       = StatusCode;
                            lvItem.SubItems[ColStatus].Text           = Status;
                            lvItem.SubItems[ColMimeType].Text         = MimeType;
                            lvItem.SubItems[ColCssSelectorLabel].Text = CssSelectorLabel;
                            lvItem.SubItems[ColExtractedValue].Text   = ExtractedValue;
                        }
                        catch (Exception ex)
                        {
                            DebugMsg(string.Format("MacroscopeDisplayDataExtractorCssSelectors: {0}", ex.Message));
                            DebugMsg(string.Format("MacroscopeDisplayDataExtractorCssSelectors: {0}", ex.StackTrace));
                        }
                    }
                    else
                    {
                        DebugMsg(string.Format("MacroscopeDisplayDataExtractorCssSelectors MISSING: {0}", PairKey));
                    }

                    if (msDoc.GetIsInternal())
                    {
                        lvItem.SubItems[ColUrl].ForeColor = Color.Green;
                    }
                    else
                    {
                        lvItem.SubItems[ColUrl].ForeColor = Color.Gray;
                    }

                    if (Regex.IsMatch(StatusCode, "^[2]"))
                    {
                        lvItem.SubItems[ColStatusCode].ForeColor = Color.Green;
                        lvItem.SubItems[ColStatus].ForeColor     = Color.Green;
                    }
                    else
                    if (Regex.IsMatch(StatusCode, "^[3]"))
                    {
                        lvItem.SubItems[ColStatusCode].ForeColor = Color.Goldenrod;
                        lvItem.SubItems[ColStatus].ForeColor     = Color.Goldenrod;
                    }
                    else
                    if (Regex.IsMatch(StatusCode, "^[45]"))
                    {
                        lvItem.SubItems[ColStatusCode].ForeColor = Color.Red;
                        lvItem.SubItems[ColStatus].ForeColor     = Color.Red;
                    }
                    else
                    {
                        lvItem.SubItems[ColStatusCode].ForeColor = Color.Blue;
                        lvItem.SubItems[ColStatus].ForeColor     = Color.Blue;
                    }
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;

                    MajorPercentage = (( decimal )100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            this.DisplayListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            this.DisplayListView.Columns[ColUrl].Width        = 300;
            this.DisplayListView.Columns[ColStatusCode].Width = 100;
            this.DisplayListView.Columns[ColStatus].Width     = 100;
            this.DisplayListView.Columns[ColMimeType].Width   = 100;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }
        /** Render Filtered DocCollection *******************************************/

        public void RenderListView(
            MacroscopeDocumentCollection DocCollection,
            MacroscopeConstants.DocumentType DocumentType
            )
        {
            if (DocCollection.CountDocuments() == 0)
            {
                return;
            }

            List <ListViewItem> ListViewItems = new List <ListViewItem>(DocCollection.CountDocuments());

            MacroscopeSinglePercentageProgressForm ProgressForm = new MacroscopeSinglePercentageProgressForm(this.MainForm);
            decimal Count           = 0;
            decimal TotalDocs       = (decimal)DocCollection.CountDocuments();
            decimal MajorPercentage = ((decimal)100 / TotalDocs) * Count;

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.ControlBox = false;

                ProgressForm.UpdatePercentages(
                    Title: "Preparing Display",
                    Message: "Processing document collection for display:",
                    MajorPercentage: MajorPercentage,
                    ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                    );
            }

            foreach (MacroscopeDocument msDoc in DocCollection.IterateDocuments())
            {
                Application.DoEvents();

                if (msDoc != null)
                {
                    switch (DocumentType)
                    {
                    case MacroscopeConstants.DocumentType.INTERNALURL:
                        if (msDoc.GetIsInternal())
                        {
                            this.RenderListView(
                                ListViewItems: ListViewItems,
                                DocCollection: DocCollection,
                                msDoc: msDoc,
                                Url: msDoc.GetUrl()
                                );
                        }
                        break;

                    case MacroscopeConstants.DocumentType.EXTERNALURL:
                        if (msDoc.GetIsExternal())
                        {
                            this.RenderListView(
                                ListViewItems: ListViewItems,
                                DocCollection: DocCollection,
                                msDoc: msDoc,
                                Url: msDoc.GetUrl()
                                );
                        }
                        break;

                    default:
                        if (
                            (msDoc.GetDocumentType() == DocumentType) ||
                            (DocumentType == MacroscopeConstants.DocumentType.ALL))
                        {
                            this.RenderListView(
                                ListViewItems: ListViewItems,
                                DocCollection: DocCollection,
                                msDoc: msDoc,
                                Url: msDoc.GetUrl()
                                );
                        }
                        break;
                    }
                }

                if (MacroscopePreferencesManager.GetShowProgressDialogues())
                {
                    Count++;
                    MajorPercentage = ((decimal)100 / TotalDocs) * Count;

                    ProgressForm.UpdatePercentages(
                        Title: null,
                        Message: null,
                        MajorPercentage: MajorPercentage,
                        ProgressLabelMajor: string.Format("Document {0} / {1}", Count, TotalDocs)
                        );
                }
            }

            this.DisplayListView.Items.AddRange(ListViewItems.ToArray());

            if (MacroscopePreferencesManager.GetShowProgressDialogues())
            {
                ProgressForm.DoClose();
            }

            if (ProgressForm != null)
            {
                ProgressForm.Dispose();
            }
        }