Ejemplo n.º 1
0
        public void CreateAndCommentJiraTicket()
        {
            string loc      = Assembly.GetExecutingAssembly().Location;
            string location = Path.GetDirectoryName(loc);

            ConfigController cfg = new ConfigController(location);

            if (cfg.LoadConfig())
            {
                JiraController jc = jc = new JiraController(
                    cfg.Get("Jira", "User", "Unknow"),
                    cfg.Get("Jira", "Pwd", "???"),
                    cfg.Get("Jira", "Url", "https://localhost/"),
                    cfg.Get("Jira", "Assignee", string.Empty)
                    );
                JiraResponce responce = jc.CreateTicket("ICR", "Critical", "The test title", "The test Body", JiraIssueTypeConst.Bug);
                Assert.IsNotNull(responce.id);
                responce = jc.AddComment(responce.key, "Test add comment to created ticket");
                Assert.IsNotNull(responce.id);
            }
        }
        private async Task ResumeAfterIncidentCommentFormDialog(IDialogContext context, IAwaitable <AddIncidentCommentQuery> result)
        {
            try
            {
                AddIncidentCommentQuery query = await result;
                if (query.TicketId == null)
                {
                    query.TicketId = ticketNumber.Entity;
                }

                JiraController jc      = new JiraController();
                bool           isAdded = jc.AddComment(query, query.TicketId.Replace(" ", ""));

                string message = isAdded ? "Comment added successfully to incident " + query.TicketId.Replace(" ", "") + "." : "There was an error while adding your worklog item. Please contact your administrator";

                await context.PostAsync(message);
            }
            catch (FormCanceledException ex)
            {
                string reply;

                if (ex.InnerException == null)
                {
                    reply = "You have canceled the operation.";
                }
                else
                {
                    reply = $"Oops! Something went wrong :( Technical Details: {ex.InnerException.Message}";
                }

                await context.PostAsync(reply);
            }
            finally
            {
                context.Done <object>(null);
            }
        }