public void Calculate()
        {
            if (IContext != null)
            {
                foreach (EmployeePlanningWeek epw in _listemployeesweek)
                {
                    IContext.WorkingModels.Calculate(epw);
                }
            }
            CalculateDaysSum();

            if (StoreWorldInfo != null)
            {
                StoreWorldInfo.SumHoursForNetPerformance = Summary.CountWorldPlanningHours;

                if (!IsCashDesk)
                {
                    StoreWorldPlanningInfo storeinfo = StoreWorldInfo as StoreWorldPlanningInfo;

                    Debug.Assert(storeinfo != null);

                    if (storeinfo != null)
                    {
                        storeinfo.Calculate(Summary.DaysSum);
                    }
                }
                else
                {
                    CashDeskPlanningInfo cashinfo = StoreWorldInfo as CashDeskPlanningInfo;
                    Debug.Assert(cashinfo != null);

                    if (cashinfo != null)
                    {
                        cashinfo.SumActualWorkingHours = SumWorkingHoursOfWeek;
                    }
                }
            }
        }
        public void AssignCashDeskInfo(CashDeskPlanningInfo cashdeskinfo, DateTime weekMondayDate)
        {
            CashDeskPlanningInfo CashDeskInfo = cashdeskinfo;
            if (CashDeskInfo != null)
            {
                DateTime sunday = DateTimeHelper.GetSunday(weekMondayDate);
                DateTime index_date = DateTimeHelper.GetMonday(weekMondayDate);
                int index = 0;
                while (index_date <= sunday)
                {
                    index = (int)index_date.DayOfWeek;
                    DateCashDeskPeoplePerHour datecashdesk = cashdeskinfo.GetDayCashDeskData(index_date);
                    days_calculators[index] = new CashDeskDailyPlanningCalculator2();
                    days_calculators[index].AssignCashDeskInfo(cashdeskinfo, index_date);

                    if (datecashdesk != null)
                    {
                        TargetUnits[index] = datecashdesk.Calculate2(CashDeskInfo.CashDeskAmount, CashDeskInfo.MinimumPresence, CashDeskInfo.MaximumPresence);
                    }
                    else
                    {
                        TargetUnits[index] = 0;
                    }

                    index_date = index_date.AddDays(1);
                }
                TargetUnits.Calculate();
            }
            else
            {
                Clear();
            }
        }
        public void AssignCashDeskInfo(CashDeskPlanningInfo cashdeskinfo, DateTime date)
        {
            _CashDeskInfo = cashdeskinfo;

            TargetedCashDeskUnits.Clear();

            if (CashDeskInfo != null)
            {
                AvgCashDeskAmount = CashDeskInfo.CashDeskAmount;
                MinPercent = CashDeskInfo.MinimumPresence;
                MaxPercent = CashDeskInfo.MaximumPresence;

                DateCashDeskPeoplePerHour datecashdesk = CashDeskInfo.GetDayCashDeskData(date);
                TargetedCashDeskUnits = new DblArray50MinMax(24, MinPercent, MaxPercent);
                if (datecashdesk != null)
                {
                    //Random n = new Random(5000);

                    for (int i = 0; i < 24; i++)
                    {
                        if (AvgCashDeskAmount != 0)
                        {
                            //TargetedCashDeskUnits.Elements[i] = n.NextDouble () / AvgCashDeskAmount;
                            TargetedCashDeskUnits.Elements[i] = datecashdesk.GetReceipt(i) / AvgCashDeskAmount;

                            // _GetPeoplePerHour(datecashdesk.GetReceipt(i), AvgCashDeskAmount);
                        }
                        else
                        {
                            TargetedCashDeskUnits.Elements[i] = 0;
                        }
                    }
                }

                TargetedCashDeskUnits.Calculate();
            }
        }
        private CashDeskPlanningInfo GetCashDeskInfo(StoreToWorld storeworld, DateTime beginWeekDate)
        {
            if (storeworld == null)
                throw new ArgumentNullException();

            if (storeworld.WorldTypeID != WorldType.CashDesk)
                throw new ArgumentException("storeworld must be cashdesk");

            DateTime endWeekDate = DateTimeHelper.GetSunday (beginWeekDate );
            CashDeskPlanningInfo worldinfo = new CashDeskPlanningInfo();
            worldinfo.StoreWorldId = storeworld.ID;
            FillCommonInfoForWorld(worldinfo, storeworld, beginWeekDate, endWeekDate);

            if (IsPlanning)
            {
                FillCashDeskEstimateData(worldinfo, storeworld, beginWeekDate, endWeekDate);

            }

            return worldinfo;
        }
        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;
            //}
        }
 public void SetCashDeskInfo(CashDeskPlanningInfo cashdeskinfo, DateTime viewdate)
 {
     ViewDate = viewdate;
     CashDeskInfo = cashdeskinfo;
 }