Пример #1
0
        public void SavePlanning2(long storeid, DateTime aBegin, DateTime aEnd, List <EmployeePlanningWeek> lstWeeks)
        {
            #region validate date
            Debug.Assert(aBegin < aEnd);
            Debug.Assert(aBegin.DayOfWeek == DayOfWeek.Monday);
            Debug.Assert(aEnd.DayOfWeek == DayOfWeek.Sunday);

            if (aEnd < DateTime.Today)
            {
                if (Log.IsWarnEnabled)
                {
                    User   user     = ServerEnvironment.AuthorizationService.GetCurrentUser();
                    string username = String.Empty;
                    if (user != null)
                    {
                        username = user.LoginName;
                    }

                    Log.Warn(string.Format("User - '{0}', try save planning date in date({1}) with input data {2}-{3} storeid={4}",
                                           new object[] { username, DateTime.Today, aBegin, aEnd, storeid }));
                }
                return;
            }
            #endregion

            try
            {
                HolidayCalculator calculatorHolidays = new HolidayCalculator();
                calculatorHolidays.Calculate(storeid, aBegin, lstWeeks);


                WorkingTimePlanningService.SetWeekTimePlanning(lstWeeks);
                AbsenceTimePlanningService.SetWeekTimePlanning(lstWeeks);


                StoreWeekCalculater calculator = new StoreWeekCalculater(storeid, aBegin, aEnd, this);

                calculator.Process();


                if (lstWeeks != null)
                {
                    long[] ids = PlanningWeekProcessor.ListToEmployeeIds(lstWeeks);

                    ExEmployeeHolidays.CalculateAndUpdate(ids, DateTimeHelper.GetYearByDate(aBegin));
                }

                _storeService.LastEmployeeWeekTimePlanningUpdate(storeid, aBegin);
            }
            catch (EntityException)
            {
                throw;
            }
            catch (Exception ex)
            {
                CheckForDBValidationException(null, ex);
                throw new SaveException(ex);
            }
        }
Пример #2
0
        private void LoadWorkingAndAbsencesHours()
        {
            long[] ids = PlanningWeekProcessor.ListToEmployeeIds(_storeEmployees);

            List <WorkingTimePlanning> _workingTimes = ClientEnvironment.WorkingTimePlanningService.GetWorkingTimePlanningsByEmployeeIds(ids, StartDate, EndDate);
            List <AbsenceTimePlanning> _absenceTimes = ClientEnvironment.AbsenceTimePlanningService.GetAbsenceTimePlanningsByEmployeeIds(ids, StartDate, EndDate);

            Absences.FillAbsencePlanningTimes(_absenceTimes);

            PlanningWeekProcessor.AssignTimes(_storeEmployees, _workingTimes, _absenceTimes);
        }
Пример #3
0
        private void LoadWorkingAndAbsenceTimes()
        {
            long[] ids = PlanningWeekProcessor.ListToEmployeeIds(PlanningEmployees);

            List <WorkingTimePlanning> _workingTimes = ClientEnvironment.WorkingTimePlanningService.GetWorkingTimePlanningsByEmployeeIds(ids, BeginTime, EndTime);
            //List<WorkingTimePlanning> _workingTimes1 = ClientEnvironment.WorkingTimePlanningService.GetEntitiesByStoreRelations(CurrentStoreId, BeginTime, EndTime);

            List <AbsenceTimePlanning> _absenceTimes = ClientEnvironment.AbsenceTimePlanningService.GetAbsenceTimePlanningsByEmployeeIds(ids, BeginTime, EndTime);

            //List<AbsenceTimePlanning> _absenceTimes = ClientEnvironment.AbsenceTimePlanningService.GetEntitiesByStoreRelations(CurrentStoreId, BeginTime, EndTime);

            if (Absences != null)
            {
                Absences.FillAbsencePlanningTimes(_absenceTimes);
            }

            PlanningWeekProcessor.AssignTimes(PlanningEmployees, _workingTimes, _absenceTimes);
        }
Пример #4
0
        public void SavePlanningWeek(List <EmployeePlanningWeek> weeks)
        {
            if (weeks == null || weeks.Count == 0)
            {
                return;
            }

            long[] ids = PlanningWeekProcessor.ListToEmployeeIds(weeks);
            List <WorkingTimePlanning> list_old = Service.GetWorkingTimePlanningsByEmployeeIds(ids, weeks[0].BeginDate, weeks[0].EndDate);

            List <WorkingTimePlanning> list_new = new List <WorkingTimePlanning>(100);

            foreach (EmployeePlanningWeek week in weeks)
            {
                foreach (EmployeePlanningDay day in week.Days.Values)
                {
                    if (day.WorkingTimeList != null)
                    {
                        list_new.AddRange(day.WorkingTimeList);
                    }
                }
            }

            if (list_new.Count > 0)
            {
                bool bFound = false;
                foreach (WorkingTimePlanning entity in list_new)
                {
                    bFound = false;
                    if (list_old != null && list_old.Count > 0)
                    {
                        for (int i = 0; i < list_old.Count; i++)
                        {
                            if (list_old[i] != null && list_old[i].Compare(entity))
                            {
                                entity.ID   = list_old[i].ID;
                                bFound      = true;
                                list_old[i] = null;
                                break;
                            }
                        }
                    }

                    if (!bFound)
                    {
                        Service.Save(entity);
                    }
                }
            }

            if (list_old != null)
            {
                foreach (WorkingTimePlanning entity in list_old)
                {
                    if (entity != null)
                    {
                        Service.Delete(entity);
                    }
                }
            }
        }