Exemplo n.º 1
0
        public void Test1()
        {
            var parameters = new Dictionary <DictionaryParameter, string>
            {
                { DictionaryParameter.LocationCountry, "GE" },
                { DictionaryParameter.Pool, "71" },
                { DictionaryParameter.OwningCountry, "GE" }
            };

            parameters[DictionaryParameter.StartDate] = (new DateTime(2015, 1, 4)).ToShortDateString();

            List <DemandGapOneRow> demandGapData;

            using (var dataAccess = new DemandGapDataAccess(parameters))
            {
                var data = dataAccess.GetDemandGapStepOne();
                demandGapData = data.ToList();
            }

            //List<MonthlyLimitRow> monthlyData;
            //List<WeeklyLimitRow> weeklyData;
            //using (var dataAccess = new VehicleDistributionDataAccess())
            //{
            //    monthlyData = dataAccess.GetMonthlyLimitRows(2);
            //    weeklyData = dataAccess.GetWeekLyLimitRows(3);
            //}
            //DemandGapCalculations.AssignGroupOne(demandGapData, monthlyData, weeklyData);
        }
        public void CalcualteLimits()
        {
            var parameters = ucParameters.GetParameters();

            parameters[DictionaryParameter.StartDate] = (new DateTime(2015, 2, 7)).ToShortDateString();
            List <DemandGapOneRow> demandGapData;

            var sb = new StringBuilder();

            using (var dataAccess = new DemandGapDataAccess(parameters))
            {
                var data = dataAccess.GetDemandGapStepOne();
                //var data2 = dataAccess.GetDemandGapOne(data);
                //var data2 = dataAccess.GetDemandGapStepOneViz();
                //ucDgVis.GridData = data2.ToList();

                demandGapData = data.ToList();
                DemandGapCalculations.CalculateGap(demandGapData);
                demandGapData = demandGapData.ToList();
                ucDemanGapStageOneGrid.GridData = demandGapData;


                //ucDemandGapOne.GridData = data2;

                //var spread = dataAccess.GetSpreadForLocation();
                // ucSpread.GridData = spread;
            }

            List <MonthlyLimitRow> monthlyData;
            List <WeeklyLimitRow>  weeklyData;

            using (var dataAccess = new MonthlyAddLimitDataAccess())
            {
                monthlyData = dataAccess.GetMonthlyLimitRows(2);
                weeklyData  = dataAccess.GetWeekLyLimitRows(3);
            }

            using (var dataAccess = new VehicleDistributionDataAccess())
            {
                if (parameters[DictionaryParameter.CarGroup] != string.Empty &&
                    (!parameters[DictionaryParameter.CarClass].Contains(LocationQueryable.Separator)))
                {
                    var carClassId = int.Parse(parameters[DictionaryParameter.CarClass]);
                    using (var lookup = new LookupDataAccess())
                    {
                        var splitCarGroupIds = lookup.FindCarGroupsInCarClass(carClassId);
                        monthlyData = monthlyData.Where(d => splitCarGroupIds.Contains(d.GetCarGroupId())).ToList();
                    }
                }

                var calculatedAdds = DemandGapCalculations.AssignGroupOne(demandGapData, monthlyData, weeklyData);
                sb.AppendLine("Additions Step 1 Generated:" + calculatedAdds.Sum(d => d.Amount));
                DemandGapCalculations.FillGapsFromMonthlyLimits(demandGapData, monthlyData, weeklyData, calculatedAdds);
                sb.AppendLine("Additions Step 1.1 Generated:" + calculatedAdds.Sum(d => d.Amount));

                dataAccess.FillNames(calculatedAdds);

                ucResult.GridData = calculatedAdds;
            }

            //ucDemanGapStageOneGrid.UpdateUpdatePanel();
            //ucDemandGapOne.UpdateUpdatePanel();

            ucMonthlyLimit.LoadData(monthlyData);
            ucWeeklyLimit.LoadData(weeklyData);


            sb.AppendLine("Total Monthly assigned:" + monthlyData.Sum(d => d.Assigned));
            sb.AppendLine("Total Weekly assigned:" + weeklyData.Sum(d => d.Assigned));
            Session[FaoCalculationTextSummary] = sb.ToString();

            Session[FaoCalculationStarted] = "Finished";
        }