Esempio n. 1
0
 public SubdivisionDlg()
 {
     this.Build();
     TabName    = "Новое подразделение";
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <Subdivision>();
     ConfigureDlg();
 }
Esempio n. 2
0
 public M2ProxyDlg()
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <M2ProxyDocument>();
     TabName    = "Новая доверенность М-2";
     ConfigureDlg();
 }
Esempio n. 3
0
 public DeliveryScheduleDlg()
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <DeliverySchedule>();
     TabName    = "Новый график доставки";
     ConfigureDlg();
 }
Esempio n. 4
0
 public CertificateDlg()
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <Certificate>();
     TabName    = "Новый сертификат";
     ConfigureDlg();
 }
Esempio n. 5
0
 public ImageLoaderDlg()
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <StoredImageResource>();
     TabName    = "Новое изображение";
     ConfigureDlg();
 }
Esempio n. 6
0
        public static IUnitOfWorkGeneric <DeliveryPoint> CreateUowForNew(Counterparty counterparty)
        {
            var uow = UnitOfWorkFactory.CreateWithNewRoot <DeliveryPoint> ();

            uow.Root.Counterparty = counterparty;
            return(uow);
        }
Esempio n. 7
0
        public SelfDeliveryDocumentDlg()
        {
            this.Build();

            UoWGeneric    = UnitOfWorkFactory.CreateWithNewRoot <SelfDeliveryDocument>();
            Entity.Author = _employeeRepository.GetEmployeeForCurrentUser(UoW);
            if (Entity.Author == null)
            {
                MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать складские документы, так как некого указывать в качестве кладовщика.");
                FailInitialize = true;
                return;
            }

            Entity.Warehouse = StoreDocumentHelper.GetDefaultWarehouse(UoW, WarehousePermissions.SelfDeliveryEdit);
            var validationResult = CheckPermission();

            if (!validationResult.CanRead)
            {
                MessageDialogHelper.RunErrorDialog("Нет прав для доступа к документу отпуска самовывоза");
                FailInitialize = true;
                return;
            }

            if (!validationResult.CanCreate)
            {
                MessageDialogHelper.RunErrorDialog("Нет прав для создания документа отпуска самовывоза");
                FailInitialize = true;
                return;
            }

            canEditDocument = true;
            ConfigureDlg();
        }
Esempio n. 8
0
        public static IUnitOfWorkGeneric <Contact> Create(Counterparty counterparty)
        {
            var uow = UnitOfWorkFactory.CreateWithNewRoot <Contact> ();

            uow.Root.Counterparty = counterparty;
            return(uow);
        }
Esempio n. 9
0
 public NomenclatureDlg()
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <Nomenclature>();
     TabName    = "Новая номенклатура";
     ConfigureDlg();
 }
Esempio n. 10
0
 public DeliveryPriceRuleDlg()
 {
     TabName = "Создание нового правила для цены доставки";
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <DeliveryPriceRule>();
     ConfigureDlg();
 }
Esempio n. 11
0
        public CashExpenseDlg(IPermissionService permissionService)
        {
            this.Build();
            UoWGeneric    = UnitOfWorkFactory.CreateWithNewRoot <Expense>();
            Entity.Casher = EmployeeRepository.GetEmployeeForCurrentUser(UoW);
            if (Entity.Casher == null)
            {
                MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать кассовые документы, так как некого указывать в качестве кассира.");
                FailInitialize = true;
                return;
            }

            var userPermission = permissionService.ValidateUserPermission(typeof(Expense), UserSingletonRepository.GetInstance().GetCurrentUser(UoW).Id);

            canCreate = userPermission.CanCreate;
            if (!userPermission.CanCreate)
            {
                MessageDialogHelper.RunErrorDialog("Отсутствуют права на создание расходного ордера");
                FailInitialize = true;
                return;
            }

            if (!accessfilteredsubdivisionselectorwidget.Configure(UoW, false, typeof(Expense)))
            {
                MessageDialogHelper.RunErrorDialog(accessfilteredsubdivisionselectorwidget.ValidationErrorMessage);
                FailInitialize = true;
                return;
            }

            Entity.Date = DateTime.Now;
            ConfigureDlg();
        }
Esempio n. 12
0
        public void BatchSubscribe_InsertAndUpdateAndDelete_GetOldAndNewPropertyValuesTest()
        {
            using (var subscruber = new BatchEventTestSubscruber()) {
                NotifyConfiguration.Instance.BatchSubscribeOnEntity <SimpleEntity>(subscruber.Handler);

                using (var uow = UnitOfWorkFactory.CreateWithNewRoot <SimpleEntity>()) {
                    uow.Root.Text = "Test text";
                    uow.Save();
                    uow.Session.Evict(uow.Root);

                    var loadedEntity = uow.GetById <SimpleEntity>(1);
                    loadedEntity.Text = "New test text";
                    uow.Save(loadedEntity);
                    uow.Commit();

                    uow.Delete(loadedEntity);
                    uow.Commit();
                }
                Assert.That(subscruber.calls.Count, Is.EqualTo(3));

                var event1 = subscruber.calls[0].First();
                Assert.That(event1.GetOldValue <SimpleEntity>(x => x.Text), Is.Null);
                Assert.That(event1.GetNewValue <SimpleEntity>(x => x.Text), Is.EqualTo("Test text"));

                var event2 = subscruber.calls[1].First();
                Assert.That(event2.GetOldValue <SimpleEntity>(x => x.Text), Is.EqualTo("Test text"));
                Assert.That(event2.GetNewValue <SimpleEntity>(x => x.Text), Is.EqualTo("New test text"));

                var event3 = subscruber.calls[2].First();
                Assert.That(event3.GetOldValue <SimpleEntity>(x => x.Text), Is.EqualTo("New test text"));
                Assert.That(event3.GetNewValue <SimpleEntity>(x => x.Text), Is.Null);
            }
        }
Esempio n. 13
0
 public CarsDlg()
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <Car>();
     TabName    = "Новый автомобиль";
     ConfigureDlg();
 }
Esempio n. 14
0
        public AdvanceReportDlg()
        {
            Build();
            UoWGeneric    = UnitOfWorkFactory.CreateWithNewRoot <AdvanceReport>();
            Entity.Casher = _employeeRepository.GetEmployeeForCurrentUser(UoW);
            if (Entity.Casher == null)
            {
                MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать кассовые документы, так как некого указывать в качестве кассира.");
                FailInitialize = true;
                return;
            }

            _canCreate = permissionResult.CanCreate;
            if (!_canCreate)
            {
                MessageDialogHelper.RunErrorDialog("Отсутствуют права на создание приходного ордера");
                FailInitialize = true;
                return;
            }

            if (!accessfilteredsubdivisionselectorwidget.Configure(UoW, false, typeof(AdvanceReport)))
            {
                MessageDialogHelper.RunErrorDialog(accessfilteredsubdivisionselectorwidget.ValidationErrorMessage);
                FailInitialize = true;
                return;
            }

            Entity.Date = DateTime.Now;
            ConfigureDlg();
            FillDebt();
        }
Esempio n. 15
0
 public FreeRentPackageDlg()
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <FreeRentPackage>();
     TabName    = "Новый пакет бесплатной аренды";
     ConfigureDlg();
 }
Esempio n. 16
0
        //Конструкторы
        public static IUnitOfWorkGeneric <TContract> Create <TContract> (Counterparty counterparty) where TContract : Contract, new()
        {
            var uow = UnitOfWorkFactory.CreateWithNewRoot <TContract> ();

            uow.Root.Counterparty = counterparty;
            uow.Root.Organization = uow.Session.QueryOver <Organization>().Take(1).SingleOrDefault();
            return(uow);
        }
Esempio n. 17
0
        public NuanceDlg(object uow)
        {
            UoWforeign = uow;
            this.Build();
            UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <Comments>();

            ConfigureDlg();
        }
Esempio n. 18
0
 public CarProxyDlg()
 {
     this.Build();
     UoWGeneric  = UnitOfWorkFactory.CreateWithNewRoot <CarProxyDocument>();
     Entity.Date = DateTime.Now;
     TabName     = "Новая доверенность на ТС";
     ConfigureDlg();
 }
Esempio n. 19
0
        protected void OnButtonChangeToEmployeeClicked(object sender, EventArgs e)
        {
            if (UoW.HasChanges || Entity.Id == 0)
            {
                if (!MessageDialogHelper.RunQuestionDialog("Для продолжения необходимо сохранить изменения, сохранить и продолжить?"))
                {
                    return;
                }
                if (Save())
                {
                    OnEntitySaved(true);
                }
                else
                {
                    return;
                }
            }
            var employeeUow = UnitOfWorkFactory.CreateWithNewRoot <Employee>();

            Personnel.ChangeTraineeToEmployee(employeeUow, Entity);

            var cs = new ConfigurationSection(new ConfigurationRoot(new List <IConfigurationProvider> {
                new MemoryConfigurationProvider(new MemoryConfigurationSource())
            }), "");

            cs["BaseUri"] = "https://driverapi.vod.qsolution.ru:7090/api/";

            var apiHelper = new ApiClientProvider.ApiClientProvider(cs);

            var driverApiRegisterEndpoint = new DriverApiUserRegisterEndpoint(apiHelper);

            var employeeViewModel = new EmployeeViewModel(
                _authorizationService,
                _employeeWageParametersFactory,
                _employeeJournalFactory,
                _subdivisionJournalFactory,
                _employeePostsJournalFactory,
                _cashDistributionCommonOrganisationProvider,
                _subdivisionService,
                _emailServiceSettingAdapter,
                _wageCalculationRepository,
                _employeeRepository,
                employeeUow,
                ServicesConfig.CommonServices,
                _validationContextFactory,
                _phonesViewModelFactory,
                _warehouseRepository,
                _routeListRepository,
                driverApiRegisterEndpoint,
                CurrentUserSettings.Settings,
                _userRepository,
                _baseParametersProvider,
                true);

            TabParent.OpenTab(DialogHelper.GenerateDialogHashName <Employee>(Entity.Id),
                              () => employeeViewModel);
            OnCloseTab(false);
        }
Esempio n. 20
0
 public NoteDlg(ushort pointNumber, ushort calendarNumber, DateTime date)
 {
     this.Build();
     UoWGeneric            = UnitOfWorkFactory.CreateWithNewRoot <Note>();
     Entity.PointNumber    = pointNumber;
     Entity.CalendarNumber = calendarNumber;
     Entity.Date           = date;
     Configure();
 }
Esempio n. 21
0
        static void AddEmailToSend(Email email)
        {
            if (!emailRepository.CanSendByTimeout(email.Recipient.EmailAddress, email.Order, email.OrderDocumentType))
            {
                logger.Error("{0} Попытка отправить почту до истечения минимального времени до повторной отправки", GetThreadInfo());
                throw new Exception("Отправка на один и тот же адрес возможна раз в 10 минут");
            }

            logger.Debug("{0} Запись в базу информации о письме", GetThreadInfo());
            using (var uow = UnitOfWorkFactory.CreateWithNewRoot <StoredEmail>($"[ES]Добавление письма на отправку")) {
                //Заполнение нового письма данными
                switch (email.OrderDocumentType)
                {
                case OrderDocumentType.Bill:
                    uow.Root.Order = uow.GetById <Order>(email.Order);
                    break;

                case OrderDocumentType.BillWSForDebt:
                    uow.Root.OrderWithoutShipmentForDebt = uow.GetById <OrderWithoutShipmentForDebt>(email.Order);
                    break;

                case OrderDocumentType.BillWSForAdvancePayment:
                    uow.Root.OrderWithoutShipmentForAdvancePayment = uow.GetById <OrderWithoutShipmentForAdvancePayment>(email.Order);
                    break;

                case OrderDocumentType.BillWSForPayment:
                    uow.Root.OrderWithoutShipmentForPayment = uow.GetById <OrderWithoutShipmentForPayment>(email.Order);
                    break;
                }

                uow.Root.DocumentType     = email.OrderDocumentType;
                uow.Root.SendDate         = DateTime.Now;
                uow.Root.StateChangeDate  = DateTime.Now;
                uow.Root.HtmlText         = email.HtmlText;
                uow.Root.Text             = email.Text;
                uow.Root.Title            = email.Title;
                uow.Root.State            = StoredEmailStates.WaitingToSend;
                uow.Root.SenderName       = email.Sender.Title;
                uow.Root.SenderAddress    = email.Sender.EmailAddress;
                uow.Root.RecipientName    = email.Recipient.Title;
                uow.Root.RecipientAddress = email.Recipient.EmailAddress;
                uow.Root.ManualSending    = email.ManualSending;
                uow.Root.Author           = email.AuthorId != 0 ? uow.GetById <Employee>(email.AuthorId) : null;
                try {
                    uow.Save();
                }
                catch (Exception ex) {
                    logger.Debug(string.Format("{1} Ошибка при сохранении. Ошибка: {0}", ex.Message, GetThreadInfo()));
                    throw ex;
                }
                email.StoredEmailId = uow.Root.Id;
                emailsQueue.Add(email);
                logger.Debug("{0} Письмо добавлено в очередь на отправку. Писем в очереди: {1}", GetThreadInfo(), emailsQueue.Count);
                logger.Debug("{0} Закончил работу.", GetThreadInfo());
            }
        }
Esempio n. 22
0
        public void DirectBatchSubscribe_NotifySaveEventTest()
        {
            using (var subscruber = new BatchEventTestSubscruber()) {
                NotifyConfiguration.Instance.BatchSubscribeOnEntity <SimpleEntity>(subscruber.Handler);

                using (var uow = UnitOfWorkFactory.CreateWithNewRoot <SimpleEntity>()) {
                    uow.Save();
                }
                Assert.That(subscruber.calls.Count, Is.EqualTo(1));
            }
        }
Esempio n. 23
0
 public CallTaskDlg()
 {
     this.Build();
     UoWGeneric                 = UnitOfWorkFactory.CreateWithNewRoot <CallTask>();
     TabName                    = "Новая задача";
     Entity.CreationDate        = DateTime.Now;
     Entity.Source              = TaskSource.Handmade;
     Entity.TaskCreator         = employeeRepository.GetEmployeeForCurrentUser(UoW);
     Entity.EndActivePeriod     = DateTime.Now.AddDays(1);
     createTaskButton.Sensitive = false;
     ConfigureDlg();
 }
Esempio n. 24
0
        public SheduleDlg(ushort pointNumber, ushort calendarNumber, DateTime date)
        {
            this.Build();
            UoWGeneric            = UnitOfWorkFactory.CreateWithNewRoot <SheduleWorks>();
            Entity.DateWork       = date;
            Entity.DateCreate     = DateTime.Now;
            Entity.PointNumber    = pointNumber;
            Entity.CalendarNumber = calendarNumber;
            Entity.CreatedBy      = UserRepository.GetCurrentUser(UoW);

            ConfigureDlg();
        }
Esempio n. 25
0
 void ConfigureNewDoc()
 {
     UoWGeneric    = UnitOfWorkFactory.CreateWithNewRoot <CarUnloadDocument>();
     Entity.Author = Repository.EmployeeRepository.GetEmployeeForCurrentUser(UoW);
     if (Entity.Author == null)
     {
         MessageDialogWorks.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать складские документы, так как некого указывать в качестве кладовщика.");
         FailInitialize = true;
         return;
     }
     Entity.Warehouse = StoreDocumentHelper.GetDefaultWarehouse(UoW, WarehousePermissions.CarUnloadEdit);
 }
Esempio n. 26
0
 public ServiceClaimDlg(ServiceClaimType type)
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <ServiceClaim>(new ServiceClaim(type));
     if (type == ServiceClaimType.RegularService)
     {
         EntitySaved += (sender, args) => CreateOrder();
     }
     Entity.ServiceStartDate = DateTime.Today;
     Entity.ServiceStartDate = DateTime.Now.AddDays(1);
     ConfigureDlg();
 }
Esempio n. 27
0
        public OrderDlg(ushort pointNumber, ushort calendarNumber, OrderTypeClass Type, DateTime date, ushort hour)
        {
            this.Build();
            UoWGeneric            = UnitOfWorkFactory.CreateWithNewRoot <WorkOrder>();
            Entity.OrderTypeClass = Type;
            Entity.Date           = date;
            Entity.Hour           = hour;
            Entity.PointNumber    = pointNumber;
            Entity.CalendarNumber = calendarNumber;
            Entity.CreatedBy      = UserRepository.GetCurrentUser(UoW);

            ConfigureDlg();
        }
Esempio n. 28
0
 public ResidueDlg()
 {
     this.Build();
     UoWGeneric    = UnitOfWorkFactory.CreateWithNewRoot <Residue> ();
     Entity.Author = Repository.EmployeeRepository.GetEmployeeForCurrentUser(UoW);
     if (Entity.Author == null)
     {
         MessageDialogWorks.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать складские документы, так как некого указывать в качестве кладовщика.");
         FailInitialize = true;
         return;
     }
     ConfigureDlg();
 }
 public TransferOperationDocumentDlg()
 {
     this.Build();
     UoWGeneric = UnitOfWorkFactory.CreateWithNewRoot <TransferOperationDocument>();
     TabName    = "Новый перенос между точками доставки";
     ConfigureDlg();
     Entity.Author = Entity.ResponsiblePerson = _employeeRepository.GetEmployeeForCurrentUser(UoW);
     if (Entity.Author == null)
     {
         MessageDialogHelper.RunErrorDialog("Ваш пользователь не привязан к действующему сотруднику, вы не можете создавать складские документы, так как некого указывать в качестве кладовщика.");
         FailInitialize = true;
         return;
     }
 }
        public void IBusinessObjectFillUowPropertyTest()
        {
            InitialiseNHibernate(typeof(BusinessObjectTestEntity).Assembly);

            using (var uow = UnitOfWorkFactory.CreateWithNewRoot <BusinessObjectTestEntity>()) {
                uow.Save();
                var savedEntity = uow.Root;
                uow.Session.Evict(savedEntity);

                var loadedEntity = uow.GetById <BusinessObjectTestEntity>(1);
                Assert.That(loadedEntity, Is.Not.EqualTo(savedEntity));
                Assert.That(loadedEntity.UoW, Is.EqualTo(uow));
            }
        }