public static bool ExecuteSmartContentRetreival(
            IWin32Window dialogOwner, ContentSourceInfo contentSourceInfo, string url, ref string title, ISmartContent newContent)
        {
            try
            {
                if (contentSourceInfo.UrlContentSourceRequiresProgress)
                {
                    // create the progress dialog and the async operation
                    UrlContentRetreivalWithProgressDialog progressDialog = new UrlContentRetreivalWithProgressDialog(contentSourceInfo);
                    progressDialog.CreateControl();

                    SmartUrlContentRetreivalAsyncOperation asyncOperation = new SmartUrlContentRetreivalAsyncOperation(progressDialog, contentSourceInfo.Instance as SmartContentSource, url, title, newContent);

                    // execute and retreive results
                    if (ExecuteWithProgress(dialogOwner, progressDialog, asyncOperation, contentSourceInfo))
                    {
                        title = asyncOperation.Title;
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    try
                    {
                        (contentSourceInfo.Instance as SmartContentSource).CreateContentFromUrl(url, ref title, 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;
            }
        }
Exemplo n.º 2
0
        public static bool ExecuteSmartContentRetreival(
            IWin32Window dialogOwner, ContentSourceInfo contentSourceInfo, string url, ref string title, ISmartContent newContent)
        {
            try
            {
                if (contentSourceInfo.UrlContentSourceRequiresProgress)
                {
                    // create the progress dialog and the async operation
                    UrlContentRetreivalWithProgressDialog progressDialog = new UrlContentRetreivalWithProgressDialog(contentSourceInfo);
                    progressDialog.CreateControl();

                    SmartUrlContentRetreivalAsyncOperation asyncOperation = new SmartUrlContentRetreivalAsyncOperation(progressDialog, contentSourceInfo.Instance as SmartContentSource, url, title, newContent);

                    // execute and retrieve results
                    if (ExecuteWithProgress(dialogOwner, progressDialog, asyncOperation, contentSourceInfo))
                    {
                        title = asyncOperation.Title;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    try
                    {
                        (contentSourceInfo.Instance as SmartContentSource).CreateContentFromUrl(url, ref title, 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);
            }
        }