Esempio n. 1
0
        public void TestCreation1()
        {
            TestComment = new IssueComment(IssueId, Comment, CreatorUserName);

            Assert.AreEqual(IssueId, TestComment.IssueId);
            Assert.AreEqual(Comment, TestComment.Comment);
            Assert.AreEqual(CreatorUserName, TestComment.CreatorUserName);

            //Test Empty Values
            Assert.AreEqual(0, TestComment.Id);
            Assert.AreEqual(Guid.Empty, TestComment.CreatorUserId);
            Assert.IsNotNull(TestComment.DateCreated);
        }
Esempio n. 2
0
        public void TestCreation()
        {
            TestComment = new IssueComment(Id, IssueId, Comment, CreatorUserName, CreatorUserId,CreatorDisplayName, DateAdded);

            Assert.AreEqual(Id, TestComment.Id);
            Assert.AreEqual(IssueId, TestComment.IssueId);
            Assert.AreEqual(Comment, TestComment.Comment);
            Assert.AreEqual(CreatorUserId, TestComment.CreatorUserId);
            Assert.AreEqual(CreatorUserName, TestComment.CreatorUserName);
            Assert.AreEqual(CreatorDisplayName, TestComment.CreatorDisplayName);
            //Assert.AreEqual(CreatorEmail, TestComment.CreatorEmail);
            Assert.AreEqual(DateAdded, TestComment.DateCreated);
        }
Esempio n. 3
0
 /// <summary>
 /// Handles the Click event of the cmdAddComment control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void cmdAddComment_Click(object sender, EventArgs e)
 {
     if (CommentHtmlEditor.Text.Trim().Length != 0)
     {
         IssueComment newComment = new IssueComment(IssueId, CommentHtmlEditor.Text.Trim(), Context.User.Identity.Name);
         newComment.Save();
         CommentHtmlEditor.Text = String.Empty;
         BindComments();
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Sends the new issue comment notification.
        /// </summary>
        /// <param name="issueId">The issue id.</param>
        /// <param name="newComment">The new comment.</param>
        public static void SendNewIssueCommentNotification(int issueId, IssueComment newComment)
        {
            if (issueId <= Globals.NewId)
                throw (new ArgumentOutOfRangeException("issueId"));
            if (newComment == null)
                throw new ArgumentNullException("newComment");

            Issue issue = DataProviderManager.Provider.GetIssueById(issueId);
            List<IssueNotification> issNotifications = DataProviderManager.Provider.GetIssueNotificationsByIssueId(issueId);

            EmailFormatTypes type = (EmailFormatTypes)HostSetting.GetHostSetting("SMTPEMailFormat", (int)EmailFormatTypes.Text);

            //load notification plugins
            NotificationManager nm = new NotificationManager(type);
            nm.LoadNotificationTypes();

            //load template and replace the tokens
            string template = nm.LoadEmailNotificationTemplate("NewIssueComment");
            Dictionary<string, object> data = new Dictionary<string, object>();

            data.Add("Issue", issue);
            data.Add("Comment", newComment);
            template = nm.GenerateNotificationContent(template, data);

            string subject = nm.LoadNotificationTemplate("NewIssueCommentSubject");
            string userDisplayName = ITUser.GetUserDisplayName(Security.GetUserName());

            foreach (IssueNotification notify in issNotifications)
            {
                try
                {
                    string notificationUserDisplayName = ITUser.GetUserDisplayName(notify.NotificationUsername);
                    nm.SendNotification(notify.NotificationUsername, String.Format(subject, issue.FullId, userDisplayName), template, notificationUserDisplayName);
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            }
        }