コード例 #1
0
 public MainWindow()
 {
     InitializeComponent();
     System.ServiceModel.Channels.Binding binding = new System.ServiceModel.BasicHttpBinding();
     System.ServiceModel.EndpointAddress  addr    = new System.ServiceModel.EndpointAddress("http://support.fwa.eu" + "/api/soap/mantisconnect.php");
     svcClient = new MantisConnectPortTypeClient(binding, addr);
 }
コード例 #2
0
        public void UpdateServiceConfiguration()
        {
            if (svcClient != null && svcClient.State == CommunicationState.Opened)
            {
                svcClient.Close();
                svcClient = null;
            }

            System.ServiceModel.Channels.Binding b = new BasicHttpBinding();

            if (Properties.Settings.Default.ExtensionConfigured)
            {
                Uri baseUrl = new Uri(Properties.Settings.Default.BaseUrl);
                if (baseUrl.Scheme.Equals("http", StringComparison.InvariantCultureIgnoreCase))
                {
                    b = new BasicHttpBinding();
                    ((BasicHttpBinding)b).MaxReceivedMessageSize = 5 * 1024 * 1024;
                }
                if (baseUrl.Scheme.Equals("https", StringComparison.InvariantCultureIgnoreCase))
                {
                    b = new BasicHttpsBinding();
                    ((BasicHttpsBinding)b).MaxReceivedMessageSize = 5 * 1024 * 1024;
                }
                svcClient = new MantisConnectPortTypeClient(b, _endpointAddr);
            }
        }
コード例 #3
0
        public async Task CreateProject(ProjectData projectData, string login, string password)
        {
            MantisConnectPortTypeClient client = new MantisConnectPortTypeClient();

            Mantis.ProjectData project = new Mantis.ProjectData();
            project.name        = projectData.Name;
            project.description = projectData.Description;
            await client.mc_project_addAsync(login, password, project);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        public void ProjectRemovalTest()
        {
            app.Navigator.GoToControlInMainMenu();
            app.Navigator.GoToControlProjects();
            if (!app.Projects.ExistProjectVerification())
            {
                MantisConnectPortTypeClient cl = new MantisConnectPortTypeClient();
                cl.mc_project_add("administrator", "root", new mantis_web_tests.MantisWebTests.ProjectData {
                    name = "123"
                });
            }
            List <ProjectData> oldProjects = app.Projects.GetProjectList();

            app.Projects.Remove(0);
            Assert.AreEqual(oldProjects.Count - 1, app.Projects.GetProjectCount());
            List <ProjectData> newProjects = app.Projects.GetProjectList();

            oldProjects.RemoveAt(0);
            Assert.AreEqual(oldProjects, newProjects);
        }
コード例 #8
0
ファイル: Plugin.cs プロジェクト: xxNull-lsk/tortoisemantis
        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;
        }
コード例 #9
0
        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));
            }
        }
コード例 #10
0
ファイル: Session.cs プロジェクト: kfalconer/mantisconnect
        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;
        }
コード例 #11
0
ファイル: Session.cs プロジェクト: kfalconer/mantisconnect
 ///<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();
     }
 }