public IList <GeographicGroup> GeographicGroupsWithCoordinatesExceptEast(
     IUnitOfWork uow, IGeographicGroupParametersProvider geographicGroupParametersProvider)
 {
     return(uow.Session.QueryOver <GeographicGroup>()
            .Where(gg => gg.BaseLatitude != null && gg.BaseLongitude != null)
            .And(gg => gg.Id != geographicGroupParametersProvider.EastGeographicGroupId)
            .List());
 }
 public Stage2OrganizationProvider(
     IOrganizationParametersProvider organizationParametersProvider,
     IOrderParametersProvider orderParametersProvider,
     IGeographicGroupParametersProvider geographicGroupParametersProvider)
 {
     _organizationParametersProvider = organizationParametersProvider
                                       ?? throw new ArgumentNullException(nameof(organizationParametersProvider));
     _orderParametersProvider = orderParametersProvider
                                ?? throw new ArgumentNullException(nameof(orderParametersProvider));
     _geographicGroupParametersProvider = geographicGroupParametersProvider
                                          ?? throw new ArgumentNullException(nameof(geographicGroupParametersProvider));
 }
Exemple #3
0
 public Stage2OrganizationProvider(
     IOrganizationParametersProvider organizationParametersProvider,
     IOrderParametersProvider orderParametersProvider,
     IGeographicGroupParametersProvider geographicGroupParametersProvider)
 {
     _organizationParametersProvider =
         organizationParametersProvider ?? throw new ArgumentNullException(nameof(organizationParametersProvider));
     _orderParametersProvider = orderParametersProvider ?? throw new ArgumentNullException(nameof(orderParametersProvider));
     if (geographicGroupParametersProvider == null)
     {
         throw new ArgumentNullException(nameof(geographicGroupParametersProvider));
     }
     _northOrganizationGeoGroupsIds = new[]
     { geographicGroupParametersProvider.NorthGeographicGroupId, geographicGroupParametersProvider.EastGeographicGroupId };
 }
Exemple #4
0
        public CarViewModel(
            IEntityUoWBuilder uowBuilder,
            IUnitOfWorkFactory unitOfWorkFactory,
            ICommonServices commonServices,
            IEmployeeJournalFactory employeeJournalFactory,
            IAttachmentsViewModelFactory attachmentsViewModelFactory,
            ICarModelJournalFactory carModelJournalFactory,
            ICarVersionsViewModelFactory carVersionsViewModelFactory,
            IRouteListsWageController routeListsWageController,
            IGeographicGroupParametersProvider geographicGroupParametersProvider,
            INavigationManager navigationManager)
            : base(uowBuilder, unitOfWorkFactory, commonServices, navigationManager)
        {
            if (navigationManager == null)
            {
                throw new ArgumentNullException(nameof(navigationManager));
            }
            _routeListsWageController = routeListsWageController ?? throw new ArgumentNullException(nameof(routeListsWageController));
            CarModelJournalFactory    = carModelJournalFactory ?? throw new ArgumentNullException(nameof(carModelJournalFactory));

            TabName = "Автомобиль";

            EmployeeJournalFactory = employeeJournalFactory;
            AttachmentsViewModel   = attachmentsViewModelFactory.CreateNewAttachmentsViewModel(Entity.ObservableAttachments);
            CarVersionsViewModel   = carVersionsViewModelFactory?.CreateCarVersionsViewModel(Entity)
                                     ?? throw new ArgumentNullException(nameof(carVersionsViewModelFactory));

            CanChangeBottlesFromAddress = commonServices.PermissionService.ValidateUserPresetPermission(
                _canChangeBottlesFromAddressPermissionName,
                commonServices.UserService.CurrentUserId
                );
            EastGeographicGroupId =
                (geographicGroupParametersProvider ?? throw new ArgumentNullException(nameof(geographicGroupParametersProvider)))
                .EastGeographicGroupId;

            CanEditCarModel       = commonServices.CurrentPermissionService.ValidateEntityPermission(typeof(CarModel)).CanUpdate;
            CanChangeCarModel     = Entity.Id == 0 || commonServices.CurrentPermissionService.ValidatePresetPermission("can_change_car_model");
            CanEditFuelCardNumber = commonServices.CurrentPermissionService.ValidatePresetPermission("can_change_fuel_card_number");

            Entity.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == nameof(Entity.Driver) && Entity.Driver != null)
                {
                    OnDriverChanged();
                }
            };
            OnDriverChanged();
        }
        public AtWorksDlg(
            IDefaultDeliveryDayScheduleSettings defaultDeliveryDayScheduleSettings,
            IEmployeeJournalFactory employeeJournalFactory,
            DriverApiUserRegisterEndpoint driverApiUserRegisterEndpoint,
            IGeographicGroupParametersProvider geographicGroupParametersProvider)
        {
            if (defaultDeliveryDayScheduleSettings == null)
            {
                throw new ArgumentNullException(nameof(defaultDeliveryDayScheduleSettings));
            }

            _employeeJournalFactory            = employeeJournalFactory ?? throw new ArgumentNullException(nameof(employeeJournalFactory));
            _driverApiRegistrationEndpoint     = driverApiUserRegisterEndpoint ?? throw new ArgumentNullException(nameof(driverApiUserRegisterEndpoint));
            _geographicGroupParametersProvider = geographicGroupParametersProvider ?? throw new ArgumentNullException(nameof(geographicGroupParametersProvider));
            Build();

            var geographicGroups =
                _geographicGroupRepository.GeographicGroupsWithCoordinatesExceptEast(UoW, _geographicGroupParametersProvider);
            var colorWhite    = new Color(0xff, 0xff, 0xff);
            var colorLightRed = new Color(0xff, 0x66, 0x66);

            ytreeviewAtWorkDrivers.ColumnsConfig = FluentColumnsConfig <AtWorkDriver> .Create()
                                                   .AddColumn("Приоритет")
                                                   .AddNumericRenderer(x => x.PriorityAtDay)
                                                   .Editing(new Gtk.Adjustment(6, 1, 10, 1, 1, 1))
                                                   .AddColumn("Статус")
                                                   .AddTextRenderer(x => x.Status.GetEnumTitle())
                                                   .AddColumn("Причина")
                                                   .AddTextRenderer(x => x.Reason)
                                                   .AddSetter((cell, driver) => cell.Editable = driver.Status == AtWorkDriver.DriverStatus.NotWorking)
                                                   .AddColumn("Водитель")
                                                   .AddTextRenderer(x => x.Employee.ShortName)
                                                   .AddColumn("Скор.")
                                                   .AddTextRenderer(x => x.Employee.DriverSpeed.ToString("P0"))
                                                   .AddColumn("График работы")
                                                   .AddComboRenderer(x => x.DaySchedule)
                                                   .SetDisplayFunc(x => x.Name)
                                                   .FillItems(UoW.GetAll <DeliveryDaySchedule>().ToList())
                                                   .Editing()
                                                   .AddColumn("Оконч. работы")
                                                   .AddTextRenderer(x => x.EndOfDayText).Editable()
                                                   .AddColumn("Экспедитор")
                                                   .AddComboRenderer(x => x.WithForwarder)
                                                   .SetDisplayFunc(x => x.Employee.ShortName).Editing().Tag(Columns.Forwarder)
                                                   .AddColumn("Автомобиль")
                                                   .AddPixbufRenderer(x => x.Car != null && x.Car.GetActiveCarVersionOnDate(x.Date).CarOwnType == CarOwnType.Company ? vodovozCarIcon : null)
                                                   .AddTextRenderer(x => x.Car != null ? x.Car.RegistrationNumber : "нет")
                                                   .AddColumn("База")
                                                   .AddComboRenderer(x => x.GeographicGroup)
                                                   .SetDisplayFunc(x => x.Name)
                                                   .FillItems(geographicGroups)
                                                   .AddSetter(
                (c, n) => {
                c.Editable      = true;
                c.BackgroundGdk = n.GeographicGroup == null
                                                                ? colorLightRed
                                                                : colorWhite;
            }
                )
                                                   .AddColumn("Грузоп.")
                                                   .AddTextRenderer(x => x.Car != null ? x.Car.CarModel.MaxWeight.ToString("D") : null)
                                                   .AddColumn("Районы доставки")
                                                   .AddTextRenderer(x => string.Join(", ", x.DistrictsPriorities.Select(d => d.District.DistrictName)))
                                                   .AddColumn("")
                                                   .AddColumn("Комментарий")
                                                   .AddTextRenderer(x => x.Comment)
                                                   .Editable(true)
                                                   .RowCells().AddSetter <CellRendererText>((c, n) => c.Foreground = n.Status == AtWorkDriver.DriverStatus.NotWorking? "gray": "black")
                                                   .Finish();

            ytreeviewAtWorkDrivers.Selection.Mode     = Gtk.SelectionMode.Multiple;
            ytreeviewAtWorkDrivers.Selection.Changed += YtreeviewDrivers_Selection_Changed;

            ytreeviewOnDayForwarders.ColumnsConfig = FluentColumnsConfig <AtWorkForwarder> .Create()
                                                     .AddColumn("Экспедитор").AddTextRenderer(x => x.Employee.ShortName)
                                                     .AddColumn("Едет с водителем").AddTextRenderer(x => RenderForwaderWithDriver(x))
                                                     .Finish();

            ytreeviewOnDayForwarders.Selection.Mode     = Gtk.SelectionMode.Multiple;
            ytreeviewOnDayForwarders.Selection.Changed += YtreeviewForwarders_Selection_Changed;

            ydateAtWorks.Date = DateTime.Today;

            int currentUserId = ServicesConfig.CommonServices.UserService.CurrentUserId;

            canReturnDriver = ServicesConfig.CommonServices.PermissionService.ValidateUserPresetPermission("can_return_driver_to_work", currentUserId);

            this.defaultDeliveryDaySchedule =
                UoW.GetById <DeliveryDaySchedule>(defaultDeliveryDayScheduleSettings.GetDefaultDeliveryDayScheduleId());

            _forwarderFilter = new EmployeeFilterViewModel();
            _forwarderFilter.SetAndRefilterAtOnce(
                x => x.RestrictCategory = EmployeeCategory.forwarder,
                x => x.CanChangeStatus  = true,
                x => x.Status           = EmployeeStatus.IsWorking);
        }