/// <summary>
        /// Saves this instance.
        /// </summary>
        /// <param name="entity">The issue work report to save.</param>
        /// <returns></returns>
        public static bool SaveOrUpdate(IssueWorkReport entity)
        {
            if (entity == null) throw new ArgumentNullException("entity");
            if (entity.IssueId <= Globals.NEW_ID) throw (new ArgumentException("Cannot save issue work report, the issue id is invalid"));

            if (!string.IsNullOrEmpty(entity.CommentText))
                entity.CommentId = DataProviderManager.Provider.CreateNewIssueComment(
                    new IssueComment
                    {
                        IssueId = entity.IssueId,
                        Comment = entity.CommentText,
                        CreatorUserName = entity.CreatorUserName,
                        DateCreated = DateTime.Now
                    });

            var tempId = DataProviderManager.Provider.CreateNewIssueWorkReport(entity);

            if (tempId > Globals.NEW_ID)
            {
                entity.Id = tempId;
                return true;
            }

            return false;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates the new issue work report.
        /// </summary>
        /// <param name="issueWorkReportToCreate">The issue work report to create.</param>
        /// <returns></returns>
        public override int CreateNewIssueWorkReport(IssueWorkReport issueWorkReportToCreate)
        {
            if (issueWorkReportToCreate == null) throw (new ArgumentNullException("issueWorkReportToCreate"));

            try
            {
                using (var sqlCmd = new SqlCommand())
                {
                    AddParamToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
                    AddParamToSqlCmd(sqlCmd, "@IssueId", SqlDbType.NVarChar, 0, ParameterDirection.Input, issueWorkReportToCreate.IssueId);
                    AddParamToSqlCmd(sqlCmd, "@CreatorUserName", SqlDbType.NVarChar, 0, ParameterDirection.Input, issueWorkReportToCreate.CreatorUserName);
                    AddParamToSqlCmd(sqlCmd, "@WorkDate", SqlDbType.DateTime, 0, ParameterDirection.Input, issueWorkReportToCreate.WorkDate);
                    AddParamToSqlCmd(sqlCmd, "@Duration", SqlDbType.Decimal, 0, ParameterDirection.Input, issueWorkReportToCreate.Duration);
                    AddParamToSqlCmd(sqlCmd, "@IssueCommentId", SqlDbType.Int, 0, ParameterDirection.Input, issueWorkReportToCreate.CommentId);

                    SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_ISSUEWORKREPORT_CREATE);
                    ExecuteScalarCmd(sqlCmd);

                    return ((int)sqlCmd.Parameters["@ReturnValue"].Value);
                }
            }
            catch (Exception ex)
            {
                throw ProcessException(ex);
            }
        }
Esempio n. 3
0
 // Issue Work Reports
 public abstract int CreateNewIssueWorkReport(IssueWorkReport workReportToCreate);
Esempio n. 4
0
        /// <summary>
        /// Handles the Click event of the cmdAddBugTimeEntry 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 AddTimeEntry_Click(object sender, EventArgs e)
        {
            if (DurationTextBox.Text.Trim().Length == 0) return;

            var selectedWorkDate = TimeEntryDate.SelectedValue == null
                                       ? DateTime.MinValue
                                       : (DateTime) TimeEntryDate.SelectedValue;
            var workDuration = Convert.ToDecimal(DurationTextBox.Text);

            var workReport = new IssueWorkReport
                                 {
                                     CommentText = CommentHtmlEditor.Text.Trim(),
                                     CreatorUserName = Context.User.Identity.Name,
                                     Duration = workDuration,
                                     IssueId = IssueId,
                                     WorkDate = selectedWorkDate
                                 };

            IssueWorkReportManager.SaveOrUpdate(workReport);

            var history = new IssueHistory
                              {
                                  IssueId = IssueId,
                                  CreatedUserName = Security.GetUserName(),
                                  DateChanged = DateTime.Now,
                                  FieldChanged = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "TimeLogged", "Time Logged"),
                                  OldValue = string.Empty,
                                  NewValue = DurationTextBox.Text.Trim()
                              };

            IssueHistoryManager.SaveOrUpdate(history);

            var changes = new List<IssueHistory> {history};

            IssueNotificationManager.SendIssueNotifications(IssueId, changes);

            CommentHtmlEditor.Text = string.Empty;

            DurationTextBox.Text = string.Empty;

            BindTimeEntries();
        }