Exemple #1
0
 public AmountIssuedWearViewModel(
     RdlViewerViewModel rdlViewerViewModel,
     IUnitOfWorkFactory uowFactory,
     SubdivisionRepository subdivisionRepository) : base(rdlViewerViewModel)
 {
     Title      = "Справка о выданной спецодежде";
     Identifier = "AmountIssuedWear";
     using (var uow = uowFactory.CreateWithoutRoot()) {
         SelectedSubdivison resultAlias = null;
         Subdivisons = subdivisionRepository.ActiveQuery(uow)
                       .SelectList(list => list
                                   .Select(x => x.Id).WithAlias(() => resultAlias.Id)
                                   .Select(x => x.Name).WithAlias(() => resultAlias.Name)
                                   )
                       .TransformUsing(Transformers.AliasToBean <SelectedSubdivison>())
                       .List <SelectedSubdivison>();
     }
     Subdivisons.Insert(0,
                        new SelectedSubdivison {
         Id   = -1,
         Name = "Без подразделения"
     });
     foreach (var item in Subdivisons)
     {
         item.PropertyChanged += (sender, e) => OnPropertyChanged(nameof(SensetiveLoad));
     }
     unitOfWork = uowFactory.CreateWithoutRoot();
 }
        public int GetTotalItemsCount()
        {
            using (var uow = unitOfWorkFactory.CreateWithoutRoot()) {
                var query = queryFunc.Invoke(uow, true);
                if (query == null)
                {
                    return(0);
                }

                return(query.ClearOrders().RowCount());
            }
        }
 public void SaveFastDeliveryAvailabilityHistory(FastDeliveryAvailabilityHistory fastDeliveryAvailabilityHistory)
 {
     using (var uow = _unitOfWorkFactory.CreateWithoutRoot("SaveFastDeliveryAvailabilityHistory"))
     {
         try
         {
             uow.Save(fastDeliveryAvailabilityHistory);
             uow.Commit();
         }
         catch (Exception e)
         {
             _logger.Error(e, "Не удалось сохранить историю проверки экспресс-доставки.");
         }
     }
 }
Exemple #4
0
        public SalaryRatesReport(IUnitOfWorkFactory unitOfWorkFactory, IWageParametersProvider wageParametersProvider,
                                 ICommonServices commonServices)
        {
            _wageParametersProvider = wageParametersProvider ?? throw new ArgumentNullException(nameof(wageParametersProvider));
            _commonServices         = commonServices ?? throw new ArgumentNullException(nameof(commonServices));

            Build();
            UoW = unitOfWorkFactory.CreateWithoutRoot();
            SalaryRateFilterNode   salaryRateFilterNodeAlias   = null;
            WageDistrictLevelRates wageDistrictLevelRatesAlias = null;

            _salaryRateFilterNodes = new GenericObservableList <SalaryRateFilterNode>(UoW.Session
                                                                                      .QueryOver(() => wageDistrictLevelRatesAlias).Where(x => !x.IsArchive)
                                                                                      .SelectList(list => list
                                                                                                  .Select(() => wageDistrictLevelRatesAlias.Name).WithAlias(() => salaryRateFilterNodeAlias.Name)
                                                                                                  .Select(() => wageDistrictLevelRatesAlias.Id).WithAlias(() => salaryRateFilterNodeAlias.WageId))
                                                                                      .TransformUsing(Transformers.AliasToBean <SalaryRateFilterNode>()).List <SalaryRateFilterNode>());

            treeViewSalaryProperties.ColumnsConfig = FluentColumnsConfig <SalaryRateFilterNode> .Create()
                                                     .AddColumn("Название").AddTextRenderer(x => x.Name)
                                                     .AddColumn("").AddToggleRenderer(x => x.Selected)
                                                     .Finish();

            treeViewSalaryProperties.ItemsDataSource = _salaryRateFilterNodes;
        }
Exemple #5
0
        public CounterpartyOrderViewModel(Counterparty client,
                                          IUnitOfWorkFactory unitOfWorkFactory,
                                          ITdiCompatibilityNavigation tdinavigation,
                                          IRouteListRepository routedListRepository,
                                          MangoManager mangoManager,
                                          IOrderParametersProvider orderParametersProvider,
                                          IEmployeeJournalFactory employeeJournalFactory,
                                          ICounterpartyJournalFactory counterpartyJournalFactory,
                                          INomenclatureRepository nomenclatureRepository,
                                          IParametersProvider parametersProvider,
                                          int count = 5)
        {
            Client                      = client;
            tdiNavigation               = tdinavigation;
            _routedListRepository       = routedListRepository;
            MangoManager                = mangoManager;
            _orderParametersProvider    = orderParametersProvider ?? throw new ArgumentNullException(nameof(orderParametersProvider));
            _employeeJournalFactory     = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            _counterpartyJournalFactory = counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory));
            _nomenclatureRepository     = nomenclatureRepository ?? throw new ArgumentNullException(nameof(nomenclatureRepository));
            _parametersProvider         = parametersProvider ?? throw new ArgumentNullException(nameof(parametersProvider));
            UoW         = unitOfWorkFactory.CreateWithoutRoot();
            LatestOrder = _orderRepository.GetLatestOrdersForCounterparty(UoW, client, count).ToList();

            RefreshOrders = _RefreshOrders;
            NotifyConfiguration.Instance.BatchSubscribe(_RefreshCounterparty)
            .IfEntity <Counterparty>()
            .AndWhere(c => c.Id == client.Id)
            .Or.IfEntity <DeliveryPoint>()
            .AndWhere(d => client.DeliveryPoints.Any(cd => cd.Id == d.Id));
        }
Exemple #6
0
 public DefaultPasswordValidationSettings GetPasswordValidationSettings()
 {
     using (var uow = unitOfWorkFactory.CreateWithoutRoot()) {
         try {
             return(new DefaultPasswordValidationSettings {
                 MinNumberCount = uow.Session.CreateSQLQuery("SELECT @@GLOBAL.simple_password_check_digits AS value")
                                  .AddScalar("value", NHibernateUtil.Int32)
                                  .List <int>().First(),
                 MinLength = uow.Session.CreateSQLQuery("SELECT @@GLOBAL.simple_password_check_minimal_length AS value")
                             .AddScalar("value", NHibernateUtil.Int32)
                             .List <int>().First(),
                 MinLetterSameCaseCount = uow.Session
                                          .CreateSQLQuery("SELECT @@GLOBAL.simple_password_check_letters_same_case AS value")
                                          .AddScalar("value", NHibernateUtil.Int32)
                                          .List <int>().First(),
                 MinOtherCharactersCount = uow.Session
                                           .CreateSQLQuery("SELECT @@GLOBAL.simple_password_check_other_characters AS value")
                                           .AddScalar("value", NHibernateUtil.Int32)
                                           .List <int>().First(),
                 AllowWhitespaces = false,
                 ASCIIOnly = true
             });
         }
         catch (Exception ex) {
             var mysqlException = ex.FindExceptionTypeInInner <MySqlException>();
             if (mysqlException == null || mysqlException.Number != 1193)
             {
                 throw;
             }
             throw new InvalidOperationException(
                       "Неправильно настроены глобальные переменные. Возможно не установлен mysql плагин simple_password_check", ex);
         }
     }
 }
Exemple #7
0
        public SetBillsReport(IUnitOfWorkFactory unitOfWorkFactory)
        {
            this.Build();

            UoW = unitOfWorkFactory.CreateWithoutRoot();

            daterangepickerOrderCreation.StartDate = DateTime.Now;
            daterangepickerOrderCreation.EndDate   = DateTime.Now;
            ybuttonCreateReport.Clicked           += (sender, e) => { OnUpdate(true); };
            ybuttonCreateReport.TooltipText        = $"Формирует отчет по заказам в статусе '{OrderStatus.WaitForPayment.GetEnumTitle()}'";

            entrySubdivision.SetEntityAutocompleteSelectorFactory(
                new EntityAutocompleteSelectorFactory <SubdivisionsJournalViewModel>(typeof(Subdivision),
                                                                                     () => {
                var filter = new SubdivisionFilterViewModel();
                var employeeAutoCompleteSelectorFactory =
                    new DefaultEntityAutocompleteSelectorFactory <Employee, EmployeesJournalViewModel, EmployeeFilterViewModel>(
                        ServicesConfig.CommonServices);

                return(new SubdivisionsJournalViewModel(
                           filter,
                           unitOfWorkFactory,
                           ServicesConfig.CommonServices,
                           employeeAutoCompleteSelectorFactory
                           ));
            })
                );
        }
        public CashInfoPanelView(IUnitOfWorkFactory uowFactory,
                                 ICashRepository cashRepository,
                                 ISubdivisionRepository subdivisionRepository,
                                 IUserRepository userRepository)
        {
            this.Build();
            _uow            = uowFactory?.CreateWithoutRoot("Боковая панель остатков по кассам") ?? throw new ArgumentNullException(nameof(uowFactory));
            _cashRepository = cashRepository ?? throw new ArgumentNullException(nameof(cashRepository));

            var currentUser           = ServicesConfig.CommonServices.UserService.GetCurrentUser(_uow);
            var availableSubdivisions = subdivisionRepository.GetCashSubdivisionsAvailableForUser(_uow, currentUser).ToList();
            var settings =
                (userRepository ?? throw new ArgumentNullException(nameof(userRepository)))
                .GetCurrentUserSettings(_uow);
            var needSave = settings.UpdateCashSortingSettings(availableSubdivisions);

            if (needSave)
            {
                _uow.Save(settings);
                _uow.Commit();
            }

            _sortedSubdivisionsIds = settings.CashSubdivisionSortingSettings
                                     .OrderBy(x => x.SortingIndex)
                                     .Select(x => x.CashSubdivision.Id)
                                     .ToList();
        }
Exemple #9
0
        public void UpdateDB()
        {
            var hops = configuration.GetHopsToLast(CurrentDBVersion).ToList();

            if (!hops.Any())
            {
                logger.Info("Нет обновлений для базы данных.");
                return;
            }

            using (var uow = unitOfWorkFactory.CreateWithoutRoot()) {
                if (connectionStringBuilder.UserID != "root" && !userService.GetCurrentUser(uow).IsAdmin)
                {
                    NotAdminErrorAndExit(CurrentDBVersion, hops.Last().Destination);
                }
            }

            if (hops.All(x => x.UpdateType == UpdateType.MicroUpdate))
            {
                RunMicroUpdateOnly();
            }
            else
            {
                RunUpdateDB();
            }
        }
        public CounterpartyTalkViewModel(
            INavigationManager navigation,
            ITdiCompatibilityNavigation tdinavigation,
            IUnitOfWorkFactory unitOfWorkFactory,
            RouteListRepository routedListRepository,
            IInteractiveService interactiveService,
            MangoManager manager) : base(navigation, manager)
        {
            this.NavigationManager = navigation ?? throw new ArgumentNullException(nameof(navigation));
            this.tdiNavigation     = tdinavigation ?? throw new ArgumentNullException(nameof(navigation));

            this.routedListRepository = routedListRepository;
            this.interactiveService   = interactiveService ?? throw new ArgumentNullException(nameof(interactiveService));
            UoW = unitOfWorkFactory.CreateWithoutRoot();

            if (ActiveCall.CounterpartyIds.Any())
            {
                var clients = UoW.GetById <Counterparty>(ActiveCall.CounterpartyIds);
                foreach (Counterparty client in clients)
                {
                    CounterpartyOrderViewModel model = new CounterpartyOrderViewModel(client, unitOfWorkFactory, tdinavigation, routedListRepository, this.MangoManager);
                    CounterpartyOrdersModels.Add(model);
                }
                currentCounterparty = CounterpartyOrdersModels.FirstOrDefault().Client;
            }
            else
            {
                throw new InvalidProgramException("Открыт диалог разговора с имеющимся контрагентом, но ни одного id контрагента не найдено.");
            }
        }
Exemple #11
0
        public IList <Domain.Orders.Order> GetSameOrderForDateAndDeliveryPoint(IUnitOfWorkFactory uowFactory, DateTime date, DeliveryPoint deliveryPoint)
        {
            var uow = uowFactory.CreateWithoutRoot();

            return(uow.Session.QueryOver <VodovozOrder>()
                   .Where(x => x.DeliveryDate == date)
                   .Where(x => x.DeliveryPoint.Id == deliveryPoint.Id)
                   .List());
        }
        public DeliveryAnalyticsViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            IInteractiveService interactiveService,
            INavigationManager navigation,
            IEntityAutocompleteSelectorFactory districtSelectorFactory)
            : base(interactiveService, navigation)
        {
            _interactiveService     = interactiveService ?? throw new ArgumentNullException(nameof(interactiveService));
            DistrictSelectorFactory = districtSelectorFactory ?? throw new ArgumentNullException(nameof(districtSelectorFactory));
            if (unitOfWorkFactory is null)
            {
                throw new ArgumentNullException(nameof(unitOfWorkFactory));
            }

            Uow   = unitOfWorkFactory.CreateWithoutRoot();
            Title = "Аналитика объёмов доставки";

            WaveList             = new GenericObservableList <WaveNode>();
            WeekDayName          = new GenericObservableList <WeekDayNodes>();
            GeographicGroupNodes = new GenericObservableList <GeographicGroupNode>();

            WageDistrictNodes = new GenericObservableList <WageDistrictNode>();

            foreach (var wage in Uow.GetAll <WageDistrict>().Select(x => x).ToList())
            {
                var wageNode = new WageDistrictNode(wage);
                wageNode.Selected = true;
                WageDistrictNodes.Add(wageNode);
            }

            foreach (var geographic in Uow.GetAll <GeographicGroup>().Select(x => x).ToList())
            {
                var geographicNode = new GeographicGroupNode(geographic);
                geographicNode.Selected = true;
                GeographicGroupNodes.Add(geographicNode);
            }

            foreach (var wave in Enum.GetValues(typeof(WaveNodes)))
            {
                var waveNode = new WaveNode {
                    WaveNodes = (WaveNodes)wave, Selected = true
                };
                WaveList.Add(waveNode);
            }

            foreach (var week in Enum.GetValues(typeof(WeekDayName)))
            {
                if ((WeekDayName)week == Domain.Sale.WeekDayName.Today)
                {
                    continue;
                }
                var weekNode = new WeekDayNodes {
                    WeekNameNode = (WeekDayName)week, Selected = true
                };
                WeekDayName.Add(weekNode);
            }
        }
 public CounterpartyReport(IEntityAutocompleteSelectorFactory salesChannelSelectorFactory,
                           IEntityAutocompleteSelectorFactory districtSelectorFactory, IUnitOfWorkFactory unitOfWorkFactory,
                           IInteractiveService interactiveService)
 {
     this.Build();
     this.interactiveService = interactiveService ?? throw new ArgumentNullException(nameof(interactiveService));
     UoW = unitOfWorkFactory.CreateWithoutRoot();
     ConfigureView(salesChannelSelectorFactory, districtSelectorFactory);
 }
 public CardPaymentsOrdersReport(IUnitOfWorkFactory unitOfWorkFactory)
 {
     Build();
     UoW = unitOfWorkFactory.CreateWithoutRoot();
     ydateperiodpicker.StartDate = DateTime.Now.Date;
     ydateperiodpicker.EndDate   = DateTime.Now.Date;
     comboPaymentFrom.ItemsList  = UoW.GetAll <PaymentFrom>();
     comboGeoGroup.ItemsList     = UoW.GetAll <GeographicGroup>();
 }
 public UnknowTalkViewModel(IUnitOfWorkFactory unitOfWorkFactory,
                            ITdiCompatibilityNavigation navigation,
                            IInteractiveQuestion interactive,
                            MangoManager manager) : base(navigation, manager)
 {
     this.tdiNavigation = navigation ?? throw new ArgumentNullException(nameof(navigation));
     this.interactive   = interactive ?? throw new ArgumentNullException(nameof(interactive));
     UoW = unitOfWorkFactory.CreateWithoutRoot();
 }
 public EmployeeIssueGraphViewModel(
     INavigationManager navigation,
     IUnitOfWorkFactory factory,
     EmployeeCard employee,
     ProtectionTools protectionTools) : base(navigation)
 {
     using (var unitOfWork = factory.CreateWithoutRoot())
         Intervals = IssueGraph.MakeIssueGraph(unitOfWork, employee, protectionTools).Intervals;
     Title = $"Хронология {employee.ShortName} - {protectionTools.Name}";
 }
Exemple #17
0
        public RequestSheetViewModel(RdlViewerViewModel rdlViewerViewModel, IUnitOfWorkFactory uowFactory, INavigationManager navigation, ILifetimeScope AutofacScope) : base(rdlViewerViewModel)
        {
            Title      = "Заявка на спецодежду";
            Identifier = "RequestSheet";

            uow = uowFactory.CreateWithoutRoot();
            var builder = new CommonEEVMBuilderFactory(rdlViewerViewModel, uow, navigation, AutofacScope);

            EntrySubdivisionViewModel = builder.ForEntity <Subdivision>().MakeByType().Finish();
        }
        public IssueByIdentifierViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            INavigationManager navigation,
            IGuiDispatcher guiDispatcher,
            IUserService userService,
            ILifetimeScope autofacScope,
            StockRepository stockRepository,
            EmployeeRepository employeeRepository,
            FeaturesService featuresService,
            IValidator validator,
            BaseParameters baseParameters,
            IInteractiveQuestion interactive,
            IChangeableConfiguration configuration,
            SizeService sizeService,
            ICardReaderService cardReaderService = null) : base(navigation)
        {
            this.unitOfWorkFactory  = unitOfWorkFactory ?? throw new ArgumentNullException(nameof(unitOfWorkFactory));
            this.guiDispatcher      = guiDispatcher ?? throw new ArgumentNullException(nameof(guiDispatcher));
            this.userService        = userService ?? throw new ArgumentNullException(nameof(userService));
            this.autofacScope       = autofacScope ?? throw new ArgumentNullException(nameof(autofacScope));
            this.employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
            this.validator          = validator ?? throw new ArgumentNullException(nameof(validator));
            this.BaseParameters     = baseParameters ?? throw new ArgumentNullException(nameof(baseParameters));
            this.interactive        = interactive ?? throw new ArgumentNullException(nameof(interactive));
            this.configuration      = configuration ?? throw new ArgumentNullException(nameof(configuration));
            SizeService             = sizeService ?? throw new ArgumentNullException(nameof(sizeService));
            this.cardReaderService  = cardReaderService;
            IsModal = false;
            EnableMinimizeMaximize = true;
            Title = "Выдача по картам СКУД";

            UowOfDialog = unitOfWorkFactory.CreateWithoutRoot();
            var entryBuilder = new CommonEEVMBuilderFactory <IssueByIdentifierViewModel>(this, this, UowOfDialog, navigation, autofacScope);

            if (cardReaderService != null)
            {
                cardReaderService.RefreshDevices();
                cardReaderService.СardStatusRead           += RusGuardService_СardStatusRead;
                cardReaderService.CardFamilies.ListChanged += CardFamilies_ListChanged;
            }
            UpdateState();


            WarehouseEntryViewModel = entryBuilder.ForProperty(x => x.Warehouse).MakeByType().Finish();
            Warehouse = stockRepository.GetDefaultWarehouse(UowOfDialog, featuresService, autofacScope.Resolve <IUserService>().CurrentUserId);

            //Настройка таймера сброса
            timerCleanSuccessfullyText           = new Timer(40000);
            timerCleanSuccessfullyText.AutoReset = false;
            timerCleanSuccessfullyText.Elapsed  += delegate(object sender, ElapsedEventArgs e) {
                guiDispatcher.RunInGuiTread(() => SuccessfullyText = null);
            };

            ReadConfig();
        }
        public AverageAnnualNeedViewModel(RdlViewerViewModel rdlViewerViewModel, IUnitOfWorkFactory uowFactory, INavigationManager navigation, ILifetimeScope autofacScope) : base(rdlViewerViewModel)
        {
            Title      = "Среднегодовая потребность";
            Identifier = "AverageAnnualNeed";

            UoW = uowFactory.CreateWithoutRoot();

            var builder = new CommonEEVMBuilderFactory(rdlViewerViewModel, UoW, navigation, autofacScope);

            SubdivisionEntry = builder.ForEntity <Subdivision>().MakeByType().Finish();
        }
 public DeliveryTimeReport(IUnitOfWorkFactory unitOfWorkFactory, IInteractiveService interactiveService)
 {
     if (unitOfWorkFactory == null)
     {
         throw new ArgumentNullException(nameof(unitOfWorkFactory));
     }
     this.interactiveService = interactiveService ?? throw new ArgumentNullException(nameof(interactiveService));
     UoW = unitOfWorkFactory.CreateWithoutRoot();
     Build();
     ConfigureDlg();
 }
Exemple #21
0
        public SendMessangeViewModel(IUnitOfWorkFactory unitOfWorkFactory, int[] employeeIds, NotificationManagerService notificationManager, IInteractiveMessage interactive, INavigationManager navigation) : base(navigation)
        {
            this.notificationManager = notificationManager ?? throw new ArgumentNullException(nameof(notificationManager));
            this.interactive         = interactive ?? throw new ArgumentNullException(nameof(interactive));
            Title = "Отправка уведомлений " + NumberToTextRus.FormatCase(employeeIds.Length, "{0} сотруднику", "{0} сотрудникам", "{0} сотрудникам");

            uow = unitOfWorkFactory.CreateWithoutRoot();

            Templates = uow.GetAll <MessageTemplate>().ToList();
            employees = uow.GetById <EmployeeCard>(employeeIds);
        }
Exemple #22
0
        public int CountSentMessages()
        {
            if (workOrder.Id == 0)
            {
                return(0);
            }

            using (var uow = unitOfWorkFactory.CreateWithoutRoot())
            {
                return(historyRepository.MessageCount(uow, workOrder.Id));
            }
        }
 public void StartDevice(DeviceInfo device)
 {
     if (device.DeviceInfoShort.DeviceAddress == 1)
     {
         using (var uow = unitOfWorkFactory.CreateWithoutRoot()) {
             Uids = uow.Session.QueryOver <EmployeeCard>()
                    .Where(x => x.CardKey != null)
                    .Select(x => x.CardKey)
                    .List <string>();
         }
     }
 }
Exemple #24
0
        public CounterpartyTalkViewModel(
            INavigationManager navigation,
            ITdiCompatibilityNavigation tdinavigation,
            IUnitOfWorkFactory unitOfWorkFactory,
            IRouteListRepository routedListRepository,
            IInteractiveService interactiveService,
            IOrderParametersProvider orderParametersProvider,
            MangoManager manager,
            IEmployeeJournalFactory employeeJournalFactory,
            ICounterpartyJournalFactory counterpartyJournalFactory,
            INomenclatureRepository nomenclatureRepository,
            IOrderRepository orderRepository,
            IParametersProvider parametersProvider,
            IDeliveryRulesParametersProvider deliveryRulesParametersProvider,
            IDeliveryPointJournalFactory deliveryPointJournalFactory) : base(navigation, manager)
        {
            NavigationManager = navigation ?? throw new ArgumentNullException(nameof(navigation));
            _tdiNavigation    = tdinavigation ?? throw new ArgumentNullException(nameof(navigation));

            _routedListRepository            = routedListRepository;
            _interactiveService              = interactiveService ?? throw new ArgumentNullException(nameof(interactiveService));
            _orderParametersProvider         = orderParametersProvider ?? throw new ArgumentNullException(nameof(orderParametersProvider));
            _employeeJournalFactory          = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            _counterpartyJournalFactory      = counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory));
            _nomenclatureRepository          = nomenclatureRepository ?? throw new ArgumentNullException(nameof(nomenclatureRepository));
            _orderRepository                 = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
            _parametersProvider              = parametersProvider ?? throw new ArgumentNullException(nameof(parametersProvider));
            _deliveryRulesParametersProvider = deliveryRulesParametersProvider ?? throw new ArgumentNullException(nameof(deliveryRulesParametersProvider));
            _uow = unitOfWorkFactory.CreateWithoutRoot();
            _deliveryPointJournalFactory =
                deliveryPointJournalFactory ?? throw new ArgumentNullException(nameof(deliveryPointJournalFactory));

            if (ActiveCall.CounterpartyIds.Any())
            {
                var clients = _uow.GetById <Counterparty>(ActiveCall.CounterpartyIds);

                foreach (Counterparty client in clients)
                {
                    CounterpartyOrderViewModel model = new CounterpartyOrderViewModel(
                        client, unitOfWorkFactory, tdinavigation, routedListRepository, MangoManager, _orderParametersProvider,
                        _employeeJournalFactory, _counterpartyJournalFactory, _nomenclatureRepository, _parametersProvider,
                        _deliveryRulesParametersProvider);
                    CounterpartyOrdersViewModels.Add(model);
                }

                currentCounterparty = CounterpartyOrdersViewModels.FirstOrDefault().Client;
            }
            else
            {
                throw new InvalidProgramException("Открыт диалог разговора с имеющимся контрагентом, но ни одного id контрагента не найдено.");
            }
        }
        public NotIssuedSheetViewModel(RdlViewerViewModel rdlViewerViewModel, IUnitOfWorkFactory uowFactory, INavigationManager navigation, ILifetimeScope autofacScope) : base(rdlViewerViewModel)
        {
            Title      = "Справка по невыданному (Детально)";
            Identifier = "NotIssuedSheet";

            UoW = uowFactory.CreateWithoutRoot();

            var builder = new CommonEEVMBuilderFactory(rdlViewerViewModel, UoW, navigation, autofacScope);

            SubdivisionEntry = builder.ForEntity <Subdivision>().MakeByType().Finish();

            excludeInVacation = true;
        }
        public DateTime?GetOrderDeliveryDate(IUnitOfWorkFactory uowFactory, int orderId)
        {
            DateTime?deliveryDate;

            using (var uow = uowFactory.CreateWithoutRoot($"Получение даты доставки заказа №{orderId}"))
            {
                deliveryDate = uow.Session.QueryOver <VodovozOrder>()
                               .Where(o => o.Id == orderId)
                               .Select(o => o.DeliveryDate)
                               .SingleOrDefault <DateTime?>();
            }

            return(deliveryDate);
        }
        public override void SendErrorReport()
        {
            if (ReportSent)
            {
                return;
            }

            if (!CanSendErrorReportManually && ErrorReportType != ReportType.Automatic)
            {
                return;
            }

            if (!CanSendErrorReportAutomatically && ErrorReportType == ReportType.Automatic)
            {
                return;
            }

            UserBase user = null;

            try {
                if (userService != null && unitOfWorkFactory != null)
                {
                    using (IUnitOfWork uow = unitOfWorkFactory.CreateWithoutRoot()) {
                        user = userService.GetCurrentUser(uow);
                    }
                }
            } catch (Exception ex) {
                AddDescription($"Не удалось автоматически получить пользователя ({ex.Message})");
            }

            if (ErrorReportType == ReportType.Automatic)
            {
                ReportSent = errorReporter.AutomaticSendErrorReport(
                    Description,
                    Email,
                    user,
                    Exceptions.ToArray()
                    );
            }
            else
            {
                ReportSent = errorReporter.ManuallySendErrorReport(
                    Description,
                    Email,
                    user,
                    Exceptions.ToArray()
                    );
            }
        }
Exemple #28
0
        public OrderAnalyticsReportViewModel(
            IUnitOfWorkFactory unitOfWorkFactory,
            IInteractiveService interactiveService,
            INavigationManager navigationManager) : base(unitOfWorkFactory, navigationManager)
        {
            this.interactiveService = interactiveService ?? throw new ArgumentNullException(nameof(interactiveService));

            if (unitOfWorkFactory == null)
            {
                throw new ArgumentNullException(nameof(unitOfWorkFactory));
            }

            Title = "Отчет аналитика заказов";
            UoW   = unitOfWorkFactory.CreateWithoutRoot();
        }
        public int?GetMaxOrderDailyNumberForDate(IUnitOfWorkFactory uowFactory, DateTime deliveryDate)
        {
            int?dailyNumber;

            using (var uow = uowFactory.CreateWithoutRoot(
                       $"Получение максимального ежедневного номера заказа на {deliveryDate}"))
            {
                dailyNumber = uow.Session.QueryOver <VodovozOrder>()
                              .Where(o => o.DeliveryDate == deliveryDate)
                              .Select(Projections.Max <VodovozOrder>(o => o.DailyNumber))
                              .SingleOrDefault <int?>();
            }

            return(dailyNumber);
        }
 public UnknowTalkViewModel(IUnitOfWorkFactory unitOfWorkFactory,
                            ITdiCompatibilityNavigation navigation,
                            IInteractiveQuestion interactive,
                            MangoManager manager,
                            IEmployeeJournalFactory employeeJournalFactory,
                            ICounterpartyJournalFactory counterpartyJournalFactory,
                            INomenclatureRepository nomenclatureRepository) : base(navigation, manager)
 {
     _tdiNavigation              = navigation ?? throw new ArgumentNullException(nameof(navigation));
     _interactive                = interactive ?? throw new ArgumentNullException(nameof(interactive));
     _employeeJournalFactory     = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
     _counterpartyJournalFactory = counterpartyJournalFactory ?? throw new ArgumentNullException(nameof(counterpartyJournalFactory));
     _nomenclatureRepository     = nomenclatureRepository ?? throw new ArgumentNullException(nameof(nomenclatureRepository));
     _uow = unitOfWorkFactory.CreateWithoutRoot();
 }