public ActionResult Submit() { var client = new AdageTracker.JIRA.Implementations.JIRAClientFactory().GetJiraClient(); var issue = client.Issues.GetIssueAsync("ATR-73").Result; var actions = client.Issues.GetActionsAsync("ATR-73").Result; issue.WorkflowTransitionAsync(actions.FirstOrDefault().Name).ConfigureAwait(false); issue.SaveChanges(); var test = new AdageTracker.Slack.Implementations.Factories.SlackClientFactory(); test.PostMessageToAdageTracker(string.Format("Moved Issue: {0} to {1}", issue.Key.Value, issue.Status.Name), "New Bot"); return(RedirectToAction("Index")); }
public IHttpActionResult Test([FromBody] object JiraData) { try { var url = "https://adagetechnologies.atlassian.net/browse/{0}"; var JIRAclient = new AdageTracker.JIRA.Implementations.JIRAClientFactory().GetJiraClient(); var slackClient = new AdageTracker.Slack.Implementations.Factories.SlackClientFactory(); // Debug using (StreamWriter _testData = new StreamWriter("C:/Working/Adage_Tracker/data.txt", true)) { _testData.WriteLine(JiraData); } var data = JIRAWebHookObject.FromJson(JiraData.ToString()); var issue = JIRAclient.Issues.GetIssueAsync(data.Issue.Key).Result; var changeLog = JIRAclient.Issues.GetChangeLogsAsync(data.Issue.Key).Result; if (changeLog.OrderByDescending(c => c.CreatedDate).FirstOrDefault().Items.Any(i => i.FromValue == "Ready for Adage QA" && i.ToValue == "In Progress")) { slackClient.PostMessageToAdageTracker(string.Format("Ticket {0}, failed QA: {1}", data.Issue.Key, string.Format(url, data.Issue.Key)), "FAIL BOT"); } else if (changeLog.OrderByDescending(c => c.CreatedDate).FirstOrDefault().Items.Any(i => i.FromValue == "Ready for Client UAT" && i.ToValue == "In Progress")) { slackClient.PostMessageToAdageTracker(string.Format("Ticket {0}, failed UAT: {1}", data.Issue.Key, string.Format(url, data.Issue.Key)), "FAIL BOT"); } } catch (Exception ex) { using (StreamWriter _testData = new StreamWriter("C:/Working/Adage_Tracker/data.txt", true)) { _testData.WriteLine(ex.Message); // Write the file. } } return(Ok("Success")); }