private void buttonAutoDetectWeblog_Click(object sender, System.EventArgs e) { try { textBoxResults.Text = String.Empty; BlogAccountDetector accountDetector = new BlogAccountDetector(this, this.weblogHomepageUrlControl.HomepageUrl, this.textBoxUsername.Text, this.textBoxPassword.Text); // setup the progress dialog and kick off the transfer using (ProgressDialog progress = new ProgressDialog()) { // configure progress source progress.ProgressProvider = accountDetector; // set progress title progress.Title = Text; progress.ProgressText = Text; // start the publisher (this is a non-blocking call) accountDetector.Start(); // show the progress dialog progress.ShowDialog(this); } // show error if (accountDetector.ErrorOccurred) { accountDetector.ShowLastError(this); } else if (!accountDetector.WasCancelled) // ran to completion { StringBuilder resultsBuilder = new StringBuilder(); resultsBuilder.AppendFormat("Service: {0}\r\nClientApi: {1}\r\nPost URL: {2}\r\nBlogID: {3}\r\n\r\n", accountDetector.ServiceName, accountDetector.ClientType, accountDetector.PostApiUrl, accountDetector.BlogId); foreach (BlogInfo blog in accountDetector.UsersBlogs) { resultsBuilder.AppendFormat("{0} ({1})\r\n", blog.HomepageUrl, blog.Id); } textBoxResults.Text = resultsBuilder.ToString(); } } catch (Exception ex) { UnexpectedErrorMessage.Show(ex); } }
public override bool ValidatePanel() { // validate we have select a provider if (comboBoxSelectProvider.SelectedItem == BlogProviderDescriptionProxy.SelectProvider) { DisplayMessage.Show(MessageId.RequiredFieldOmitted, FindForm(), Res.Get(StringId.CWSelectProviderWeblogProvider)); comboBoxSelectProvider.Focus(); return(false); } // validate that we have a post api url else if (textBoxServerApiUrl.Text.Trim() == String.Empty) { DisplayMessage.Show(MessageId.RequiredFieldOmitted, FindForm(), Res.Get(StringId.CWSelectProviderApiUrl)); textBoxServerApiUrl.Focus(); return(false); } else if (!ValidateNoParameters(textBoxServerApiUrl)) { return(false); } else { using (new WaitCursor()) { IBlogProviderDescription provider = SelectedBlogProvider; BlogAccountDetector blogAccountDetector = new BlogAccountDetector( provider.ClientType, provider.PostApiUrl, new BlogCredentialsAccessor(_accountId, _credentials)); if (blogAccountDetector.ValidateService()) { BlogInfo blogInfo = blogAccountDetector.DetectAccount(_homepageUrl, null); if (blogInfo != null) { _targetBlog = blogInfo; } _usersBlogs = blogAccountDetector.UsersBlogs; return(true); } else { if (blogAccountDetector.ErrorMessageType != MessageId.None) { DisplayMessage.Show(blogAccountDetector.ErrorMessageType, FindForm(), blogAccountDetector.ErrorMessageParams); } textBoxServerApiUrl.Focus(); return(false); } } } }
private void buttonAutoDetectWeblog_Click(object sender, System.EventArgs e) { try { textBoxResults.Text = String.Empty ; BlogAccountDetector accountDetector = new BlogAccountDetector(this, this.weblogHomepageUrlControl.HomepageUrl, this.textBoxUsername.Text, this.textBoxPassword.Text); // setup the progress dialog and kick off the transfer using (ProgressDialog progress = new ProgressDialog()) { // configure progress source progress.ProgressProvider = accountDetector; // set progress title progress.Title = Text; progress.ProgressText = Text ; // start the publisher (this is a non-blocking call) accountDetector.Start(); // show the progress dialog progress.ShowDialog(this); } // show error if ( accountDetector.ErrorOccurred ) { accountDetector.ShowLastError(this); } else if (!accountDetector.WasCancelled)// ran to completion { StringBuilder resultsBuilder = new StringBuilder(); resultsBuilder.AppendFormat( "Service: {0}\r\nClientApi: {1}\r\nPost URL: {2}\r\nBlogID: {3}\r\n\r\n", accountDetector.ServiceName, accountDetector.ClientType, accountDetector.PostApiUrl, accountDetector.BlogId ) ; foreach ( BlogInfo blog in accountDetector.UsersBlogs ) resultsBuilder.AppendFormat( "{0} ({1})\r\n", blog.HomepageUrl, blog.Id ) ; textBoxResults.Text = resultsBuilder.ToString() ; } } catch(Exception ex) { UnexpectedErrorMessage.Show(ex); } }