//cheapest bars public async Task CheapestBars(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; string loc = ""; if (message.Text.ToLower() == "no") { await context.PostAsync("I hope i was helful \n Enjoy the rest!!!"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("I hope i was helful \n Enjoy the rest"); context.Wait(redirect); } else if (loc != null) { EditDistance distance = new EditDistance(message.Text); loc = distance.Location(); SqlConnection connection = new SqlConnection("Data Source=CHRISTOS\\SQLEXPRESS;Initial Catalog=Tourist;Integrated Security=True"); SqlCommand cmd = new SqlCommand(); connection.Open(); cmd = new SqlCommand(" select * from Bars Where City ='" + loc.ToUpper() + "' ORDER BY Price_rate ASC ", connection); SqlDataReader reader = cmd.ExecuteReader(); if (!reader.Read()) { await context.PostAsync("The district that you provide does not exist. \n Please try again!!"); context.Wait(CheapestBars); } else { await context.PostAsync("Here is the cheapest bars in order....."); while (reader.Read()) { String msg = " Bar Name: " + reader[1].ToString() + "\nAddress :" + reader[2].ToString() + "\nCity: " + reader[3].ToString() + "\nPricing rate: " + reader[6].ToString() + "/5"; await context.PostAsync(msg); } await Task.Delay(4000); await context.PostAsync("Do you want any other district??"); context.Wait(CheapestBars); } } }
public async Task RestaurantsInfo(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; string loc = ""; if (message.Text.ToLower() == "no") { await context.PostAsync("Have a nice day!!!"); } else if (message.Text.ToLower() == "yes") { context.Wait(RestaurantsInfo); } else if (loc != null) { EditDistance distance = new EditDistance(message.Text); loc = distance.Location(); SqlConnection connection = new SqlConnection("Data Source=CHRISTOS\\SQLEXPRESS;Initial Catalog=Tourist;Integrated Security=True"); SqlCommand cmd = new SqlCommand(); connection.Open(); cmd = new SqlCommand("SELECT * FROM Restaurant WHERE City = '" + loc.ToLower() + "'", connection); SqlDataReader reader = cmd.ExecuteReader(); if (!reader.Read()) { await context.PostAsync("The district that you provide does not exist \n Please try again!!"); context.Wait(CheapestRestaurants); } else { await context.PostAsync("Here is my recommendations....."); while (reader.Read()) { String msg = " Restaurant Name: " + reader[1].ToString() + "\nAddress :" + reader[2].ToString() + "\nCity: " + reader[3].ToString() + "\nPhone: " + reader[4].ToString() + "\n Rate:" + reader[5].ToString() + "/5"; await context.PostAsync(msg); } await Task.Delay(6000); await context.PostAsync("Do you want any other district??"); } } }
//*********INFORMATIONS ABOUT PLACES********* public async Task MuseumsInfo(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; string loc = ""; if (message.Text.ToLower() == "no") { await context.PostAsync("I hope i was helpful.\n Enjoy the rest!!!"); } else if (loc != null) { EditDistance distance = new EditDistance(message.Text); loc = distance.Location(); SqlConnection connection = new SqlConnection("Data Source=CHRISTOS\\SQLEXPRESS;Initial Catalog=Tourist;Integrated Security=True"); SqlCommand cmd = new SqlCommand(); connection.Open(); cmd = new SqlCommand("SELECT * FROM Museum WHERE City = '" + loc.ToLower() + "'", connection); SqlDataReader reader = cmd.ExecuteReader(); if (!reader.Read()) { await context.PostAsync("The district that you provide does not exist. \n Please try again!!"); context.Wait(CheapestRestaurants); } else { await context.PostAsync("Here is my recommendations....."); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Here is my recomontations"); while (reader.Read()) { String msg = " Museum Name: " + reader[1].ToString() + "\nCity :" + reader[2].ToString() + "\nAddress: " + reader[3].ToString() + "\nPhone: " + reader[4].ToString(); await context.PostAsync(msg); } await Task.Delay(6000); await context.PostAsync("Do you want any other district??"); context.Wait(MuseumsInfo); } } }
//current location function public async Task LocationsCoordinates(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; string loc = ""; if (message.Text == "no") { await context.PostAsync("Have a nice day!!!"); } else if (message.Text == "yes" || message.Text == "yeah") { await context.PostAsync("Choose one of the two categories: \n--> Distances \n-->Nearest places "); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Choose one of the two categories:"); context.Wait(ChooseMsg); } else if (message.Text != null) { EditDistance distance = new EditDistance(message.Text); loc = distance.Location(); SqlConnection connection = new SqlConnection("Data Source=CHRISTOS\\SQLEXPRESS;Initial Catalog=Tourist;Integrated Security=True"); SqlCommand cmd = new SqlCommand(); connection.Open(); cmd = new SqlCommand("SELECT * FROM Location WHERE Town = '" + message.Text.ToLower() + "'", connection); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { await context.PostAsync("Here is your Coordinates\n Use them when it requires....."); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Here is your Coordinates\n Use them when it requires"); String msg = "Your Latitude is: '" + reader[3] + "' \n Your Longitude is: '" + reader[4]; await context.PostAsync(msg); Slat = Convert.ToDouble(reader[3].ToString()); Slng = Convert.ToDouble(reader[4].ToString()); await Task.Delay(3000); await context.PostAsync("Do you want use them now?"); SpeechSynthesizer sound1 = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound1.Speak("Do you want use them now?"); } else if (!reader.Read()) { await context.PostAsync("Sorry you provide false Town!!\n Please try again"); context.Wait(LocationsCoordinates); } } }
//****the bellow function is for the answer choice****** public async Task ChooseMsg(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; EditDistance distance = new EditDistance(message.Text); String answer = distance.Similarity(); if (answer == "distances") { await context.PostAsync("Choose a place:" + "\n -Museums \n -Restaurants \n -Bars "); } else if (answer == "museums") { await context.PostAsync("Give your Latitude:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Give your Latitude:"); context.Wait(DistanceMuseumsLat); } else if (answer == "restaurants") { await context.PostAsync("Give your Latitude:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Give your Latitude:"); context.Wait(DistanceRestaurantsLat); } else if (answer == "bars") { await context.PostAsync("Do you like to use your latitude?"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Give your Latitude:"); context.Wait(DistanceBarsLat); } else if (answer == "nearest places") { await context.PostAsync("what places do you want? " + "\n -Nearest-Museums \n -Nearest-Restaurants \n -Nearest-Bars"); } else if (answer == "nearest-museums") { await context.PostAsync("Give your Latitude:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Give your Latitude:"); context.Wait(NearestMuseumsLat); } else if (answer == "nearest-restaurants") { await context.PostAsync("Give your Latitude:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Give your Latitude:"); context.Wait(NearestRestaurantLat); } else if (answer == "nearest-bars") { await context.PostAsync("Give your Latitude:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Give your Latitude:"); context.Wait(NearestBarsLat); } else if (answer == "cheapest places") { await context.PostAsync("What places do you want to know for?" + "\n -Cheapest-Restaurants \n -Cheapest-Bars"); } else if (answer == "cheapest-restaurants") { await context.PostAsync("Please provide a district:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Please provide a city:"); context.Wait(CheapestRestaurants); } else if (answer == "cheapest-bars") { await context.PostAsync("Please provide a district:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Please provide a city:"); context.Wait(CheapestBars); } else if (answer == "informations") { await context.PostAsync("what places information do you want for? " + "\n -Museums-Info \n -Restaurants-Info \n -Bars-Info"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("what places information do you want for?"); } else if (answer == "museums-info") { await context.PostAsync("Please provide a district:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Please provide a district:"); context.Wait(MuseumsInfo); } else if (answer == "restaurants-info") { await context.PostAsync("Please provide a district:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Please provide a city:"); context.Wait(RestaurantsInfo); } else if (message.Text == "bars-info") { await context.PostAsync("Please provide a district:"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Please provide a district:"); context.Wait(BarsInfo); } else if (answer == "location") { await context.PostAsync("Please provide your current town: "); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Please provide your town:"); context.Wait(LocationsCoordinates); } else { await context.PostAsync("Sorry i couldn't understand!! \n Please select one of the following options:\n-My location \n-Distances \n-Nearest places \nCheapest-places \n-Informations"); SpeechSynthesizer sound = new SpeechSynthesizer(); //Add System.Speech Reference First In Order To Creating It. sound.Speak("Sorry i couldn't understand. Please select one of the following options: "); context.Wait(ChooseMsg); } }