/// <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> /// Gets the name of the tab. /// </summary> /// <param name="tabName"></param> /// <param name="tabValue"></param> /// <returns></returns> private string GetTabName(string tabName, string tabValue) { switch (tabValue.ToLower()) { case "tabcomments": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : IssueCommentManager.GetByIssueId(IssueId).Count)); case "tabhistory": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : IssueHistoryManager.GetByIssueId(IssueId).Count)); case "tabattachments": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : IssueAttachmentManager.GetByIssueId(IssueId).Count)); case "tabnotifications": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : IssueNotificationManager.GetByIssueId(IssueId).Count)); case "tabrelatedissues": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : RelatedIssueManager.GetRelatedIssues(IssueId).Count)); case "tabparentissues": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : RelatedIssueManager.GetParentIssues(IssueId).Count)); case "tabsubissues": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : RelatedIssueManager.GetChildIssues(IssueId).Count)); case "tabrevisions": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : IssueRevisionManager.GetByIssueId(IssueId).Count)); case "tabtimetracking": return(string.Format("{0} ({1})", tabName, IssueId == 0 ? 0 : IssueWorkReportManager.GetByIssueId(IssueId).Count)); default: return(tabName); } }
/// <summary> /// Binds the notifications. /// </summary> private void BindNotifications() { NotificationsDataGrid.DataSource = IssueNotificationManager.GetByIssueId(IssueId); NotificationsDataGrid.DataBind(); lstProjectUsers.DataSource = UserManager.GetUsersByProjectId(ProjectId); lstProjectUsers.DataBind(); List <ProjectNotification> projectNotifications = (List <ProjectNotification>)ProjectNotificationManager.GetByProjectId(ProjectId); List <IssueNotification> CurrentUsers = IssueNotificationManager.GetByIssueId(IssueId); foreach (IssueNotification item in CurrentUsers) { if (lstProjectUsers.Items.FindByValue(item.NotificationUsername) != null) { ListItem DelIndex = null; DelIndex = lstProjectUsers.Items.FindByValue(item.NotificationUsername); lstProjectUsers.Items.Remove(DelIndex); } } lstNotificationUsers.DataSource = CurrentUsers; lstNotificationUsers.DataBind(); // filter out project notifications and disable them foreach (ListItem item in lstNotificationUsers.Items) { if (projectNotifications.Any(p => p.NotificationUsername == item.Value)) { item.Attributes.Add("disabled", "disabled"); item.Text += GetLocalResourceObject("ProjectLevel").ToString(); } } }
/// <summary> /// Handles the Click event of the btnDontRecieveNotfictaions 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 btnDontRecieveNotfictaions_Click(object sender, EventArgs e) { var notify = new IssueNotification { IssueId = IssueId, NotificationUsername = Page.User.Identity.Name }; IssueNotificationManager.Delete(notify); BindNotifications(); }
/// <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) { var notify = new IssueNotification { IssueId = IssueId, NotificationUsername = Page.User.Identity.Name }; IssueNotificationManager.SaveOrUpdate(notify); BindNotifications(); }
/// <summary> /// Admin Notification List edit Remove Button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelNot_Click(object sender, EventArgs e) { if (lstNotificationUsers.SelectedItem == null) { return; } var notify = new IssueNotification { IssueId = IssueId, NotificationUsername = lstNotificationUsers.SelectedItem.Value }; IssueNotificationManager.Delete(notify); BindNotifications(); }
/// <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(); }
/// <summary> /// Gets the name of the tab. /// </summary> /// <param name="tabName"></param> /// <param name="tabValue"></param> /// <returns></returns> private string GetTabName(string tabName, string tabValue) { int cnt; switch (tabValue.ToLower()) { case "tabcomments": cnt = IssueId == 0 ? 0 : IssueCommentManager.GetByIssueId(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "bold")); case "tabhistory": cnt = IssueId == 0 ? 0 : IssueHistoryManager.GetByIssueId(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "normal")); case "tabattachments": cnt = IssueId == 0 ? 0 : IssueAttachmentManager.GetByIssueId(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "bold")); case "tabnotifications": cnt = IssueId == 0 ? 0 : IssueNotificationManager.GetByIssueId(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "normal")); case "tabrelatedissues": cnt = IssueId == 0 ? 0 : RelatedIssueManager.GetRelatedIssues(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "bold")); case "tabparentissues": cnt = IssueId == 0 ? 0 : RelatedIssueManager.GetParentIssues(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "bold")); case "tabsubissues": cnt = IssueId == 0 ? 0 : RelatedIssueManager.GetChildIssues(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "bold")); case "tabrevisions": cnt = IssueId == 0 ? 0 : IssueRevisionManager.GetByIssueId(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "normal")); case "tabtimetracking": cnt = IssueId == 0 ? 0 : IssueWorkReportManager.GetByIssueId(IssueId).Count; return(string.Format("<span class='{2}'>{0} ({1})</span>", tabName, cnt, cnt == 0 ? "normal" : "normal")); default: return(tabName); } }
/// <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(); }
/// <summary> /// Send notifications for the new issue /// </summary> /// <param name="issue">The issue generated from the email</param> void SendNotifications(Issue issue) { if (issue == null) { return; } List <DefaultValue> defValues = IssueManager.GetDefaultIssueTypeByProjectId(issue.ProjectId); DefaultValue selectedValue = defValues.FirstOrDefault(); if (selectedValue != null) { if (selectedValue.OwnedByNotify) { var oUser = UserManager.GetUser(issue.OwnerUserName); if (oUser != null) { var notify = new IssueNotification { IssueId = issue.Id, NotificationUsername = oUser.UserName }; IssueNotificationManager.SaveOrUpdate(notify); } } if (selectedValue.AssignedToNotify) { var oUser = UserManager.GetUser(issue.AssignedUserName); if (oUser != null) { var notify = new IssueNotification { IssueId = issue.Id, NotificationUsername = oUser.UserName }; IssueNotificationManager.SaveOrUpdate(notify); } } } //send issue notifications IssueNotificationManager.SendIssueAddNotifications(issue.Id); }
/// <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(); }
/// <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); } }
/// <summary> /// Saves the issue. /// </summary> /// <returns></returns> private bool SaveIssue() { decimal estimation; decimal.TryParse(txtEstimation.Text.Trim(), out estimation); var dueDate = DueDatePicker.SelectedValue ?? DateTime.MinValue; var issue = new Issue { AffectedMilestoneId = DropAffectedMilestone.SelectedValue, AffectedMilestoneImageUrl = string.Empty, AffectedMilestoneName = DropAffectedMilestone.SelectedText, AssignedDisplayName = DropAssignedTo.SelectedText, AssignedUserId = Guid.Empty, AssignedUserName = DropAssignedTo.SelectedValue, CategoryId = DropCategory.SelectedValue, CategoryName = DropCategory.SelectedText, CreatorDisplayName = Security.GetDisplayName(), CreatorUserId = Guid.Empty, CreatorUserName = Security.GetUserName(), DateCreated = DateTime.Now, Description = DescriptionHtmlEditor.Text.Trim(), Disabled = false, DueDate = dueDate, Estimation = estimation, Id = 0, IsClosed = false, IssueTypeId = DropIssueType.SelectedValue, IssueTypeName = DropIssueType.SelectedText, IssueTypeImageUrl = string.Empty, LastUpdate = DateTime.Now, LastUpdateDisplayName = Security.GetDisplayName(), LastUpdateUserName = Security.GetUserName(), MilestoneDueDate = null, MilestoneId = DropMilestone.SelectedValue, MilestoneImageUrl = string.Empty, MilestoneName = DropMilestone.SelectedText, OwnerDisplayName = DropOwned.SelectedText, OwnerUserId = Guid.Empty, OwnerUserName = DropOwned.SelectedValue, PriorityId = DropPriority.SelectedValue, PriorityImageUrl = string.Empty, PriorityName = DropPriority.SelectedText, Progress = Convert.ToInt32(ProgressSlider.Text), ProjectCode = string.Empty, ProjectId = ProjectId, ProjectName = string.Empty, ResolutionId = DropResolution.SelectedValue, ResolutionImageUrl = string.Empty, ResolutionName = DropResolution.SelectedText, StatusId = DropStatus.SelectedValue, StatusImageUrl = string.Empty, StatusName = DropStatus.SelectedText, Title = Server.HtmlEncode(TitleTextBox.Text), TimeLogged = 0, Visibility = chkPrivate.Checked ? 1 : 0, Votes = 0 }; if (!IssueManager.SaveOrUpdate(issue)) { Message1.ShowErrorMessage(Resources.Exceptions.SaveIssueError); return(false); } if (!CustomFieldManager.SaveCustomFieldValues(issue.Id, ctlCustomFields.Values, true)) { Message1.ShowErrorMessage(Resources.Exceptions.SaveCustomFieldValuesError); return(false); } IssueId = issue.Id; //add attachment if present. if (AspUploadFile.HasFile) { // get the current file var uploadFile = AspUploadFile.PostedFile; string inValidReason; var validFile = IssueAttachmentManager.IsValidFile(uploadFile.FileName, out inValidReason); if (validFile) { if (uploadFile.ContentLength > 0) { byte[] fileBytes; using (var input = uploadFile.InputStream) { fileBytes = new byte[uploadFile.ContentLength]; input.Read(fileBytes, 0, uploadFile.ContentLength); } var issueAttachment = 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 = uploadFile.FileName, IssueId = issue.Id, Size = fileBytes.Length }; if (!IssueAttachmentManager.SaveOrUpdate(issueAttachment)) { Message1.ShowErrorMessage(string.Format(GetGlobalResourceObject("Exceptions", "SaveAttachmentError").ToString(), uploadFile.FileName)); } } } else { Message1.ShowErrorMessage(inValidReason); return(false); } } //create a vote for the new issue var vote = new IssueVote { IssueId = issue.Id, VoteUsername = Security.GetUserName() }; if (!IssueVoteManager.SaveOrUpdate(vote)) { Message1.ShowErrorMessage(Resources.Exceptions.SaveIssueVoteError); return(false); } if (chkNotifyOwner.Checked && !string.IsNullOrEmpty(issue.OwnerUserName)) { var oUser = UserManager.GetUser(issue.OwnerUserName); if (oUser != null) { var notify = new IssueNotification { IssueId = issue.Id, NotificationUsername = oUser.UserName }; IssueNotificationManager.SaveOrUpdate(notify); } } if (chkNotifyAssignedTo.Checked && !string.IsNullOrEmpty(issue.AssignedUserName)) { var oUser = UserManager.GetUser(issue.AssignedUserName); if (oUser != null) { var notify = new IssueNotification { IssueId = issue.Id, NotificationUsername = oUser.UserName }; IssueNotificationManager.SaveOrUpdate(notify); } } //send issue notifications IssueNotificationManager.SendIssueAddNotifications(issue.Id); return(true); }