Example #1
0
        internal static IQueryable <ForecastRawDataHolder> GetFrozenZoneForecastRawData(Dictionary <string, string> parameters, MarsDBDataContext dataContext)
        {
            var fullDataSet = from fc in dataContext.MARS_CMS_FORECAST_HISTORies
                              select fc;

            var restrictedData = ForecastParameterRestriction.RestrictHistoricalForecastByParameters(parameters, fullDataSet, dataContext);

            var joinedData = from rd in restrictedData
                             join adj in dataContext.MARS_CMS_FORECAST_ADJUSTMENTs on
                             new { rd.REP_DATE, rd.CMS_LOCATION_GROUP_ID, rd.CAR_CLASS_ID }
            equals new { adj.REP_DATE, adj.CMS_LOCATION_GROUP_ID, adj.CAR_CLASS_ID }
            into adj
            from joinedAdjustment in adj.DefaultIfEmpty()
            select new ForecastRawDataHolder()
            {
                ReportDate      = rd.REP_DATE,
                LocationGroupId = rd.CMS_LOCATION_GROUP_ID,
                CarClassId      = rd.CAR_CLASS_ID,
                OnRent          = rd.CURRENT_ONRENT ?? 0,
                OnRentLy        = rd.ONRENT_LY ?? 0,
                Constrained     = rd.CMS_CONSTRAINED ?? 0,
                Unconstrained   = rd.CMS_UNCONSTRAINED ?? 0,
                Fleet           = 0,
                AlreadyBooked   = 0,
                TopDown         = joinedAdjustment.ADJUSTMENT_TD ?? 0,
                BottomUp1       = joinedAdjustment.ADJUSTMENT_BU1 ?? 0,
                BottomUp2       = joinedAdjustment.ADJUSTMENT_BU2 ?? 0,
                Reconciliation  = joinedAdjustment.ADJUSTMENT_RC ?? 0
            };

            return(joinedData);
        }
Example #2
0
        internal static IQueryable <MARS_CMS_FORECAST_HISTORY> GetBenchmarkRawData(IDictionary <string, string> parameters, MarsDBDataContext dataContext)
        {
            var fullDataSet = from fc in dataContext.MARS_CMS_FORECAST_HISTORies
                              select fc;

            var restrictedData = ForecastParameterRestriction.RestrictHistoricalForecastByParameters(parameters, fullDataSet, dataContext);

            return(restrictedData);
        }
Example #3
0
        internal static IQueryable <FutureTrendOrSupplyAnalysisRawDataHolder> GetRawFrozenZoneFutureTrendData(MarsDBDataContext dataContext, Dictionary <string, string> parameters, byte scenarioId)
        {
            var country  = parameters.ContainsKey(ParameterNames.Country) ? parameters[ParameterNames.Country] : null;
            var fromDate = DateTime.Parse(parameters.ContainsKey(ParameterNames.FromDate) ? parameters[ParameterNames.FromDate] : null);
            var toDate   = DateTime.Parse(parameters.ContainsKey(ParameterNames.ToDate) ? parameters[ParameterNames.ToDate] : null);

            var fullDataSet = from fc in dataContext.MARS_CMS_FORECAST_HISTORies
                              select fc;

            var restrictedData = ForecastParameterRestriction.RestrictHistoricalForecastByParameters(parameters, fullDataSet, dataContext);

            var joinedData = from rd in restrictedData
                             join nf in dataContext.MARS_CMS_NECESSARY_FLEETs on
                             new { rd.CMS_LOCATION_GROUP_ID, rd.CAR_CLASS_ID }
            equals
            new { nf.CMS_LOCATION_GROUP_ID, nf.CAR_CLASS_ID }
            into nessearyFleetDetails
            from joinednessFleetDetails in nessearyFleetDetails.DefaultIfEmpty()
            join fps in dataContext.FleetPlanSummary(country == String.Empty ? null : country, scenarioId, fromDate, toDate) on
            new { date = (DateTime?)rd.REP_DATE, classId = rd.CAR_CLASS_ID, locGroupId = rd.CMS_LOCATION_GROUP_ID }
            equals
            new { date = fps.targetDate, classId = fps.CAR_CLASS_ID.Value, locGroupId = fps.LOCATION_GROUP_ID.Value }
            into fleetDetails
            from joinedFleetDetails in fleetDetails.DefaultIfEmpty()
            select new FutureTrendOrSupplyAnalysisRawDataHolder
            {
                ReportDate           = rd.REP_DATE,
                Constrained          = rd.CMS_CONSTRAINED_FROZEN ?? 0,
                Unconstrained        = rd.CMS_UNCONSTRAINED_FROZEN ?? 0,
                Booked               = 0,
                Utilization          = joinednessFleetDetails.UTILISATION ?? 0,
                NonRevFleet          = joinednessFleetDetails.NONREV_FLEET ?? 0,
                OnRent               = rd.CURRENT_ONRENT ?? 0,
                NessesaryConstrained = joinednessFleetDetails.UTILISATION == 0 ? 0 : (rd.CMS_CONSTRAINED_FROZEN / joinednessFleetDetails.UTILISATION * HUNDRED) + (joinednessFleetDetails.NONREV_FLEET * rd.CMS_CONSTRAINED_FROZEN / HUNDRED)
                                       ?? rd.CMS_CONSTRAINED_FROZEN ?? 0,
                NessesaryUnconstrained = joinednessFleetDetails.UTILISATION == 0 ? 0 :
                                         (rd.CMS_UNCONSTRAINED_FROZEN / joinednessFleetDetails.UTILISATION * HUNDRED)
                                         + (joinednessFleetDetails.NONREV_FLEET * rd.CMS_UNCONSTRAINED_FROZEN
                                            / HUNDRED)
                                         ?? rd.CMS_UNCONSTRAINED_FROZEN ?? 0,
                NessesaryBooked = 0,
                Expected        = rd.OPERATIONAL_FLEET ?? 0 + joinedFleetDetails.amount.GetValueOrDefault(0),
                LocationGroupId = rd.CMS_LOCATION_GROUP_ID,
                CarClassId      = rd.CAR_CLASS_ID,
                Country         = rd.COUNTRY
            };

            return(joinedData);
        }
Example #4
0
        internal static IQueryable <KpiRawDataHolderOld> GetFrozenZoneRawKpiData(MarsDBDataContext dataContext, Dictionary <string, string> parameters)
        {
            var fullDataSet = from fc in dataContext.MARS_CMS_FORECAST_HISTORies
                              select fc;

            var restrictedData = ForecastParameterRestriction.RestrictHistoricalForecastByParameters(parameters, fullDataSet, dataContext);

            var joinedData = from rd in restrictedData
                             select new KpiRawDataHolderOld
            {
                OnRent           = rd.CURRENT_ONRENT ?? 0,
                OperationalFleet = rd.OPERATIONAL_FLEET ?? 0 + rd.FLEET_MOVEMENT_FROZEN ?? 0,
                IdleFleet        = (rd.TOTAL_FLEET - rd.CURRENT_ONRENT) ?? 0,
                TotalFleet       = rd.TOTAL_FLEET ?? 0,
                ReportDate       = rd.REP_DATE,
                Country          = rd.COUNTRY
            };

            return(joinedData);
        }