コード例 #1
0
        private void ProcessEmployee()
        {
            var    currentDate          = DateTime.Today;
            var    employees            = _employeeService.GetAllEmployees();
            double emplCount            = employees.Count;
            var    emplOrganisationList = _employeeOrganisationService.Get(o => o.ToList());

            SetStatus(1, "Обновление данных с БД - загрузка", true);
            int i = 0;

            foreach (var employee in employees)
            {
                i++;
                var emplOrgRecordList = emplOrganisationList.Where(eo => eo.EmployeeID == employee.ID &&
                                                                   (!eo.OrganisationDateEnd.HasValue || eo.OrganisationDateEnd.Value.Date >= currentDate.Date) &&
                                                                   (currentDate.Date >= eo.OrganisationDateBegin.Value.Date));

                var mainRecord = emplOrgRecordList.FirstOrDefault(eo => eo.IsMainPlaceWork);
                if (mainRecord != null || emplOrgRecordList.Count() == 1)
                {
                    mainRecord = emplOrgRecordList.First();
                    employee.OrganisationID             = mainRecord.OrganisationID;
                    employee.EmployeePositionOfficialID = mainRecord.EmployeePositionOfficialID;
                }
                else
                {
                    employee.OrganisationID             = null;
                    employee.EmployeePositionOfficialID = null;
                }
                _employeeService.UpdateWithoutVersion(employee);

                int statusValue = (int)((i / emplCount) * 99);
                SetStatus(1 + statusValue, "Обработка данных сотрудника: " + employee.FullName);
            }
        }
コード例 #2
0
 public ActionResult Index() => View(_employeeOrganisationService.Get(eos => eos /*.Include(eo => eo.Organisation)*/.ToList()));