public List <object> MakeToSave(IProgressBarDisplayable progress, IUnitOfWork uow) { var countColumn = Columns.First(x => x.DataType == DataTypeWorkwearItems.Count); var rows = UsedRows.Where(x => !x.Skipped && x.ChangedColumns.Any()).ToList(); var grouped = UsedRows.Where(x => x.Operation != null) .GroupBy(x => x.Employee); logger.Debug($"В обработке {grouped.Count()} сотрудников."); progress.Start(maxValue: grouped.Count(), text: "Подготовка"); foreach (var employeeGroup in grouped) { progress.Add(text: $"Подготовка {employeeGroup.Key.ShortName}"); var rowByItem = employeeGroup.GroupBy(x => x.WorkwearItem); foreach (var itemGroup in rowByItem) { var last = itemGroup.OrderByDescending(x => x.Date).First(); if (itemGroup.Key.LastIssue == null || itemGroup.Key.LastIssue < last.Date) { itemGroup.Key.LastIssue = last.Date; itemGroup.Key.Amount = last.CellIntValue(countColumn.Index).Value; itemGroup.Key.NextIssue = itemGroup.Key.ActiveNormItem.CalculateExpireDate(last.Date.Value, itemGroup.Key.Amount); dataParser.ChangedEmployees.Add(employeeGroup.Key); } } } List <object> toSave = new List <object>(); toSave.AddRange(dataParser.UsedNomeclature.Where(x => x.Id == 0)); toSave.AddRange(dataParser.ChangedEmployees); toSave.AddRange(UsedRows.Where(x => x.Operation != null).Select(x => x.Operation)); return(toSave); }
private void RecalculateCounters() { CountersViewModel.SetCount(CountersWorkwearItems.SkipRows, UsedRows.Count(x => x.Skipped)); CountersViewModel.SetCount(CountersWorkwearItems.UsedEmployees, UsedRows.Select(x => x.Employee).Distinct().Count(x => x != null)); CountersViewModel.SetCount(CountersWorkwearItems.NewOperations, UsedRows.Count(x => x.Operation != null && x.Operation.Id == 0)); CountersViewModel.SetCount(CountersWorkwearItems.WorkwearItemNotFound, UsedRows.Count(x => x.Employee != null && x.WorkwearItem == null)); CountersViewModel.SetCount(CountersWorkwearItems.NewNomenclatures, dataParser.UsedNomeclature.Count(x => x.Id == 0)); }
private void RecalculateCounters() { CountersViewModel.SetCount(CountersEmployee.SkipRows, UsedRows.Count(x => x.Skipped)); CountersViewModel.SetCount(CountersEmployee.MultiMatch, UsedRows.Count(x => !x.Skipped && x.Employees.Count > 1)); CountersViewModel.SetCount(CountersEmployee.NewEmployee, UsedRows.Count(x => !x.Skipped && x.EditingEmployee.Id == 0)); CountersViewModel.SetCount(CountersEmployee.NotChangedEmployee, UsedRows.Count(x => !x.Skipped && !x.HasChanges)); CountersViewModel.SetCount(CountersEmployee.ChangedEmployee, UsedRows.Count(x => !x.Skipped && x.HasChanges && x.EditingEmployee.Id > 0)); CountersViewModel.SetCount(CountersEmployee.NewPosts, dataParser.UsedPosts.Count(x => x.Id == 0)); CountersViewModel.SetCount(CountersEmployee.NewDepartments, dataParser.UsedDepartment.Count(x => x.Id == 0)); CountersViewModel.SetCount(CountersEmployee.NewSubdivisions, dataParser.UsedSubdivisions.Count(x => x.Id == 0)); }
private void RecalculateCounters() { CountersViewModel.SetCount(CountersNorm.SkipRows, UsedRows.Count(x => x.Skipped)); CountersViewModel.SetCount(CountersNorm.AmbiguousNorms, dataParser.MatchPairs.Count(x => x.Norms.Count > 1)); CountersViewModel.SetCount(CountersNorm.NewNorms, dataParser.UsedNorms.Count(x => x.Id == 0)); CountersViewModel.SetCount(CountersNorm.NewNormItems, UsedRows.Count(x => !x.Skipped && x.NormItem.Id == 0 && x.ChangedColumns.Any())); CountersViewModel.SetCount(CountersNorm.ChangedNormItems, UsedRows.Count(x => !x.Skipped && x.NormItem.Id > 0 && x.ChangedColumns.Any())); CountersViewModel.SetCount(CountersNorm.NewPosts, dataParser.UsedPosts.Count(x => x.Id == 0)); CountersViewModel.SetCount(CountersNorm.NewSubdivisions, dataParser.UsedSubdivisions.Count(x => x.Id == 0)); CountersViewModel.SetCount(CountersNorm.NewProtectionTools, dataParser.UsedProtectionTools.Count(x => x.Id == 0)); CountersViewModel.SetCount(CountersNorm.NewItemTypes, dataParser.UsedItemTypes.Count(x => x.Id == 0)); CountersViewModel.SetCount(CountersNorm.UndefinedItemTypes, dataParser.UndefinedProtectionNames.Count); }
public List <object> MakeToSave(IProgressBarDisplayable progress, IUnitOfWork uow) { var rows = UsedRows.Where(x => x.ChangedColumns.Any()).ToList(); progress.Start(maxValue: rows.Count, text: "Подготовка"); List <object> toSave = new List <object>(); toSave.AddRange(dataParser.UsedSubdivisions.Where(x => x.Id == 0)); toSave.AddRange(dataParser.UsedDepartment.Where(x => x.Id == 0)); toSave.AddRange(dataParser.UsedPosts.Where(x => x.Id == 0)); foreach (var row in rows) { toSave.AddRange(dataParser.PrepareToSave(uow, matchSettingsViewModel, row)); } return(toSave); }
public List <object> MakeToSave(IProgressBarDisplayable progress, IUnitOfWork uow) { var rows = UsedRows.Where(x => !x.Skipped && x.ChangedColumns.Any()).ToList(); progress.Start(maxValue: rows.Count, text: "Подготовка"); List <object> toSave = new List <object>(); toSave.AddRange(dataParser.UsedSubdivisions.Where(x => x.Id == 0)); toSave.AddRange(dataParser.UsedPosts.Where(x => x.Id == 0)); toSave.AddRange(dataParser.UsedItemTypes.Where(x => x.Id == 0)); toSave.AddRange(dataParser.UsedProtectionTools.Where(x => x.Id == 0)); toSave.AddRange(dataParser.UsedNorms.Where(x => x.Id == 0)); foreach (var row in rows) { toSave.AddRange(dataParser.PrepareToSave(uow, row)); } return(toSave); }