Exemplo n.º 1
0
 private bool CanAdd()
 {
     if (NewWork != null)
     {
         NewWork.ValidateProperties();
         return(!NewWork.HasErrors);
     }
     return(false);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the status of an Page, moving it from one list to another.
        /// </summary>
        /// <param name="page">Page to be updated</param>
        /// <param name="new_status">New status to be assigned</param>
        /// <returns>False if the Page already has the new status. True if new status assigned.</returns>
        public bool UpdateStatus(Page page, UrlStatus new_status)
        {
            StatusReport report;

            Block();

            if (page.final_url != null)
            {
                report = IntrCheckLink(page.final_url);

                if (report.url_status == UrlStatus.Free)
                {
                    report = IntrCheckLink(page.org_url);
                }
            }
            else
            {
                report = IntrCheckLink(page.org_url);
            }

            if (report.url_status == new_status)
            {
                Release();
                return(false);
            }

            switch (report.url_status)
            {
            case UrlStatus.ToDo:
                links_todo.RemoveAt(report.index);
                break;

            case UrlStatus.Iprg:
                links_iprg.RemoveAt(report.index);
                break;

            case UrlStatus.Saved:
                links_saved.RemoveAt(report.index);
                break;

            case UrlStatus.Failed:
                links_failed.RemoveAt(report.index);
                break;
            }

            switch (new_status)
            {
            case UrlStatus.ToDo:
                links_todo.Add(page);
                NewWork.Invoke(page);
                break;

            case UrlStatus.Iprg:
                links_iprg.Add(page);
                break;

            case UrlStatus.Saved:
                links_saved.Add(page);
                break;

            case UrlStatus.Failed:
                links_failed.Add(page.org_url.str);
                break;
            }
            Release();
            return(true);
        }