コード例 #1
0
        public ActionResult EventandTrainingTab(string id)
        {
            EandTModel eventsListData = new EandTModel();

            eventsListData = GetDataHelper.GetEandT();
            foreach (var item in eventsListData.EventsAndtraining)
            {
                if (item.ETID == id)
                {
                    GetDataHelper.ETStatusUpdate(item.ETID);
                }
            }
            eventsListData = GetDataHelper.GetEandT();
            EventsAndTraining[] EventGrid            = new EventsAndTraining[eventsListData.EventsAndtraining.Length];
            EventsAndTraining[] UpcomingEventGrid    = new EventsAndTraining[eventsListData.EventsAndtraining.Length];
            EventsAndTraining[] TrainingGrid         = new EventsAndTraining[eventsListData.EventsAndtraining.Length];
            EventsAndTraining[] UpcomingTrainingGrid = new EventsAndTraining[eventsListData.EventsAndtraining.Length];
            TrainingGrid         = eventsListData.EventsAndtraining.Where(i => i.UserAdded == true).ToArray();
            UpcomingTrainingGrid = eventsListData.EventsAndtraining.Where(i => i.UserAdded == false).ToArray();
            EventGrid            = eventsListData.EventsAndtraining.Where(i => i.UserAdded == true).ToArray();
            UpcomingEventGrid    = eventsListData.EventsAndtraining.Where(i => i.UserAdded == false).
                                   Where(i => i.UserAdded == false).ToArray();
            EventGrid                        = TrainingGrid;
            UpcomingEventGrid                = UpcomingTrainingGrid;
            eventsListData.EventGrid         = EventGrid;
            eventsListData.UpcomingEventGrid = UpcomingEventGrid;
            return(View(eventsListData));
        }
コード例 #2
0
        private async Task <HttpResponseMessage> HandleInvokeActivity(Activity activity)
        {
            var    activityValue = activity.Value.ToString();
            string ETid;

            Models.TaskInfo     taskInfo;
            Models.TaskEnvelope taskEnvelope;
            switch (activity.Name)
            {
            case "signin/verifyState":
                await Conversation.SendAsync(activity, () => new RootDialog());

                break;

            case "composeExtension/query":
                // Handle fetching task module content
                var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                var response  = MessageExtension.HandleMessageExtensionQuery(connector, activity);
                return(response != null?Request.CreateResponse <ComposeExtensionResponse>(response) : new HttpResponseMessage(HttpStatusCode.OK));

            case "task/fetch":
                // Handle fetching task module content
                string action = string.Empty;

                try
                {
                    var input = JsonConvert.DeserializeObject <TaskFetchData>(activityValue);
                    action = input.data.data;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    // action = JsonConvert.DeserializeObject<Models.BotFrameworkCardValue<string>>(activityValue);
                }
                taskInfo = GetTaskInfo(action);

                taskEnvelope = new Models.TaskEnvelope
                {
                    Task = new Models.Task()
                    {
                        Type     = Models.TaskType.Continue.ToString().ToLower(),
                        TaskInfo = taskInfo
                    }
                };
                return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));

            case "task/submit":
                string taskId = JsonConvert.DeserializeObject <TaskModuleSubmitData <TicketTaskData> >(activityValue).Data.action;
                //string commandid = details.commandId;
                switch (taskId)
                {
                case "ticketcomplete":
                    var createTicketData = JsonConvert.DeserializeObject <SubmitActionData <TicketTaskData> >(activityValue).data;
                    taskInfo = GetTaskInfo(taskId);
                    var ticketurl = "?ticketNoId=" + createTicketData.ticketNo + "&description=" + createTicketData.TDescription + "&category=" + createTicketData.TCategory + "&priority=" + createTicketData.TPriority;
                    taskInfo.Url         = taskInfo.Url + ticketurl;
                    taskInfo.FallbackUrl = taskInfo.FallbackUrl + ticketurl;

                    taskEnvelope = new Models.TaskEnvelope
                    {
                        Task = new Models.Task()
                        {
                            Type     = Models.TaskType.Continue.ToString().ToLower(),
                            TaskInfo = taskInfo
                        }
                    };

                    return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));

                case "podecline":
                    var podeclineData = JsonConvert.DeserializeObject <SubmitActionData <PODeclineData> >(activityValue).data;
                    taskInfo = GetTaskInfo(taskId);
                    var declineUrl = "?poNo=" + podeclineData.poNumber;
                    taskInfo.Url         = taskInfo.Url + declineUrl;
                    taskInfo.FallbackUrl = taskInfo.FallbackUrl + declineUrl;

                    taskEnvelope = new Models.TaskEnvelope
                    {
                        Task = new Models.Task()
                        {
                            Type     = Models.TaskType.Continue.ToString().ToLower(),
                            TaskInfo = taskInfo
                        }
                    };

                    return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));

                case "decline":
                    var declineData = JsonConvert.DeserializeObject <SubmitActionData <DeclineData> >(activityValue).data;
                    taskId   = "declined";
                    taskInfo = GetTaskInfo(taskId);
                    var decUrl = "?poNo=" + declineData.PONo + "&reason=" + declineData.reason + "&comment=" + declineData.comments;
                    taskInfo.Url         = taskInfo.Url + decUrl;
                    taskInfo.FallbackUrl = taskInfo.FallbackUrl + decUrl;

                    taskEnvelope = new Models.TaskEnvelope
                    {
                        Task = new Models.Task()
                        {
                            Type     = Models.TaskType.Continue.ToString().ToLower(),
                            TaskInfo = taskInfo
                        }
                    };

                    return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));

                case "editVisitorRequest":
                    taskInfo     = GetTaskInfo(taskId);
                    taskEnvelope = new Models.TaskEnvelope
                    {
                        Task = new Models.Task()
                        {
                            Type     = Models.TaskType.Continue.ToString().ToLower(),
                            TaskInfo = taskInfo
                        }
                    };
                    return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));

                case "editTicket":

                    taskInfo     = GetTaskInfo(taskId);
                    taskEnvelope = new Models.TaskEnvelope
                    {
                        Task = new Models.Task()
                        {
                            Type     = Models.TaskType.Continue.ToString().ToLower(),
                            TaskInfo = taskInfo
                        }
                    };

                    return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));

                case "sendrequest":
                    var savevisitordata = JsonConvert.DeserializeObject <SubmitActionData <VisitorData> >(activityValue).data;
                    taskInfo = GetTaskInfo(taskId);
                    var vurl = "?Date=" + savevisitordata.Vdate + "&Time=" + savevisitordata.Vtime + "&Contact=" + savevisitordata.Vcontact + "&location=" + savevisitordata.VhostLocation + "&purpose=" + savevisitordata.Vpurpose + "&hostName=" + savevisitordata.VhostName + "&org=" + savevisitordata.Vorg;
                    taskInfo.Url         = taskInfo.Url + vurl;
                    taskInfo.FallbackUrl = taskInfo.FallbackUrl + vurl;

                    taskEnvelope = new Models.TaskEnvelope
                    {
                        Task = new Models.Task()
                        {
                            Type     = Models.TaskType.Continue.ToString().ToLower(),
                            TaskInfo = taskInfo
                        }
                    };

                    return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));

                case TaskModuleIds.toggleEventStatus:
                    // TODO Event - EventTaskData
                    var eventData = JsonConvert.DeserializeObject <SubmitActionData <EventTaskData> >(activityValue).data;

                    //will update the button action Added<->Removed
                    GetDataHelper.ETStatusUpdate(eventData.eventId);
                    return(new HttpResponseMessage(HttpStatusCode.Accepted));

                default:         // Handled all remaining cases for task module. Ex-  Close, PoDeclinedClosed
                    return(Request.CreateResponse(HttpStatusCode.OK));
                }

            case "composeExtension/submitAction":

                var    details   = JsonConvert.DeserializeObject <SubmitActionData>(activityValue);
                string commandid = details.commandId;
                switch (details.commandId)
                {
                case "createticket":
                    var createTicketData = JsonConvert.DeserializeObject <SubmitActionData <TicketTaskData> >(activityValue);
                    if (createTicketData.data == null)
                    {
                        commandid    = details.commandId;
                        taskInfo     = GetTaskInfo(commandid);
                        taskEnvelope = new Models.TaskEnvelope
                        {
                            Task = new Models.Task()
                            {
                                Type     = Models.TaskType.Continue.ToString().ToLower(),
                                TaskInfo = taskInfo
                            }
                        };

                        return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));
                    }
                    else if (createTicketData.data.action == "submit")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else if (createTicketData.data.action == "submitTicket")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        commandid = createTicketData.data.action;
                        taskInfo  = GetTaskInfo(commandid);
                        var ticketurl = "?ticketNoId=" + createTicketData.data.ticketNo + "&description=" + createTicketData.data.TDescription + "&category=" + createTicketData.data.TCategory + "&priority=" + createTicketData.data.TPriority;
                        taskInfo.Url         = taskInfo.Url + ticketurl;
                        taskInfo.FallbackUrl = taskInfo.FallbackUrl + ticketurl;
                        taskEnvelope         = new Models.TaskEnvelope
                        {
                            Task = new Models.Task()
                            {
                                Type     = Models.TaskType.Continue.ToString().ToLower(),
                                TaskInfo = taskInfo
                            }
                        };

                        return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));
                    }

                case "visitorregistration":
                    var savevisitordata = JsonConvert.DeserializeObject <SubmitActionData <VisitorData> >(activityValue);

                    if (savevisitordata.data == null)
                    {
                        commandid    = details.commandId;
                        taskInfo     = GetTaskInfo(commandid);
                        taskEnvelope = new Models.TaskEnvelope
                        {
                            Task = new Models.Task()
                            {
                                Type     = Models.TaskType.Continue.ToString().ToLower(),
                                TaskInfo = taskInfo
                            }
                        };

                        return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));
                    }
                    else if (savevisitordata.data.action == "submitVisitor")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else if (savevisitordata.data.action == "submitRequest")
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        commandid = savevisitordata.data.action;
                        taskInfo  = GetTaskInfo(commandid);
                        var ticketurl = "?Date=" + savevisitordata.data.Vdate + "&Time=" + savevisitordata.data.Vtime + "&Contact=" + savevisitordata.data.Vcontact + "&location=" + savevisitordata.data.VhostLocation + "&purpose=" + savevisitordata.data.Vpurpose + "&hostName=" + savevisitordata.data.VhostName + "&org=" + savevisitordata.data.Vorg;
                        taskInfo.Url         = taskInfo.Url + ticketurl;
                        taskInfo.FallbackUrl = taskInfo.FallbackUrl + ticketurl;
                        taskEnvelope         = new Models.TaskEnvelope
                        {
                            Task = new Models.Task()
                            {
                                Type     = Models.TaskType.Continue.ToString().ToLower(),
                                TaskInfo = taskInfo
                            }
                        };

                        return(Request.CreateResponse(HttpStatusCode.OK, taskEnvelope));
                    }

                default:
                    commandid = details.commandId;
                    break;
                }
                break;

            case "composeExtension/onCardButtonClicked":
                ETid = JsonConvert.DeserializeObject <Models.TaskModuleSubmitData <string> >(activityValue).Data;
                GetDataHelper.ETStatusUpdate(ETid);
                break;
            }
            return(new HttpResponseMessage(HttpStatusCode.Accepted));
        }