/// <summary>
 /// Admin Notification List edit Add Button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnAddNot_Click(object sender, EventArgs e)
 {
     if (lstProjectUsers.SelectedItem != null)
     {
         IssueNotification notify = new IssueNotification(IssueId, lstProjectUsers.SelectedItem.Value);
         notify.Save();
         BindNotifications();
     }
 }
Example #2
0
        /// <summary>
        /// Saves the bug
        /// </summary>
        /// <returns></returns>
        public bool Save()
        {
            if (Id <= Globals.NewId)
            {
                int TempId = DataProviderManager.Provider.CreateNewIssue(this);

                if (TempId > 0)
                {
                    _Id = TempId;

                    return true;
                }
                else
                    return false;
            }
            else
            {
                List<IssueHistory> issueChanges = GetIssueChanges();
                if (issueChanges.Count > 0)
                {

                    bool result = DataProviderManager.Provider.UpdateIssue(this);
                    if (result)
                    {
                        UpdateIssueHistory(issueChanges);

                        IssueNotification.SendIssueNotifications(Id, issueChanges);
                        if (this._SendNewAssigneeNotification)
                        {
                            //add this user to notifications and send them a notification
                            IssueNotification issueNotification = new IssueNotification(Id, this.AssignedUserName);
                            issueNotification.Save();
                            IssueNotification.SendNewAssigneeNotification(Id, this._AssignedUserName);
                        }
                    }
                    return result;
                }
                return true;
            }
        }
Example #3
0
        /// <summary>
        /// Saves the bug.
        /// </summary>
        /// <returns></returns>
        private bool SaveIssue()
        {
            decimal estimation;
            decimal.TryParse(txtEstimation.Text.Trim(), out estimation);
            DateTime dueDate = DueDate.Text.Length > 0 ? DateTime.Parse(DueDate.Text) : DateTime.MinValue;

            bool NewIssue = (IssueId <= 0);

            // WARNING: DO NOT ENCODE THE HTMLEDITOR TEXT.
            // It expects raw input. So pass through a raw string.
            // This is a potential XSS vector as the Issue Class should
            // handle sanitizing the input and checking that its input is HtmlEncoded
            // (ie no < or > characters), not the IssueDetail.aspx.cs

            Issue newIssue = new Issue(IssueId, ProjectId, string.Empty, string.Empty, Server.HtmlEncode(TitleTextBox.Text), DescriptionHtmlEditor.Text.Trim(),
                DropCategory.SelectedValue, DropCategory.SelectedText, DropPriority.SelectedValue, DropPriority.SelectedText,
                string.Empty, DropStatus.SelectedValue, DropStatus.SelectedText, string.Empty, DropIssueType.SelectedValue,
                DropIssueType.SelectedText, string.Empty, DropResolution.SelectedValue, DropResolution.SelectedText, string.Empty,
                DropAssignedTo.SelectedText, DropAssignedTo.SelectedValue, Guid.Empty, Security.GetDisplayName(),
                Security.GetUserName(), Guid.Empty, DropOwned.SelectedText, DropOwned.SelectedValue, Guid.Empty, dueDate,
                DropMilestone.SelectedValue, DropMilestone.SelectedText, string.Empty, null, DropAffectedMilestone.SelectedValue, DropAffectedMilestone.SelectedText,
                string.Empty, chkPrivate.Checked == true ? 1 : 0,
                0, estimation, DateTime.MinValue, DateTime.MinValue, Security.GetUserName(), Security.GetDisplayName(),
                Convert.ToInt32(ProgressSlider.Text), false, 0);

            if (!newIssue.Save())
            {
                Message1.ShowErrorMessage("Could not save issue");
                return false;
            }

            IssueId = newIssue.Id;

            if (!CustomField.SaveCustomFieldValues(IssueId, ctlCustomFields.Values))
            {
                Message1.ShowErrorMessage("Could not save issue custom fields");
                return false;
            }

            //if new issue check if notify owner and assigned is checked.
            if (NewIssue)
            {
                //add attachment if present.
                // get the current file
                HttpPostedFile uploadFile = this.AspUploadFile.PostedFile;
                HttpContext context = HttpContext.Current;
                if (uploadFile.ContentLength > 0)
                {
                    IssueAttachment.UploadFile(IssueId, uploadFile, context, AttachmentDescription.Text.Trim());
                }

                //create a vote for the new issue
                IssueVote vote = new IssueVote(IssueId, Security.GetUserName());
                if (!vote.Save())
                    Message1.ShowErrorMessage("Could not save issue vote.");

                if (chkNotifyOwner.Checked)
                {
                    System.Web.Security.MembershipUser oUser = ITUser.GetUser(newIssue.OwnerUserName);
                    if (oUser != null)
                    {
                        IssueNotification notify = new IssueNotification(IssueId, oUser.UserName);
                        notify.Save();
                    }
                }
                if (chkNotifyAssignedTo.Checked && !string.IsNullOrEmpty(newIssue.AssignedUserName))
                {
                    System.Web.Security.MembershipUser oUser = ITUser.GetUser(newIssue.AssignedUserName);
                    if (oUser != null)
                    {
                        IssueNotification notify = new IssueNotification(IssueId, oUser.UserName);
                        notify.Save();
                    }
                }
                IssueNotification.SendIssueAddNotifications(IssueId);
            }

            return true;
        }
 /// <summary>
 /// Handles the Click event of the btnReceiveNotifications control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnReceiveNotifications_Click(object sender, EventArgs e)
 {
     IssueNotification notify = new IssueNotification(IssueId, Page.User.Identity.Name);
     notify.Save();
     BindNotifications();
 }