/// <summary> /// Method to Update an issue /// </summary> /// <param name="updatedIssue"></param> /// <returns></returns> public int UpdateIssue(IssueBase updatedIssue) { //Find the issue from the list, remove it and add the updated issue again to the list. foreach (var issue in allIssues) { if (issue.IssueID == updatedIssue.IssueID) { allIssues.Remove(issue);//Remove Item from the list. break; } } allIssues.Add(updatedIssue); //Log this information if (updatedIssue.IssueTitle.Length > 15) { _objLogHelper.LogInfo($"{updatedIssue.IssueTitle.Substring(0, 15)} ... updated."); } else { _objLogHelper.LogInfo($"{updatedIssue.IssueTitle} ... updated."); } return(updatedIssue.IssueID); }
/// <summary> /// Save - Adds a new issue or update existing issue. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { bool newIssue = false; string type = cmbType.SelectedItem.ToString(); //Get the issue type from Issue Type Combobox if (issueToSave == null) //IssueToSave null means, we are creating a new Issue object. { newIssue = true; switch (type) { case "Operational": issueToSave = new OperationalIssue(); break; case "Service": issueToSave = new ServiceIssue(); break; case "Engineering": issueToSave = new EngineeringIssue(); break; default: break; } } int issueId; int.TryParse(txtIssueID.Text, out issueId); issueToSave.IssueID = issueId; issueToSave.IssueTitle = txtIssueTitle.Text; issueToSave.IssueDescription = txtIssueDesc.Text; issueToSave.IssueTitle = txtIssueTitle.Text; Priority issuePriority; Enum.TryParse(cmbPriorityList.SelectedItem.ToString(), out issuePriority); issueToSave.IssuePriority = issuePriority; Status issueStatus; Enum.TryParse(cmbStatus.SelectedItem.ToString(), out issueStatus); issueToSave.IssueStatus = issueStatus; if (newIssue) { _issueBiz.AddIssue(issueToSave); } else { _issueBiz.UpdateIssue(issueToSave); } LoadIssues(); }
/// <summary> /// Add an issue /// </summary> /// <param name="orgId"> </param> /// <param name="issue"></param> public HttpResponseMessage PostIssue(string orgId, IssueBase issue) { SetOrganisation(orgId); Auditor.Trace(GetType(), "Request to create issue with Id:={0}, ApplicationId:={1}", issue.Id, issue.ApplicationId); _issueCache.Add(issue); return(Request.CreateResponse(HttpStatusCode.Created, issue)); }
/// <summary> /// Transition the issue /// </summary> /// <param name="issue">Issue</param> /// <param name="transition">string with the transition to use</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Task</returns> public static async Task TransitionAsync(this IssueBase issue, string transition, CancellationToken cancellationToken = default) { var jiraClient = issue.AssociatedJiraClient; var transitions = await jiraClient.Issue.GetTransitionsAsync(issue.Key, cancellationToken); var newTransition = transitions.First(t => string.Equals(t.Name, transition, StringComparison.OrdinalIgnoreCase)); await issue.AssociatedJiraClient.Issue.TransitionAsync(issue.Key, newTransition, cancellationToken); }
/// <summary> /// Clear all fields to Create a new Issue. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNew_Click(object sender, EventArgs e) { issueToSave = null; txtIssueID.Text = ""; txtIssueTitle.Text = ""; txtIssueDesc.Text = ""; cmbPriorityList.SelectedIndex = 0; cmbStatus.SelectedIndex = 0; cmbType.SelectedIndex = 0; dgrdIssues.ClearSelection(); cmbType.Enabled = true; btnResolve.Enabled = false; }
//Method to Add new Issue public int AddIssue(IssueBase issue) { allIssues.Add(issue); //Log this infomation. if (issue.IssueTitle.Length > 15) { _objLogHelper.LogInfo($"{issue.IssueTitle.Substring(0, 15)} ... Added."); } else { _objLogHelper.LogInfo($"{issue.IssueTitle} ... Added."); } return(issue.IssueID); }
/// <summary> /// DataGridView Selection changed event. This gets triggered when a row is selected. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgrdIssues_SelectionChanged(object sender, EventArgs e) { try { if (dgrdIssues.SelectedRows.Count > 0) { int selectedIssueID; int.TryParse(dgrdIssues.SelectedRows[0].Cells[0].Value.ToString(), out selectedIssueID); //---- Get the Actual Issue object from All Issue List. List <IssueBase> allIssues = _issueBiz.GetAllIssues(); foreach (var issue in allIssues) { if (issue.IssueID == selectedIssueID) { issueToSave = issue; break; } } //IssueToSave is now pointing to IssueBase object to update. //Populating Controls txtIssueID.Text = issueToSave.IssueID.ToString(); txtIssueTitle.Text = issueToSave.IssueTitle; txtIssueDesc.Text = issueToSave.IssueDescription; cmbPriorityList.SelectedItem = issueToSave.IssuePriority; cmbStatus.SelectedItem = issueToSave.IssueStatus; cmbType.SelectedItem = _issueBiz.GetIssueType(issueToSave); cmbType.Enabled = false; btnResolve.Enabled = true; } } catch (Exception ex) { _logHelper.LogInfo($"Error Occured"); } }
public void Update(IssueBase issue) { var appIssues = GetCachedIssues(issue.ApplicationId, issue.OrganisationId); lock (appIssues.SyncLock) { //TODO: would be better to have a List<Ref<IssueBase>> and update it directly perhaps var index = appIssues.List.FindIndex(m => m.Id == issue.Id); if (index >= 0) { Trace("Updating issue in cache at index {0} with Id:={1}", index, issue.Id); appIssues.List[index] = issue; } else { Error("Adding new issue to cache (from update method!) with Id:-{0}", issue.Id); appIssues.List.Add(issue); } OrderIssues(appIssues); } }
public void Add(IssueBase issue) { var appIssues = GetCachedIssues(issue.ApplicationId, issue.OrganisationId); lock (appIssues.SyncLock) { var index = appIssues.List.FindIndex(m => m.Id == issue.Id); if (index == -1) { Trace("Adding new issue to cache with Id:-{0}", issue.Id); appIssues.List.Add(issue); //TODO: would be more efficient to go through the list looking for the right spot to add the new issue } else { Error("Updating issue in cache (from add method!) at index {0} with Id:={1}", index, issue.Id); appIssues.List[index] = issue; } OrderIssues(appIssues); } }
//Method to return Issue Type for an issue object. public string GetIssueType(IssueBase issue) { string type = issue.GetType().Name; string result = ""; switch (type) { case "EngineeringIssue": result = "Engineering"; break; case "OperationalIssue": result = "Operational"; break; case "ServiceIssue": result = "Service"; break; default: break; } return(result); }
/// <summary> /// Assign the issue to someone /// </summary> /// <param name="issue">Issue to comment</param> /// <param name="newUser">User to assign to</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Task</returns> public static Task AssignAsync(this IssueBase issue, User newUser, CancellationToken cancellationToken = default) { return(issue.AssociatedJiraClient.Issue.AssignAsync(issue.Key, newUser, cancellationToken)); }
/// <summary> /// Add a comment to the issue /// </summary> /// <param name="issue">Issue to comment</param> /// <param name="comment">string with the comment to add</param> /// <param name="visibility">Visibility optional</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Task</returns> public static Task AddCommentAsync(this IssueBase issue, string comment, Visibility visibility = null, CancellationToken cancellationToken = default) { return(issue.AssociatedJiraClient.Issue.AddCommentAsync(issue.Key, comment, visibility, cancellationToken)); }
/// <summary> /// Transition the issue /// </summary> /// <param name="issue">Issue</param> /// <param name="transition">string with the transition to use</param> /// <param name="cancellationToken">CancellationToken</param> /// <returns>Task</returns> public static Task TransitionAsync(this IssueBase issue, Transition transition, CancellationToken cancellationToken = default) { return(issue.AssociatedJiraClient.Issue.TransitionAsync(issue.Key, transition, cancellationToken)); }
/// <summary> /// Method to Resolve the issue /// </summary> /// <param name="issue"></param> public void ResolveIssue(IssueBase issue) { string message = issue.ResolveIssue(); _objLogHelper.LogInfo(message); }