public double GetTrendCorrection(long storeworldid, DateTime date) { if (_listEntities == null || _listEntities.Count == 0) return 1; if (_cache_entity != null) { if (_cache_entity.StoreWorldID == storeworldid && DateTimeHelper.Between(date, _cache_entity.BeginTime, _cache_entity.EndTime)) return _cache_entity.Value; _cache_entity = null; } TrendCorrection trend = _listEntities.Find(delegate(TrendCorrection trend1) { if (trend1.StoreWorldID == storeworldid) return DateTimeHelper.Between(date, trend1.BeginTime, trend1.EndTime); else return false; } ); _cache_entity = trend; //foreach (TrendCorrection trend in _listEntities) //{ // if (DateTimeHelper.IsHitInInterval(date, trend.BeginTime, trend.EndTime)) // return trend.Value; //} return (trend != null) ? trend.Value : 1; }
bool InsertTrend() { if (ValidateEntity()) { TrendCorrection trend = CreateEntity(); try { trend = ClientEnvironment.StoreService.TrendCorrectionService.Save(trend); StoreToWorld sw = (StoreToWorld)lookUpWorlds.Properties.GetDataSourceRowByKeyValue(StoreWorldId); if (sw != null) trend.WorldName = sw.WorldName; _entity = trend; _modified = true; return true; } catch(ValidationException) { ErrorMessage(GetLocalized("ErrorTrendCorrectionRangeIntersect"), GetLocalized("Attention")); } } return false; }
void CopyEntity(TrendCorrection source, TrendCorrection dest) { dest.StoreWorldID = source.StoreWorldID; dest.Name = source.Name; dest.BeginTime = source.BeginTime; dest.EndTime = source.EndTime; dest.Value = source.Value; dest.ID = source.ID; }