public static LocalizedRoute Create(string culture, RouteInformation original, RouteInformation translated) => new LocalizedRoute { Culture = culture, Original = original, Translated = translated };
public static string GetOutputPathFromRouteInformation(RouteInformation route, string prefix) { var path = route.Path; if (path.StartsWith("/debug/")) { path = path.Replace("/debug/", string.Empty); } else if (path.StartsWith("debug/")) { path = path.Replace("debug/", string.Empty); } path = path.Replace("/databases/*/", string.Empty) .Replace("debug/", string.Empty) //if debug/ left in the middle, remove it as well .Replace("/", "."); if (path.StartsWith(".")) { path = path.Substring(1); } path = string.IsNullOrWhiteSpace(prefix) == false ? $"{prefix}/{path}.json" : // .ZIP File Format Specification 4.4.17 file name: (Variable) $"{path}.json"; return(path); }
public static string GetOutputPathFromRouteInformation(RouteInformation route, string prefix) { var path = route.Path; if (path.StartsWith("/debug/")) { path = path.Replace("/debug/", string.Empty); } else if (path.StartsWith("debug/")) { path = path.Replace("debug/", string.Empty); } path = path.Replace("/databases/*/", string.Empty) .Replace("debug/", string.Empty) //if debug/ left in the middle, remove it as well .Replace("/", "."); if (path.StartsWith(".")) { path = path.Substring(1); } path = string.IsNullOrWhiteSpace(prefix) == false? Path.Combine(prefix, $"{path}.json") : $"{path}.json"; return(path); }
private static bool IsValidRouteMatching(RouteInformation usedIdentifierRoute, string routeMatching, int matchingIndex, List <string> checkParams) { var matchingParameter = usedIdentifierRoute.RouteParameters.FirstOrDefault(x => x.Name == routeMatching); if (matchingIndex >= checkParams.Count || matchingParameter == null) { return(false); } var matchingValue = checkParams[matchingIndex]; if (ValidateDefaults(matchingParameter.ParameterType, usedIdentifierRoute.Defaults, routeMatching, matchingValue)) { return(true); } var typeConverter = TypeDescriptor.GetConverter(matchingParameter.ParameterType); if (!typeConverter.CanConvertFrom(typeof(string)) || !typeConverter.IsValid(matchingValue)) { return(false); } object value = typeConverter.ConvertFromString(matchingValue); if (!ValidateConstraints(value, usedIdentifierRoute.Constraints, routeMatching)) { return(false); } return(true); }
/// <summary> /// Plan given that we are starting on a road /// </summary> /// <param name="currentLane"></param> /// <param name="currentPosition"></param> /// <param name="goal"></param> /// <returns></returns> public RoadPlan PlanNavigableArea(INavigableTravelArea currentArea, Coordinates currentPosition, INavigableNode goal, List <ArbiterWaypoint> ignorable) { // get all downstream points of interest as well as the goal point of interest List <DownstreamPointOfInterest> downstreamPoints = currentArea.Downstream(currentPosition, ignorable, goal); // so, for each exit downstream we need to plan from the end of each interconnect to the goal this.RouteTimes(downstreamPoints, goal); // get road plan RoadPlan rp = this.GetRoadPlan(downstreamPoints); #region Output // update arbiter information List <RouteInformation> routeInfo = rp.RouteInformation(currentPosition); // make sure we're in a road state if (CoreCommon.CorePlanningState == null || CoreCommon.CorePlanningState is UrbanChallenge.Arbiter.Core.Common.State.TravelState) { // check route 1 if (routeInfo.Count > 0) { RouteInformation ri = routeInfo[0]; CoreCommon.CurrentInformation.Route1 = ri; CoreCommon.CurrentInformation.Route1Time = ri.RouteTimeCost.ToString("F6"); CoreCommon.CurrentInformation.Route1Wp = ri.Waypoint; } } #endregion // return road plan return(rp); }
public void QueryStringScraper_should_support_types( string method, string name, Type type) { // arrange var routeInformation = new RouteInformation { RouteTemplate = "route" }; // will not support for get a list as querystring var description = new ControllerActionDescriptor { MethodInfo = typeof(FakeController).GetMethod(method) }; // act QueryStringScraper.CompleteQueryStringRequiredParams(routeInformation, description); // assert Assert.Single(routeInformation.QueryParams); Assert.Equal(name, routeInformation.QueryParams.First().Key); Assert.Equal(type, routeInformation.QueryParams.First().Value); }
public async Task InternalRouteInformationEvaluator_should_not_ignore_route_if_regex_does_not_match() { // arrange var contextAccessor = new Mock <IAutoHealthCheckContextAccessor>(); var context = new Mock <IAutoHealthCheckContext>(); var routeEvaluator = new Mock <IRouteEvaluator>(); routeEvaluator.Setup(c => c.Evaluate(It.IsAny <IRouteInformation>())) .Returns(Task.FromResult(true)); contextAccessor.Setup(c => c.Context) .Returns(context.Object); context.Setup(c => c.Configurations) .Returns(new AutoHealthCheckConfigurations { ExcludeRouteRegexs = new List <Regex> { new Regex("^[0-9]+$") } }); var evaluator = new InternalRouteInformationEvaluator(contextAccessor.Object, routeEvaluator.Object); var routeInformation = new RouteInformation { RouteTemplate = "get/api/3123" // no only numbers }; // act var include = await evaluator.Evaluate(routeInformation); // assert Assert.True(include); // this should be true as the regex does not match with the route }
public async Task <RouteInformation> GetRoute(double startLat, double startLon, double endLat, double endLon) { DirectionsRequest directionsRequest = new DirectionsRequest() { Origin = string.Format("{0},{1}", startLat, startLon), Destination = string.Format("{0},{1}", endLat, endLon), ApiKey = Config.MappingConfig.GoogleMapsApiKey }; async Task <RouteInformation> getRoute() { DirectionsResponse directions = await GoogleMapsApi.GoogleMaps.Directions.QueryAsync(directionsRequest); var info = new RouteInformation(); if (directions != null && directions.Status == DirectionsStatusCodes.OK) { var route = directions.Routes.FirstOrDefault(); if (route != null) { info.Name = route.Summary; info.ProcessedOn = DateTime.UtcNow; info.Successful = true; } } return(info); }; return(await _cacheProvider.RetrieveAsync <RouteInformation>(string.Format(RouteCacheKey, string.Format("{0}{1}", startLat, startLon).GetHashCode(), string.Format("{0}{1}", endLat, endLon).GetHashCode()), getRoute, CacheLength)); }
private void webClient_DownloadCombinedTrainsCompleted(object sender, DownloadStringCompletedEventArgs e) { try { string json = e.Result; if (!string.IsNullOrEmpty(json)) { RouteInformation routeInformation = JsonConvert.DeserializeObject <RouteInformation>(json); detailedStationList[tempIndex].fromDistance = Math.Round(routeInformation.resourceSets[0].resources[0].travelDistance, 1); detailedStationList[tempIndex].fromDistanceDisplay = getDistanceFromDisplay(detailedStationList[tempIndex].fromDistance); } } catch (Exception ex) { //Telerik.Windows.Controls.RadMessageBox.ShowAsync("AW SNAP :-(", Telerik.Windows.Controls.MessageBoxButtons.OK, "We are having trouble downloading data due to network connectivity or temporary server unavailability at the moment. Please make sure you are connected to internet and try again."); detailedStationList[tempIndex].fromDistance = 1000; ShellToast toast = new ShellToast(); toast.Title = "AW SNAP :("; toast.Content = "We could not retreive some routing infomation. But this won't affect to your routing options as offline maps features would still available"; toast.Show(); } tempIndex++; if (detailedStationList.Count == tempIndex) { this.busyIndicator.IsRunning = false; populateStations(); } }
public async Task InternalRouteInformationEvaluator_should_ignore_route_if_evaluator_return_false() { // arrange var contextAccessor = new Mock <IAutoHealthCheckContextAccessor>(); var context = new Mock <IAutoHealthCheckContext>(); var routeEvaluator = new Mock <IRouteEvaluator>(); routeEvaluator.Setup(c => c.Evaluate(It.IsAny <IRouteInformation>())) .Returns(Task.FromResult(false)); contextAccessor.Setup(c => c.Context) .Returns(context.Object); context.Setup(c => c.Configurations) .Returns(new AutoHealthCheckConfigurations()); var evaluator = new InternalRouteInformationEvaluator(contextAccessor.Object, routeEvaluator.Object); var routeInformation = new RouteInformation { RouteTemplate = "get/api/3123" }; // act var include = await evaluator.Evaluate(routeInformation); // assert Assert.False(include); }
public async Task InternalRouteInformationEvaluator_should_ignore_route_if_any_regex_is_excluding_template() { // arrange var contextAccessor = new Mock <IAutoHealthCheckContextAccessor>(); var context = new Mock <IAutoHealthCheckContext>(); var routeEvaluator = new Mock <IRouteEvaluator>(); routeEvaluator.Setup(c => c.Evaluate(It.IsAny <IRouteInformation>())) .Returns(Task.FromResult(true)); contextAccessor.Setup(c => c.Context) .Returns(context.Object); context.Setup(c => c.Configurations) .Returns(new AutoHealthCheckConfigurations { ExcludeRouteRegexs = new List <Regex> { new Regex("^[0-9]+$") } }); var evaluator = new InternalRouteInformationEvaluator(contextAccessor.Object, routeEvaluator.Object); var routeInformation = new RouteInformation { RouteTemplate = "324234" }; // act var include = await evaluator.Evaluate(routeInformation); // assert Assert.False(include); // route should be ignored as there is numbers }
private IList <Seat> GetSeatInformation(RouteInformation routeInformation, CtripRegexExpression ctripRegex) { IList <Seat> seatList = new List <Seat>(); Seat seat; string strUrl = GetUrl(routeInformation.OriginalAirport, routeInformation.DestinationAirport, routeInformation.DepartureTime, routeInformation.FlightNO); IList <string> resultList = RegexOperation.GetValuesByRegex(string.Format(ctripRegex.GetAllCabinInfomation(), routeInformation.FlightNO.Trim()), DownHtmlSource(strUrl)); if (resultList == null) { return(seatList); } string strPrice = string.Empty; foreach (string strResult in resultList) { seat = new Seat(); seat.Cabin = RegexOperation.GetValueByRegex(ctripRegex.GetOtherCanbin(), strResult); strPrice = RegexOperation.GetValueByRegex(ctripRegex.GetOtherCanbinPrice(), strResult); if (!string.IsNullOrEmpty(strPrice)) { seat.Price = double.Parse(strPrice); } seat.Count = 9; seatList.Add(seat); } return(seatList); }
public IEnumerable <RouteInformation> GetAllRouteInformations() { List <RouteInformation> ret = new List <RouteInformation>(); var routes = m_actionDescriptorCollectionProvider.ActionDescriptors.Items; foreach (ActionDescriptor _e in routes) { RouteInformation info = new RouteInformation(); // Area if (_e.RouteValues.ContainsKey("area")) { info.Area = _e.RouteValues["area"]; } // Path and Invocation of Razor Pages if (_e is PageActionDescriptor) { var e = _e as PageActionDescriptor; info.Path = e.ViewEnginePath; info.Invocation = e.RelativePath; } // Path of Route Attribute if (_e.AttributeRouteInfo != null) { var e = _e; info.Path = $"/{e.AttributeRouteInfo.Template}"; } // Path and Invocation of Controller/Action if (_e is ControllerActionDescriptor) { var e = _e as ControllerActionDescriptor; if (info.Path == "") { info.Path = $"/{e.ControllerName}/{e.ActionName}"; } info.Invocation = $"{e.ControllerName}Controller.{e.ActionName}"; } // Special controller path if (info.Path == "/RouteAnalyzer_Main/ShowAllRoutes") { info.Path = RouteAnalyzerRouteBuilderExtensions.RouteAnalyzerUrlPath; } // Additional information of invocation info.Invocation += $" ({_e.DisplayName})"; // Generating List ret.Add(info); } // Result return(ret); }
public void RouteInformation_default_method_should_be_get() { // arrange var routeInformation = new RouteInformation(); // act // asserts Assert.Equal("GET", routeInformation.HttpMethod); }
public static MvcHtmlString Action <TController>( this HtmlHelper helper, Expression <Action <TController> > action, object routeValues = null) where TController : Controller { var routeInfo = RouteInformation.FromExpression <TController>(action, routeValues); return(helper.Action(routeInfo.ActionName, routeInfo.ControllerName, routeInfo.RouteValueDictionary)); }
public static string Action <TController>( this UrlHelper url, Expression <Func <TController, Task> > action, object routeValues = null) where TController : Controller { var routeInfo = RouteInformation.FromExpression <TController>(action, routeValues); return(url.Action(routeInfo.ActionName, routeInfo.ControllerName, routeInfo.RouteValueDictionary)); }
public AccountViewData(string returnUrl, bool allowAuthoriseAttributeOnAction) { DisplayAuthLinks = false; DisplaySearch = false; RouteInformation ri = new RouteInformation(returnUrl, MvcApplication.RegisterRoutes); ReturnUrl = ri.SanitiseUrl(allowAuthoriseAttributeOnAction); CancelUrl = ri.SanitiseUrl(false); }
public static void RenderAction <TController>( this HtmlHelper helper, Expression <Func <TController, Task> > action, object routeValues = null) where TController : Controller { var routeInfo = RouteInformation.FromExpression <TController>(action, routeValues); helper.RenderAction(routeInfo.ActionName, routeInfo.ControllerName, routeInfo.RouteValueDictionary); }
public void GetQueryString_Simple() { RouteInformation route = new RouteInformation { Path = "/a/b/" }; var excpected = ""; Assert.AreEqual(excpected, route.GetQueryString("/a/b/")); }
public void GetQueryString_WithSlashedParamerterAndQuestionQuery() { var url = "/a/b/c?id=100"; RouteInformation route = new RouteInformation { Path = url }; var excpected = "/c?id=100"; Assert.AreEqual(excpected, route.GetQueryString(url)); }
/// <summary> /// Plan given that we are starting on a road /// </summary> /// <param name="currentLane"></param> /// <param name="currentPosition"></param> /// <param name="goal"></param> /// <returns></returns> public RoadPlan PlanRoads(ArbiterLane currentLane, Coordinates currentPosition, INavigableNode goal, List <ArbiterWaypoint> ignorable) { // get all downstream points of interest List <DownstreamPointOfInterest> downstreamPoints = new List <DownstreamPointOfInterest>(); // get exits downstream from this current position in the way downstreamPoints.AddRange(this.Downstream(currentPosition, currentLane.Way, true, ignorable)); // determine if goal is downstream in a specific lane, add to possible route times to consider DownstreamPointOfInterest goalDownstream = this.IsGoalDownStream(currentLane.Way, currentPosition, goal); // add goal to points downstream if it exists if (goalDownstream != null) { downstreamPoints.Add(goalDownstream); } // so, for each exit downstream we need to plan from the end of each interconnect to the goal this.DetermineDownstreamPointRouteTimes(downstreamPoints, goal, currentLane.Way); // get road plan RoadPlan rp = this.GetRoadPlan(downstreamPoints, currentLane.Way); // update arbiter information List <RouteInformation> routeInfo = rp.RouteInformation(currentPosition); // make sure we're in a road state if (CoreCommon.CorePlanningState == null || CoreCommon.CorePlanningState is TravelState || CoreCommon.CorePlanningState is TurnState) { // check route 1 if (routeInfo.Count > 0) { RouteInformation ri = routeInfo[0]; CoreCommon.CurrentInformation.Route1 = ri; CoreCommon.CurrentInformation.Route1Time = ri.RouteTimeCost.ToString("F6"); CoreCommon.CurrentInformation.Route1Wp = ri.Waypoint; } // check route 2 if (routeInfo.Count > 1) { RouteInformation ri = routeInfo[1]; CoreCommon.CurrentInformation.Route2 = ri; CoreCommon.CurrentInformation.Route2Time = ri.RouteTimeCost.ToString("F6"); CoreCommon.CurrentInformation.Route2Wp = ri.Waypoint; } } // return road plan return(rp); }
public void CalculateNewReport_StartsAtHome_IsRoundTrip() { var report = GetDriveReport(); report.FourKmRule = false; report.IsRoundTrip = true; report.KilometerAllowance = KilometerAllowance.Calculated; report.DriveReportPoints = new List <DriveReportPoint>() { new DriveReportPoint() // Same as home adress to trigger StartsAtHome { Longitude = "12341234", Latitude = "12341234" }, new DriveReportPoint() { Longitude = "11111111", Latitude = "11111111" } }; var distance = report.Distance; var calculator = GetCalculator(new List <Employment>() { new Employment() { PersonId = 1, OrgUnit = new OrgUnit() { Address = new WorkAddress() { StreetName = "Katrinebjergvej", StreetNumber = "93B", ZipCode = 8200, Town = "Aarhus N" } }, WorkDistanceOverride = 10 // Distance from Home to Work is set to 10 } }); var route = new RouteInformation() { Length = 42 }; var result = calculator.Calculate(route, report); // The driven distance should be substracted the persons distance from home to work Assert.AreEqual((distance - 10) * 2, report.Distance); }
public async Task <bool> DeleteRoute(RouteInformation route) { try { _context.RouteInformations.Remove(route); var result = await _context.SaveChangesAsync(); return(result > 0); } catch (Exception) { return(false); } }
public async Task <BlittableJsonReaderObject> InvokeAndReadObjectAsync(RouteInformation route, JsonOperationContext context, Dictionary <string, StringValues> parameters = null) { var response = await InvokeAsync(route, parameters); try { return(context.ReadForMemory(response.Body, $"read/local endpoint/{route.Path}")); } catch (InvalidStartOfObjectException e) { //precaution, ideally this exception should never be thrown throw new InvalidOperationException("Expected to find a blittable object as a result of debug endpoint, but found something else (see inner exception for details). This should be investigated as all RavenDB endpoints are supposed to return an object.", e); } }
private static FlightOtherPrice CreateCtripOtherPrice(RouteInformation routeInformation, int sourceType) { FlightOtherPrice otherPrice = new FlightOtherPrice(); otherPrice.Airliner = routeInformation.AirLine; otherPrice.Arrival = routeInformation.DestinationAirport; otherPrice.Cabin = routeInformation.Cabin; otherPrice.CreateDate = DateTime.Now; otherPrice.Departure = routeInformation.OriginalAirport; otherPrice.Flight = routeInformation.FlightNO; otherPrice.LowestPrice = routeInformation.TicketPrice; otherPrice.Sourcetype = sourceType; return(otherPrice); }
private static FlightOtherPrice CreateElongOtherPrice(RouteInformation routeInformation) { FlightOtherPrice otherPrice = new FlightOtherPrice(); otherPrice.Airliner = routeInformation.AirLine; otherPrice.Arrival = routeInformation.DestinationAirport; otherPrice.Cabin = routeInformation.Cabin; otherPrice.CreateDate = DateTime.Now; otherPrice.Departure = routeInformation.OriginalAirport; otherPrice.Flight = routeInformation.FlightNO; otherPrice.LowestPrice = routeInformation.TicketPrice; otherPrice.Sourcetype = (int)EnumDef.ETicketPriceOrigin.艺龙; return(otherPrice); }
public static string Action <TController>( this UrlHelper url, Expression <Action <TController> > action, object routeValues = null) where TController : Controller { var routeInfo = RouteInformation.FromExpression <TController>(action, routeValues); if (!DetermineUsingAreas(url.RouteCollection)) { routeInfo.RouteValueDictionary.Remove("area"); } return(url.Action(routeInfo.ActionName, routeInfo.ControllerName, routeInfo.RouteValueDictionary)); }
public async Task <bool> CreateRoute(RouteInformation newRoute) { try { await _context.RouteInformations.AddAsync(newRoute); var result = await _context.SaveChangesAsync(); return(result > 0); } catch (Exception ex) { return(false); } }
public static MvcHtmlString Action <TController>( this HtmlHelper helper, Expression <Func <TController, Task> > action, object routeValues = null) where TController : Controller { var routeInfo = RouteInformation.FromExpression <TController>(action, routeValues); if (!DetermineUsingAreas(helper.RouteCollection)) { routeInfo.RouteValueDictionary.Remove("area"); } return(helper.Action(routeInfo.ActionName, routeInfo.ControllerName, routeInfo.RouteValueDictionary)); }
public static void RenderAction <TController>( this HtmlHelper helper, Expression <Action <TController> > action, object routeValues = null) where TController : Controller { var routeInfo = RouteInformation.FromExpression <TController>(action, routeValues); if (!DetermineUsingAreas(helper.RouteCollection)) { routeInfo.RouteValueDictionary.Remove("area"); } helper.RenderAction(routeInfo.ActionName, routeInfo.ControllerName, routeInfo.RouteValueDictionary); }
/// <summary> /// Get routes and alternative routes for the given set of coordinates. /// </summary> /// <param name="transportType">Type of transport. Car or Bike.</param> /// <param name="routeCoordinates"></param> /// <exception cref="RouteInformationException">Thrown if no route was returned or no rute was found.</exception> /// <returns></returns> public IEnumerable <RouteInformation> GetRoute(DriveReportTransportType transportType, IEnumerable <Coordinates> routeCoordinates) { List <RouteInformation> routes = new List <RouteInformation>(); HttpWebRequest request = CreateRequest(transportType, routeCoordinates); RootRouteObject result = ExecuteAndRead(transportType, request); if (result == null) { var e = new RouteInformationException("No route returned."); //Logger.Error("Exception when getting route information", e); throw e; } //From septima 01/09 2016: //Routingservices kan forventes senere at returnere status = 200, //idet OSRM er gået fra at bruge "C style" exit-koder, til "HTTP Style" status-koder. if (result.status != 0 && result.status / 100 == 2) { var e = new RouteInformationException("No route found.");; //Logger.Error("Exception when getting route information", e); throw e; } var route = new RouteInformation(); route.Length = result.route_summary.distance_not_including_ferry; route.Duration = result.route_summary.total_time; route.EndStreet = result.route_summary.end_point; route.StartStreet = result.route_summary.start_point; route.GeoPoints = result.route_geometry; routes.Add(route); for (int i = 0; i < result.alternative_summaries.Count; i++) { route = new RouteInformation { Length = result.alternative_summaries[i].total_distance, Duration = result.alternative_summaries[i].total_time, EndStreet = result.alternative_summaries[i].end_point, StartStreet = result.alternative_summaries[i].start_point, GeoPoints = result.alternative_geometries[i] }; routes.Add(route); } return(routes); }
/// <summary> /// ��ȡ����������Ϣ /// </summary> /// <param name="strContent"></param> /// <param name="etripRegex"></param> /// <returns></returns> private RouteInformation GetElongRouteInformation(string strContent, ElongRegexEpression etripRegex) { if (string.IsNullOrEmpty(strContent)) return null; string strRule = RegexOperation.GetValueByRegex(etripRegex.GetRuleData(),strContent); string strTable = RegexOperation.GetValueByRegex(etripRegex.GetSingleRowRegex(), strContent); if (string.IsNullOrEmpty(strTable)) return null; string airline = RegexOperation.GetValueByRegex(etripRegex.GetAirLineRegex(), strContent); if (string.IsNullOrEmpty(airline)) return null; RouteInformation elongrouteInformation = new RouteInformation(); IList<string> valueList; //�������С�������� valueList = RegexOperation.GetValuesByRegex(etripRegex.GetCityRegex(), strContent); if (valueList != null && valueList.Count == 2) { elongrouteInformation.OriginalAirport = valueList[0]; elongrouteInformation.DestinationAirport = valueList[1]; } //�������� //elongrouteInformation.OriginalAirport = RegexOperation.GetValuesByRegex(etripRegex.GetDepartureCityRegex(), strContent).ToString(); //������� // elongrouteInformation.DestinationAirport = RegexOperation.GetValuesByRegex(etripRegex.GetArrivalCityRegex(), strContent).ToString(); //���չ�˾ elongrouteInformation.AirLine = RegexOperation.GetValueByRegex(etripRegex.GetAirLineRegex(), strTable).ToString(); //����� elongrouteInformation.FlightNO = RegexOperation.GetValueByRegex(etripRegex.GetFlightNORegex(), strContent).ToString(); //��λ elongrouteInformation.Cabin = RegexOperation.GetValueByRegex(etripRegex.GetCabinRegex(), strContent).ToString(); //���� elongrouteInformation.FlightType = RegexOperation.GetValueByRegex(etripRegex.GetFlightTypeRegex(), strRule).ToString(); //�˸� elongrouteInformation.ChangeRule = RegexOperation.GetValueByRegex(etripRegex.GetChangeRuleRegex(), strContent).ToString(); //�ۿ� elongrouteInformation.Ediscount = RegexOperation.GetValueByRegex(etripRegex.GetDiscountRegex(), strContent).ToString(); //˰�� string eAirportFuel = RegexOperation.GetValueByRegex(etripRegex.GetEAirportFuelRegex(), strTable).ToString(); if (!string.IsNullOrEmpty(eAirportFuel)) { elongrouteInformation.Eairportfuel = double.Parse(eAirportFuel); } //���� string airPort = RegexOperation.GetValueByRegex(etripRegex.GetAirportRegex(), strContent).ToString(); if (!string.IsNullOrEmpty(airPort)) { elongrouteInformation.AirportTax = double.Parse(airPort); } //ȼ�� string fuel = RegexOperation.GetValueByRegex(etripRegex.GetFuelRegex(), strContent).ToString(); if (!string.IsNullOrEmpty(fuel)) { elongrouteInformation.FuelTax = double.Parse(fuel); } //Ʊ�� string ticketPrice = RegexOperation.GetValueByRegex(etripRegex.GetTicketPriceRegex(), strContent).ToString(); if (!string.IsNullOrEmpty(ticketPrice)) { elongrouteInformation.TicketPrice = double.Parse(ticketPrice); } string yearmonthday = RegexOperation.GetValueByRegex(etripRegex.GetYearMonthDay(), strRule).ToString(); //����ʱ�� string departureTime = RegexOperation.GetValueByRegex(etripRegex.GetDepartureTimeRegex(), strContent).ToString(); string yd = yearmonthday+" "+departureTime; if (!string.IsNullOrEmpty(departureTime)) { elongrouteInformation.DepartureTime = DateTime.Parse(yd); } //����ʱ�� string arrivalTime=RegexOperation.GetValueByRegex(etripRegex.GetArrivalTimeRegex(), strContent).ToString(); string ya = yearmonthday+" "+arrivalTime; if (!string.IsNullOrEmpty(arrivalTime)) { elongrouteInformation.ArriveTime = DateTime.Parse(ya); } return elongrouteInformation; }
private RouteInformation GetRouteInformation(string strContent, VeryTripRegexExpression veryTripRegex) { if (string.IsNullOrEmpty(strContent)) return null; string strFirstContent = RegexOperation.GetValueByRegex(veryTripRegex.GetSingleRowFirstRegex(), strContent); if (string.IsNullOrEmpty(strFirstContent)) return null; RouteInformation routeInformation = new RouteInformation(); routeInformation.OriginalAirport = RegexOperation.GetValueByRegex(veryTripRegex.GetDepartureCityRegex(), strFirstContent); routeInformation.DestinationAirport = RegexOperation.GetValueByRegex(veryTripRegex.GetArrivalCityRegex(), strFirstContent); if (GetFlightDate().HasValue) { string strStartTime = RegexOperation.GetValueByRegex(veryTripRegex.GetDepartureTimeRegex(), strFirstContent); string strEndTime = RegexOperation.GetValueByRegex(veryTripRegex.GetArrivalTimeRegex(), strFirstContent); routeInformation.DepartureTime = DateTime.Parse(GetFlightDate().Value.ToString("yyyy-MM-dd") + " " + strStartTime + ":00"); routeInformation.ArriveTime = DateTime.Parse(GetFlightDate().Value.ToString("yyyy-MM-dd") + " " + strEndTime + ":00"); routeInformation.AirDate = GetFlightDate().Value; } //routeInformation.Discount = double.Parse(strDiscount); //string strTicketPrice = RegexOperation.GetValueByRegex(veryTripRegex.GetTicketPriceRegex(), strTbodyData); //if (!string.IsNullOrEmpty(strTicketPrice)) // routeInformation.TicketPrice = double.Parse(strTicketPrice); //routeInformation.Meal = RegexOperation.GetValueByRegex(veryTripRegex.GetMealRegex(), strTbodyData); //routeInformation.AirLine = RegexOperation.GetValueByRegex(veryTripRegex.GetAirLineRegex(), strTbodyData); //routeInformation.ChangeRule = RegexOperation.GetValueByRegex(veryTripRegex.GetChangeRuleRegex(), strContent); //routeInformation.FlightInterval = RegexOperation.GetValueByRegex(veryTripRegex.GetFlightIntervalRegex(), strContent); routeInformation.FlightNO = RegexOperation.GetValueByRegex(veryTripRegex.GetFlightNORegex(), strFirstContent); routeInformation.AirLine = routeInformation.FlightNO.Substring(0, 2); routeInformation.FlightType = RegexOperation.GetValueByRegex(veryTripRegex.GetFlightTypeRegex(), strFirstContent); string strStops = RegexOperation.GetValueByRegex(veryTripRegex.GetStops(), strFirstContent); if (!string.IsNullOrEmpty(strStops)) routeInformation.Stops = int.Parse(strStops); //routeInformation.Cabin = RegexOperation.GetValueByRegex(veryTripRegex.GetCabinRegex(), strContent); string strYprice = RegexOperation.GetValueByRegex(veryTripRegex.GetYpriceRegex(), strFirstContent); if (!string.IsNullOrEmpty(strYprice)) routeInformation.Yprice = double.Parse(strYprice); //string strAirportFuelTax = RegexOperation.GetValueByRegex(veryTripRegex.GetAirportFuelRegex(), strContent); //if (!string.IsNullOrEmpty(strAirportFuelTax)) //{ // string[] strDatas = strAirportFuelTax.Split('��'); // if (!string.IsNullOrEmpty(strDatas[0])) // routeInformation.AirportTax = double.Parse(strDatas[0]); // if (!string.IsNullOrEmpty(strDatas[1])) // routeInformation.FuelTax = double.Parse(strDatas[1]); //} return routeInformation; }