/// <summary>
        /// Handles the ItemCommand event of the TimeEntriesDataGrid control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param>
        protected void TimeEntriesDataGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            var id = Convert.ToInt32(e.CommandArgument);

            if (!IssueWorkReportManager.Delete(id))
            {
                return;
            }

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

            IssueHistoryManager.SaveOrUpdate(history);

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

            IssueNotificationManager.SendIssueNotifications(IssueId, changes);

            BindTimeEntries();
        }
        /// <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(),
                TriggerLastUpdateChange = true
            };

            IssueHistoryManager.SaveOrUpdate(history);

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

            IssueNotificationManager.SendIssueNotifications(IssueId, changes);

            CommentHtmlEditor.Text = string.Empty;

            DurationTextBox.Text = string.Empty;

            BindTimeEntries();
        }
Example #3
0
        /// <summary>
        /// Handles the Click event of the cmdUpdate 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 CmdAddRelatedIssueClick(object sender, EventArgs e)
        {
            if (IssueIdTextBox.Text == String.Empty)
            {
                return;
            }

            if (!Page.IsValid)
            {
                return;
            }

            RelatedIssuesMessage.Visible = false;

            var issueId = Utilities.ParseFullIssueId(IssueIdTextBox.Text.Trim());

            if (issueId <= Globals.NEW_ID)
            {
                return;
            }

            RelatedIssueManager.CreateNewRelatedIssue(IssueId, issueId);

            IssueIdTextBox.Text = String.Empty;

            var history = new IssueHistory
            {
                IssueId                 = IssueId,
                CreatedUserName         = Security.GetUserName(),
                DateChanged             = DateTime.Now,
                FieldChanged            = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "RelatedIssue", "Related Issue"),
                OldValue                = string.Empty,
                NewValue                = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "Added", "Added"),
                TriggerLastUpdateChange = true
            };

            IssueHistoryManager.SaveOrUpdate(history);

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

            IssueNotificationManager.SendIssueNotifications(IssueId, changes);

            BindRelated();
        }
Example #4
0
        /// <summary>
        /// GRDs the bugs item command.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param>
        protected void GrdBugsItemCommand(Object s, DataGridCommandEventArgs e)
        {
            var commandArgument = e.CommandArgument.ToString();
            var commandName     = e.CommandName.ToLower().Trim();
            var currentIssueId  = Globals.NEW_ID;

            switch (commandName)
            {
            case "delete":
                currentIssueId = int.Parse(commandArgument);
                RelatedIssueManager.DeleteParentIssue(IssueId, currentIssueId);
                break;
            }

            if (currentIssueId > Globals.NEW_ID)
            {
                var history = new IssueHistory
                {
                    IssueId                 = IssueId,
                    CreatedUserName         = Security.GetUserName(),
                    DateChanged             = DateTime.Now,
                    FieldChanged            = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "ParentIssue", "Parent Issue"),
                    OldValue                = string.Empty,
                    NewValue                = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "Deleted", "Deleted"),
                    TriggerLastUpdateChange = true
                };

                IssueHistoryManager.SaveOrUpdate(history);

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

                IssueNotificationManager.SendIssueNotifications(IssueId, changes);
            }

            BindRelated();
        }
Example #5
0
        /// <summary>
        /// Uploads the document.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void UploadDocument(object sender, EventArgs e)
        {
            // get the current file
            var uploadFile = AspUploadFile.PostedFile;

            // if there was a file uploaded
            if (uploadFile != null && uploadFile.ContentLength > 0)
            {
                var inValidReason = string.Empty;
                var fileName = Path.GetFileName(uploadFile.FileName);

                var validFile = IssueAttachmentManager.IsValidFile(fileName, out inValidReason);

                if (validFile)
                {
                    byte[] fileBytes;
                    using (var input = uploadFile.InputStream)
                    {
                        fileBytes = new byte[uploadFile.ContentLength];
                        input.Read(fileBytes, 0, uploadFile.ContentLength);
                    }

                    var attachment = new IssueAttachment
                    {
                        Id = Globals.NEW_ID,
                        Attachment = fileBytes,
                        Description = AttachmentDescription.Text.Trim(),
                        DateCreated = DateTime.Now,
                        ContentType = uploadFile.ContentType,
                        CreatorDisplayName = string.Empty,
                        CreatorUserName = Security.GetUserName(),
                        FileName = fileName,
                        IssueId = IssueId,
                        Size = fileBytes.Length
                    };

                    if (!IssueAttachmentManager.SaveOrUpdate(attachment))
                    {
                        AttachmentsMessage.ShowErrorMessage(string.Format(GetGlobalResourceObject("Exceptions", "SaveAttachmentError").ToString(), uploadFile.FileName));
                        if (Log.IsWarnEnabled) Log.Warn(string.Format(GetGlobalResourceObject("Exceptions", "SaveAttachmentError").ToString(), uploadFile.FileName));
                        return;
                    }

                    //add history record and send notifications
                    var history = new IssueHistory
                    {
                        IssueId = IssueId,
                        CreatedUserName = Security.GetUserName(),
                        DateChanged = DateTime.Now,
                        FieldChanged = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "Attachment", "Attachment"),
                        OldValue = fileName,
                        NewValue = ResourceStrings.GetGlobalResource(GlobalResources.SharedResources, "Added", "Added"),
                        TriggerLastUpdateChange = true
                    };

                    IssueHistoryManager.SaveOrUpdate(history);

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

                    IssueNotificationManager.SendIssueNotifications(IssueId, changes);

                    BindAttachments();
                }
                else
                    AttachmentsMessage.ShowErrorMessage(inValidReason); 
            }
        }