private async void OpenStoryFromSource() { EnableCredentialFields(false); try { UpdateStatusMessage("Getting basic story information"); log.InfoFormat("Opening story from Writing.com"); WritingClient wc = GetWritingClient(); var story = await wc.GetInteractive(new Uri(tbStoryUrl.Text)); story.HasChanged = true; // Got the story, lets ready the form UpdateStatusMessage("Got the basic story information, press \'Update story from Writing.com\' to get the rest"); _OpenStory(story); } catch (Exception ex) { log.Error("An error occured when trying to get the story info.", ex); } finally { EnableCredentialFields(true); // Always reenable stuff } }
private WritingClient GetWritingClient() { string username = tbWritingUsername.Text; string password = tbWritingPassword.Text; Uri writingRoot = new Uri("https://www.writing.com"); if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException("username", "Writing username cannot be left empty"); } if (string.IsNullOrEmpty(password)) { throw new ArgumentNullException("password", "Writing password cannot be left empty"); } WritingClient wc = new WritingClient(new WritingClientSettings() { WritingCredentials = new System.Net.NetworkCredential(tbWritingUsername.Text, tbWritingPassword.Text), WritingUrlRoot = writingRoot }); return(wc); }
public WStoryExporter(WritingClient writingClient) { _wc = writingClient; Init(); }