Ejemplo n.º 1
0
        private int LoadEstimateSum(BufferHourAvailable entity)
        {
            EstimatedWorldHoursBuilder2 b = new EstimatedWorldHoursBuilder2();

            int value = b.Build(StoreWorld, entity.WeekBegin, entity.WeekEnd);

            if (entity.SumActualBVEstimated != value)
            {
                entity.SumActualBVEstimated = value;
                _DoUpdateEntity(entity);
            }

            return(value);
        }
Ejemplo n.º 2
0
        public bool TestAndCompare2(StoreToWorld storeworld, int year)
        {
            bool equal = true;

#if DEBUG
            DateTime begin       = DateTimeHelper.GetBeginYearDate(year);
            DateTime end         = DateTimeHelper.GetEndYearDate(year);
            int      count_weeks = DateTimeHelper.GetCountWeekInYear(year);

            int[] sums  = new int[count_weeks];
            int[] sums2 = new int[count_weeks];

            DateTime date = begin;

            EstimatedWorldHoursBuilder  b  = new EstimatedWorldHoursBuilder();
            EstimatedWorldHoursBuilder2 b2 = new EstimatedWorldHoursBuilder2();
            for (int i = 0; i < count_weeks; i++)
            {
                sums[i]  = b.Build(storeworld, date, DateTimeHelper.GetSunday(date));
                sums2[i] = b2.Build(storeworld, date, DateTimeHelper.GetSunday(date));

                date = DateTimeHelper.GetNextMonday(date);
            }
            int[] sums3 = BuildYear(storeworld, year);

            for (int i = 0; i < count_weeks; i++)
            {
                Debug.WriteLine(sums[i].ToString() + " ----------------- " + sums2[i] + " ----- " + sums[i]);

                Debug.Assert(sums[i] == sums2[i]);
                Debug.Assert(sums[i] == sums3[i]);
                Debug.Assert(sums2[i] == sums3[i]);
                equal &= (sums[i] == sums2[i]) & (sums2[i] == sums3 [i]);
            }
#endif
            return(equal);
        }
Ejemplo n.º 3
0
        public bool TestAndCompare2(StoreToWorld storeworld, int year)
        {
            bool equal = true;

            #if DEBUG
            DateTime begin = DateTimeHelper.GetBeginYearDate(year);
            DateTime end = DateTimeHelper.GetEndYearDate(year);
            int count_weeks = DateTimeHelper.GetCountWeekInYear(year);

            int[] sums = new int[count_weeks];
            int[] sums2 = new int[count_weeks];

            DateTime date = begin;

            EstimatedWorldHoursBuilder b = new EstimatedWorldHoursBuilder();
            EstimatedWorldHoursBuilder2 b2 = new EstimatedWorldHoursBuilder2();
            for (int i = 0; i < count_weeks; i++)
            {
                sums[i] = b.Build(storeworld, date, DateTimeHelper.GetSunday(date));
                sums2[i] = b2.Build(storeworld, date, DateTimeHelper.GetSunday(date));

                date = DateTimeHelper.GetNextMonday(date);
            }
            int[] sums3 = BuildYear(storeworld, year);

            for (int i = 0; i < count_weeks; i++)
            {
                Debug.WriteLine(sums[i].ToString() + " ----------------- " + sums2[i] + " ----- " + sums[i]);

                Debug.Assert(sums[i] == sums2[i]);
                Debug.Assert(sums[i] == sums3[i]);
                Debug.Assert(sums2[i] == sums3[i]);
                equal &= (sums[i] == sums2[i]) & (sums2[i] == sums3 [i]);
            }

            #endif
            return equal;
        }
        private void FillCashDeskEstimateData(CashDeskPlanningInfo cashdesk, StoreToWorld storeworld, DateTime begin, DateTime end)
        {
            Debug.Assert(cashdesk != null);
            Debug.Assert(begin < end);
            Debug.Assert(begin.DayOfWeek == DayOfWeek.Monday);
            Debug.Assert(end.DayOfWeek == DayOfWeek.Sunday);

            if (cashdesk == null)
                return;

            if (_trendhelper == null)
            {
                _trendhelper = new TrendCorrectionHelper(_storeservice.TrendCorrectionService);
                _trendhelper.LoadByStoreAndDateRange(storeworld.StoreID, begin, end);
            }

            bool isExistsTrendCorrection = _trendhelper.IsExistsForWorld(storeworld.ID);
            decimal trendcorrection = 1;

            IList lst = _storetoworldservice.GetCashDeskPeopleEstimated(begin, end, storeworld.StoreID);

            if (lst != null)
            {
                foreach (CashDeskPeoplePerHourEstimateShort cashdeskitem in lst)
                {
                    if (isExistsTrendCorrection)
                    {
                        trendcorrection = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, cashdeskitem.Date));
                        cashdeskitem.PeoplePerHour = Convert.ToInt16(cashdeskitem.PeoplePerHour * trendcorrection);
                        cashdeskitem.TargReceiptsPerHour = cashdeskitem.TargReceiptsPerHour * trendcorrection;
                        cashdesk.AddCashDeskItem(cashdeskitem);
                    }
                    else
                    {
                        cashdesk.AddCashDeskItem(cashdeskitem);
                    }
                }
            }

            EstimatedWorldHoursBuilder2 estimatedHoursLoader = new EstimatedWorldHoursBuilder2();
            estimatedHoursLoader.AssignTrendCorrecttionHelper(_trendhelper);

            cashdesk.SumPlannedWorkingHours = estimatedHoursLoader.Build(storeworld, begin, end);

            //IList list = _storetoworldservice.GetEstimatedWorldWorkingHours(begin, end, storeworld.StoreID, storeworld.WorldID);
            //if (list != null)
            //{
            //    int totalTime = 0;
            //    foreach (EstimatedWorldWorkingHours workinghours in list)
            //    {
            //        if (isExistsTrendCorrection)
            //        {
            //            trendcorrection = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, workinghours.Date));
            //        }
            //        totalTime += (int)(workinghours.WorkingHours * 60 * trendcorrection);
            //    }

            //    cashdesk.SumPlannedWorkingHours = totalTime;
            //}
        }
        private void FillCashDeskEstimateData(CashDeskPlanningInfo cashdesk, StoreToWorld storeworld, DateTime begin, DateTime end)
        {
            Debug.Assert(cashdesk != null);
            Debug.Assert(begin < end);
            Debug.Assert(begin.DayOfWeek == DayOfWeek.Monday);
            Debug.Assert(end.DayOfWeek == DayOfWeek.Sunday);

            if (cashdesk == null)
            {
                return;
            }

            if (_trendhelper == null)
            {
                _trendhelper = new TrendCorrectionHelper(_storeservice.TrendCorrectionService);
                _trendhelper.LoadByStoreAndDateRange(storeworld.StoreID, begin, end);
            }

            bool    isExistsTrendCorrection = _trendhelper.IsExistsForWorld(storeworld.ID);
            decimal trendcorrection         = 1;

            IList lst = _storetoworldservice.GetCashDeskPeopleEstimated(begin, end, storeworld.StoreID);

            if (lst != null)
            {
                foreach (CashDeskPeoplePerHourEstimateShort cashdeskitem in lst)
                {
                    if (isExistsTrendCorrection)
                    {
                        trendcorrection                  = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, cashdeskitem.Date));
                        cashdeskitem.PeoplePerHour       = Convert.ToInt16(cashdeskitem.PeoplePerHour * trendcorrection);
                        cashdeskitem.TargReceiptsPerHour = cashdeskitem.TargReceiptsPerHour * trendcorrection;
                        cashdesk.AddCashDeskItem(cashdeskitem);
                    }
                    else
                    {
                        cashdesk.AddCashDeskItem(cashdeskitem);
                    }
                }
            }

            EstimatedWorldHoursBuilder2 estimatedHoursLoader = new EstimatedWorldHoursBuilder2();

            estimatedHoursLoader.AssignTrendCorrecttionHelper(_trendhelper);

            cashdesk.SumPlannedWorkingHours = estimatedHoursLoader.Build(storeworld, begin, end);


            //IList list = _storetoworldservice.GetEstimatedWorldWorkingHours(begin, end, storeworld.StoreID, storeworld.WorldID);
            //if (list != null)
            //{
            //    int totalTime = 0;
            //    foreach (EstimatedWorldWorkingHours workinghours in list)
            //    {
            //        if (isExistsTrendCorrection)
            //        {
            //            trendcorrection = Convert.ToDecimal(_trendhelper.GetTrendCorrection(storeworld.ID, workinghours.Date));
            //        }
            //        totalTime += (int)(workinghours.WorkingHours * 60 * trendcorrection);
            //    }

            //    cashdesk.SumPlannedWorkingHours = totalTime;
            //}
        }