Проектирование и разработка web-сервиса

Проведение исследования опыта взаимодействия в сети. Методы улучшения согласования с пользователем web-сервиса. Особенность проектирования онлайн-приложения. Изучение разработки контроллеров и моделей. Характеристика создания интерфейса программы.

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык русский
Дата добавления 11.08.2017
Размер файла 1,3 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

List<TravelSolution> TravelSolutions_list = new List<TravelSolution>();

foreach (IWebElement TrS in TravelSolution)

{

TravelSolution NewSolution = new TravelSolution();

NewSolution.originTime = TrS.FindElement(By.CssSelector("tr.firstrow > td.time")).Text;

NewSolution.originStation = TrS.FindElement(By.CssSelector("tr.firstrow > td.station.first")).Text;

NewSolution.destinationeTime = TrS.FindElement(By.CssSelector("tr.last > td.time")).Text;

NewSolution.destinationStation = TrS.FindElement(By.CssSelector("tr.last > td.station.stationDest")).Text;

NewSolution.duration = TrS.FindElement(By.CssSelector("tr.firstrow > td.duration.lastrow")).Text;

NewSolution.price = TrS.FindElement(By.CssSelector("tr.firstrow > td.farePep.lastrow.button-inside.tablebutton.borderright > span > span > span")).Text + ", " + TrS.FindElement(By.CssSelector("tr.firstrow > td.fareStd.lastrow.button-inside.tablebutton > span > span")).Text;

TravelSolutions_list.Add(NewSolution);

}

string json = JsonConvert.SerializeObject(TravelSolutions_list);

return json;

}

}

}

public class Renfe : Railway // Испания

{

public string Json()

{

var driverService = ChromeDriverService.CreateDefaultService();

driverService.HideCommandPromptWindow = true;

var options = new ChromeOptions();

options.AddArgument("--window-position=-32000,-32000");

var driver = new ChromeDriver(driverService, options);

using (driver)

{

driver.Navigate().GoToUrl("http://www.renfe.com/EN/viajeros/index.html");

IWebElement originStation = driver.FindElement(By.CssSelector("#IdOrigen"));

originStation.SendKeys(this.originStation);

originStation.SendKeys(Keys.Down);

originStation.SendKeys(Keys.Tab);

IWebElement depatureStation = driver.FindElement(By.CssSelector("#IdDestino"));

depatureStation.SendKeys(this.arrivalStaton);

depatureStation.SendKeys(Keys.Down);

depatureStation.SendKeys(Keys.Tab);

IWebElement date = driver.FindElement(By.CssSelector("#__fechaIdaVisual"));

date.Clear();

string D = this.Data.Substring(3).Remove(3);

string M = this.Data.Remove(2);

string Y = this.Data.Substring(5);

string str = D + M + Y;

date.SendKeys(str);

//IWebElement time = driver.FindElement(By.Id("departureTimeText"));

//time.Clear();

//time.SendKeys("08");

IWebElement adults = driver.FindElement(By.CssSelector("#__numAdultos"));

adults.Clear();

adults.SendKeys(this.Adults);

IWebElement search = driver.FindElement(By.CssSelector("#datosBusqueda > button"));

search.SendKeys(Keys.Enter);

System.Threading.Thread.Sleep(5000);

IWebElement TravelSolutions = driver.FindElement(By.CssSelector("#listaTrenesTBodyIda"));

IList<IWebElement> TraveSolution = TravelSolutions.FindElements(By.CssSelector("tr[id ^= 'tren']"));

List<TravelSolution> TravelSolutions_list = new List<TravelSolution>();

foreach (IWebElement TrS in TraveSolution)

{

TravelSolution NewSolution = new TravelSolution();

NewSolution.originTime = TrS.FindElement(By.CssSelector("td:nth-child(2) > span")).Text; //

NewSolution.originStation = this.originStation;

NewSolution.destinationeTime = TrS.FindElement(By.CssSelector("td:nth-child(3) > span")).Text; //

NewSolution.destinationStation = this.arrivalStaton;

NewSolution.duration = TrS.FindElement(By.CssSelector("td:nth-child(4) > span")).Text; //

try

{

NewSolution.price = TrS.FindElement(By.CssSelector("button[id ^= 'trenButton']")).Text;

}

catch

{

NewSolution.price = "Null";

}

TravelSolutions_list.Add(NewSolution);

}

string json = JsonConvert.SerializeObject(TravelSolutions_list);

return json;

}

}

}

public class SBB : Railway // швейцария

{

public string Json()

{

using (var driver = new ChromeDriver())

{

driver.Navigate().GoToUrl("http://www.sbb.ch/en/home.html");

IWebElement originStation = driver.FindElement(By.CssSelector("#fromField"));

originStation.SendKeys(this.originStation);

IWebElement depatureStation = driver.FindElement(By.CssSelector("#toField"));

depatureStation.SendKeys(this.arrivalStaton);

//IWebElement date = driver.FindElement(By.CssSelector("#combo_datetimepicker > div.mod_datepicker.var_arrows.var_icon"));

//date.Clear();

//string D = this.Data.Substring(3).Remove(2);

//string M = this.Data.Remove(2);

//string Y = this.Data.Substring(6);

//string str = D + "." + M + "." + Y;

//date.SendKeys(str);

IWebElement time = driver.FindElement(By.CssSelector("#timepicker"));

time.Clear();

time.SendKeys(this.Time);

IWebElement search = driver.FindElement(By.CssSelector("#checkoutForm > fieldset.mod_fieldset.mod_fieldset_section.var_secondline > div > div.mod_group.mod_timetable_input_form_buttonwrapper > button"));

search.Submit();

System.Threading.Thread.Sleep(3000);

IList<IWebElement> TravelSolution = driver.FindElements(By.CssSelector("div[id ^= 'shopForm_aktuelleVerbindungen_']"));

List<TravelSolution> TravelSolutions_list = new List<TravelSolution>();

foreach (IWebElement TrS in TravelSolution)

{

TravelSolution NewSolution = new TravelSolution();

try

{

NewSolution.originStation = this.originStation;

NewSolution.destinationStation = this.arrivalStaton;

NewSolution.price = "Null";

IWebElement verbindung = TrS.FindElement(By.CssSelector("div.mod_timetable_summary"));

NewSolution.originTime = verbindung.FindElement(By.CssSelector("div.mod_timetable_section > div > div.mod_timetable_pearl_chain_container > div.mod_timetable_starttime > span:nth-child(2)")).Text;

NewSolution.destinationeTime = verbindung.FindElement(By.CssSelector("div.mod_timetable_section > div > div.mod_timetable_pearl_chain_container > div.mod_timetable_endtime > span:nth-child(2)")).Text;

NewSolution.duration = verbindung.FindElement(By.CssSelector("div.mod_timetable_section2 > div.mod_timetable_duration > span:nth-child(2)")).Text;

}

catch

{

break;

}

TravelSolutions_list.Add(NewSolution);

}

string json = JsonConvert.SerializeObject(TravelSolutions_list);

return json;

}

}

}

public class Sncf : Railway // франция

{

public string Json()

{

using (var driver = new ChromeDriver())

{

driver.Navigate().GoToUrl("https://railengine.ru.voyages-sncf.com/railengine");

IWebElement DepartStation = driver.FindElement(By.Name("re_origincityname"));

DepartStation.Clear();

DepartStation.SendKeys(this.originStation);

IWebElement ArriveStation = driver.FindElement(By.Name("re_destinationcityname"));

ArriveStation.Clear();

ArriveStation.SendKeys(this.arrivalStaton);

IWebElement Date = driver.FindElement(By.Name("re_departuredate"));

Date.Clear();

string D = this.Data.Substring(3).Remove(3);

string M = this.Data.Remove(2);

string Y = this.Data.Substring(5);

string str = D + M + Y;

Date.SendKeys(str);

IWebElement time = driver.FindElement(By.Name("re_departuredate_hour"));

IList<IWebElement> Times = time.FindElements(By.TagName("option"));

foreach (IWebElement T in Times)

{

if (T.Text == this.Time)

{

T.Click();

break;

}

}

IWebElement search = driver.FindElement(By.CssSelector("#ptpsearchform-search"));

search.Submit();

IWebElement TravelSolutions = driver.FindElement(By.CssSelector("#ptpresult > div.railengine-main-content > div.ptpresult-solutions.box.box-shadow"));

IList<IWebElement> TravelSolution = TravelSolutions.FindElements(By.CssSelector("div[id ^= 'ptpresult-solution']"));

List<TravelSolution> TravelSolutions_list = new List<TravelSolution>();

foreach (var TrS in TravelSolution)

{

TravelSolution NewSolution = new TravelSolution();

NewSolution.originTime = TrS.FindElement(By.CssSelector("div.train-info > div.travel-resume-detail.direct > div > div.travel_cities > div.departure > div.hour > p")).Text;

NewSolution.originStation = TrS.FindElement(By.CssSelector("div.train-info > div.travel-resume-detail.direct > div > div.travel_cities > div.departure > div.station > p")).Text;

NewSolution.destinationeTime = TrS.FindElement(By.CssSelector("div.train-info > div.travel-resume-detail.direct > div > div.travel_cities > div.arrival > div.hour > p")).Text;

NewSolution.destinationStation = TrS.FindElement(By.CssSelector("div.train-info > div.travel-resume-detail.direct > div > div.travel_cities > div.arrival > div.station > p")).Text;

NewSolution.duration = TrS.FindElement(By.CssSelector("div.train-info > div.header-block-train > div > span")).Text;

NewSolution.price = "от " + TrS.FindElement(By.CssSelector("div.ptpresult-details-wrap.ptpresult-packages > table > tbody > tr:nth-child(1) > td.price > label > spanth-child(5)"));

TravelSolutions_list.Add(NewSolution);

}

string json = JsonConvert.SerializeObject(TravelSolutions_list);

return json;

}

}

}

public class Trenitalia : Railway

{

string CalcDate(string Date)

{

string D = Date.Substring(3).Remove(2);

string M = Date.Remove(2);

string Y = Date.Substring(6);

string str = D + "-" + M + "-" + Y;

return str;

}

public string Json()

{

var driverService = ChromeDriverService.CreateDefaultService();

driverService.HideCommandPromptWindow = true;

var options = new ChromeOptions();

options.AddArgument("--window-position=-32000,-32000");

var driver = new ChromeDriver(driverService, options);

using (driver)

{

driver.Navigate().GoToUrl("https://www.lefrecce.it/B2CWeb/searchExternal.do?parameter=initBaseSearch&lang=en");

IWebElement originStation = driver.FindElement(By.Id("origin"));

originStation.SendKeys(this.originStation);

IWebElement depatureStation = driver.FindElement(By.Id("destination"));

depatureStation.SendKeys(this.arrivalStaton);

IWebElement date = driver.FindElement(By.Id("calenderId1Text"));

date.Clear();

date.SendKeys(CalcDate(this.Data));

IWebElement time = driver.FindElement(By.Id("departureTimeText"));

time.Clear();

time.SendKeys(this.Time);

IWebElement adults = driver.FindElement(By.Id("adultCountText"));

IList<IWebElement> ad = adults.FindElements(By.TagName("ul"));

foreach (IWebElement ADD in ad)

{

if (ADD.Text == this.Adults)

{

ADD.Click();

break;

}

}

IWebElement search = driver.FindElement(By.Id("searchButton"));

search.Click();

IWebElement TravelSolutions = driver.FindElement(By.CssSelector("#accordion > div"));

IList<IWebElement> TravelSolution = TravelSolutions.FindElements(By.CssSelector("div[id ^= 'travelSolution']"));

List<TravelSolution> TravelSolutions_list = new List<TravelSolution>();

foreach (IWebElement TrS in TravelSolution)

{

TravelSolution NewSolution = new TravelSolution();

IList<IWebElement> a = TrS.FindElements(By.CssSelector("tr[id ^= 'a_']"));

foreach (var AA in a)

{

NewSolution.originTime = AA.FindElement(By.CssSelector("td:nth-child(1) > div > span.top.time")).Text;

NewSolution.originStation = AA.FindElement(By.CssSelector("td:nth-child(1) > div > span.bottom")).Text;

NewSolution.destinationeTime = AA.FindElement(By.CssSelector("td:nth-child(2) > div > span.top.time")).Text;

NewSolution.destinationStation = AA.FindElement(By.CssSelector("td:nth-child(2) > div > span.bottom")).Text;

NewSolution.duration = TrS.FindElement(By.CssSelector("td.padding-0.text-center > div.descr.text-center")).Text;

try

{

NewSolution.price = TrS.FindElement(By.CssSelector("td:nth-child(5) > span:nth-child(4) > div:nth-child(1) > span.price")).Text;

}

catch

{

NewSolution.price = "Null";

}

}

TravelSolutions_list.Add(NewSolution);

}

string json = JsonConvert.SerializeObject(TravelSolutions_list);

return json;

}

}

}

public class VR : Railway // Финляндия

{

string CalcDate(string Date)

{

string D = Date.Substring(3).Remove(2);

string M = Date.Remove(2);

string Y = Date.Substring(6);

string str = D + "." + M + "." + Y;

return str;

}

public string Json()

{

var driverService = ChromeDriverService.CreateDefaultService();

driverService.HideCommandPromptWindow = true;

var options = new ChromeOptions();

options.AddArgument("--window-position=-32000,-32000");

var driver = new ChromeDriver(driverService, options);

using (driver)

{

driver.Navigate().GoToUrl("https://www.vr.fi/cs/vr/ru/etusivu_ru");

IWebElement originStation = driver.FindElement(By.CssSelector("#tabs1_station"));

originStation.SendKeys("Helsinki");

IWebElement depatureStation = driver.FindElement(By.CssSelector("#tabs1_stationdestination"));

depatureStation.SendKeys("Tampere");

IWebElement date = driver.FindElement(By.CssSelector("#tabs1_startDate"));

date.Clear();

date.SendKeys(CalcDate("05/15/2017"));

IWebElement time = driver.FindElement(By.CssSelector("#tabs1_startTime00"));

time.Clear();

time.SendKeys("08:00");

IWebElement search = driver.FindElement(By.CssSelector("#tabs1_submitbutton1"));

search.SendKeys(Keys.Enter);

IList<IWebElement> TraveSolution = driver.FindElements(By.CssSelector("tr[id ^= 'option_']"));

List<TravelSolution> TravelSolutions_list = new List<TravelSolution>();

foreach (IWebElement TrS in TraveSolution)

{

TravelSolution NewSolution = new TravelSolution();

NewSolution.originTime = TrS.FindElement(By.CssSelector("td.tripStartDomestic")).Text; //

NewSolution.originStation = "Helsinki";

NewSolution.destinationeTime = TrS.FindElement(By.CssSelector("td.tripEndDomestic")).Text; //

NewSolution.destinationStation = "Tampere";

NewSolution.duration = TrS.FindElement(By.CssSelector("td.tripDurationDomestic.tripTrainTypesDurationFont")).Text; //

try

{

NewSolution.price = TrS.FindElement(By.CssSelector("td.tripPriceFrom > div > div.priceBoxPrice")).Text;

}

catch

{

NewSolution.price = "Null";

}

TravelSolutions_list.Add(NewSolution);

}

string json = JsonConvert.SerializeObject(TravelSolutions_list);

return json;

}

}

}

Layout = null;

}

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width" />

<title>StartPage</title>

<link rel="stylesheet" href="/Styles/StartPage.css" />

</head>

<body>

<div class="Form">

<h3 style="font-size:32px; font-family:Tahoma;">Выберете компанию</h3>

<p style="font-size:23px; font-family:Tahoma;">

Company: @Html.DropDownListFor(x => x.Company, new[] {

new SelectListItem() {Text = "Trenitalia(Италия)", Value = "Trenitalia"},

new SelectListItem() {Text = "Amtrak(Америка)", Value = "Amtrak"},

new SelectListItem() {Text = "Deutsche Bahn(Германия)", Value = "Deutsche Bahn"},

new SelectListItem() {Text = "Sncf(Франция)", Value = "Sncf"},

new SelectListItem() {Text = "SBB(Швейцария)", Value = "SBB"},

new SelectListItem() {Text = "BelgianRail(Бельгия)", Value = "BelgianRail"},

new SelectListItem() {Text = "Renfe(Испания)", Value = "Renfe"},

new SelectListItem() {Text = "Comboios De Portugal(Португалия)", Value = "CP"},

new SelectListItem() {Text = "VR(Финляндия)", Value = "VR"},

}, "--Не выбрано--", new { style = "font-size:17px"})

</p>

<input type="submit" value="Далее" style="font-size:19px; -webkit-border-radius: 3px;"/>

}

</div>

</body>

</html>

@{

Layout = null;

}

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width" />

<title>Trenitalia</title>

<link rel="stylesheet" href="/Styles/FormStyle.css" />

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

<script>

$( function() {

$( "#datepicker" ).datepicker();

} );

</script>

</head>

<body>

<div class="Form">

<h3 style="font-size:32px; font-family:Tahoma;" >Trenitalia</h3>

<p style="font-size:19px; font-family:Tahoma;">Depature: @Html.TextBoxFor(x => x.originStation) Arrival: @Html.TextBoxFor(x => x.arrivalStaton)</p>

<p style="font-size:19px; font-family:Tahoma;">Data: @Html.TextBoxFor(x => x.Data, new { @id = "datepicker" }) Time: @Html.TextBoxFor(x => x.Time)</p>

<p style="font-size:19px; font-family:Tahoma;">

new SelectListItem() {Text = "1", Value = "1" },

new SelectListItem() {Text = "2", Value = "2" },

new SelectListItem() {Text = "3", Value = "3" },

new SelectListItem() {Text = "4", Value = "4" },

new SelectListItem() {Text = "5", Value = "5" },

}, new { style = "font-size:17px" })

new SelectListItem() {Text = "0", Value = "0" },

new SelectListItem() {Text = "1", Value = "1" },

new SelectListItem() {Text = "2", Value = "2" },

new SelectListItem() {Text = "3", Value = "3" },

new SelectListItem() {Text = "4", Value = "4" },

new SelectListItem() {Text = "5", Value = "5" },

}, new { style = "font-size:17px" })

</p>

<input type="submit" value="Search" style="font-size:19px; -webkit-border-radius: 3px;" />

}

</div>

</body>

</html>

@model MyWebService.Models.Trenitalia

@{

Layout = null;

}

<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width" />

<title>PageJson</title>

</head>

<body>

</body>

</html>

Размещено на Allbest.ru


Подобные документы

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.