public ActionResult PutRateInfo(int id, RateInfo rateInfo) { if (!ModelState.IsValid) { return(Json("Model is not valid", JsonRequestBehavior.AllowGet)); } if (id != rateInfo.RateInfoId) { return(Json("Model id is not valid", JsonRequestBehavior.AllowGet)); } db.Entry(rateInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RateInfoExists(id)) { return(Json("Data is not in table", JsonRequestBehavior.AllowGet)); } else { throw; } } return(Json(rateInfo, JsonRequestBehavior.AllowGet)); }
private static bool IsValid(RateInfo _RateInfo) { DateTime arg_06_0 = _RateInfo.BeginDay; DateTime arg_0D_0 = _RateInfo.EndDay; return(_RateInfo.BeginDay.Year <= DateTime.Now.Year && DateTime.Now.Year <= _RateInfo.EndDay.Year && _RateInfo.BeginDay.DayOfYear <= DateTime.Now.DayOfYear && DateTime.Now.DayOfYear <= _RateInfo.EndDay.DayOfYear && !(_RateInfo.BeginTime.TimeOfDay > DateTime.Now.TimeOfDay) && !(DateTime.Now.TimeOfDay > _RateInfo.EndTime.TimeOfDay)); }
public static float GetRate(eRateType eType) { float rate = 1f; RateMgr.m_lock.AcquireReaderLock(-1); float result; try { RateInfo _RateInfo = RateMgr.GetRateInfoWithType((int)eType); if (_RateInfo == null) { result = rate; return(result); } if (_RateInfo.Rate == 0f) { result = 1f; return(result); } if (RateMgr.IsValid(_RateInfo)) { rate = _RateInfo.Rate; } } catch { } finally { RateMgr.m_lock.ReleaseReaderLock(); } result = rate; return(result); }
private static bool IsValid(RateInfo areaFightInfo) { //DateTime arg_07_0 = areaFightInfo.BeginDay; //DateTime arg_0E_0 = areaFightInfo.EndDay; //bool flag = 0 == 0; return(!(areaFightInfo.BeginTime.TimeOfDay > DateTime.Now.TimeOfDay) && !(areaFightInfo.EndTime.TimeOfDay < DateTime.Now.TimeOfDay)); }
/// <summary> /// 获取游戏倍率 /// </summary> /// <param name="eType">倍率类型</param> /// <returns></returns> public static float GetRate(eRateType eType) { float rate = 1; m_lock.AcquireReaderLock(Timeout.Infinite); try { RateInfo _RateInfo = GetRateInfoWithType((int)eType); if (_RateInfo == null) { return(rate); } if (_RateInfo.Rate == 0) { return(1); } if (IsValid(_RateInfo)) { rate = _RateInfo.Rate; } } catch { } finally { m_lock.ReleaseReaderLock(); } return(rate); }
public static float GetRate(eRateType eType) { float num = 1f; RateMgr.m_lock.AcquireReaderLock(15000); try { RateInfo rateInfoWithType = RateMgr.GetRateInfoWithType((int)eType); if (rateInfoWithType == null) { float result = num; return(result); } if (rateInfoWithType.Rate == 0f) { float result = 1f; return(result); } if (RateMgr.IsValid(rateInfoWithType)) { num = rateInfoWithType.Rate; } } catch { } finally { RateMgr.m_lock.ReleaseReaderLock(); } return(num); }
private CurrentRatesInfoDto LoadRates(CurrencyDto[] currencies) { var rates = new List <CurrencyRateInfoDto>(); foreach (CurrencyDto currency in currencies) { if (currency.IsoCode == DefaultCurrencyIsoCode) { continue; } RateInfo rate = _rates.GetRateOrDefault(currency.IsoCode, DefaultCurrencyIsoCode); if (rate == null) { continue; } var currencyRateInfo = new CurrencyRateInfoDto(currency.IsoCode, rate.Rate, rate.Date); rates.Add(currencyRateInfo); } var ratesInfo = new CurrentRatesInfoDto(rates, DefaultCurrencyIsoCode); return(ratesInfo); }
private static bool IsValid(RateInfo _RateInfo) { //DateTime arg_07_0 = _RateInfo.BeginDay; //DateTime arg_0E_0 = _RateInfo.EndDay; // bool flag = 0 == 0; return(_RateInfo.BeginDay.Ticks <= DateTime.Now.Ticks && _RateInfo.EndDay.Ticks >= DateTime.Now.Ticks && !(_RateInfo.BeginTime.TimeOfDay > DateTime.Now.TimeOfDay) && !(_RateInfo.EndTime.TimeOfDay < DateTime.Now.TimeOfDay)); }
public void PeacemakerUpdate() { if (Manager == null) { return; } Rate rate = this.Rate; if (rate == null) { return; // || rate.Frame == ServiceConfiguration.TimeFrame.LIVE) return; } ChartPoint[] ACPints; DataPoint[] ADPoints; ChartPointInfo.DataPointType CPIDType = ChartPointInfo.DataPointType.Candle; SeriesChartType SCType = SeriesChartType.Candlestick; if (rate.Frame == ServiceConfiguration.TimeFrame.LIVE) { CPIDType = ChartPointInfo.DataPointType.AskLine; SCType = SeriesChartType.Line; } if (RateInfo.EqualsOrigin(rate, RateOld)) { int count = ChartMain.CountPoints(rate.Pair, this); ACPints = Manager.ForexArchive.GetChartPoints(rate, count); if (ACPints.Length <= 0) { return; } ADPoints = ChartPointInfo.ToDataPoints(ACPints, CPIDType); } else { RateOld = rate; ChartMain.ClearSeries(this); ChartMain.Add(rate.Pair, SCType, this); if (SCType == SeriesChartType.Candlestick) { ChartMain.SetCandlestickSettings(this, rate.Pair, Color.Green, Color.Red, Color.Black, Color.Transparent); } ACPints = Manager.ForexArchive.GetChartPoints(rate); ADPoints = ChartPointInfo.ToDataPoints(ACPints, CPIDType); } ChartMain.AddRange(this, rate.Pair, ADPoints, ChartValueType.DateTime, ChartValueType.Double); }
public int AddRate(RateInfo ri) { con.Open(); string sql = String.Format("INSERT INTO Rate VALUES ('{0}', '{1}', '{2}','{3}','{4}')", null, ri.Startdate, ri.Enddate, ri.Exchange, ri.Remark); MySqlCommand cmd = new MySqlCommand(sql, con); int iRet = cmd.ExecuteNonQuery();//这里返回的是受影响的行数,为int值。可以根据返回的值进行判断是否插入成功。 con.Close(); return(iRet); }
public ActionResult GetRateById(int id) { RateInfo rateInfo = db.RateInfoset.Find(id); if (rateInfo == null) { return(Json("Not Found", JsonRequestBehavior.AllowGet)); } return(Json(rateInfo, JsonRequestBehavior.AllowGet)); }
unsafe public static void InitRates(RateInfo* arr, int arr_size) { try { getInstance().getRates().rateInfo = arr; getInstance().getRates().rateInfoSize = arr_size; } catch (Exception e) { LOG.Error(e); } }
//----------------------------- private --------------------------------------------- static int getCarrierLCRRank(int pCarrierRouteId, DateTime pDateHour) { var _LCRRank = int.MaxValue; var _rateInfo = RateInfo.GetCarrierRateInfo(pCarrierRouteId, pDateHour); if (_rateInfo != null) { //TODO: combine other CarrierRoute's variables to get the LCRRank _LCRRank = _rateInfo.GetNormalizedCost(); } return(_LCRRank); }
public ActionResult DeleteRateInfo(int id) { RateInfo rateInfo = db.RateInfoset.Find(id); if (rateInfo == null) { return(Json("Model not found", JsonRequestBehavior.AllowGet)); } db.RateInfoset.Remove(rateInfo); db.SaveChanges(); return(Json(rateInfo, JsonRequestBehavior.AllowGet));; }
public bool Add(RateInfo ri, out string msg) { msg = null; bool isSuccess = false; if (ri.Startdate.Trim().Length != 0 || ri.Enddate.Trim().Length != 0 || ri.Exchange.Trim().Length != 0 || ri.Remark.Trim().Length != 0) //判断从传递来的username是否为空 { rdb.AddRate(ri); //传给DAL操作增加一个新用户 isSuccess = true; } else { msg = "不能为空"; } return(isSuccess);//返回界面层是否添加成功 }
public void GetRateInfoForAnimalTest() { ZooSpendingCalculator calculator = new ZooSpendingCalculator(); // Lion RateInfo rateInfoLion = calculator.GetRateInfoForAnimal("Lion"); Assert.AreEqual(0.10, rateInfoLion.rate, "wrong rate value"); Assert.AreEqual("meat", rateInfoLion.foodType, "wrong food type"); Assert.AreEqual(0, rateInfoLion.percentage, "wrong percentage value"); // Tiger RateInfo rateInfoTiger = calculator.GetRateInfoForAnimal("Tiger"); Assert.AreEqual(0.09, rateInfoTiger.rate, "wrong rate value"); Assert.AreEqual("meat", rateInfoTiger.foodType, "wrong food type"); Assert.AreEqual(0, rateInfoLion.percentage, "wrong percentage value"); // Giraffe RateInfo rateInfoGiraffe = calculator.GetRateInfoForAnimal("Giraffe"); Assert.AreEqual(0.08, rateInfoGiraffe.rate, "wrong rate value"); Assert.AreEqual("fruit", rateInfoGiraffe.foodType, "wrong food type"); Assert.AreEqual(0, rateInfoLion.percentage, "wrong percentage value"); // Zebra RateInfo rateInfoZebra = calculator.GetRateInfoForAnimal("Zebra"); Assert.AreEqual(0.08, rateInfoZebra.rate, "wrong rate value"); Assert.AreEqual("fruit", rateInfoZebra.foodType, "wrong food type"); Assert.AreEqual(0, rateInfoLion.percentage, "wrong percentage value"); // Wolf RateInfo rateInfoWolf = calculator.GetRateInfoForAnimal("Wolf"); Assert.AreEqual(0.07, rateInfoWolf.rate, "wrong rate value"); Assert.AreEqual("both", rateInfoWolf.foodType, "wrong food type"); Assert.AreEqual(0.9, rateInfoWolf.percentage, 0, "wrong percentage value"); // Piranha RateInfo rateInfoPiranha = calculator.GetRateInfoForAnimal("Piranha"); Assert.AreEqual(0.5, rateInfoPiranha.rate, "wrong rate value"); Assert.AreEqual("both", rateInfoPiranha.foodType, "wrong food type"); Assert.AreEqual(0.5, rateInfoPiranha.percentage, 0, "wrong percentage value"); }
public RateInfo GetRateWithType(int serverId, int type) { SqlDataReader reader = null; RateInfo result; try { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@ServerID", serverId), new SqlParameter("@Type", type) }; this.db.GetReader(ref reader, "SP_Rate_WithType", para); if (reader.Read()) { result = new RateInfo { ServerID = (int)reader["ServerID"], Type = type, Rate = (float)reader["Rate"], BeginDay = (DateTime)reader["BeginDay"], EndDay = (DateTime)reader["EndDay"], BeginTime = (DateTime)reader["BeginTime"], EndTime = (DateTime)reader["EndTime"] }; return(result); } } catch (Exception e) { if (true) { BaseBussiness.log.Error("GetRate type: " + type, e); } } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } result = null; return(result); }
public ArrayList GetRate(int serverId) { SqlDataReader reader = null; try { ArrayList arrryList = new ArrayList(); SqlParameter[] para = new SqlParameter[1]; para[0] = new SqlParameter("@ServerID", serverId); db.GetReader(ref reader, "SP_Rate", para); while (reader.Read()) { RateInfo info = new RateInfo(); info.ServerID = (int)reader["ServerID"]; info.Rate = (float)(decimal)reader["Rate"]; info.BeginDay = (DateTime)reader["BeginDay"]; info.EndDay = (DateTime)reader["EndDay"]; info.BeginTime = (DateTime)reader["BeginTime"]; info.EndTime = (DateTime)reader["EndTime"]; info.Type = (int)reader["Type"]; arrryList.Add(info); } arrryList.TrimToSize(); return(arrryList); } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("GetRates", e); } } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } return(null); }
public ActionResult <Rate> Create(RateInfo rateInfo, string productId) { var apiRep = new APIResponse(); var UserId = string.Empty; if (HttpContext.User.Identity is ClaimsIdentity identity) { UserId = identity.FindFirst(ClaimTypes.Name).Value; } List <Order> UserOrder = _orderService.GetById(UserId); var flag = 0; foreach (Order item in UserOrder) { for (var i = 0; i < item.orderinfo.carts.Length; i++) { if (productId == item.orderinfo.carts[i].ProductId) { flag = 1; break; } } } if (flag == 1) { var _rate = new Rate { userId = UserId, productId = productId, rate = rateInfo }; var rate = _rateService.Create(_rate); apiRep.Error = false; apiRep.Data = rate; } else { apiRep.Error = true; apiRep.Message = "You didn't buy this product yet!"; } return(Ok(apiRep)); }
public RateInfo LoadRateInfoFromBinaryData() { string path = Application.persistentDataPath + "/CircleGameRateInfo.hehe"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); RateInfo info = formatter.Deserialize(stream) as RateInfo; stream.Close(); return(info); } else { Debug.Log("Save file not found in " + path); return(null); } }
public RateInfo GetRateWithType(int serverId, int type) { SqlDataReader reader = null; try { SqlParameter[] para = new SqlParameter[2]; para[0] = new SqlParameter("@ServerID", serverId); para[1] = new SqlParameter("@Type", type); db.GetReader(ref reader, "SP_Rate_WithType", para); if (reader.Read()) { RateInfo info = new RateInfo(); info.ServerID = (int)reader["ServerID"]; info.Type = type; info.Rate = (float)reader["Rate"]; info.BeginDay = (DateTime)reader["BeginDay"]; info.EndDay = (DateTime)reader["EndDay"]; info.BeginTime = (DateTime)reader["BeginTime"]; info.EndTime = (DateTime)reader["EndTime"]; return(info); } } catch (Exception e) { if (log.IsErrorEnabled) { log.Error("GetRate type: " + type, e); } } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } return(null); }
private void button1_Click(object sender, EventArgs e) { ri = new RateInfo() { Startdate = dateTimePicker1.Text, Enddate = dateTimePicker2.Text, Exchange = textBox1.Text, Remark = textBox2.Text }; string messageStr = null; if (rm.Add(ri, out messageStr)) { MessageBox.Show("添加成功"); this.Hide(); } else { MessageBox.Show(messageStr); } }
public ActionResult <Rate> Create(RateInfo rateInfo, string productId) { var apiRep = new APIResponse(); // var UserId = string.Empty; // if (HttpContext.User.Identity is ClaimsIdentity identity) // { // UserId = identity.FindFirst(ClaimTypes.Name).Value; // } var _rate = new Rate { userId = "2", productId = productId, rate = rateInfo }; var rate = _rateService.Create(_rate); apiRep.Error = false; apiRep.Data = rate; return(Ok(apiRep)); }
// Use this for initialization void Start() { instance = this; DontDestroyOnLoad(gameObject); //ClearRateInfoBinaryData(); RateInfo tmp = LoadRateInfoFromBinaryData(); if (tmp == null) { rateInfo.count++; rateInfo.is_Rated = false; instance.SaveRateInfoBinaryData(); } else { rateInfo = tmp; rateInfo.count++; instance.SaveRateInfoBinaryData(); } }
private static RateInfo GetRateInfo(List <Rate> ratesWeek) { var rateInfo = new RateInfo(); rateInfo.StartDay = ratesWeek.Min(x => x.Date.Day); rateInfo.EndDay = ratesWeek.Max(x => x.Date.Day); rateInfo.CurrencyCode = ratesWeek.FirstOrDefault().CurrencyCode; ratesWeek.Sort((x, y) => x.Value.CompareTo(y.Value)); rateInfo.Minimum = ratesWeek[0].Value; rateInfo.Maximum = ratesWeek[ratesWeek.Count() - 1].Value; if (ratesWeek.Count() % 2 == 0) { var half = ratesWeek.Count() / 2; rateInfo.Median = (ratesWeek[half].Value + ratesWeek[half - 1].Value) / 2; } else { rateInfo.Median = ratesWeek[ratesWeek.Count() / 2].Value; } return(rateInfo); }
private static bool IsValid(RateInfo _RateInfo) { if (_RateInfo.BeginDay == null || _RateInfo.EndDay == null) { return(false); } if (_RateInfo.BeginDay.Year > DateTime.Now.Year || DateTime.Now.Year > _RateInfo.EndDay.Year) { return(false); } if (_RateInfo.BeginDay.DayOfYear > DateTime.Now.DayOfYear || DateTime.Now.DayOfYear > _RateInfo.EndDay.DayOfYear) { return(false); } if (_RateInfo.BeginTime.TimeOfDay > DateTime.Now.TimeOfDay || DateTime.Now.TimeOfDay > _RateInfo.EndTime.TimeOfDay) { return(false); } return(true); }
private void LoadDefaultConfig() { VideoVolume = 30; MicrophoneVolume = 50; UseMicrophoneID = 0; RecordingStatusChangesAccordingToLiveBroadcastStatus = false; UploadCompletedAutoDeleteLocalFile = false; IsAutoUpload = false; AutoDelayDuration = 10; UseResolutionInfo = new ResolutionInfo { ID = 2, DisplayName = "960*540", Width = 960, Height = 540 }; UseRateInfo = new RateInfo { ID = 3, DisplayName = "1500kbps", Value = 1500 }; UseFrameRateInfo = new FrameRateInfo { ID = 1, DisplayName = "25Fps", Value = 25 }; if (!Directory.Exists(AllDataSavePath)) { Directory.CreateDirectory(AllDataSavePath); } Save(); }
public async Task <IActionResult> Post([FromHeader(Name = "Authorization")] string authorization, [FromBody] LogContractInput contract) { if (string.IsNullOrEmpty(authorization)) { return(Unauthorized()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!Guid.TryParse(authorization, out Guid accessToken)) { return(BadRequest("There is something wrong in Authorization header. Please check access token, It should be 32 character id for authorization.")); } if (!ObjectId.TryParse(contract.ApplicationId, out ObjectId applicationId)) { return(BadRequest("There is something wrong in Request. Please check applicationId, It should be 32 character id.")); } int throttleTimeoutForMethodCall = 600; int requestNumber = 3; bool allowExecute = true; if (applicationId != null && !string.IsNullOrEmpty(applicationId.ToString())) { var objectIdStr = applicationId.ToString(); RateInfo rate; bool isExist = _cache.TryGetValue(objectIdStr, out rate); if (!isExist) { rate = new RateInfo(); var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(60)); _cache.Set(objectIdStr, rate, cacheEntryOptions); allowExecute = true; } if (allowExecute) { if (rate.Hits == requestNumber) { allowExecute = false; var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(throttleTimeoutForMethodCall)); _cache.Set(objectIdStr, rate, cacheEntryOptions); } rate.Hits++; if (!allowExecute) { return(BadRequest(string.Format("Rate limit exceeded!! You can call API {0} times per minute", requestNumber))); } } } if (await _db.GetCollection <Token>("Token").Find(a => a.Value == accessToken.ToString().Replace("-", string.Empty) && a.ApplicationId == applicationId).FirstOrDefaultAsync() == null) { return(Ok(new LogContractOutput() { Success = false })); } var log = new Log { ApplicationId = applicationId, Level = contract.Level, Logger = contract.Logger, Message = contract.Message }; await _db.GetCollection <Log>("Log").InsertOneAsync(log); return(Ok(new LogContractOutput() { Success = true })); }
public static void CheckEquivalence(this CurrencyRate rate, RateInfo info) { info.Rate.Should().Be(rate.Value); info.CurrencyTo.Should().Be(rate.CurrencyTo); info.ExpireAt.Should().Be(rate.ExpirationTime); }
private bool Parse() { String jsonSliderData = ParseByPattern(_html, PATTERN_SLIDER_DATA); if (!jsonSliderData.Equals("")) { try { // тарифы dynamic sliderData = JsonConvert.DeserializeObject(jsonSliderData); IEnumerable<JProperty> properties = sliderData.Properties(); String[] productIds = properties.Select(p => p.Name).ToArray(); _productInfos = new ProductInfo[productIds.Length]; for (int i = 0; i < productIds.Length; ++i) { String productId = productIds[i]; dynamic productData = sliderData[productId]; var product = new ProductInfo(); product.productId = productId; product.currentRateCode = productData["offerCode"]; JArray steps = productData["steps"]; product.rateInfos = new RateInfo[steps.Count]; for (int j = 0; j < steps.Count; ++j) { var rate = new RateInfo(); dynamic step = steps[j]; rate.code = step["code"]; rate.amountNumber = step["amountNumber"]; rate.amountString = NameImprover.ImproveAmountString(step["amountString"].ToString()); rate.remainNumber = step["remainNumber"]; rate.remainString = step["remainString"]; rate.speedNumber = NameImprover.ImproveSpeedNumber(step["speedNumber"].ToString()); rate.speedString = NameImprover.ImproveSpeedString(step["speedString"].ToString()); product.rateInfos[j] = rate; } _productInfos[i] = product; } // устройства String[] datas = _html.Split(new string[] { PATTERN_DEVICE }, StringSplitOptions.None); for (int i = 0; i < datas.Length; ++i) { String productId = ParseByPattern(datas[i], PATTERN_PRODUCT_ID); int index = Array.IndexOf(productIds, productId); if (index != -1) { _productInfos[index].deviceId = ParseByPattern(datas[i], PATTERN_DEVICE_ID); _productInfos[index].deviceName = ParseByPattern(datas[i], PATTERN_DEVICE_NAME); _productInfos[index].days = ParseByPattern(datas[i], PATTERN_DAYS); } } // баланс _balance = ParseByPattern(_html, PATTERN_MONEY); _balance = NameImprover.ImproveMoneyString(_balance); return true; } catch (Exception e) { Console.WriteLine(e.Message); _productInfos = null; return false; } } return false; }
public unsafe static void InitRates(Int64 ix, RateInfo* arr, int arr_size) { LOG.Info("Initializing Rates: " + ix); bool initialized = false; while (!initialized) { try { getInstance(ix).rateInfo = arr; getInstance(ix).rateInfoSize = arr_size; initialized = true; } catch (Exception e) { LOG.Error(e); } } }
public static bool Payment(string ioRecordId, string parkingId, ResultAgs billResult, string operatorId) { if (billResult == null) { throw new MyException("获取缴费信息失败"); } if (billResult.FeeRule == null) { throw new MyException("获取收费规则失败"); } if (billResult.Rate == null) { throw new MyException("获取缴费金额失败"); } using (DbOperator dbOperator = ConnectionManager.CreateConnection()) { try { dbOperator.BeginTransaction(); List <string> carderateIds = new List <string>(); Dictionary <string, decimal> sellers = new Dictionary <string, decimal>(); if (billResult.Carderates != null && billResult.Carderates.Count > 0) { carderateIds = billResult.Carderates.Select(p => p.CarDerateID).ToList(); foreach (var item in billResult.Carderates) { if (sellers.ContainsKey(item.Derate.SellerID)) { sellers[item.Derate.SellerID] = sellers[item.Derate.SellerID] + item.FreeMoney; continue; } sellers.Add(item.Derate.SellerID, item.FreeMoney); } } RateInfo rate = billResult.Rate; ParkOrder order = ParkOrderServices.AddCentralFeeOrder(parkingId, ioRecordId, rate.Amount, rate.UnPayAmount, rate.DiscountAmount, carderateIds, billResult.FeeRule.FeeRuleID, rate.CashTime, rate.CashMoney, operatorId, dbOperator); if (order == null) { throw new MyException("创建缴费订单失败"); } if (carderateIds.Count > 0) { IParkSeller factory = ParkSellerFactory.GetFactory(); factory.UpdateParkCarDerateStatus(carderateIds, 2, dbOperator); foreach (var item in sellers) { bool result = factory.SellerDebit(item.Key, item.Value, dbOperator); if (!result) { throw new MyException("商家扣款失败"); } } } dbOperator.CommitTransaction(); OperateLogServices.AddOperateLog(OperateType.Other, string.Format("中央收费,ioRecordId:{0},parkingId:{1},operatorId:{2},收费金额:{3},优惠金额:{4}", ioRecordId, parkingId, operatorId, rate.UnPayAmount, rate.DiscountAmount)); } catch { dbOperator.RollbackTransaction(); throw; } } return(true); }
/// <summary> /// Select the cheapest hotel from the available hotels and get the details of the selected hotel /// </summary> /// <param name="hotelResponse"></param> /// <returns></returns> /// public HotelDetailsRsp HotelDetails(BaseHotelSearchRsp hotelResponse) { HotelSearchResult closest = null; HotelSearchResult cheapest = null; int lowestDistance = Int32.MaxValue; double lowestPrice = Int32.MaxValue; IEnumerator <HotelSearchResult> searchResults = hotelResponse.HotelSearchResult.ToList().GetEnumerator(); while (searchResults.MoveNext()) { HotelSearchResult result = searchResults.Current; IEnumerator <HotelService.HotelProperty> hotelProperties = result.HotelProperty.ToList().GetEnumerator(); if (result.RateInfo != null && result.RateInfo.Count() > 0) { while (hotelProperties.MoveNext()) { HotelService.HotelProperty property = hotelProperties.Current; if (property.Availability.CompareTo(HotelService.typeHotelAvailability.Available) == 0) { if (property.ReserveRequirement.CompareTo(HotelService.typeReserveRequirement.Other) == 0) { continue; } if (property.Distance != null) //check lowest distance for closet hotel from the reference point { int distance = Convert.ToInt32(property.Distance.Value); if (distance < lowestDistance) { ClosestHotelCode = property.HotelCode; closest = result; lowestDistance = distance; } } IEnumerator <RateInfo> hotelRates = result.RateInfo.ToList().GetEnumerator(); while (hotelRates.MoveNext()) { RateInfo rate = hotelRates.Current; double minRate = 0.0; if (rate.MinimumAmount != null) { minRate = Helper.parseNumberWithCurrency(rate.MinimumAmount); } else if (rate.ApproximateMinimumStayAmount != null) { minRate = Helper.parseNumberWithCurrency(rate.ApproximateMinimumStayAmount); } else if (rate.ApproximateMinimumAmount != null) { minRate = Helper.parseNumberWithCurrency(rate.ApproximateMinimumAmount); } if (minRate == 0.0) { if (rate.MaximumAmount != null) { minRate = Helper.parseNumberWithCurrency(rate.MaximumAmount) / 2; } else if (rate.ApproximateMinimumAmount != null) { minRate = Helper.parseNumberWithCurrency(rate.ApproximateMinimumAmount) / 2; } else if (rate.ApproximateMaximumAmount != null) { minRate = Helper.parseNumberWithCurrency(rate.ApproximateMaximumAmount) / 2; } } if (minRate < lowestPrice)/// Check the lowest price { CheapestHotelCode = property.HotelCode; cheapest = result; lowestPrice = minRate; if (rate.RateSupplier != null) { RateSupplier = rate.RateSupplier; } } } } } } } if (hotelResponse.HostToken != null) { hostToken = hotelResponse.HostToken; } if (closest == null) { HotelSearchResult[] hotelSearchResult = new HotelSearchResult[1]; hotelSearchResult[0] = cheapest; } HotelSearchResult[] hotelSearchResultBoth = new HotelSearchResult[2]; hotelSearchResultBoth[0] = cheapest; hotelSearchResultBoth[1] = closest; HotelDetailsReq detailsRequest = new HotelDetailsReq(); detailsRequest.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH); detailsRequest.TraceId = "Trace"; detailsRequest.AuthorizedBy = "User"; detailsRequest.ReturnMediaLinks = true; HotelService.BillingPointOfSaleInfo billSaleInfo = new HotelService.BillingPointOfSaleInfo(); billSaleInfo.OriginApplication = CommonUtility.GetConfigValue(ProjectConstants.APP); detailsRequest.BillingPointOfSaleInfo = billSaleInfo; detailsRequest.HotelProperty = cheapest.HotelProperty[0];// Cheapsest hotel selected HotelService.HotelDetailsModifiers hotelDetailsModifiers = new HotelService.HotelDetailsModifiers(); hotelDetailsModifiers.HotelStay = GetHotelStay(); hotelDetailsModifiers.NumberOfAdults = numberOfAdults; hotelDetailsModifiers.NumberOfRooms = numberOfRooms; hotelDetailsModifiers.RateRuleDetail = HotelService.typeRateRuleDetail.Complete; hotelDetailsModifiers.PermittedProviders = new HotelService.PermittedProviders() { Provider = new HotelService.Provider() { Code = providerCode } }; detailsRequest.HotelDetailsModifiers = hotelDetailsModifiers; HotelDetailsServicePortTypeClient detailsClient = new HotelDetailsServicePortTypeClient("HotelDetailsServicePort", WsdlService.HOTEL_ENDPOINT); detailsClient.ClientCredentials.UserName.UserName = Helper.RetrunUsername(); detailsClient.ClientCredentials.UserName.Password = Helper.ReturnPassword(); try { var httpHeaders = Helper.ReturnHttpHeader(); detailsClient.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders)); detailsResponse = detailsClient.service(detailsRequest); } catch (Exception se) { detailsClient.Abort(); } HotelRulesRsp hotelRulesResponse = HotelRules(cheapest.HotelProperty[0]); return(detailsResponse); }