public IList <IReservationDetailsEntity> getList(IMainFilterEntity filter, IReservationDetailsFilterEntity rdfe, string sortExpression, string sortDirection) { using (var db = new PoolingDataClassesDataContext()) { //db.Log = new DebugTextWriter(); IQueryable <Mars.App.Classes.DAL.Pooling.PoolingDataContext.Reservation> q = _resCarFilterQ.FilterByCarParameters(db, filter); if (rdfe.CheckInOut == CHECKIN) { q = _resFilterQ.FilterByReturnLocation(q, filter); q = _resCIQueryable.GetQueryable(q, rdfe, filter); } else { q = _resFilterQ.FilterByRentalLocation(q, filter); q = _resCOQueryable.GetQueryable(q, rdfe, filter); } q = _resBFQ.GetQueryable(q, rdfe); q = _resSortQ.getQueryable(sortExpression, sortDirection, q); _list = _resDetQ.getQueryable(db, q).ToList(); var ss = _list.Count(); return(_list); } }
public void TestReservationCheckOutDataAccess() { var mfe = GetMainFilterExample(); var resCarFilterQ = new ReservationsFilterCar(); var resFilterQ = new ReservationsSiteFilter(); var reqCo = new PoolingCheckOutReservations(); var resCOSiteQ = new ResSiteCOQueryable(); var resCOFleetQ = new PoolingCheckOutReservationsWithLabels(); List <DayActualEntity> dayActuals; List <DayActualEntity> fleet; List <DayActualEntity> site; using (var db = new PoolingDataClassesDataContext()) { var q2And3 = resCarFilterQ.FilterByCarParameters(db, mfe, false); q2And3 = resFilterQ.FilterByRentalLocation(q2And3, mfe); mfe.Branch = ""; site = resCOSiteQ.GetQueryableCO(q2And3, mfe, Enums.DayActualTime.THREE).ToList(); mfe.Branch = "GELEJ50"; fleet = resCOFleetQ.GetQueryable(q2And3, mfe, Enums.DayActualTime.THREE).ToList(); dayActuals = reqCo.GetReservationsWithoutLabels(q2And3, mfe, Enums.DayActualTime.THREE).ToList(); } TestResultComparison.CheckAllPoolingValues(dayActuals, fleet, site, "GELEJ50"); }
public void TestReservationCheckInDataAccess() { var mfe = GetMainFilterExample(); var resCarFilterQ = new ReservationsFilterCar(); var resFilterQ = new ReservationsSiteFilter(); var reqCi = new ResActualCIQueryable(); var resCiSiteQ = new ResSiteCIQueryable(); var resCiFleetQ = new PoolingCheckInReservations(); List <DayActualEntity> dayActuals; List <DayActualEntity> site; List <DayActualEntity> fleet; using (var db = new PoolingDataClassesDataContext()) { var q2And3 = resCarFilterQ.FilterByCarParameters(db, mfe, true); q2And3 = resFilterQ.FilterByReturnLocation(q2And3, mfe); mfe.Branch = ""; site = resCiSiteQ.GetQueryableCI(q2And3, mfe, Enums.DayActualTime.THREE, db); mfe.Branch = "GELEJ50"; fleet = resCiFleetQ.GetFleetReservationsWithLabels(q2And3, mfe, Enums.DayActualTime.THREE, db); dayActuals = reqCi.GetQueryable(q2And3, mfe, Enums.DayActualTime.THREE); } TestResultComparison.CheckAllPoolingValues(dayActuals, fleet, site, "GELEJ50"); }
public override IList <AlertsPopupEntity> GetTable(params String[] s) { Int32 hr = DateTime.Now.Hour + 1; Int32 frhr = hr + 4; DateTime endOfDay = DateTime.Now.Date.AddDays(1); using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { IQueryable <AlertsPopupEntity> q = from p in db.Reservations where p.CAR_GROUP.car_group1 == s[1] && p.LOCATION1.location1 == s[0] && (p.RS_ARRIVAL_DATE == DateTime.Now.Date) select new AlertsPopupEntity { ResNbr = p.RES_ID_NBR, RtrnLoc = p.LOCATION.location1, RtrnDate = p.RS_ARRIVAL_TIME }; if (s[2] == _columns.divNextHour.ToString()) { return((from p in q where p.RtrnDate.Value.Hour < hr select p).ToList()); } if (s[2] == _columns.divFollow4Hours.ToString()) { return((from p in q where p.RtrnDate.Value.Hour >= hr && p.RtrnDate.Value.Hour < frhr select p).ToList()); } return((from p in q where p.RtrnDate.Value.Hour >= frhr select p).ToList()); } }
public IQueryable <IReservationDetailsEntity> getQueryable(PoolingDataClassesDataContext db, IQueryable <Reservation> q) { var returned = from p in q select new ReservationDetailsEntity { CAR_CLASS = p.CAR_GROUP.CAR_CLASS.car_class1, CAR_SEGMENT = p.CAR_GROUP.CAR_CLASS.CAR_SEGMENT.car_segment1, CARVAN = "", CDPID_NBR = p.CDPID_NBR, CI_DAYS = p.CI_DAYS, CI_HOURS = p.CI_HOURS, CI_HOURS_OFFSET = p.CI_HOURS_OFFSET, CMS_LOC_GRP = p.LOCATION1.CMS_LOCATION_GROUP.cms_location_group1, CMS_POOL = p.LOCATION1.CMS_LOCATION_GROUP.CMS_POOL.cms_pool1, CNTID_NBR = p.CNTID_NBR, CO_DAYS = p.CO_DAYS, CO_HOURS = p.CO_HOURS, COUNTRY = p.COUNTRY, CUST_NAME = p.CUST_NAME, DATE_SOLD = p.DATE_SOLD, FLIGHT_NBR = p.FLIGHT_NBR, GR_INCL_GOLDUPGR = p.CAR_GROUP.car_group1, ReservedCarGroup = p.ReservedCarGroup, GS = p.GS, ICIND = p.ICIND, IMPORTTIME = DateTime.Now, N1TYPE = p.N1TYPE, NEVERLOST = p.NEVERLOST, NO1_CLUB_GOLD = p.NO1_CLUB_GOLD, ONEWAY = p.ONEWAY, OPS_AREA = p.LOCATION1.OPS_AREA.ops_area1, OPS_REGION = p.LOCATION1.OPS_AREA.OPS_REGION.ops_region1, PHONE = p.PHONE, PREDELIVERY = p.PREDELIVERY, PREPAID = p.PREPAID, R1 = "", R2 = "", R3 = "", RATE_QUOTED = p.RATE_QUOTED, REMARKS = string.Join("<br/><br/>", p.ResRemarks.Where(o => o.ResRmkType == "FLDRMK").Select(d => d.Remark)), RENT_LOC = p.RentalLocation.location1, REP_MONTH = "", REP_YEAR = "", RES_DAYS = p.RES_DAYS, RES_ID_NBR = p.RES_ID_NBR, RES_LOC = p.RentalLocation.location1, RES_VEH_CLASS = p.CAR_GROUP.car_group1, RS_ARRIVAL_DATE = p.RS_ARRIVAL_DATE, RS_ARRIVAL_TIME = p.RS_ARRIVAL_TIME, RTRN_DATE = p.RTRN_DATE, RTRN_LOC = p.ReturnLocation.location1, RTRN_TIME = p.RTRN_TIME, SUBTOTAL_2 = p.SUBTOTAL_2, TACO = p.TACO, TS = DateTime.Now }; return(returned); }
public static IList <ResTopic> GetResTopicList() { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { var returned = db.ResTopics.ToList(); return(returned); } }
public static List <DayActualEntity> GetPoolingCheckOutDataForAlerts(PoolingDataClassesDataContext db, IMainFilterEntity mfe) { var q2And3 = CarParametersFilter.FilterByCarParameters(db, mfe, false); q2And3 = SiteParametersFilter.FilterByRentalLocation(q2And3, mfe); var returned = _resCOFleetQ.GetCheckOutReservationsForAlerts(q2And3, db, mfe); return(returned); }
public IList <DropdownEntity> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { return((from p in db.COUNTRies where p.active orderby p.country_description select new DropdownEntity { Name = p.country_description, Code = p.country1 }).ToList()); } }
public IList <string> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { var returned = (from p in db.ResTopics where p.Name.Contains("Reservations") select p.Name).ToList(); return(returned); } }
public IList <string> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { var returned = (from p in db.ResTopics where !p.Name.Equals("Predelivery") select p.Name).ToList(); return(returned); } }
public IList <DropdownEntity> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { string country = dependants[0] == "***All***" ? string.Empty : dependants[0] ?? ""; return((from p in db.OPS_REGIONs where p.COUNTRy1.country_description == country && p.COUNTRy1.active select new DropdownEntity { Name = p.ops_region1, Id = p.ops_region_id }).ToList()); } }
public IList <DropdownEntity> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { string country = dependants[0] == "***All***" ? string.Empty : dependants[0] ?? ""; return((from p in db.CMS_POOLs where p.COUNTRy1.country_description == country orderby p.cms_pool1 select new DropdownEntity { Name = p.cms_pool1, Id = p.cms_pool_id }).ToList()); } }
public IList <DropdownEntity> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { string poolId = dependants[0] == "***All***" ? string.Empty : dependants[0] ?? ""; string countryName = dependants[1]; return((from lg in db.CMS_LOCATION_GROUPs where lg.CMS_POOL.cms_pool1 == poolId && lg.CMS_POOL.COUNTRy1.country_description == countryName select new DropdownEntity { Name = lg.cms_location_group1, Id = lg.cms_location_group_id }).ToList()); } }
public static List <DayActualEntity> GetPoolingCheckOutData(IMainFilterEntity mfe, bool hourlyTimeSlots , PoolingDataClassesDataContext db) { var q2And3 = CarParametersFilter.FilterByCarParameters(db, mfe, false); q2And3 = SiteParametersFilter.FilterByRentalLocation(q2And3, mfe); var l = _reqCo.GetReservationsWithoutLabels(q2And3, mfe, hourlyTimeSlots ? Enums.DayActualTime.THREE : Enums.DayActualTime.THIRTY).ToList(); var returned = l; return(returned); }
public static List <DayActualEntity> GetPoolingCheckInDataWithLabels(IMainFilterEntity mfe, bool hourlyTimeSlots , PoolingDataClassesDataContext db, bool siteQ) { var q2And3 = CarParametersFilter.FilterByCarParameters(db, mfe, true); q2And3 = SiteParametersFilter.FilterByReturnLocation(q2And3, mfe); var checkinData = siteQ ? _resCISiteQ.GetQueryableCI(q2And3, mfe, hourlyTimeSlots ? Enums.DayActualTime.THREE : Enums.DayActualTime.THIRTY, db) : _resCIFleetQ.GetFleetReservationsWithLabels(q2And3, mfe, hourlyTimeSlots ? Enums.DayActualTime.THREE : Enums.DayActualTime.THIRTY, db); var returned = checkinData.ToList(); return(returned); }
public static string LookupGoldLevel(string resIdNumber) { string returned; using (var db = new PoolingDataClassesDataContext()) { var data = from r in db.Reservations join rlp in db.ResLoyaltyPrograms on r.N1TYPE equals rlp.N1Type where r.RES_ID_NBR == resIdNumber select rlp.ResGoldLevel.GoldLevelName; returned = data.FirstOrDefault(); } return(returned); }
public IList <DropdownEntity> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { List <string> l = new List <string>(); string country = dependants[0] == "***All***" ? string.Empty : dependants[0] ?? ""; string carSegment = dependants[1] == "***All***" ? string.Empty : dependants[1] ?? ""; return((from p in db.CAR_CLASSes where p.CAR_SEGMENT.car_segment1 == carSegment && p.CAR_SEGMENT.COUNTRy1.country_description == country select new DropdownEntity { Name = p.car_class1, Id = p.car_class_id }).ToList()); } }
public static List <DayActualEntity> GetPoolingCheckInData(IMainFilterEntity mfe, bool hourlyTimeSlots , PoolingDataClassesDataContext db) { var q2And3 = CarParametersFilter.FilterByCarParameters(db, mfe, true); q2And3 = SiteParametersFilter.FilterByReturnLocation(q2And3, mfe); var checkinData = _reqCi.GetQueryable(q2And3, mfe, hourlyTimeSlots ? Enums.DayActualTime.THREE : Enums.DayActualTime.THIRTY); var returned = checkinData.ToList(); return(returned); }
public static List <DayActualEntity> GetPoolingCheckOutDataWithLabels(IMainFilterEntity mfe, bool hourlyTimeSlots , PoolingDataClassesDataContext db, bool siteQ) { var q2And3 = CarParametersFilter.FilterByCarParameters(db, mfe, false); q2And3 = SiteParametersFilter.FilterByRentalLocation(q2And3, mfe); var l = siteQ ? _resCOSiteQ.GetQueryableCO(q2And3, mfe, hourlyTimeSlots ? Enums.DayActualTime.THREE : Enums.DayActualTime.THIRTY).ToList() : _resCOFleetQ.GetQueryable(q2And3, mfe, hourlyTimeSlots ? Enums.DayActualTime.THREE : Enums.DayActualTime.THIRTY).ToList(); var returned = l; return(returned); }
public IQueryable <Reservation> GetQueryable(PoolingDataClassesDataContext db, IMainFilterEntity filter) { return(from p in db.Reservations where (p.LOCATION1.COUNTRy1.country_description == filter.Country || String.IsNullOrEmpty(filter.Country)) && ((filter.Logic == true && (filter.PoolRegion == p.LOCATION1.CMS_LOCATION_GROUP.CMS_POOL.cms_pool1 || String.IsNullOrEmpty(filter.PoolRegion)) && (filter.LocationGrpArea == p.LOCATION1.CMS_LOCATION_GROUP.cms_location_group1 || String.IsNullOrEmpty(filter.LocationGrpArea)) && (filter.Branch == p.LOCATION1.location1 || String.IsNullOrEmpty(filter.Branch))) || (filter.Logic == false && (filter.PoolRegion == p.LOCATION1.OPS_AREA.OPS_REGION.ops_region1 || String.IsNullOrEmpty(filter.PoolRegion)) && (filter.LocationGrpArea == p.LOCATION1.OPS_AREA.ops_area1 || String.IsNullOrEmpty(filter.LocationGrpArea)) && (filter.Branch == p.LOCATION1.location1 || String.IsNullOrEmpty(filter.Branch)))) && (filter.CarSegment == p.CAR_GROUP.CAR_CLASS.CAR_SEGMENT.car_segment1 || String.IsNullOrEmpty(filter.CarSegment)) && (filter.CarClass == p.CAR_GROUP.CAR_CLASS.car_class1 || String.IsNullOrEmpty(filter.CarClass)) && (filter.CarGroup == p.CAR_GROUP.car_group1 || String.IsNullOrEmpty(filter.CarGroup)) select p); }
//ILog _logger = log4net.LogManager.GetLogger("Pooling"); public IReservationDBUpdateEntity getItem() { using (var db = new PoolingDataClassesDataContext()) { try { var lastReservation = db.ReservationTeradataControlLogs.Where(d => d.Processed).Max(d => d.TeradataTimeStamp); if (!lastReservation.HasValue) { lastReservation = DateTime.MinValue; } string centralZoneId = "Central Standard Time"; string gmtZoneId = "GMT Standard Time"; TimeZoneInfo centralZone = TimeZoneInfo.FindSystemTimeZoneById(centralZoneId); TimeZoneInfo gmtZone = TimeZoneInfo.FindSystemTimeZoneById(gmtZoneId); var convertedDate = TimeZoneInfo.ConvertTime(lastReservation.Value, centralZone, gmtZone); convertedDate = convertedDate.AddSeconds(-convertedDate.Second); var lastFleet = ImportDetails.GetLastDataImportTime((int)ImportDetails.ImportType.Availability); lastFleet = lastFleet.AddSeconds(-lastFleet.Second); var returned = new ReservationDBUpdateEntity { TeraDataMessage = string.Format("Reservations up to: {0} GMT", convertedDate) , FleetMessage = string.Format("Fleet Last Updated: {0} GMT", lastFleet) }; return(returned); //return (from p in db.ResControls // select new ReservationDBUpdateEntity // { // LastUpdate = p.TimeStamp // , Id = p.Id // }).OrderByDescending(p => p.Id).First(); } catch (SqlException ex) { //if (_logger != null) _logger.Error("Exception thrown in ReservationLogRepository, message : " + ex.Message); } return(new ReservationDBUpdateEntity()); } }
public IList <DropdownEntity> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { string opsArea = dependants[0] == "***All***" ? string.Empty : dependants[0] ?? ""; string opsRegionDescription = dependants[1]; string countryDescription = dependants[2]; var returned = (from p in db.LOCATIONs where p.OPS_AREA.ops_area1 == opsArea && p.OPS_AREA.OPS_REGION.ops_region1 == opsRegionDescription && p.COUNTRy1.country_description == countryDescription select new DropdownEntity { Name = p.location1, Id = p.ops_area_id }).ToList(); return(returned); } }
public IList <DropdownEntity> getList(params string[] dependants) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { string LocationGroup = dependants[0] == "***All***" ? string.Empty : dependants[0] ?? ""; string pool = dependants[1]; string country = dependants[2]; var returned = (from p in db.LOCATIONs where p.CMS_LOCATION_GROUP.cms_location_group1 == LocationGroup && p.CMS_LOCATION_GROUP.CMS_POOL.cms_pool1 == pool && p.COUNTRy1.country_description == country select new DropdownEntity { Name = p.location1, Id = p.cms_location_group_id ?? -1 }).ToList(); return(returned); } }
IList <DayActualEntity> GetPoolingCOData(IMainFilterEntity mfe) { using (var db = new PoolingDataClassesDataContext()) { IList <DayActualEntity> l = new List <DayActualEntity>(); try { IQueryable <App.Classes.DAL.Pooling.PoolingDataContext.Reservation> q2And3 = _resCarFilterQ.FilterByCarParameters(db, mfe, false); q2And3 = _resFilterQ.FilterByRentalLocation(q2And3, mfe); l = _reqCo.GetReservationsWithoutLabels(q2And3, mfe, _time).ToList(); } catch (SqlException ex) { // ILog _logger = LogManager.GetLogger("Pooling"); // if (_logger != null) _logger.Error(" SQL Exception thrown in DayActualRepository accessing Reservations table, message : " + ex.Message); } return(l); } }
IList <DayActualEntity> GetPoolingCOData(Enums.DayActualTime tme) { using (PoolingDataClassesDataContext db = new PoolingDataClassesDataContext()) { IList <DayActualEntity> l = new List <DayActualEntity>(); try { IQueryable <App.Classes.DAL.Pooling.PoolingDataContext.Reservation> q2And3 = _resCarFilterQ.FilterByCarParameters(db, Filter, false); q2And3 = _resFilterQ.FilterByRentalLocation(q2And3, Filter); l = _resFleetCOQ.GetQueryable(q2And3, Filter, tme).ToList(); } catch (SqlException ex) { // ILog _logger = log4net.LogManager.GetLogger("Pooling"); // if (_logger != null) _logger.Error(" SQL Exception thrown in SiteComparisonRepository accessing Reservations table, message : " + ex.Message); } return(l); } }
public static List <DayActualEntity> GetPoolingCheckInDataForAlerts(PoolingDataClassesDataContext db, IMainFilterEntity filter) { var q2And3 = from p in db.Reservations where (p.CAR_GROUP.CAR_CLASS.CAR_SEGMENT.car_segment1 == filter.CarSegment || String.IsNullOrEmpty(filter.CarSegment)) && (p.CAR_GROUP.CAR_CLASS.car_class1 == filter.CarClass || String.IsNullOrEmpty(filter.CarClass)) && (p.CAR_GROUP.car_group1 == filter.CarGroup || String.IsNullOrEmpty(filter.CarGroup)) select p; if (filter.ExcludeLongterm) { //q2And3 = q2And3.Where(d => !(d.RentalLocation.served_by_locn.Substring(5, 1) != "5" && // SqlMethods.DateDiffDay(d.RS_ARRIVAL_DATE, d.RTRN_DATE) > 27)); q2And3 = q2And3.Except(q2And3.Where(d => d.RentalLocation.served_by_locn.Substring(5, 1) != "5" && SqlMethods.DateDiffDay(d.RS_ARRIVAL_DATE, d.RTRN_DATE) > 27)); } q2And3 = SiteParametersFilter.FilterByReturnLocation(q2And3, filter); var returned = _resCIFleetQ.GetCheckInReservationsOffsetForAlerts(q2And3, db, filter); return(returned); }
IList <AlertTempEntity> GetPoolingCOData() { using (var db = new PoolingDataClassesDataContext()) { //db.Log = new DebugTextWriter(); var l = new List <AlertTempEntity>(); try { IQueryable <App.Classes.DAL.Pooling.PoolingDataContext.Reservation> q1 = _resCarFilterQ.FilterByCarParameters(db, Filter, false); q1 = _resFilterQ.FilterByRentalLocation(q1, Filter); l = _resQCo.GetQueryable(q1, DateSelected).ToList(); //l = l.OrderByDescending(d => d.Amnt).ToList(); } catch (SqlException ex) { // ILog _logger = log4net.LogManager.GetLogger("Pooling"); //if (_logger != null) _logger.Error(" SQL Exception thrown in AlertsRepository accessing Reservations table, message : " + ex.Message); } return(l); } }
public static List <DayActualEntity> GetLocationCarGroups(IMainFilterEntity mfe, DateTime toDate) { List <DayActualEntity> feaData, adjustments, buffers, reservationsCheckIn, reservationsCheckOut, emptyHolders; //var sw = new Stopwatch(); //sw.Start(); using (var db = new MarsDBDataContext()) { emptyHolders = DayActualEntityRetrievers.GetPoolingEmptyAlertsHolders(db, mfe); buffers = DayActualEntityRetrievers.GetBuffersForAlerts(mfe, db); adjustments = DayActualEntityRetrievers.GetCurrentAdditionDeletion(mfe, true, db, true); feaData = DayActualEntityRetrievers.GetFeaFullForAlerts(mfe, db).ToList(); } using (var db = new PoolingDataClassesDataContext()) { reservationsCheckIn = DayActualEntityRetrievers.GetPoolingCheckInDataForAlerts(db, mfe); reservationsCheckOut = DayActualEntityRetrievers.GetPoolingCheckOutDataForAlerts(db, mfe); } var alertsList = new List <DayActualEntity>(); var now = DateTime.Now.GetDateAndHourOnlyByCountry(mfe.Country); var hourUntilEndOfPeriod = (toDate - now).TotalHours; for (int i = 0; i < hourUntilEndOfPeriod; i++) { int timeSlot = i; var feaD = feaData.AsParallel().Where(d => d.Tme == timeSlot).OrderBy(d => d.Label).ToList(); var bufferD = buffers.AsParallel().OrderBy(d => d.Label).ToList(); var adjustmentD = adjustments.AsParallel().Where(d => d.Tme == timeSlot).OrderBy(d => d.Label).ToList(); var resInD = reservationsCheckIn.AsParallel().Where(d => d.Tme == timeSlot).OrderBy(d => d.Label).ToList(); var resOutD = reservationsCheckOut.AsParallel().Where(d => d.Tme == timeSlot).OrderBy(d => d.Label).ToList(); foreach (var d in emptyHolders) { //var feaEntity = d; var feaEntity = feaD.FirstOrDefault(f => f.Label == d.Label); var bufferEntity = bufferD.FirstOrDefault(f => f.Label == d.Label); var adjustmentEntity = adjustmentD.FirstOrDefault(f => f.Label == d.Label); var resCheckInsEntity = resInD.FirstOrDefault(f => f.Label == d.Label); var resCheckOutsEntity = resOutD.FirstOrDefault(f => f.Label == d.Label); DayActualEntity entityToAdd; var lbl = d.Label; var previousBalance = alertsList.Where(a => a.Label == lbl).OrderByDescending(a => a.Tme).FirstOrDefault(); var previousBalanceInt = previousBalance == null ? 0 : previousBalance.Balance; if (feaEntity == null && bufferEntity == null && adjustmentEntity == null && resCheckInsEntity == null && resCheckOutsEntity == null) { if (previousBalanceInt != 0) { entityToAdd = new DayActualEntity { Tme = i, Label = d.Label, Balance = previousBalanceInt }; alertsList.Add(entityToAdd); } continue; } var feaAvailable = feaEntity == null ? 0 : feaEntity.Available; var feaOffset = feaEntity == null ? 0 : feaEntity.Offset; var adjustment = adjustmentEntity == null ? 0 : adjustmentEntity.AddditionDeletion; var buffer = bufferEntity == null ? 0 : bufferEntity.Buffer; var reservations = resCheckOutsEntity == null ? 0 : resCheckOutsEntity.Reservations; var resCheckInOffset = resCheckInsEntity == null ? 0 : resCheckInsEntity.Offset; var available = i == 0 ? feaAvailable + adjustment : previousBalanceInt + buffer; var balance = available - reservations + (feaOffset + resCheckInOffset) - buffer + adjustment; entityToAdd = new DayActualEntity { Tme = i, Label = d.Label, Balance = balance }; alertsList.Add(entityToAdd); //if (balance < 0) //{ // if (i == 0) // { // alertsList.Add(entityToAdd); // } // else // { // OnlyAddNewOrHigherEntities(alertsList, entityToAdd, now); // } //} } } return(alertsList); }
public List <DayActualEntity> GetCheckOutReservationsForAlerts(IQueryable <Reservation> q, PoolingDataClassesDataContext db, IMainFilterEntity filter) { var now = DateTime.Now.GetDateAndHourOnlyByCountry(filter.Country); var reservationData = from p in q where (SqlMethods.DateDiffHour(now, p.RS_ARRIVAL_DATE.Value.AddHours(p.RS_ARRIVAL_TIME.Value.Hour)) >= 0 && SqlMethods.DateDiffHour(now, p.RS_ARRIVAL_DATE.Value.AddHours(p.RS_ARRIVAL_TIME.Value.Hour)) <= 71) group p by new { Time = SqlMethods.DateDiffHour(now, p.RS_ARRIVAL_DATE.Value.AddHours(p.RS_ARRIVAL_TIME.Value.Hour)), CarGroup = p.CAR_GROUP.car_group1, Location = p.RentalLocation.location1 } into g select new DayActualEntity { Label = g.Key.Location + " " + g.Key.CarGroup, Tme = g.Key.Time, Reservations = g.Sum(p => p.RES_ID_NBR != null ? 1 : 0) }; var returned = reservationData.ToList(); return(returned); }
public static List <DayActualEntity> CalculateTopics(bool hourlyTimeSlots, int timeSlots, IMainFilterEntity mfe , bool withLabels, bool siteQ = false) { var returned = new List <DayActualEntity>(); List <DayActualEntity> feaData, adjustments, checkInData, checkOutData; var bufferData = new List <DayActualEntity>(); int buffer = 0; using (var db = new MarsDBDataContext()) { db.Log = new DebugTextWriter(); feaData = withLabels ? DayActualEntityRetrievers.GetFeaDataWithLabel(mfe, hourlyTimeSlots, db, siteQ) : DayActualEntityRetrievers.GetFeaData(mfe, hourlyTimeSlots, db); adjustments = withLabels ? DayActualEntityRetrievers.GetAdditionDeletionDataWithLabels(mfe, hourlyTimeSlots, db, siteQ) : DayActualEntityRetrievers.GetCurrentAdditionDeletion(mfe, hourlyTimeSlots, db); if (withLabels) { bufferData = DayActualEntityRetrievers.GetBuffersWithLabels(mfe, db, siteQ); } else { buffer = DayActualEntityRetrievers.GetBuffers(mfe, db); } } using (var db = new PoolingDataClassesDataContext()) { checkInData = withLabels ? DayActualEntityRetrievers.GetPoolingCheckInDataWithLabels(mfe, hourlyTimeSlots, db, siteQ) : DayActualEntityRetrievers.GetPoolingCheckInData(mfe, hourlyTimeSlots, db); checkOutData = withLabels ? DayActualEntityRetrievers.GetPoolingCheckOutDataWithLabels(mfe, hourlyTimeSlots, db, siteQ) : DayActualEntityRetrievers.GetPoolingCheckOutData(mfe, hourlyTimeSlots, db); } var emptyHolder = new DayActualEntity(); var checkInLocations = checkInData.Select(d => d.Label).Distinct().ToList(); var checkOutLocations = checkInData.Select(d => d.Label).Distinct().ToList(); var labels = withLabels ? GetLabels(mfe, siteQ) : new List <string> { null }; if (withLabels) { labels.AddRange(checkInLocations); labels.AddRange(checkOutLocations); labels = labels.Distinct().ToList(); } for (var i = 0; i < timeSlots; i++) { foreach (var lbl in labels) { var fea = feaData.FirstOrDefault(d => d.Tme == i && (d.Label == lbl)) ?? emptyHolder; var adj = adjustments.FirstOrDefault(d => d.Tme == i && (d.Label == lbl)) ?? emptyHolder; var ci = checkInData.FirstOrDefault(d => d.Tme == i && (d.Label == lbl)) ?? emptyHolder; var co = checkOutData.FirstOrDefault(d => d.Tme == i && (d.Label == lbl)) ?? emptyHolder; var bufferHolder = bufferData.FirstOrDefault(d => d.Label == lbl) ?? emptyHolder; if (withLabels) { buffer = bufferHolder.Buffer; } var previousBalance = returned.FirstOrDefault(d => d.Tme == i - 1 && (d.Label == lbl)); var previousBalanceInt = previousBalance == null ? 0 : previousBalance.Balance; var available = i == 0 ? fea.Available + adj.AddditionDeletion : previousBalanceInt + buffer; var balance = available //+ fea.Opentrips - co.Reservations + (fea.Offset + ci.Offset) - buffer + adj.AddditionDeletion; var dae = new DayActualEntity { Tme = i, Label = lbl, Available = available, Opentrips = fea.Opentrips, Reservations = co.Reservations, OnewayRes = co.OnewayRes, GoldServiceReservations = co.GoldServiceReservations, PrepaidReservations = 0, // co.PrepaidReservations, Checkin = fea.Checkin + ci.Checkin, OnewayCheckin = fea.OnewayCheckin + ci.OnewayCheckin, Offset = fea.Offset + ci.Offset, LocalCheckIn = fea.LocalCheckIn,// + ci.LocalCheckIn, Balance = balance, Buffer = buffer, AddditionDeletion = adj.AddditionDeletion, JustAdditions = adj.JustAdditions, JustDeletions = adj.JustDeletions, }; returned.Add(dae); if (string.IsNullOrEmpty(lbl)) { break; } } } return(returned); }