Exemplo n.º 1
0
        public void Resolve(string resolution, ManagedSecurityContext sec)
        {
            switch (mInstance.Status.Name)
            {
            case "Resolved":
            case "Closed":
                throw new InvalidOperationException();
            }

            mInstance.Status     = ManagedBugStatus.Find(Session, "Resolved");
            mInstance.Resolution = ManagedBugResolution.Find(Session, resolution);
            Save(sec);
        }
Exemplo n.º 2
0
        public void Reopen(ManagedSecurityContext sec)
        {
            switch (mInstance.Status.Name)
            {
            case "Resolved":
            case "Closed":
                break;

            default:
                throw new InvalidOperationException();
            }

            mInstance.Status = ManagedBugStatus.Find(Session, "Reopened");
            Save(sec);
        }
Exemplo n.º 3
0
        public override Bug GetInstance(ISession session, ManagedSecurityContext sec)
        {
            Bug instance = base.GetInstance(session, sec);

            if (Id == 0)
            {
                instance.AccountId = GetOwner(session, AccountId, sec).Id;
                instance.Project   = session.Load <BugProject>(this.ProjectId);
            }

            instance.Subject = this.Subject;
            instance.Details = this.Details;
            if (!string.IsNullOrEmpty(this.Status))
            {
                instance.Status = ManagedBugStatus.Find(session, this.Status);
            }
            if (instance.Status == null)
            {
                instance.Status = session.Load <BugStatu>(ManagedBugStatus.FindId(session, "Open"));
            }
            if (!string.IsNullOrEmpty(this.Type))
            {
                instance.Type = ManagedBugType.Find(session, this.Type);
            }
            if (!string.IsNullOrEmpty(this.Priority))
            {
                instance.Priority = ManagedBugPriority.Find(session, this.Priority);
            }
            if (!string.IsNullOrEmpty(this.Severity))
            {
                instance.Severity = ManagedBugSeverity.Find(session, this.Severity);
            }
            if (!string.IsNullOrEmpty(this.Resolution))
            {
                instance.Resolution = ManagedBugResolution.Find(session, this.Resolution);
            }
            if (instance.Resolution == null)
            {
                instance.Resolution = session.Load <BugResolution>(ManagedBugResolution.FindId(session, "None"));
            }
            return(instance);
        }
Exemplo n.º 4
0
        public string GetQuery(ISession session)
        {
            StringBuilder s_query = new StringBuilder();

            s_query.AppendLine("SELECT {Bug.*} FROM Bug {Bug}");

            if (!string.IsNullOrEmpty(SearchQuery))
            {
                int maxsearchresults = ManagedConfiguration.GetValue(session, "SnCore.MaxSearchResults", 128);
                s_query.AppendFormat("\nINNER JOIN FREETEXTTABLE(Bug, ([Subject], [Details]), " +
                                     "'{0}', {1}) AS ft ON Bug.Bug_Id = ft.[KEY] ",
                                     Renderer.SqlEncode(SearchQuery), maxsearchresults);
            }

            s_query.AppendFormat(" WHERE Bug.Project_Id = {0}", ProjectId);

            if (!Resolved)
            {
                s_query.AppendFormat(" AND NOT Bug.Status_Id = {0}", ManagedBugStatus.FindId(session, "Resolved"));
            }

            if (!Closed)
            {
                s_query.AppendFormat(" AND NOT Bug.Status_Id = {0}", ManagedBugStatus.FindId(session, "Closed"));
            }

            if (!Open)
            {
                s_query.AppendFormat(" AND NOT Bug.Status_Id = {0}", ManagedBugStatus.FindId(session, "Open"));
                s_query.AppendFormat(" AND NOT Bug.Status_Id = {0}", ManagedBugStatus.FindId(session, "Reopened"));
            }

            if (string.IsNullOrEmpty(SearchQuery) && !string.IsNullOrEmpty(SortExpression))
            {
                s_query.AppendFormat(" ORDER BY Bug.{0} {1}",
                                     Renderer.SqlEncode(SortExpression),
                                     (SortDirection == TransitSortDirection.Ascending) ? "ASC" : "DESC");
            }

            return(s_query.ToString());
        }
Exemplo n.º 5
0
        public void Close(ManagedSecurityContext sec)
        {
            switch (mInstance.Status.Name)
            {
            case "Resolved":
                break;

            default:
                throw new InvalidOperationException();
            }

            mInstance.Status = ManagedBugStatus.Find(Session, "Closed");
            Save(sec);

            // notify that the bug has been closed, account may not exist any more

            Session.Flush();

            ManagedAccount acct = new ManagedAccount(Session, mInstance.AccountId);

            ManagedSiteConnector.TrySendAccountEmailMessageUriAsAdmin(Session, acct,
                                                                      string.Format("EmailBugClosed.aspx?id={0}", mInstance.Id));
        }