private void btnTest_Click(object sender, RoutedEventArgs e) { string result = svcClient.mc_version(); var projects = svcClient.mc_projects_get_user_accessible("nicolas.pernot", "Alphamax321%"); MessageBox.Show(string.Format("Mantis version : {0}", result)); foreach (var item in projects) { MessageBox.Show(item.name); } }
public List <ProjectData> GetProjectList() { if (_cache != null) { return(new List <ProjectData>(_cache)); } _cache = new List <ProjectData>(); MantisConnectPortTypeClient cl = new MantisConnectPortTypeClient(); var a = cl.mc_projects_get_user_accessible("administrator", "root"); _cache.AddRange(a.Select(x => new ProjectData(x.name))); return(new List <ProjectData>(_cache)); }
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 static List <ProjectData> GetAllProjects(string login, string password) { MantisConnectPortTypeClient client = new MantisConnectPortTypeClient(); var projects = client.mc_projects_get_user_accessible(login, password); List <ProjectData> result = new List <ProjectData>(); foreach (var project in projects) { result.Add(new ProjectData() { Id = Convert.ToInt32(project.id), Name = project.name, Description = project.description, Status = Convert.ToInt32(project.status.id), State = Convert.ToInt32(project.view_state.id) }); } return(result); }
protected override async Task <SendResult> Send(IWin32Window Owner, Output Output, ImageData ImageData) { try { HttpBindingBase binding; if (Output.Url.StartsWith("https", StringComparison.InvariantCultureIgnoreCase)) { binding = new BasicHttpsBinding(); } else { binding = new BasicHttpBinding(); } binding.MaxBufferSize = int.MaxValue; binding.MaxReceivedMessageSize = int.MaxValue; MantisConnectPortTypeClient mantisConnect = new MantisConnectPortTypeClient(binding, new EndpointAddress(Output.Url + "/api/soap/mantisconnect.php")); string userName = Output.UserName; string password = Output.Password; bool showLogin = string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password); bool rememberCredentials = false; string fileName = AttributeHelper.ReplaceAttributes(Output.FileName, ImageData); while (true) { if (showLogin) { // Show credentials window Credentials credentials = new Credentials(Output.Url, userName, password, rememberCredentials); var ownerHelper = new System.Windows.Interop.WindowInteropHelper(credentials); ownerHelper.Owner = Owner.Handle; if (credentials.ShowDialog() != true) { return(new SendResult(Result.Canceled)); } userName = credentials.UserName; password = credentials.Password; rememberCredentials = credentials.Remember; } try { // Get available projects ProjectData[] projects = await Task.Factory.StartNew(() => mantisConnect.mc_projects_get_user_accessible(userName, password)); // Show send window Send send = new Send(Output.Url, Output.LastProjectID, Output.LastIssueID, projects, fileName); var ownerHelper = new System.Windows.Interop.WindowInteropHelper(send); ownerHelper.Owner = Owner.Handle; if (!send.ShowDialog() == true) { return(new SendResult(Result.Canceled)); } string projectID = null; string issueID = null; if (send.CreateNewIssue) { projectID = send.ProjectID; ObjectRef[] priorities = await Task.Factory.StartNew(() => mantisConnect.mc_enum_priorities(userName, password)); ObjectRef[] severities = await Task.Factory.StartNew(() => mantisConnect.mc_enum_severities(userName, password)); string[] categories = await Task.Factory.StartNew(() => mantisConnect.mc_project_get_categories(userName, password, projectID)); ObjectRef projectRef = new ObjectRef(); projectRef.id = send.ProjectID; IssueData issue = new IssueData(); issue.summary = HttpUtility.HtmlEncode(send.Summary); issue.description = HttpUtility.HtmlEncode(send.Description); issue.priority = priorities[0]; issue.severity = severities[0]; issue.status = new ObjectRef(); issue.date_submitted = DateTime.UtcNow; issue.category = categories[0]; issue.reproducibility = new ObjectRef(); issue.resolution = new ObjectRef(); issue.project = projectRef; issue.projection = new ObjectRef(); issue.eta = new ObjectRef(); issue.view_state = new ObjectRef(); issueID = await Task.Factory.StartNew(() => mantisConnect.mc_issue_add(userName, password, issue)); } else { issueID = send.IssueID; projectID = Output.LastProjectID; } IFileFormat fileFormat = FileHelper.GetFileFormat(Output.FileFormatID); string fullFileName = String.Format("{0}.{1}", send.FileName, fileFormat.FileExtension); byte[] fileBytes = FileHelper.GetFileBytes(Output.FileFormatID, ImageData); await Task.Factory.StartNew(() => mantisConnect.mc_issue_attachment_add(userName, password, issueID, fullFileName, fileFormat.MimeType, fileBytes)); // Open issue in browser if (Output.OpenItemInBrowser) { WebHelper.OpenUrl(String.Format("{0}/view.php?id={1}", Output.Url, issueID)); } return(new SendResult(Result.Success, new Output(Output.Name, Output.Url, (rememberCredentials) ? userName : Output.UserName, (rememberCredentials) ? password : Output.Password, Output.FileName, Output.FileFormatID, Output.OpenItemInBrowser, projectID, issueID))); } catch (FaultException ex) when(ex.Reason.ToString() == "Access denied") { // Login failed showLogin = true; } } } catch (Exception ex) { return(new SendResult(Result.Failed, ex.Message)); } }