Exemplo n.º 1
0
        public static TaskEnvelope ImpactAddEnvelope()
        {
            var response = new TaskEnvelope
            {
                Task = new TaskProperty()
                {
                    Type     = "continue",
                    TaskInfo = new TaskInfo()
                    {
                        Title  = "IncidentAdded",
                        Height = "small",
                        Width  = 500,
                        Card   = new Attachment
                        {
                            ContentType = AdaptiveCard.ContentType,
                            Content     = ImpactTrackerResponseCard("Incident has been created")
                        }
                    }
                }
            };

            return(response);
        }
Exemplo n.º 2
0
        public static TaskEnvelope GetUserInput()
        {
            var response = new TaskEnvelope
            {
                Task = new TaskProperty()
                {
                    Type     = "continue",
                    TaskInfo = new TaskInfo()
                    {
                        Title  = "GetUserInput",
                        Height = "medium",
                        Width  = 500,
                        Card   = new Attachment
                        {
                            ContentType = AdaptiveCard.ContentType,
                            Content     = TicketDialogHelper.CreateIncidentAdaptiveCard()
                        }
                    }
                }
            };

            return(response);
        }
        private async Task <HttpResponseMessage> HandleInvokeMessagesAsync(Activity activity, CancellationToken cancellationToken)
        {
            var activityValue = activity.Value.ToString();

            if (activity.Name == "task/fetch")
            {
                JToken       data         = JObject.Parse(activityValue).First.First;
                var          message      = Convert.ToString(data.SelectToken("text"));
                TaskEnvelope taskEnvelope = new TaskEnvelope();
                TaskInfo     taskInfo     = new TaskInfo();

                // Employee time off requests - pending request approval task module
                if (message.ToLowerInvariant() == Constants.TorListOpenModal.ToLowerInvariant())
                {
                    var        card       = this.GetTORApprovalCard(data);
                    Attachment attachment = new Attachment()
                    {
                        ContentType = AdaptiveCard.ContentType,
                        Content     = card,
                    };

                    taskInfo.Card            = attachment;
                    taskInfo.Height          = "large";
                    taskInfo.Width           = "medium";
                    taskInfo.Title           = KronosResourceText.ManagerViewTOR_Title;
                    taskInfo.CompletionBotId = AppSettings.Instance.MicrosoftAppId;
                    taskEnvelope.Task        = new TaskDetail()
                    {
                        Type     = "continue",
                        TaskInfo = taskInfo,
                    };
                    return(this.Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));
                }
            }
            else if (activity.Name == "task/submit")
            {
                JToken data = JObject.Parse(activityValue).First.First;
                try
                {
                    var message = Convert.ToString(data.SelectToken("msteams").SelectToken("text"));
                    if (message.ToLowerInvariant() == Constants.TORApproveRequest.ToLowerInvariant() || message.ToLowerInvariant() == Constants.TORRefuseRequest.ToLowerInvariant())
                    {
                        var tempAct = activity;
                        tempAct.Text = message;
                        tempAct.Type = ActivityTypes.Message;
                        MicrosoftAppCredentials.TrustServiceUrl($"{activity.ServiceUrl}", DateTime.MaxValue);

                        using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, tempAct))
                        {
                            var dialog = scope.Resolve <IDialog <object> >();
                            await Conversation.SendAsync(tempAct, () => dialog, cancellationToken);
                        }
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(new HttpResponseMessage(HttpStatusCode.Accepted));
        }