public static bool ExecuteSimpleContentRetreival(
            IWin32Window dialogOwner, ContentSourceInfo contentSourceInfo, string url, ref string title, ref string newContent)
        {
            try
            {
                // if there is progress requested then just do it on the main UI thread
                if (contentSourceInfo.UrlContentSourceRequiresProgress)
                {
                    // create the progress dialog and the async operation
                    UrlContentRetreivalWithProgressDialog progressDialog = new UrlContentRetreivalWithProgressDialog(contentSourceInfo);
                    progressDialog.CreateControl();
                    SimpleUrlContentRetreivalAsyncOperation asyncOperation = new SimpleUrlContentRetreivalAsyncOperation(progressDialog, contentSourceInfo.Instance as ContentSource, url, title);

                    // execute and retreive results
                    if (ExecuteWithProgress(dialogOwner, progressDialog, asyncOperation, contentSourceInfo))
                    {
                        title = asyncOperation.Title;
                        newContent = asyncOperation.NewContent;
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    try
                    {
                        (contentSourceInfo.Instance as ContentSource).CreateContentFromUrl(url, ref title, ref newContent);
                        return true;
                    }
                    catch (Exception ex)
                    {
                        ContentSourceManager.DisplayContentRetreivalError(dialogOwner, ex, contentSourceInfo);
                        return false;
                    }
                }

            }
            catch (Exception ex)
            {
                Trace.Fail("Unexpected exception executing network operation for content source: " + ex.ToString());
                return false;
            }
        }
Example #2
0
        public static bool ExecuteSimpleContentRetreival(
            IWin32Window dialogOwner, ContentSourceInfo contentSourceInfo, string url, ref string title, ref string newContent)
        {
            try
            {
                // if there is progress requested then just do it on the main UI thread
                if (contentSourceInfo.UrlContentSourceRequiresProgress)
                {
                    // create the progress dialog and the async operation
                    UrlContentRetreivalWithProgressDialog progressDialog = new UrlContentRetreivalWithProgressDialog(contentSourceInfo);
                    progressDialog.CreateControl();
                    SimpleUrlContentRetreivalAsyncOperation asyncOperation = new SimpleUrlContentRetreivalAsyncOperation(progressDialog, contentSourceInfo.Instance as ContentSource, url, title);

                    // execute and retrieve results
                    if (ExecuteWithProgress(dialogOwner, progressDialog, asyncOperation, contentSourceInfo))
                    {
                        title      = asyncOperation.Title;
                        newContent = asyncOperation.NewContent;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    try
                    {
                        (contentSourceInfo.Instance as ContentSource).CreateContentFromUrl(url, ref title, ref newContent);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        ContentSourceManager.DisplayContentRetreivalError(dialogOwner, ex, contentSourceInfo);
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.Fail("Unexpected exception executing network operation for content source: " + ex.ToString());
                return(false);
            }
        }