Ejemplo n.º 1
0
        public void UpdateAllInFlag(DateTime date)
        {
            DateTime fromDate = DateTimeHelper.GetMonday(date);


            AllInManagers = new CacheEmployeesAllIn();
            AllInManagers.LoadByEmployee(Employee.ID);



            PlanningWeeks = new SrvEmployeeWeekPlanningList(Employee.ID, fromDate);
            PlanningDays  = new SrvEmployeesPlanningDayList(Employee.ID, fromDate);
            PlanningWeeks.AllInManager = AllInManagers;


            List <EmployeeWeekTimePlanning> list =
                PlanningWeeks.GetEntitiesByEmployeeId(Employee.ID);

            if (list != null && list.Count > 0)
            {
                int lastSaldo = GetLastSaldoForPlanning(fromDate);

                bool bAllIn = false;
                foreach (EmployeeWeekTimePlanning week_entity in list)
                {
                    if (week_entity.WeekBegin < fromDate)
                    {
                        continue;
                    }

                    bAllIn = AllInManagers.GetAllIn(week_entity.EmployeeID, week_entity.WeekBegin, week_entity.WeekEnd);

                    Debug.WriteLine(Employee.FullName + week_entity.Dump());


                    if (week_entity.AllIn != bAllIn)
                    {
                        week_entity.AllIn = bAllIn;

                        if (!week_entity.AllIn)
                        {
                            week_entity.AdditionalCharge = PlanningDays.GetAdditionalChargesForWeekRange(week_entity.EmployeeID,
                                                                                                         week_entity.WeekBegin, week_entity.WeekEnd);;

                            week_entity.CalculateSaldo(lastSaldo);
                        }
                        else
                        {
                            week_entity.AdditionalCharge = 0;
                        }
                        PlanningWeeks.UpdateEntity(week_entity);
                    }

                    Debug.WriteLine(Employee.FullName + week_entity.Dump());

                    lastSaldo = week_entity.Saldo;
                }
            }
        }
Ejemplo n.º 2
0
        public void ProcessWeeks(List <EmployeePlanningWeek> weeks, long[] ids)
        {
            // 1.need load dayinfo for previous and next weeks
            // 2. load dayinfo from begin of month(month of monday)
            DateTime beginMonth       = new DateTime(CurrentMonday.Year, CurrentMonday.Month, 1);
            DateTime beginMonthMonday = DateTimeHelper.GetMonday(beginMonth);


            DateTime beginPrevWeek = CurrentMonday.AddDays(-7);
            DateTime endNextWeek   = CurrentMonday.AddDays(13);

            DateTime beginDate = (beginMonthMonday < beginPrevWeek) ? beginMonthMonday : beginPrevWeek;

            SrvEmployeesPlanningDayList  cache_planning_days = new SrvEmployeesPlanningDayList(ids, beginDate, endNextWeek);
            SrvEmployeesRecordingDayList cache_actual_days   = new SrvEmployeesRecordingDayList(ids, beginDate, endNextWeek);

            foreach (EmployeePlanningWeek w in weeks)
            {
                ProcessWeek(cache_planning_days.GetList(w.EmployeeId), cache_actual_days.GetList(w.EmployeeId), w);
            }
        }
Ejemplo n.º 3
0
        public virtual void Save()
        {
            if (_employeeweeks != null && _employeeweeks.Count > 0)
            {
                long[] ids = EmployeeWeekProcessor.GetEmployeeIds(_employeeweeks);
                // load from BeginDate to 2079 year
                SrvEmployeeWeekPlanningList plan_list = new SrvEmployeeWeekPlanningList(ids, BeginDate);
                SrvEmployeesPlanningDayList day_list  = new SrvEmployeesPlanningDayList(ids, BeginDate);
                foreach (EmployeeWeek w in _employeeweeks)
                {
                    plan_list.UpdateSaldoAfterPlanning(w);
                    foreach (EmployeeDay ed in w.DaysList)
                    {
                        day_list.CompareAndSave(ed);
                    }
                }


                EmployeePlanningWorkingModelHelper wmhelper = new EmployeePlanningWorkingModelHelper(_timeservice.EmployeePlanningWorkingModelService);

                wmhelper.SaveEmployeeWorkingModel(_employeeweeks);
            }
        }
Ejemplo n.º 4
0
        public virtual void Save()
        {
            if (_employeeweeks != null && _employeeweeks.Count > 0)
            {
                 long[] ids = EmployeeWeekProcessor.GetEmployeeIds(_employeeweeks);
                // load from BeginDate to 2079 year
                 SrvEmployeeWeekPlanningList plan_list = new SrvEmployeeWeekPlanningList(ids, BeginDate);
                 SrvEmployeesPlanningDayList day_list = new SrvEmployeesPlanningDayList(ids, BeginDate);
                 foreach (EmployeeWeek w in _employeeweeks)
                 {
                     plan_list.UpdateSaldoAfterPlanning(w);
                     foreach (EmployeeDay ed in w.DaysList)
                     {
                         day_list.CompareAndSave (ed);
                     }
                 }

                 EmployeePlanningWorkingModelHelper wmhelper = new EmployeePlanningWorkingModelHelper(_timeservice.EmployeePlanningWorkingModelService);

                 wmhelper.SaveEmployeeWorkingModel(_employeeweeks);
            }
        }
Ejemplo n.º 5
0
        public void ProcessWeeks(List<EmployeePlanningWeek> weeks, long[] ids)
        {
            // 1.need load dayinfo for previous and next weeks
            // 2. load dayinfo from begin of month(month of monday)
            DateTime beginMonth = new DateTime(CurrentMonday.Year, CurrentMonday.Month, 1);
            DateTime beginMonthMonday = DateTimeHelper.GetMonday(beginMonth);

            DateTime beginPrevWeek = CurrentMonday.AddDays(-7);
            DateTime endNextWeek = CurrentMonday.AddDays(13);

            DateTime beginDate = (beginMonthMonday < beginPrevWeek) ? beginMonthMonday : beginPrevWeek;

            SrvEmployeesPlanningDayList cache_planning_days = new SrvEmployeesPlanningDayList(ids, beginDate, endNextWeek);
            SrvEmployeesRecordingDayList cache_actual_days = new SrvEmployeesRecordingDayList(ids, beginDate, endNextWeek);

            foreach (EmployeePlanningWeek w in weeks)
            {
                ProcessWeek(cache_planning_days.GetList(w.EmployeeId), cache_actual_days.GetList(w.EmployeeId), w);
            }
        }
Ejemplo n.º 6
0
        public void UpdateAllInFlag(DateTime date)
        {
            DateTime fromDate = DateTimeHelper.GetMonday(date);

            AllInManagers = new CacheEmployeesAllIn();
            AllInManagers.LoadByEmployee(Employee.ID);

            PlanningWeeks = new SrvEmployeeWeekPlanningList(Employee.ID, fromDate);
            PlanningDays = new SrvEmployeesPlanningDayList(Employee.ID, fromDate);
            PlanningWeeks.AllInManager = AllInManagers;

            List<EmployeeWeekTimePlanning> list =
                PlanningWeeks.GetEntitiesByEmployeeId(Employee.ID);

            if (list != null && list.Count > 0)
            {
                int lastSaldo = GetLastSaldoForPlanning(fromDate);

                bool bAllIn = false;
                foreach (EmployeeWeekTimePlanning week_entity in list)
                {
                    if (week_entity.WeekBegin < fromDate) continue;

                    bAllIn = AllInManagers.GetAllIn(week_entity.EmployeeID, week_entity.WeekBegin, week_entity.WeekEnd);

                    Debug.WriteLine(Employee.FullName + week_entity.Dump ());

                    if (week_entity.AllIn != bAllIn)
                    {
                        week_entity.AllIn = bAllIn;

                        if (!week_entity.AllIn)
                        {
                            week_entity.AdditionalCharge = PlanningDays.GetAdditionalChargesForWeekRange(week_entity.EmployeeID ,
                                week_entity.WeekBegin, week_entity.WeekEnd); ;

                            week_entity.CalculateSaldo(lastSaldo);
                        }
                        else
                        {
                            week_entity.AdditionalCharge = 0;
                        }
                        PlanningWeeks.UpdateEntity(week_entity);
                    }

                    Debug.WriteLine(Employee.FullName + week_entity.Dump());

                    lastSaldo = week_entity.Saldo;
                }
            }
        }