Exemple #1
0
        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);
        }
        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);
        }