private void _btnOK_Click(object sender, System.EventArgs e) { ConfluenceSoap confluence = new ConfluenceSoap(); try { _lblProgress.Visible = true; _lblProgress.Refresh(); if (_edtUrl.Text.IndexOf("://") < 0) { _edtUrl.Text = "http://" + _edtUrl.Text; } confluence.Url = _edtUrl.Text + LoginManager.ServicePath; _loginToken = confluence.login(_edtUserName.Text, _edtPassword.Text); } catch (Exception ex) { _lblProgress.Text = ex.Message; return; } LoginManager.Url = _edtUrl.Text; LoginManager.UserName = _edtUserName.Text; LoginManager.Password = _edtPassword.Text; DialogResult = DialogResult.OK; }
public static ConfluenceSoap GetConfluenceService() { ConfluenceSoap confluence = new ConfluenceSoap(); confluence.Url = ServiceUrl; return(confluence); }
private bool PostPage(ConfluenceSoap confluence, string loginToken) { string spaceKey = (_cmbSpaces.SelectedItem as SpaceSummary).Key; string title = _edtTitle.Text; RemotePage page = new RemotePage(); RemotePageSummary[] pageSummaries = confluence.getPages(loginToken, spaceKey); foreach (RemotePageSummary pageSummary in pageSummaries) { if (pageSummary.title == _edtTitle.Text) { DialogResult confirm = MessageBox.Show(this, "A page named '" + title + "' already exists. Do you want to overwrite it?", "Post to Confluence", MessageBoxButtons.YesNo); if (confirm != DialogResult.Yes) { _lblProgress.Text = ""; return(false); } page = confluence.getPage(loginToken, pageSummary.id); break; } } page.space = spaceKey; page.title = title; page.content = _edtContent.Text; page.parentId = _parentId; confluence.storePage(loginToken, page); return(true); }
private void LoadPages() { _lblProgress.Visible = true; _lblProgress.Refresh(); _confluence = LoginManager.GetConfluenceService(); _confluence.Beginlogin(LoginManager.UserName, LoginManager.Password, new AsyncCallback(LoginDone), null); }
private void PostBlog(ConfluenceSoap confluence, string loginToken) { RemoteBlogEntry entry = new RemoteBlogEntry(); entry.space = (_cmbSpaces.SelectedItem as SpaceSummary).Key; entry.title = _edtTitle.Text; entry.content = _edtContent.Text; confluence.storeBlogEntry(loginToken, entry); }
private void RefreshSpaceList() { _lblProgress.Text = "Refreshing space list..."; _confluence = new ConfluenceSoap(); _confluence.Url = LoginManager.ServiceUrl; _asyncOperation = true; _confluence.BegingetSpaces(_loginToken, new AsyncCallback(GetSpacesDone), null); UpdateButtonStatus(); }
private void _btnPost_Click(object sender, System.EventArgs e) { bool postSuccess = false; _lblProgress.Text = "Posting..."; _lblProgress.Refresh(); ConfluenceSoap confluence = new ConfluenceSoap(); confluence.Url = LoginManager.ServiceUrl; // the login token may have expired, so let's login again, just in case string loginToken = confluence.login(LoginManager.UserName, LoginManager.Password); try { if (_radNewPage.Checked) { postSuccess = PostPage(confluence, loginToken); } else { PostBlog(confluence, loginToken); postSuccess = true; } } catch (Exception ex) { _lblProgress.Text = ex.Message; } Core.SettingStore.WriteString("PostToConfluence", "LastSpace", (_cmbSpaces.SelectedItem as SpaceSummary).Key); Core.SettingStore.WriteBool("PostToConfluence", "LastNewPage", _radNewPage.Checked); if (postSuccess) { Close(); } else { _asyncOperation = false; UpdateButtonStatus(); } }
/// <summary> /// Returns the login token for Confluence Remote API calls. If there is no /// stored login information, or the stored login information is not valid, /// </summary> /// <returns>The login token or null if the login was cancelled by the user</returns> public static string GetLoginToken() { string url = LoginManager.Url; string userName = LoginManager.UserName; string password = LoginManager.Password; // try stored login information if (url.Length > 0 && userName.Length > 0 && password.Length > 0) { ConfluenceSoap confluence = new ConfluenceSoap(); confluence.Url = LoginManager.ServiceUrl; try { return(confluence.login(userName, password)); } catch (Exception) { // ignore } } return(GetLoginTokenFromDialog()); }