public LicenseValidator(ToolDbContext context) { RuleFor(x => x.SerialNr) .Length(1, 100); RuleFor(x => x.ExpirationDate) .GreaterThan(DateTime.Now); }
public ToolValidator(ToolDbContext context) { RuleFor(x => x.Name) .Length(1, 100); RuleFor(x => x.Vendor) .Length(5, 500); }
public tusersController(ToolDbContext context) { _context = context; }
public LicensesController(ToolDbContext context) { _context = context; }
public ToolsController(ToolDbContext context) { _context = context; }
public override void Execute() { var urls = "http://192.168.1.111:8088/MuB2TPriceQuery/InterRT"; var taxUrls = "http://192.168.1.111:8088/MuB2TPriceQuery/TaxClient"; List <PriceSearchQuery> querys = null; using (ToolDbContext dbContext = new ToolDbContext()) { querys = dbContext.PriceSearchQuerys.ToList(); } Parallel.ForEach(querys, (itemQuery) => { var flightNos = itemQuery.FlightNo.Split('/'); var cabinNames = itemQuery.CabinName.Split('/'); if (itemQuery.BeginDate.Value < DateTime.Now.AddDays(1)) { itemQuery.BeginDate = DateTime.Now.AddDays(1); } foreach (var itemCabinName in cabinNames) { for (var date = itemQuery.BeginDate.Value; date < itemQuery.EndDate.Value; date = date.AddDays(1)) { B2XTaxYQ taxModel = null; #region 税费查询 try { B2XTaxYQ bt = new B2XTaxYQ(); bt.pfList = new List <PsgFare>(); bt.pfList.Add(new PsgFare() { psgType = "ADT" }); bt.salesCountry = "CN"; bt.salesCurrency = "CNY"; bt.segList = new List <Segment>(); bt.segList.Add(new Segment() { clazz = itemCabinName, destcd = itemQuery.ArrivePort, orgcd = itemQuery.DepartPort }); bt.ticketingDate = DateTime.Now.ToString("yyyy-MM-dd"); string postdata = JsonConvert.SerializeObject(bt); string responsedata = webRequestPost(taxUrls, postdata, null).ToString().Trim(); var taxResults = new RtFlightTaxQueryLog() { ArrivePort = itemQuery.ArrivePort, CreateDate = DateTime.Now, //DepartCabinName = "N", DepartCabinName = itemCabinName, DepartPort = itemQuery.DepartPort, ResponseData = responsedata, RouteType = "OW", DepartDate = date, Status = 0 }; taxModel = JsonConvert.DeserializeObject <B2XTaxYQ>(responsedata); using (ToolDbContext context = new ToolDbContext()) { context.RtFlightTaxQueryLogs.Add(taxResults); context.SaveChanges(); } } catch (Exception ex) { //Logger.WriteLog("税费查询接口请求异常日志" + System.DateTime.Now + ex.Message); } #endregion foreach (var itemFlightNo in flightNos) { #region 价格查询 try { OdInfoInput oiiOW = new OdInfoInput(); oiiOW.cabinRank = "ECONOMY"; oiiOW.channelNo = 220; oiiOW.currency = "CNY"; oiiOW.kamNo = ""; oiiOW.language = "ZH"; oiiOW.paxType = ""; oiiOW.promotionCode = ""; oiiOW.queryType = "all"; oiiOW.routeList = new List <RouteInfo>(); oiiOW.routeList.Add(new RouteInfo() { cabinName = itemCabinName, //cabinName = "N", flightNo = itemFlightNo, routeDirect = "depart", routeName = itemQuery.DepartPort + "/" + itemQuery.ArrivePort, travelDate = date.ToString("yyyy-MM-dd") }); oiiOW.routeType = "OW"; oiiOW.saleDate = DateTime.Now.ToString("yyyy-MM-dd"); oiiOW.specialFareCode = ""; oiiOW.taxesFlag = false; string postdata = JsonConvert.SerializeObject(oiiOW); string responsedata = webRequestPost(urls, postdata, null).ToString().Trim(); var priceQueryLog = new RtInterFlightPriceQueryLog() { ArrivePort = itemQuery.ArrivePort, DepartCabinName = itemCabinName, DepartDate = date, DepartPort = itemQuery.DepartPort, FlightNo = itemFlightNo, ResponseData = responsedata, RouteType = "OW", CreateDate = DateTime.Now, Status = 0 }; OdInfoOutput model = JsonConvert.DeserializeObject <OdInfoOutput>(responsedata); var flightPrice = new ETL0RtFlightPrice() { ArrivePort = itemQuery.ArrivePort, CreateDate = DateTime.Now, DepartPort = itemQuery.DepartPort, DepartDate = date, FlightNo = itemFlightNo, Status = 0 }; if (taxModel != null && taxModel.pfList != null && taxModel.pfList.Any() && taxModel.pfList[0].taxList != null) { flightPrice.Tax = new Decimal(taxModel.pfList[0].taxList.Sum(a => a.taxAmount ?? 0)); } Func <string, decimal> sum = (ls) => { var s = ls.Split('/'); return(s.Sum(b => decimal.Parse(b))); }; flightPrice.Price = model.routeCombineList[0].odFareInfoList.Where(a => a.passengerType == "ADT").Min(b => sum(b.price)); flightPrice.CabinName = model.routeCombineList[0].odFareInfoList.Where(a => a.passengerType == "ADT").Where(b => sum(b.price) == flightPrice.Price).First().cabinName; using (ToolDbContext context = new ToolDbContext()) { context.RtInterFlightPriceQueryLogs.Add(priceQueryLog); context.ETL0RtFlightPrices.Add(flightPrice); context.SaveChanges(); } Console.WriteLine(itemFlightNo + " " + itemCabinName + " " + date.ToString("yyyy-MM-dd")); } catch (Exception ex) { //throw ex; } #endregion } } } }); Console.WriteLine("End"); Console.Read(); }
public ValuesController(ToolDbContext db) { _db = db; }
public EmployeesController(ToolDbContext context) { _context = context; }
public EmployeeValidator(ToolDbContext context) { RuleFor(x => x.Name) .Length(1, 100); }
public ActionResult GetB2TFlightNo() { string departPort = "SHA/PVG/NKG/WNZ/HGH/WUX/NGB"; string arrivePort = "AKJ/AKL/BKK/CDG/CJU/CMB/CNX/CTS/DEL/DPS/DXB/FCO/FRA/FUK/GMP/HIJ/HKG/HKT/HND/HNL/ICN/JFK/KIJ/KIX/KMQ/KUL/LAX/LED/LHR/MAD/MEL/MFM/MLE/MNL/MWX/NGO/NRT/OKA/OKJ/ORD/PNH/PUS/REP/SFO/SGN/SIN/SVO/SYD/TAE/TOY/TPE/TSA/YVR/YYZ"; DateTime beginDate = DateTime.Today.AddDays(1); DateTime endDate = new DateTime(2017, 12, 31); string cabinNameStr = "C/D/F/I/J/P/B/E/H/K/L/M/N/R/S/T/V/W/Y"; var cabinNames = cabinNameStr.Split('/'); var urls = "http://192.168.1.111:8080/MuB2TPriceQuery/InterRT"; var taxUrls = "http://192.168.1.111:8080/MuB2TPriceQuery/TaxClient"; #region 获取航班号 var departs = departPort.Split('/'); var arrives = arrivePort.Split('/'); foreach (var itemDepart in departs) { foreach (var itemArrive in arrives) { using (ToolDbContext dbContext = new ToolDbContext()) { if (!dbContext.FlightNos.Where(a => a.ArrivePort == itemArrive && a.DepartPort == itemDepart).Any()) { var flights = GetB2TFlightNo(itemDepart, itemArrive); if (flights != null && flights.Any()) { dbContext.FlightNos.Add(new EntityModel.Tool.MuB2T.FlightNo() { ArrivePort = itemArrive, DepartPort = itemDepart, CreateDate = DateTime.Now, FlightNos = string.Join(",", flights), Status = 0 }); } } if (!dbContext.FlightNos.Where(a => a.ArrivePort == itemDepart && a.DepartPort == itemArrive).Any()) { var flights = GetB2TFlightNo(itemArrive, itemDepart); if (flights != null && flights.Any()) { dbContext.FlightNos.Add(new EntityModel.Tool.MuB2T.FlightNo() { ArrivePort = itemDepart, DepartPort = itemArrive, CreateDate = DateTime.Now, FlightNos = string.Join(",", flights), Status = 0 }); } } dbContext.SaveChanges(); } } } #endregion #region 获取价格及税费 List <FlightNo> ls = null; using (ToolDbContext dbContext = new ToolDbContext()) { ls = dbContext.FlightNos.ToList(); } if (ls != null && ls.Any()) { var flightLs = ls.Select(a => a.FlightNos.Split(',')).ToList(); foreach (var item in ls) { var flightNos = item.FlightNos.Split(','); foreach (var flightNo in flightNos) { foreach (var cabinNameD in cabinNames) { for (var date = beginDate; date <= endDate; date = date.AddDays(1)) { var results = new List <RtInterFlightPriceQueryLog>(); var taxResults = new List <RtFlightTaxQueryLog>(); #region 价格查询 try { OdInfoInput oiiOW = new OdInfoInput(); oiiOW.cabinRank = "ECONOMY"; oiiOW.channelNo = 220; oiiOW.currency = "CNY"; oiiOW.kamNo = ""; oiiOW.language = "ZH"; oiiOW.paxType = ""; oiiOW.promotionCode = ""; oiiOW.queryType = "all"; oiiOW.routeList = new List <RouteInfo>(); oiiOW.routeList.Add(new RouteInfo() { cabinName = cabinNameD, flightNo = flightNo, routeDirect = "depart", routeName = item.DepartPort + "/" + item.ArrivePort, travelDate = date.ToString("yyyy-MM-dd") }); oiiOW.routeType = "OW"; oiiOW.saleDate = DateTime.Now.ToString("yyyy-MM-dd"); oiiOW.specialFareCode = ""; oiiOW.taxesFlag = false; string postdata = JsonConvert.SerializeObject(oiiOW); string responsedata = webRequestPost(urls, postdata, null).ToString().Trim(); results.Add(new RtInterFlightPriceQueryLog() { ArrivePort = item.ArrivePort, DepartCabinName = cabinNameD, DepartDate = date, DepartPort = item.DepartPort, FlightNo = flightNo, ResponseData = responsedata, RouteType = "OW", CreateDate = DateTime.Now, Status = 0 }); } catch { } #endregion #region 税费查询 try { B2XTaxYQ bt = new B2XTaxYQ(); bt.pfList = new List <PsgFare>(); bt.pfList.Add(new PsgFare() { psgType = "ADT" }); bt.pfList.Add(new PsgFare() { psgType = "CHD" }); bt.salesCountry = "CN"; bt.salesCurrency = "CNY"; bt.segList = new List <Segment>(); bt.segList.Add(new Segment() { clazz = cabinNameD, destcd = item.ArrivePort, orgcd = item.DepartPort }); bt.ticketingDate = DateTime.Now.ToString("yyyy-MM-dd"); string postdata = JsonConvert.SerializeObject(bt); string responsedata = webRequestPost(taxUrls, postdata, null).ToString().Trim(); taxResults.Add(new RtFlightTaxQueryLog() { ArrivePort = item.ArrivePort, CreateDate = DateTime.Now, DepartCabinName = cabinNameD, DepartPort = item.DepartPort, ResponseData = responsedata, RouteType = "OW", Status = 0 }); } catch (Exception ex) { //Logger.WriteLog("税费查询接口请求异常日志" + System.DateTime.Now + ex.Message); } #endregion var r = ls.Where(a => a.DepartPort == item.ArrivePort && a.ArrivePort == item.DepartPort); string rtFlightNos = ""; if (r != null && r.Any()) { rtFlightNos = r.First().FlightNos; } if (!string.IsNullOrWhiteSpace(rtFlightNos)) { foreach (var cabinNameR in cabinNames) { /* #region 往返价格查询 * foreach (var rtFlightNo in rtFlightNos.Split(',')) * { * * for (var i = 3; i < 30; i++) * { * try * { * OdInfoInput oiiRT = new OdInfoInput(); * oiiRT.cabinRank = "ECONOMY"; * oiiRT.channelNo = 220; * oiiRT.currency = "CNY"; * oiiRT.kamNo = ""; * oiiRT.language = "ZH"; * oiiRT.paxType = ""; * oiiRT.promotionCode = ""; * oiiRT.queryType = "all"; * oiiRT.routeList = new List<RouteInfo>(); * oiiRT.routeList.Add(new RouteInfo() * { * cabinName = cabinNameD, * flightNo = flightNo, * routeDirect = "depart", * routeName = item.DepartPort + "/" + item.ArrivePort, * travelDate = date.ToString("yyyy-MM-dd") * }); * oiiRT.routeList.Add(new RouteInfo() * { * cabinName = cabinNameR, * flightNo = rtFlightNo, * routeDirect = "return", * routeName = item.ArrivePort + "/" + item.DepartPort, * travelDate = date.AddDays(i).ToString("yyyy-MM-dd") * }); * oiiRT.routeType = "RT"; * oiiRT.saleDate = DateTime.Now.ToString("yyyy-MM-dd"); * oiiRT.specialFareCode = ""; * oiiRT.taxesFlag = false; * string postdata = JsonConvert.SerializeObject(oiiRT); * string responsedata = webRequestPost(urls, postdata, null).ToString().Trim(); * results.Add(new RtInterFlightPriceQueryLog() * { * ArrivePort = item.ArrivePort, * DepartCabinName = cabinNameD, * DepartDate = date, * DepartPort = item.DepartPort, * FlightNo = flightNo, * ResponseData = responsedata, * RouteType = "RT", * ReturnCabinName = cabinNameR, * ReturnDate = date.AddDays(i), * RtFlightNo = rtFlightNo, * CreateDate = DateTime.Now, * Status = 0 * }); * } * catch * { * } * } * * } #endregion * */ #region 往返税费查询 try { B2XTaxYQ bt = new B2XTaxYQ(); bt.pfList = new List <PsgFare>(); bt.pfList.Add(new PsgFare() { psgType = "ADT" }); bt.pfList.Add(new PsgFare() { psgType = "CHD" }); bt.salesCountry = "CN"; bt.salesCurrency = "CNY"; bt.segList = new List <Segment>(); bt.segList.Add(new Segment() { clazz = cabinNameD, destcd = item.ArrivePort, orgcd = item.DepartPort }); bt.segList.Add(new Segment() { clazz = cabinNameR, destcd = item.DepartPort, orgcd = item.ArrivePort }); bt.ticketingDate = DateTime.Now.ToString("yyyy-MM-dd"); string postdata = JsonConvert.SerializeObject(bt); string responsedata = webRequestPost(taxUrls, postdata, null).ToString().Trim(); taxResults.Add(new RtFlightTaxQueryLog() { ArrivePort = item.ArrivePort, CreateDate = DateTime.Now, DepartCabinName = cabinNameD, DepartPort = item.DepartPort, ResponseData = responsedata, ReturnCabinName = cabinNameR, RouteType = "RT", Status = 0 }); } catch (Exception ex) { //Logger.WriteLog("税费查询接口请求异常日志" + System.DateTime.Now + ex.Message); } #endregion } } lock (this) { try { using (ToolDbContext dbContext = new ToolDbContext()) { #region 价格查询插入数据库 if (results != null && results.Any()) { foreach (var result in results) { dbContext.RtInterFlightPriceQueryLogs.Add(result); } } #endregion #region 税费查询插入数据库 if (taxResults != null && taxResults.Any()) { foreach (var result in taxResults) { dbContext.RtFlightTaxQueryLogs.Add(result); } } #endregion dbContext.SaveChanges(); } } catch { } } } } } } } #endregion return(Content("")); }
public HomeController(ToolDbContext context) { _context = context; }