Пример #1
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;
        }
Пример #2
0
        /// <summary>
        /// Handles the Click event of the VoteButton 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 VoteButton_Click(object sender, EventArgs e)
        {
            if (!User.Identity.IsAuthenticated)
                Response.Redirect(string.Format("~/Login.aspx?ReturnUrl={0}", Server.UrlEncode(Request.RawUrl)));

            IssueVote vote = new IssueVote(this.IssueId, Security.GetUserName());
            vote.Save();
            int count = Convert.ToInt32(IssueVoteCount.Text) + 1;
            Votes.Text = GetLocalResourceObject("Votes").ToString();
            IssueVoteCount.Text = count.ToString();
            VoteButton.Visible = false;
            VotedLabel.Visible = true;
        }