Exemplo n.º 1
0
        public FuelDocumentsJournalViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IEmployeeService employeeService,
            ISubdivisionRepository subdivisionRepository,
            IFuelRepository fuelRepository,
            ICounterpartyJournalFactory counterpartyJournalFactory,
            INomenclatureSelectorFactory nomenclatureSelectorFactory,
            IEmployeeJournalFactory employeeJournalFactory,
            ISubdivisionJournalFactory subdivisionJournalFactory,
            ICarJournalFactory carJournalFactory,
            IReportViewOpener reportViewOpener,
            IFileChooserProvider fileChooserProvider,
            ExpenseCategoryJournalFilterViewModel expenseCategoryJournalFilterViewModel
            ) :
            base(unitOfWorkFactory, commonServices)
        {
            this.commonServices                        = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            this.employeeService                       = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            this.subdivisionRepository                 = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            this.fuelRepository                        = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
            this.counterpartyJournalFactory            = counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory));
            this.nomenclatureSelectorFactory           = nomenclatureSelectorFactory ?? throw new ArgumentNullException(nameof(nomenclatureSelectorFactory));
            this.employeeJournalFactory                = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            _subdivisionJournalFactory                 = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));
            this.carJournalFactory                     = carJournalFactory ?? throw new ArgumentNullException(nameof(carJournalFactory));
            this.reportViewOpener                      = reportViewOpener ?? throw new ArgumentNullException(nameof(reportViewOpener));
            this.fileChooserProvider                   = fileChooserProvider ?? throw new ArgumentNullException(nameof(fileChooserProvider));
            this.expenseCategoryJournalFilterViewModel = expenseCategoryJournalFilterViewModel ?? throw new ArgumentNullException(nameof(expenseCategoryJournalFilterViewModel));


            TabName = "Журнал учета топлива";

            var loader = new ThreadDataLoader <FuelDocumentJournalNode>(unitOfWorkFactory);

            loader.MergeInOrderBy(x => x.CreationDate, true);
            DataLoader = loader;

            RegisterIncomeInvoice();
            RegisterTransferDocument();
            RegisterWriteoffDocument();

            FinishJournalConfiguration();

            UpdateOnChanges(
                typeof(FuelIncomeInvoice),
                typeof(FuelIncomeInvoiceItem),
                typeof(FuelTransferDocument),
                typeof(FuelWriteoffDocument),
                typeof(FuelWriteoffDocumentItem)
                );
        }
        public FuelWriteoffDocumentViewModel(
            IEntityUoWBuilder uoWBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            IEmployeeService employeeService,
            IFuelRepository fuelRepository,
            ISubdivisionRepository subdivisionRepository,
            ICommonServices commonServices,
            IEmployeeJournalFactory employeeJournalFactory,
            IReportViewOpener reportViewOpener,
            IFileChooserProvider fileChooserProvider,
            ExpenseCategoryJournalFilterViewModel expenseCategoryJournalFilterViewModel,
            ISubdivisionJournalFactory subdivisionJournalFactory
            )
            : base(uoWBuilder, unitOfWorkFactory, commonServices)
        {
            this.unitOfWorkFactory     = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this.employeeService       = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            this.fuelRepository        = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
            this.subdivisionRepository = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            this.commonServices        = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            EmployeeJournalFactory     = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            this.reportViewOpener      = reportViewOpener ?? throw new ArgumentNullException(nameof(reportViewOpener));
            this.expenseCategoryJournalFilterViewModel = expenseCategoryJournalFilterViewModel ?? throw new ArgumentNullException(nameof(expenseCategoryJournalFilterViewModel));
            this.fileChooserProvider  = fileChooserProvider ?? throw new ArgumentNullException(nameof(fileChooserProvider));
            SubdivisionJournalFactory = subdivisionJournalFactory ?? throw new ArgumentNullException(nameof(subdivisionJournalFactory));

            CreateCommands();
            UpdateCashSubdivisions();

            TabName = "Акт выдачи топлива";
            if (CurrentEmployee == null)
            {
                AbortOpening("К вашему пользователю не привязан сотрудник, невозможно открыть документ");
            }

            if (UoW.IsNew)
            {
                Entity.Date    = DateTime.Now;
                Entity.Cashier = CurrentEmployee;
            }

            ValidationContext.ServiceContainer.AddService(typeof(IFuelRepository), fuelRepository);
            ConfigureEntries();
        }
        public FuelTransferDocumentViewModel(
            IEntityUoWBuilder uoWBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            IEmployeeService employeeService,
            ISubdivisionRepository subdivisionRepository,
            IFuelRepository fuelRepository,
            ICommonServices commonServices,
            IEmployeeJournalFactory employeeJournalFactory,
            ICarJournalFactory carJournalFactory,
            IReportViewOpener reportViewOpener
            ) : base(uoWBuilder, unitOfWorkFactory, commonServices)
        {
            this.employeeService        = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            this.subdivisionRepository  = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            this.fuelRepository         = fuelRepository ?? throw new ArgumentNullException(nameof(fuelRepository));
            this.employeeJournalFactory = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            this.carJournalFactory      = carJournalFactory ?? throw new ArgumentNullException(nameof(carJournalFactory));
            this.reportViewOpener       = reportViewOpener ?? throw new ArgumentNullException(nameof(reportViewOpener));
            TabName = "Документ перемещения топлива";

            if (CurrentEmployee == null)
            {
                AbortOpening("К вашему пользователю не привязан сотрудник, невозможно открыть документ");
            }
            ConfigureEntityPropertyChanges();
            CreateCommands();

            FuelBalanceViewModel = new FuelBalanceViewModel(subdivisionRepository, fuelRepository);

            UpdateCashSubdivisions();
            UpdateFuelTypes();
            UpdateBalanceCache();

            if (uoWBuilder.IsNewEntity)
            {
                Entity.CreationTime = DateTime.Now;
                Entity.Author       = CurrentEmployee;
            }

            ConfigureEntries();
        }
        public ComplaintsJournalViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IUndeliveriesViewOpener undeliveriesViewOpener,
            IEmployeeService employeeService,
            IEntityAutocompleteSelectorFactory employeeSelectorFactory,
            IEntityAutocompleteSelectorFactory counterpartySelectorFactory,
            IEntityAutocompleteSelectorFactory nomenclatureSelectorFactory,
            IRouteListItemRepository routeListItemRepository,
            ISubdivisionService subdivisionService,
            ComplaintFilterViewModel filterViewModel,
            IFilePickerService filePickerService,
            ISubdivisionRepository subdivisionRepository,
            IReportViewOpener reportViewOpener,
            IGtkTabsOpenerForRouteListViewAndOrderView gtkDialogsOpener,
            INomenclatureRepository nomenclatureRepository,
            IUserRepository userRepository
            ) : base(filterViewModel, unitOfWorkFactory, commonServices)
        {
            this.unitOfWorkFactory           = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this.commonServices              = commonServices ?? throw new ArgumentNullException(nameof(commonServices));
            this.undeliveriesViewOpener      = undeliveriesViewOpener ?? throw new ArgumentNullException(nameof(undeliveriesViewOpener));
            this.employeeService             = employeeService ?? throw new ArgumentNullException(nameof(employeeService));
            this.employeeSelectorFactory     = employeeSelectorFactory ?? throw new ArgumentNullException(nameof(employeeSelectorFactory));
            this.counterpartySelectorFactory = counterpartySelectorFactory ?? throw new ArgumentNullException(nameof(counterpartySelectorFactory));
            this.nomenclatureSelectorFactory = nomenclatureSelectorFactory ?? throw new ArgumentNullException(nameof(nomenclatureSelectorFactory));
            this.filePickerService           = filePickerService ?? throw new ArgumentNullException(nameof(filePickerService));
            this.subdivisionRepository       = subdivisionRepository ?? throw new ArgumentNullException(nameof(subdivisionRepository));
            this.routeListItemRepository     = routeListItemRepository ?? throw new ArgumentNullException(nameof(routeListItemRepository));
            this.subdivisionService          = subdivisionService ?? throw new ArgumentNullException(nameof(subdivisionService));
            this.reportViewOpener            = reportViewOpener ?? throw new ArgumentNullException(nameof(reportViewOpener));
            this.gtkDlgOpener           = gtkDialogsOpener ?? throw new ArgumentNullException(nameof(gtkDialogsOpener));
            this.nomenclatureRepository = nomenclatureRepository ?? throw new ArgumentNullException(nameof(nomenclatureRepository));
            this.userRepository         = userRepository ?? throw new ArgumentNullException(nameof(userRepository));

            TabName = "Журнал рекламаций";

            RegisterComplaints();

            var threadLoader = DataLoader as ThreadDataLoader <ComplaintJournalNode>;

            threadLoader.MergeInOrderBy(x => x.Id, true);

            FinishJournalConfiguration();

            FilterViewModel.SubdivisionService = subdivisionService;
            FilterViewModel.EmployeeService    = employeeService;

            var currentUserSettings        = userRepository.GetUserSettings(UoW, commonServices.UserService.CurrentUserId);
            var defaultSubdivision         = currentUserSettings.DefaultSubdivision;
            var currentEmployeeSubdivision = employeeService.GetEmployeeForUser(UoW, commonServices.UserService.CurrentUserId).Subdivision;

            FilterViewModel.CurrentUserSubdivision = currentEmployeeSubdivision;

            if (FilterViewModel.SubdivisionService.GetOkkId() == currentEmployeeSubdivision.Id)
            {
                FilterViewModel.ComplaintStatus = ComplaintStatuses.Checking;
            }
            else
            {
                if (currentUserSettings.UseEmployeeSubdivision)
                {
                    FilterViewModel.Subdivision = currentEmployeeSubdivision;
                }
                else
                {
                    FilterViewModel.Subdivision = defaultSubdivision;
                }

                FilterViewModel.ComplaintStatus = currentUserSettings.DefaultComplaintStatus;
            }

            UpdateOnChanges(
                typeof(Complaint),
                typeof(ComplaintGuiltyItem),
                typeof(ComplaintResult),
                typeof(Subdivision),
                typeof(ComplaintDiscussion),
                typeof(DeliveryPoint),
                typeof(Fine),
                typeof(Order),
                typeof(RouteList),
                typeof(RouteListItem)
                );
            this.DataLoader.ItemsListUpdated += (sender, e) => CurrentObjectChanged?.Invoke(this, new CurrentObjectChangedArgs(null));

            DataLoader.PostLoadProcessingFunc = BeforeItemsUpdated;
        }