private void buttonConnect_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; BasicHttpBinding binding = new BasicHttpBinding(); EndpointAddress endpoint = new EndpointAddress(textBoxAPIURL.Text); MantisConnectPortTypeClient client = new MantisConnectPortTypeClient(binding, endpoint); ProjectData[] projects = new ProjectData[0]; listBoxProject.BeginUpdate(); listBoxProject.Items.Clear(); listBoxProject.Enabled = false; try { projects = client.mc_projects_get_user_accessible(textBoxUsername.Text, textBoxPassword.Text); } catch (CommunicationException communicationException) { MessageBox.Show(communicationException.ToString(), "communication exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (projects.Length > 0) { listBoxProject.Items.AddRange(projects); listBoxProject.SelectedIndex = 0; listBoxProject.Enabled = true; } } catch (ProtocolException protocolException) { MessageBox.Show("connection failed: \n" + protocolException.Message); } catch (UriFormatException uriFormatException) { MessageBox.Show("incorrect URL: \n" + uriFormatException.Message); } catch (EndpointNotFoundException endpointNotFoundException) { MessageBox.Show("enpoint not found: \n" + endpointNotFoundException.Message); } finally { listBoxProject.EndUpdate(); this.Cursor = Cursors.Default; } }
public string GetCommitMessage(IntPtr hParentWnd, string parameters, string commonRoot, string[] pathList, string originalMessage) { connectionErrorReported = false; cs = new ConnectionSettings(parameters); IssuesForm form = new IssuesForm(this, cs); this.form = form; // WTF does this take so long? BasicHttpBinding binding = new BasicHttpBinding(); EndpointAddress endpoint = new EndpointAddress(cs.URL); client = new MantisConnectPortTypeClient(binding, endpoint); client.mc_versionCompleted += new EventHandler<mc_versionCompletedEventArgs>(client_mc_versionCompleted); client.mc_projects_get_user_accessibleCompleted += new EventHandler<mc_projects_get_user_accessibleCompletedEventArgs>(client_mc_projects_get_user_accessibleCompleted); client.mc_enum_statusCompleted += new EventHandler<mc_enum_statusCompletedEventArgs>(client_mc_enum_statusCompleted); client.mc_projects_get_user_accessibleAsync(cs.Username, cs.Password); client.mc_enum_statusAsync(cs.Username, cs.Password); if (form.ShowDialog() == DialogResult.OK) { IssueHeaderData issue = form.GetSelectedIssue(); if (issue != null) { String retMessage = String.Format("BUGFIX: {0}\nissue {1}\n", issue.summary, issue.id); return retMessage; } } return originalMessage; }
private MantisConnectPortTypeClient CreateMantisClientProxyInstance() { Binding basicHttpBinding = new BasicHttpBinding(IsSecure() ? BasicHttpSecurityMode.TransportWithMessageCredential : BasicHttpSecurityMode.None); var client = new MantisConnectPortTypeClient(basicHttpBinding, new EndpointAddress(Url)); if (IsSecure()) { client.ClientCredentials.UserName.UserName = Username; client.ClientCredentials.UserName.Password = Password; } return client; }
///<summary> /// Check there exists an issue with the specified id. ///</summary> /// <exception cref="MCException"></exception> public bool IssueExists(long issueId) { var mc = new MantisConnectPortTypeClient("MantisConnectPort", Url); try { return mc.mc_issue_exists(Username, Password, issueId.ToString()); } catch (Exception ex) { throw new MCException(String.Format("Error checking issue {0}", issueId), ex); } finally { mc.CloseSafely(); } }