Example #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);
            }
        }
Example #2
0
        public void ClearEmployeeTimeRange(long employeeId, DateTime aBegin, DateTime aEnd)
        {
            try
            {
                // week
                // day
                // working time
                // absence time
                // workingmodel

                EmployeePlanningWorkingModelService models =
                    (EmployeePlanningWorkingModelService as EmployeePlanningWorkingModelService);
                models.ClearEmployeeByDateRange(employeeId, aBegin, aEnd);

                AbsenceTimePlanningService absences = (AbsenceTimePlanningService as AbsenceTimePlanningService);
                absences.ClearEmployeeByDateRange(employeeId, aBegin, aEnd);
                WorkingTimePlanningService times = (WorkingTimePlanningService as WorkingTimePlanningService);
                times.ClearEmployeeByDateRange(employeeId, aBegin, aEnd);

                EmployeeDayStatePlanningService daystate =
                    (EmployeeDayStatePlanningService as EmployeeDayStatePlanningService);
                daystate.ClearEmployeeByDateRange(employeeId, aBegin, aEnd);

                EmployeeWeekTimePlanningService weekstate =
                    (EmployeeWeekTimePlanningService as EmployeeWeekTimePlanningService);
                weekstate.ClearEmployeeByDateRange(employeeId, aBegin, aEnd);
            }
            catch (EntityException)
            {
                throw;
            }
            catch (Exception ex)
            {
                CheckForDBValidationException(null, ex);
                throw new SaveException(ex);
            }
        }