Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="session">The session to use for all communication with the webservice.
        /// The user name and password are used from their to provide such details to the
        /// webservice with each call without exposing such detail to the user of the 
        /// library.</param>
        public Request(Session session)
        {
            this.session = session;

            mc = new MyMantisConnect();
            mc.Url = session.Url;

            if (session.NetworkCredential != null)
                mc.Credentials = session.NetworkCredential;
        }
Пример #2
0
        public void Login(string mantisConnectUrl, string mantisUsername, string mantisPassword, string httpAuthUsername, string httpAuthPassword, Action<string> onCompleted)
        {
            this.backgroundWorkerService.EnqueueTask("Opening session", (param) =>
                {
                    string errorMessage = null;
                    try
                    {
                        Session session = new Session(mantisConnectUrl, mantisUsername, mantisPassword, new NetworkCredential(httpAuthUsername, httpAuthPassword));
                        session.Connect();

                        IsLoggedIn = true;
                        CurrentUsername = mantisUsername;
                        MantisSession = session;
                    }
                    catch (WebException)
                    {
                        errorMessage = "Unable to reach the mantis connect. Check the url and the http authentication if required.";
                    }
                    catch (Exception)
                    {
                        errorMessage = "Unknown error.";
                    }

                    if (errorMessage != null || this.dataLoaded)
                    {
                        if (onCompleted != null)
                        {
                            DispatcherHelper.CheckBeginInvokeOnUI(() => onCompleted(errorMessage));
                        }
                    }
                    else
                    {
                        this.backgroundWorkerService.EnqueueTask("Downloading data", (param2) =>
                        {
                            MantisData data = new MantisData();
                            data.UpdateFromMantis(MantisSession);
                            data.SaveToCache();
                            Data = data;
                            this.dataLoaded = true;
                            DispatcherHelper.CheckBeginInvokeOnUI(() =>
                            {
                                if (MantisDataChanged != null)
                                    MantisDataChanged(this, EventArgs.Empty);
                            });
                            if (onCompleted != null)
                            {
                                DispatcherHelper.CheckBeginInvokeOnUI(() => onCompleted(null));
                            }
                        });
                    }
                });
        }
Пример #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="prjct"></param>
        /// <param name="session"></param>
        /// <returns></returns>
        public int ProjectVersionAdd(ProjectVersion prjct, Session session)
        {
            ValidateProjectId(prjct.Id);

            DateTime before = DateTime.Now;
            try
            {
                MantisConnect.MantisConnectWebservice.ProjectVersionData vd = new MantisConnect.MantisConnectWebservice.ProjectVersionData();
                vd.project_id = prjct.ProjectId.ToString();
                vd.id = prjct.id.ToString();
                vd.name = prjct.Name;
                return Convert.ToInt32(mc.mc_project_version_add(session.Username, session.Password, vd));
            }
            finally
            {
                TimeSpan timeSpan = new TimeSpan(DateTime.Now.Ticks - before.Ticks);
                Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "{0}: AddIssue()", timeSpan.ToString()));
            }
        }
Пример #4
0
        public void UpdateFromMantis(Session mantisSession)
        {
            Categories.Clear();
            Versions.Clear();
            Users.Clear();

            Project[] projects = mantisSession.Request.UserGetAccesibleProjects();
            Projects = projects.Select(w => w.Name).ToArray();
            foreach (Project project in projects)
            {
                Categories.Add(project.Name,
                    mantisSession.Request.ProjectGetCategories(project.Id));

                Versions.Add(project.Name,
                    mantisSession.Request.ProjectGetVersionsReleased(project.Id)
                        .Concat(mantisSession.Request.ProjectGetVersionsUnreleased(project.Id))
                        .OrderBy(v => v.Name)
                        .Select(w => w.Name)
                        .ToArray());

                Users.Add(project.Name, mantisSession.Request.ProjectGetUsers(project.Id).ToArray());
            }
            Priorities = mantisSession.Config.PriorityEnum.Labels;
            Etas = mantisSession.Config.EtaEnum.Labels;
            Severities = mantisSession.Config.SeverityEnum.Labels;
            Reproducibilities = mantisSession.Config.ReproducibilityEnum.Labels;
        }