コード例 #1
0
        /// <summary>
        /// btnSubmit_Click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var success = false;
            try
            {
                if (!String.IsNullOrEmpty(txtSubject.Text) && !String.IsNullOrEmpty(txtDescription.Text))
                {
                    var issue = new Issue();
                    issue.Subject = txtSubject.Text;
                    issue.ProjectID = Int32.Parse(ddlProjects.SelectedValue);
                    issue.CurrentPriority = (Issue.IssuePriority)Enum.Parse(typeof(Issue.IssuePriority), ddlIssuePriority.SelectedValue);
                    issue.CurrentStatus = (Issue.IssueStatus)Enum.Parse(typeof(Issue.IssueStatus), ddlIssueStatus.SelectedValue);
                    issue.Description = txtDescription.Text;
                    issue.Milestone = 0; //TODO: check where this value comes from.
                    issue.EntryDate = DateTime.Parse(txtEntryDate.Text);
                    issue.IssueCategoryName = txtCategory.Text;

                    // assignee
                    var user = new User();
                    user.UserId = Int32.Parse(ddlAssignee.SelectedItem.Value);
                    issue.Assignee = user;

                    // add new issue.
                    success = IssueBLL.AddIssue(issue);

                    if (success) Response.Redirect("~/Issues.aspx");
                }

            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
ファイル: IssueTest.cs プロジェクト: benhejl/SWENG500_Team1
        public void RequiredPasswordFieldTest()
        {
            var issue = new Issue()
            {
                Subject = ""

            };

            var context = new ValidationContext(issue, serviceProvider: null, items: null);
            var results = new List<ValidationResult>();

            var isValid = Validator.TryValidateObject(issue, context, results);

            var sb = new StringBuilder();

            if (!isValid)
            {
                foreach (var validationResult in results)
                {
                    // add validation error message to string builder.
                    sb.Append(validationResult.ErrorMessage);
                }
            }

            // check if "The Subject field is required." is in the error message.
            Assert.IsTrue(sb.ToString().Contains("The Subject field is required."));
        }
コード例 #3
0
ファイル: IssueTest.cs プロジェクト: benhejl/SWENG500_Team1
 public void IssueConstructorTest()
 {
     Issue target = new Issue();
     Assert.IsInstanceOfType(target, typeof(Issue));
     Assert.AreEqual(target.CurrentPriority, Issue.IssuePriority.Medium);
     Assert.AreEqual(target.CurrentStatus, Issue.IssueStatus.Unresolved);
 }
コード例 #4
0
ファイル: IssueDAL.cs プロジェクト: benhejl/SWENG500_Team1
        /// <summary>
        /// AddIssue - Add New Issue
        /// </summary>
        /// <param name="issue">Issue</param>
        /// <returns>bool</returns>
        public static bool AddIssue(Issue issue)
        {
            try
            {
                var returnValue = false;
                var id = 0;

                // wrap in a TransactionScope since we are updating two tables - Issues and IssueAssignments
                using (TransactionScope transaction = new TransactionScope())
                {

                    using (var db = new ProjectManagerEntities())
                    {

                            db.Connection.Open();
                            var i = new IssueDAL();
                            //i.IssueID = -1;
                            i.Subject = issue.Subject;
                            i.ProjectID = issue.ProjectID;
                            i.Priority = issue.CurrentPriority.ToString();
                            i.Status = issue.CurrentStatus.ToString();
                            i.Description = issue.Description;
                            i.IssueCategoryName = issue.IssueCategoryName;
                            i.EntryDate = issue.EntryDate;

                            // save issue.
                            db.IssueDALs.AddObject(i);
                            db.SaveChanges();

                            // get the newly inserted issueid.
                            id = i.IssueID;

                            // save issue assignment.
                            var issueAssignment = new IssueAssignmentDAL();
                            issueAssignment.IssueID = id;
                            issueAssignment.UserID = issue.Assignee.UserId;
                            db.IssueAssignmentDALs.AddObject(issueAssignment);
                            db.SaveChanges();

                        }

                        transaction.Complete();

                        // successfully inserted.
                        returnValue = true;
                }

                return returnValue;

            }
            catch (TransactionAbortedException)
            {
                throw;
            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #5
0
ファイル: Project.cs プロジェクト: benhejl/SWENG500_Team1
        public void AddIssue(Issue issue)
        {
            if (null == issue)
            {
                throw new ArgumentNullException();
            }

            Issues.Add(issue);
        }
コード例 #6
0
ファイル: IssueBLL.cs プロジェクト: benhejl/SWENG500_Team1
 /// <summary>
 /// EditIssue
 /// </summary>
 /// <param name="issue">Issue</param>
 /// <returns>bool</returns>
 public static bool EditIssue(Issue issue)
 {
     try
     {
         return IssueDAL.EditIssue(issue);
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #7
0
ファイル: ProjectTest.cs プロジェクト: benhejl/SWENG500_Team1
        public void AddIssueTest()
        {
            Project project = BuildDefaultProject();
            Issue issue = new Issue();
            project.AddIssue(issue);
            Assert.AreEqual(project.Issues.Count, 1);
            Assert.AreSame(project.Issues[0], issue);

            issue = new Issue();
            project.AddIssue(issue);
            Assert.AreEqual(project.Issues.Count, 2);
            Assert.AreNotSame(project.Issues[0], issue);
            Assert.AreSame(project.Issues[1], issue);
        }
コード例 #8
0
ファイル: ProjectTest.cs プロジェクト: benhejl/SWENG500_Team1
        public void OpenIssuesTest()
        {
            Project project = BuildDefaultProject();
            Issue issue = new Issue();
            project.AddIssue(issue);

            Assert.AreEqual(project.OpenIssues(), 1);
            issue.CurrentStatus = Issue.IssueStatus.Resolved;

            Assert.AreEqual(project.OpenIssues(), 0);

            project.AddIssue(new Issue());
            Assert.AreEqual(project.OpenIssues(), 1);
        }
コード例 #9
0
        public void SummaryForProjectTest()
        {
            IssueStatus target = new IssueStatus();
            Project project = null;
            TableRow[] actual = target.SummaryForProject(project);
            Assert.AreEqual(actual.Length, 0);

            project = new Project(1, "Test", DateTime.Now.Subtract(TimeSpan.FromDays(5)), DateTime.Now, "Status", "Description", "Category", DateTime.Now);
            actual = target.SummaryForProject(project);
            Assert.AreEqual(actual.Length, 4);
            Assert.AreEqual(actual[2].Cells[1].Text, "0");
            Assert.AreEqual(actual[3].Cells[1].Text, "0");

            project.AddIssue(new Issue());
            Issue issue = new Issue();
            issue.UpdateStatus(Issue.IssueStatus.Resolved, DateTime.Now);
            project.AddIssue(issue);
            actual = target.SummaryForProject(project);
            Assert.AreEqual(actual.Length, 4);
            Assert.AreEqual(actual[2].Cells[1].Text, "1");
            Assert.AreEqual(actual[3].Cells[1].Text, "1");
        }
コード例 #10
0
ファイル: IssueTest.cs プロジェクト: benhejl/SWENG500_Team1
        public void StatusOnTest()
        {
            Issue issue = new Issue();
            issue.EntryDate = DateTime.Now;
            DateTime statusTime = DateTime.Now;
            issue.UpdateStatus(Issue.IssueStatus.Unresolved, statusTime);

            Issue.IssueStatus status = issue.StatusOn(statusTime.AddDays(1));
            Assert.AreEqual(status, Issue.IssueStatus.Unresolved);

            issue.UpdateStatus(Issue.IssueStatus.Resolved, statusTime.AddDays(2));
            status = issue.StatusOn(statusTime.AddDays(3));
            Assert.AreEqual(status, Issue.IssueStatus.Resolved);

            issue = new Issue();
            issue.EntryDate = DateTime.Now;
            DateTime testBoundary = DateTime.Now.AddDays(10);
            issue.UpdateStatus(Issue.IssueStatus.Resolved, DateTime.Now);
            issue.UpdateStatus(Issue.IssueStatus.Unresolved, testBoundary);
            Assert.AreEqual(issue.StatusOn(DateTime.Now), Issue.IssueStatus.Resolved);
            Assert.AreEqual(issue.StatusOn(DateTime.Now.AddDays(5)), Issue.IssueStatus.Resolved);
            Assert.AreEqual(issue.StatusOn(testBoundary.Subtract(TimeSpan.FromMilliseconds(100))), Issue.IssueStatus.Resolved);
            Assert.AreEqual(issue.StatusOn(testBoundary), Issue.IssueStatus.Unresolved);
            Assert.AreEqual(issue.StatusOn(testBoundary.AddMilliseconds(100)), Issue.IssueStatus.Unresolved);
            Assert.AreEqual(issue.StatusOn(testBoundary.AddDays(1)), Issue.IssueStatus.Unresolved);
        }
コード例 #11
0
 private Issue CreateIssue(Issue.IssuePriority priority)
 {
     Issue issue = new Issue();
     issue.CurrentPriority = priority;
     return issue;
 }
コード例 #12
0
 private static void AddIssues(Project project, int resolved, int unresolved)
 {
     Issue issue;
     for (int i = 0; i < resolved; i++)
     {
         issue = new Issue();
         issue.CurrentStatus = Issue.IssueStatus.Resolved;
         project.Issues.Add(issue);
     }
     for (int i = 0; i < unresolved; i++)
     {
         issue = new Issue();
         issue.CurrentStatus = Issue.IssueStatus.Unresolved;
         project.Issues.Add(issue);
     }
 }
コード例 #13
0
 private Project CreateInitialProject()
 {
     Project project = new Project(1, "Test", DateTime.Now.Subtract(TimeSpan.FromDays(5)), DateTime.Now, "Status", "Description", "Category", DateTime.Now);
     Issue issue = new Issue();
     issue.Assignee = new User(0, "User1", "", "", "", "", "", "", "", "");
     project.AddIssue(issue);
     return project;
 }
コード例 #14
0
 /// <summary>
 ///  Create a new IssueTransition object and initialize the members describing the transition.
 /// </summary>
 /// <param name="newStatus">Status that the issue transitioned to.</param>
 /// <param name="occurredOn">When did the status change occur.</param>
 /// <param name="comments">Comments added for the transition by the user.</param>
 public IssueTransition(Issue.IssueStatus newStatus, DateTime occurredOn, string comments)
 {
     Status = newStatus;
     OccurredOn = occurredOn;
     Comments = comments != null ? comments : string.Empty;
 }
コード例 #15
0
 private Project CreateSecondTestProject()
 {
     Project project = CreateInitialProject();
     User user2 = new User(0, "User2", "", "", "", "", "", "", "", "");
     Issue issue = new Issue();
     issue.Assignee = user2;
     project.AddIssue(issue);
     issue = new Issue();
     issue.Assignee = user2;
     project.AddIssue(issue);
     return project;
 }
コード例 #16
0
ファイル: IssueTest.cs プロジェクト: benhejl/SWENG500_Team1
        public void UpdateStatusTest()
        {
            Issue target = new Issue();
            target.UpdateStatus(Issue.IssueStatus.Unresolved, DateTime.Now);
            Assert.AreEqual(target.CurrentStatus, Issue.IssueStatus.Unresolved);

            target.UpdateStatus(Issue.IssueStatus.Resolved, DateTime.Now.AddMinutes(1));
            Assert.AreEqual(target.CurrentStatus, Issue.IssueStatus.Resolved);

            target.UpdateStatus(Issue.IssueStatus.Unresolved, DateTime.Now.Subtract(TimeSpan.FromDays(1)));
            Assert.AreEqual(target.CurrentStatus, Issue.IssueStatus.Resolved);

            target.UpdateStatus(Issue.IssueStatus.Unresolved, DateTime.Now.Add(TimeSpan.FromDays(1)));
            Assert.AreEqual(target.CurrentStatus, Issue.IssueStatus.Unresolved);
        }
コード例 #17
0
 private Project CreateThirdTestProject()
 {
     Project project = CreateSecondTestProject();
     User user = new User(0, "AUser", "", "", "", "", "", "", "", "");
     Issue issue = new Issue();
     issue.Assignee = user;
     project.AddIssue(issue);
     return project;
 }
コード例 #18
0
ファイル: IssueDAL.cs プロジェクト: benhejl/SWENG500_Team1
        /// <summary>
        /// EditIssue
        /// </summary>
        /// <param name="issue">Issue</param>
        /// <returns>bool</returns>
        public static bool EditIssue(Issue issue)
        {
            try
            {
                var returnValue = false;

                // wrap in a TransactionScope since we are updating two tables - Issues and IssueAssignments
                using (TransactionScope transaction = new TransactionScope())
                {

                    using (var db = new ProjectManagerEntities())
                    {
                        db.Connection.Open();

                        var query = (from i in db.IssueDALs
                                    where i.IssueID == issue.IssueID
                                    select i).First();

                        if (query != null)
                        {
                            query.IssueID = issue.IssueID;
                            query.Subject = issue.Subject;
                            query.ProjectID = issue.ProjectID;
                            query.Priority = issue.CurrentPriority.ToString();
                            query.Status = issue.CurrentStatus.ToString();
                            query.Description = issue.Description;
                            query.IssueCategoryName = issue.IssueCategoryName;
                            query.EntryDate = issue.EntryDate;
                        }

                        // update issue.
                        db.SaveChanges();

                        // get Issue Assignment for this issue.
                        var query2 = (from ia in db.IssueAssignmentDALs
                                     where ia.IssueID == issue.IssueID
                                     select ia).First();

                        if (query2 != null)
                        {
                            query2.IssueID = issue.IssueID;
                            query2.UserID = issue.Assignee.UserId;
                        }

                        // update issue assignment.
                        db.SaveChanges();

                    }

                    transaction.Complete();

                    // successfully inserted.
                    returnValue = true;
                }

                return returnValue;

            }
            catch (TransactionAbortedException)
            {
                throw;
            }
            catch (Exception)
            {

                throw;
            }
        }
コード例 #19
0
 private static void AddIssuePriorityCount(Project project, int count, Issue.IssuePriority priority)
 {
     for (int i = 0; i < count; i++)
     {
         Issue issue = new Issue();
         issue.CurrentPriority = priority;
         project.AddIssue(issue);
     }
 }
コード例 #20
0
ファイル: IssueDAL.cs プロジェクト: benhejl/SWENG500_Team1
        /// <summary>
        /// Get Issue
        /// </summary>
        /// <param name="issueID">int</param>
        /// <returns>Issue</returns>
        public static Issue GetIssue(int issueID)
        {
            var issue = new Issue();

            try
            {
                // get issue information from database.
                using (var db = new ProjectManagerEntities())
                {
                    var query = (from i in db.IssueDALs
                                 join ia in db.IssueAssignmentDALs on i.IssueID equals ia.IssueID into IandIA
                                 from iaJoin in IandIA.DefaultIfEmpty()
                                 join u in db.UserDALs on iaJoin.UserID equals u.UserID into IAandU
                                 from uJoin in IAandU.DefaultIfEmpty()
                                 where i.IssueID == issueID
                                 select new
                                 {
                                     IssueID = iaJoin.IssueID,
                                     Subject = i.Subject,
                                     Priority = i.Priority,
                                     Status = i.Status,
                                     ProjectID = i.ProjectID,
                                     UserID = uJoin.UserID,
                                     Username = uJoin.UserName,
                                     Password = uJoin.Password,
                                     UserRole = uJoin.UserRole,
                                     FirstName = uJoin.FirstName,
                                     LastName = uJoin.LastName,
                                     Email = uJoin.Email,
                                     PhoneNumber = uJoin.PhoneNumber,
                                     Position = uJoin.Position,
                                     TeamName = uJoin.TeamName,
                                     IssueCategoryName = i.IssueCategoryName,
                                     EntryDate = i.EntryDate,
                                     Description = i.Description

                                 }).FirstOrDefault();

                    if (query != null)
                    {
                        // build the issue object.
                        issue = new Issue()
                        {
                            IssueID = query.IssueID,
                            Subject = query.Subject,
                            CurrentStatus = (Issue.IssueStatus)Enum.Parse(typeof(Issue.IssueStatus), query.Status),
                            CurrentPriority = (Issue.IssuePriority)Enum.Parse(typeof(Issue.IssuePriority), query.Priority),
                            ProjectID = query.ProjectID,
                            IssueCategoryName = query.IssueCategoryName,
                            EntryDate = query.EntryDate ?? DateTime.MinValue,
                            Description = query.Description

                        };

                        // Get the Issue Assignee
                        var user = new User(query.UserID, query.Username, query.Password, query.UserRole, query.FirstName, query.LastName, query.Email, query.PhoneNumber, query.Position, query.TeamName);
                        user.FirstName = query.FirstName;
                        user.LastName = query.LastName;
                        issue.Assignee = user;

                    }
                }

            }
            catch (Exception)
            {
                throw;
            }

            return issue;
        }
コード例 #21
0
ファイル: IssueDAL.cs プロジェクト: benhejl/SWENG500_Team1
        /// <summary>
        /// GetIssueList
        /// </summary>
        /// <returns></returns>
        public List<Issue> GetIssueList(int projectID)
        {
            List<Issue> issues = new List<Issue>();

            try
            {
                using (var db = new ProjectManagerEntities())
                {
                    // get the list of issues for a specific ProjectID.
                    var query = (from i in db.IssueDALs
                                 join ia in db.IssueAssignmentDALs on i.IssueID equals ia.IssueID into IandIA
                                 from iaJoin in IandIA.DefaultIfEmpty()
                                 join u in db.UserDALs on iaJoin.UserID equals u.UserID into IAandU
                                 from uJoin in IAandU.DefaultIfEmpty()
                                 where i.ProjectID == projectID
                                 select new
                                 {
                                     IssueID = iaJoin.IssueID,
                                     Subject = i.Subject,
                                     Priority = i.Priority,
                                     Status = i.Status,
                                     ProjectID = i.ProjectID,
                                     UserID = uJoin.UserID,
                                     Username = uJoin.UserName,
                                     Password = uJoin.Password,
                                     UserRole = uJoin.UserRole,
                                     FirstName = uJoin.FirstName,
                                     LastName = uJoin.LastName,
                                     Email = uJoin.Email,
                                     PhoneNumber = uJoin.PhoneNumber,
                                     Position = uJoin.Position,
                                     TeamName = uJoin.TeamName,
                                     IssueCategoryName = i.IssueCategoryName,
                                     EntryDate = i.EntryDate,
                                     Description = i.Description

                                 });

                    foreach (var item in query)
                    {
                        // build the issue object.
                        var myissue = new Issue()
                        {
                            IssueID = item.IssueID,
                            Subject = item.Subject,
                            CurrentStatus = (Issue.IssueStatus)Enum.Parse(typeof(Issue.IssueStatus), item.Status),
                            CurrentPriority = (Issue.IssuePriority)Enum.Parse(typeof(Issue.IssuePriority), item.Priority),
                            ProjectID = item.ProjectID,
                            IssueCategoryName = item.IssueCategoryName,
                            EntryDate = item.EntryDate ?? DateTime.MinValue,
                            Description = item.Description
                        };

                        // Get the Issue Assignee
                        var user = new User(item.UserID, item.Username, item.Password, item.UserRole, item.FirstName, item.LastName, item.Email, item.PhoneNumber, item.Position, item.TeamName);
                        user.FirstName = item.FirstName;
                        user.LastName = item.LastName;
                        myissue.Assignee = user;

                        issues.Add(myissue);
                    }

                }

            }
            catch (Exception)
            {
                throw;
            }

            return issues;
        }
コード例 #22
0
ファイル: IssueTest.cs プロジェクト: benhejl/SWENG500_Team1
 public void UpdateStatusBeforeCreatedTest()
 {
     Issue issue = new Issue();
     issue.EntryDate = DateTime.Now;
     issue.UpdateStatus(Issue.IssueStatus.Unresolved, DateTime.Now.Subtract(TimeSpan.FromDays(1)));
 }