Exemple #1
0
        public async Task Detalis(IDialogContext context, LuisResult result)
        {
            string placeA = this.startstation;
            string placeB = this.endstation;

            //Item 1 is Name and Item2 is the SiteID Needed for the next API call.
            var start = Sl.slPlace(placeA);

            var end = Sl.slPlace(placeB);

            var route     = Sl.slRoute(start.Item2.ToString(), end.Item2.ToString(), end.Item1.ToString());
            var routedata = (JObject)JsonConvert.DeserializeObject(route.Item1);
            var lista     = new List <JToken>();
            var lista2    = new List <string>();

            lista.Add(routedata["Trip"][0]["LegList"]["Leg"]);

            Console.WriteLine(routedata);
            var    newjson        = JsonConvert.DeserializeObject <RootObject>(route.Item1);
            string endStation     = newjson.Trip[0].LegList.Leg[0].Destination.name.ToString();
            string endStationTime = newjson.Trip[0].LegList.Leg[0].Destination.time.ToString();



            try
            {
                JToken byte1 = Sl.formatter(lista[0][0]);
                await context.PostAsync(byte1.ToString());

                JToken byte2 = Sl.formatter(lista[0][1]);
                await context.PostAsync(byte2.ToString());

                JToken byte3 = Sl.formatter(lista[0][2]);
                await context.PostAsync(byte3.ToString());

                JToken byte4 = Sl.formatter(lista[0][3]);
                await context.PostAsync(byte4.ToString());

                JToken byte5 = Sl.formatter(lista[0][4]);
                await context.PostAsync(byte5.ToString());

                JToken byte6 = Sl.formatter(lista[0][5]);
                await context.PostAsync(byte6.ToString());

                JToken byte7 = Sl.formatter(lista[0][6]);
                await context.PostAsync(byte7.ToString());
            }
            catch (Exception)
            {
            }
            await this.SlButtons(context, result, endStation, endStationTime);
        }
Exemple #2
0
        public async Task slBot(IDialogContext context, LuisResult result)
        {
            //Gets the quesry and splits/formats the string to get start and stop sites.
            var    valuesEntity = result.Query.ToString();
            string s            = "";

            s = valuesEntity.ToString();

            string[] words  = s.Split(' ');
            string   placeA = words[1];
            string   placeB = words[2];

            this.startstation = placeA;
            this.endstation   = placeB;

            //First API Call to get Site ID from name
            //Item 1 is Name and Item2 is the SiteID Needed for the next API call.
            var start = Sl.slPlace(placeA);

            var end = Sl.slPlace(placeB);

            //2ns API call to get route from A to B
            var route = Sl.slRoute(start.Item2.ToString(), end.Item2.ToString(), end.Item1.ToString());
            //To Json object/class
            var routedata = (JObject)JsonConvert.DeserializeObject(route.Item1);
            var lista     = new List <JToken>();
            var lista2    = new List <string>();

            lista.Add(routedata["Trip"][0]["LegList"]["Leg"]);

            //Define parameters from result
            Console.WriteLine(routedata);
            var newjson = JsonConvert.DeserializeObject <RootObject>(route.Item1);

            string endStation = newjson.Trip[0].LegList.Leg[0].Destination.name.ToString();

            string endStationTime = newjson.Trip[0].LegList.Leg[0].Destination.time.ToString();

            string startStation = newjson.Trip[0].LegList.Leg[0].Origin.name.ToString();

            string startVehicle = newjson.Trip[0].LegList.Leg[0].name.ToString();

            string startTime = newjson.Trip[0].LegList.Leg[0].Origin.time.ToString();

            await context.PostAsync(startTime + " " + startVehicle + " > " + startStation);

            await this.SlButtons(context, result, endStation, endStationTime);
        }