Beispiel #1
0
        private async Task HandleMessage(IDialogContext context, IMessageActivity message)
        {
            if (message.Text != null && message.Text.Contains("Show aircraft by Id"))
            {
                //var reply = context.MakeMessage();
                var      reply         = (Activity)message;
                Activity replyActivity = reply.CreateReply();
                var      actionId      = Guid.NewGuid().ToString();
                var      flightnumber  = System.Text.RegularExpressions.Regex.Match(message.Text, @"\(([^)]*)\)").Groups[1].Value;
                var      list          = await DocumentDBRepository <AirCraftInfo> .GetItemsAsync(d => d.AircraftId == flightnumber);

                var aircraftInfoCard = O365CardHelper.GetO365ConnectorCardResult(list.FirstOrDefault(), actionId);

                replyActivity.Attachments.Add(aircraftInfoCard.ToAttachment());
                ConnectorClient connector   = new ConnectorClient(new Uri(message.ServiceUrl));
                var             msgToUpdate = await connector.Conversations.ReplyToActivityAsync(replyActivity);

                context.ConversationData.SetValue(actionId, msgToUpdate.Id);
                privateStorage.Add(actionId, msgToUpdate.Id);
                //await context.PostAsync((replyActivity));
            }
            else
            {
                var messageText = message.Text.ToLower();
                var reply       = context.MakeMessage();

                reply.Attachments.Add(GetCardsInformation());

                await context.PostAsync((reply));

                context.Wait(MessageReceivedAsync);
            }
        }
Beispiel #2
0
        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument)
        {
            var message = await argument;

            if (message.Text != null && message.Text.Contains("Show details of flight"))
            {
                var reply        = context.MakeMessage();
                var flightnumber = System.Text.RegularExpressions.Regex.Match(message.Text, @"\(([^)]*)\)").Groups[1].Value;
                var list         = await DocumentDBRepository <FlightInfo> .GetItemsAsync(d => d.FlightNumber == flightnumber);

                var flightresultCard = O365CardHelper.GetO365ConnectorCardResult(list.FirstOrDefault());

                reply.Attachments.Add(flightresultCard.ToAttachment());
                await context.PostAsync((reply));
            }
            else
            {
                var           messageText = message.Text.ToLower();
                var           reply       = context.MakeMessage();
                List <Cities> lst         = new List <Cities>();
                Cities        obj         = new Cities();
                obj.CityName = "Seattle";
                obj.CityCode = "SEA";
                lst.Add(obj);
                Cities obj1 = new Cities();
                obj1.CityName = "Newark";
                obj1.CityCode = "EWR";
                lst.Add(obj1);
                Cities obj3 = new Cities();
                obj3.CityCode = "BWI";
                obj3.CityName = "Washington, DC";
                lst.Add(obj3);
                Cities obj4 = new Cities();
                obj4.CityCode = "BSZ";
                obj4.CityName = "Boston, MA";
                lst.Add(obj4);
                Cities obj5 = new Cities();
                obj5.CityCode = "JFK";
                obj5.CityName = "New York";
                lst.Add(obj5);
                Cities obj6 = new Cities();
                obj6.CityCode = "ORD";
                obj6.CityName = "Chicago";
                lst.Add(obj6);
                var citieslist = lst;
                reply.Attachments.Add(GetCardsInformation(citieslist));

                await context.PostAsync((reply));

                context.Wait(MessageReceivedAsync);
            }
        }
Beispiel #3
0
        private static async Task AttachBaggageInformation(string PNR, Activity replyActivity)
        {
            var list = await DocumentDBRepository <Baggage> .GetItemsAsync(d => d.PNR == PNR);

            if (list.Count() == 0)
            {
                replyActivity.Text = "Baggage with PNR " + PNR + " not found in the system.";
            }
            else
            {
                var replyCard = O365CardHelper.GetO365ConnectorCardResult(list.FirstOrDefault());
                replyActivity.Attachments.Add(replyCard.ToAttachment());
            }
        }
Beispiel #4
0
        private static async Task MarkFreeAirCraft(AirCraftDetails aircardInfo, Activity replyActivity)
        {
            var aircraftInfo = await DocumentDBRepository <AirCraftInfo> .GetItemsAsync(d => d.FlightNumber == aircardInfo.FlightNumber && d.AircraftId == aircardInfo.AircraftId);

            if (aircraftInfo.Count() > 0)
            {
                try
                {
                    var list = aircraftInfo.FirstOrDefault();

                    list.Status = Status.Available;
                    var aircraftDetails = await DocumentDBRepository <AirCraftInfo> .UpdateItemAsync(list.Id, list);

                    var replyCard = O365CardHelper.GetO365ConnectorCardResult(aircraftInfo.FirstOrDefault(), aircardInfo.ActionId);
                    replyActivity.Attachments.Add(replyCard.ToAttachment());
                    //replyActivity.Text = $"Aircraft {aircardInfo.AircraftId} is available";
                }
                catch (Exception e)
                {
                    replyActivity.Text = e.Message.ToString();
                }
            }
        }