コード例 #1
0
        public async Task Update(eFormRentableItemPnDbContext dbContext)
        {
            RentableItem rentableItem = await dbContext.RentableItem.FirstOrDefaultAsync(x => x.Id == Id);

            if (rentableItem == null)
            {
                throw new NullReferenceException($"Could not find RentableItem with id {Id}");
            }

            rentableItem.Brand            = Brand;
            rentableItem.ModelName        = ModelName;
            rentableItem.RegistrationDate = RegistrationDate;
            rentableItem.VinNumber        = VinNumber;
            rentableItem.SerialNumber     = SerialNumber;
            rentableItem.PlateNumber      = PlateNumber;
            rentableItem.eFormId          = eFormId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                rentableItem.UpdatedAt       = DateTime.Now;
                rentableItem.UpdatedByUserId = UpdatedByUserId;
                rentableItem.Version        += 1;

                await dbContext.RentableItemsVersion.AddAsync(MapVersion(rentableItem));

                await dbContext.SaveChangesAsync();
            }
        }
コード例 #2
0
        public async Task Update(eFormRentableItemPnDbContext dbContext)
        {
            ContractInspectionItem inspectionItem =
                await dbContext.ContractInspectionItem.FirstOrDefaultAsync(x => x.Id == Id);

            if (inspectionItem == null)
            {
                throw new NullReferenceException($"Could not find inspection item with id: {Id}");
            }

            inspectionItem.SiteId = SiteId;
            inspectionItem.ContractInspectionId = ContractInspectionId;
            inspectionItem.RentableItemId       = RentableItemId;
            inspectionItem.Status    = Status;
            inspectionItem.SDKCaseId = SDKCaseId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                inspectionItem.UpdatedAt       = DateTime.Now;
                inspectionItem.UpdatedByUserId = UpdatedByUserId;
                inspectionItem.Version        += 1;

                await dbContext.ContractInspectionItemVersion.AddAsync(MapVersion(inspectionItem));

                await dbContext.SaveChangesAsync();
            }
        }
コード例 #3
0
        public async Task Update(eFormRentableItemPnDbContext dbContext)
        {
            Contract contract = await dbContext.Contract.FirstOrDefaultAsync(x => x.Id == Id);

            if (contract == null)
            {
                throw new NullReferenceException($"Could not find Contract with id {Id}");
            }
            contract.CustomerId    = CustomerId;
            contract.WorkflowState = contract.WorkflowState;
            contract.ContractNr    = ContractNr;
            contract.ContractStart = ContractStart;
            contract.ContractEnd   = ContractEnd;

            if (dbContext.ChangeTracker.HasChanges())
            {
                contract.UpdatedAt       = DateTime.Now;
                contract.UpdatedByUserId = UpdatedByUserId;
                contract.Version        += 1;

                await dbContext.ContractVersion.AddAsync(MapVersion(contract));

                await dbContext.SaveChangesAsync();
            }
        }
コード例 #4
0
 public MailService(IImportsService importsService,
                    eFormRentableItemPnDbContext dbContext,
                    CustomersPnDbAnySql customerDbContext)
 {
     _importsService    = importsService;
     _dbContext         = dbContext;
     _customerDbContext = customerDbContext;
 }
コード例 #5
0
        private void GetContext(string connectionStr)
        {
            eFormRentableItemPnDbContextFactory contextFactory = new eFormRentableItemPnDbContextFactory();

            DbContext = contextFactory.CreateDbContext(new[] { connectionStr });

            DbContext.Database.Migrate();
            DbContext.Database.EnsureCreated();
        }
 public RentableItemsService(eFormRentableItemPnDbContext dbContext,
                             ILogger <RentableItemsService> logger,
                             IEFormCoreService coreHelper,
                             IRentableItemsLocalizationService rentableItemLocalizationService)
 {
     _dbContext  = dbContext;
     _logger     = logger;
     _coreHelper = coreHelper;
     _rentableItemsLocalizationService = rentableItemLocalizationService;
 }
コード例 #7
0
 public ImportsService(IEFormCoreService coreHelper,
                       CustomersPnDbAnySql customerDbContext,
                       ILogger <ContractRentableItemService> logger,
                       eFormRentableItemPnDbContext dbContext)
 {
     _coreHelper        = coreHelper;
     _customerDbContext = customerDbContext;
     _dbContext         = dbContext;
     _logger            = logger;
 }
コード例 #8
0
        //public RentableItemsPnDbAnySql db;

        public void GetContext(string connectionStr)
        {
            DbContextOptionsBuilder <eFormRentableItemPnDbContext> dbContextOptionsBuilder = new DbContextOptionsBuilder <eFormRentableItemPnDbContext>();

            dbContextOptionsBuilder.UseMySql(connectionStr);
            DbContext = new eFormRentableItemPnDbContext(dbContextOptionsBuilder.Options);

            DbContext.Database.Migrate();
            DbContext.Database.EnsureCreated();
        }
 public ContractRentableItemService(eFormRentableItemPnDbContext dbContext,
                                    ILogger <ContractRentableItemService> logger,
                                    IEFormCoreService coreHelper,
                                    IRentableItemsLocalizationService rentableItemLocalizationService,
                                    CustomersPnDbAnySql customerDbContext
                                    )
 {
     _dbContext  = dbContext;
     _logger     = logger;
     _coreHelper = coreHelper;
     _rentableItemsLocalizationService = rentableItemLocalizationService;
     _customerDbContext = customerDbContext;
 }
コード例 #10
0
        public RentableItemsSettingsService(ILogger <RentableItemsSettingsService> logger,
                                            eFormRentableItemPnDbContext dbContext,
                                            IEFormCoreService coreHelper,
                                            IPluginDbOptions <RentableItemBaseSettings> options,
                                            IRentableItemsLocalizationService rentableItemsLocalizationService,
                                            IHttpContextAccessor httpContextAccessor)

        {
            _logger              = logger;
            _dbContext           = dbContext;
            _coreHelper          = coreHelper;
            _options             = options;
            _httpContextAccessor = httpContextAccessor;
            _rentablteItemsLocalizationsService = rentableItemsLocalizationService;
        }
コード例 #11
0
        public async Task Create(eFormRentableItemPnDbContext dbContext)
        {
            CreatedAt     = DateTime.Now;
            UpdatedAt     = DateTime.Now;
            Version       = 1;
            WorkflowState = Constants.WorkflowStates.Created;

            await dbContext.Contract.AddAsync(this);

            await dbContext.SaveChangesAsync();

            await dbContext.ContractVersion.AddAsync(MapVersion(this));

            await dbContext.SaveChangesAsync();
        }
コード例 #12
0
        public static void SeedData(eFormRentableItemPnDbContext dbContext)
        {
            var seedData          = new RentableItemsConfigurationSeedData();
            var configurationList = seedData.Data;

            foreach (var configurationItem in configurationList)
            {
                if (!dbContext.PluginConfigurationValues.Any(x => x.Name == configurationItem.Name))
                {
                    var newConfigValue = new PluginConfigurationValue
                    {
                        Name            = configurationItem.Name,
                        Value           = configurationItem.Value,
                        CreatedAt       = DateTime.UtcNow,
                        Version         = 1,
                        WorkflowState   = Constants.WorkflowStates.Created,
                        CreatedByUserId = 1
                    };
                    dbContext.PluginConfigurationValues.Add(newConfigValue);
                    dbContext.SaveChanges();
                }
            }

            // Seed plugin permissions
            var newPermissions = RentableItemsPermissionsSeedData.Data
                                 .Where(p => dbContext.PluginPermissions.All(x => x.ClaimName != p.ClaimName))
                                 .Select(p => new PluginPermission
            {
                PermissionName  = p.PermissionName,
                ClaimName       = p.ClaimName,
                CreatedAt       = DateTime.UtcNow,
                Version         = 1,
                WorkflowState   = Constants.WorkflowStates.Created,
                CreatedByUserId = 1
            }
                                         );

            dbContext.PluginPermissions.AddRange(newPermissions);

            dbContext.SaveChanges();
        }
コード例 #13
0
        public async Task Delete(eFormRentableItemPnDbContext dbContext)
        {
            ContractInspection contractInspection =
                await dbContext.ContractInspection.FirstOrDefaultAsync(x => x.Id == Id);

            if (contractInspection == null)
            {
                throw new NullReferenceException($"Could not find Contract Inspection with id {Id}");
            }

            contractInspection.WorkflowState = Constants.WorkflowStates.Removed;
            if (dbContext.ChangeTracker.HasChanges())
            {
                contractInspection.UpdatedAt       = DateTime.Now;
                contractInspection.UpdatedByUserId = UpdatedByUserId;
                contractInspection.Version        += 1;

                await dbContext.ContractInspectionVersion.AddAsync(MapVersion(contractInspection));

                await dbContext.SaveChangesAsync();
            }
        }
コード例 #14
0
        public async Task Delete(eFormRentableItemPnDbContext dbContext)
        {
            RentableItem rentableItem = await dbContext.RentableItem.FirstOrDefaultAsync(x => x.Id == Id);

            if (rentableItem == null)
            {
                throw new NullReferenceException($"Could not find RentableItem with id {Id}");
            }

            rentableItem.WorkflowState = Constants.WorkflowStates.Removed;

            if (dbContext.ChangeTracker.HasChanges())
            {
                rentableItem.UpdatedAt       = DateTime.Now;
                rentableItem.UpdatedByUserId = UpdatedByUserId;
                rentableItem.Version        += 1;

                await dbContext.RentableItemsVersion.AddAsync(MapVersion(rentableItem));

                await dbContext.SaveChangesAsync();
            }
        }
コード例 #15
0
        public async Task Update(eFormRentableItemPnDbContext dbContext)
        {
            ContractRentableItem contractRentableItem =
                await dbContext.ContractRentableItem.FirstOrDefaultAsync(x => x.Id == Id);

            if (contractRentableItem == null)
            {
                throw new NullReferenceException($"Could not find ContractRentableItem with Id:{Id}");
            }

            contractRentableItem.ContractId     = ContractId;
            contractRentableItem.RentableItemId = RentableItemId;

            if (dbContext.ChangeTracker.HasChanges())
            {
                contractRentableItem.UpdatedAt       = DateTime.Now;
                contractRentableItem.UpdatedByUserId = UpdatedByUserId;
                contractRentableItem.Version        += 1;

                await dbContext.ContractRentableItemVersion.AddAsync(MapVersion(contractRentableItem));

                await dbContext.SaveChangesAsync();
            }
        }
 public eFormProcessedHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper)
 {
     _dbContext = dbContextHelper.GetDbContext();
     _sdkCore   = sdkCore;
 }
 public ContractInspectionCreateHandler(Core core, eFormRentableItemPnDbContext context)
 {
     _core      = core;
     _dbContext = context;
 }
コード例 #18
0
 public EformCompletedHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper)
 {
     _dbContext = dbContextHelper.GetDbContext();
     _sdkCore   = sdkCore;
 }
コード例 #19
0
        public bool Start(string sdkConnectionString, string serviceLocation)
        {
            Console.WriteLine("[INF] RentableItemsPlugin start called");
            try
            {
                string dbNameSection;
                string dbPrefix;
                if (sdkConnectionString.ToLower().Contains("convert zero datetime"))
                {
                    dbNameSection = Regex.Match(sdkConnectionString, @"(Database=\w*;)").Groups[0].Value;
                    dbPrefix      = Regex.Match(sdkConnectionString, @"Database=(\d*)_").Groups[1].Value;
                }
                else
                {
                    dbNameSection = Regex.Match(sdkConnectionString, @"(Initial Catalog=\w*;)").Groups[0].Value;
                    dbPrefix      = Regex.Match(sdkConnectionString, @"Initial Catalog=(\d*)_").Groups[1].Value;
                }


                string pluginDbName     = $"Initial Catalog={dbPrefix}_eform-angular-rentableitem-plugin;";
                string connectionString = sdkConnectionString.Replace(dbNameSection, pluginDbName);


                if (!_coreAvailable && !_coreStatChanging)
                {
                    _serviceLocation  = serviceLocation;
                    _coreStatChanging = true;

                    if (string.IsNullOrEmpty(_serviceLocation))
                    {
                        throw new ArgumentException("serviceLocation is not allowed to be null or empty");
                    }

                    if (string.IsNullOrEmpty(connectionString))
                    {
                        throw new ArgumentException("serverConnectionString is not allowed to be null or empty");
                    }

                    eFormRentableItemPnDbContextFactory contextFactory = new eFormRentableItemPnDbContextFactory();

                    _dbContext = contextFactory.CreateDbContext(new[] { connectionString });
                    _dbContext.Database.Migrate();

                    _coreAvailable    = true;
                    _coreStatChanging = false;
                    _dbContextHelper  = new DbContextHelper(connectionString);

                    startSdkCoreSqlOnly(sdkConnectionString);

                    _container = new WindsorContainer();
                    _container.Register(Component.For <DbContextHelper>().Instance(_dbContextHelper));
                    _container.Register(Component.For <eFormCore.Core>().Instance(_sdkCore));
                    _container.Install(
                        new RebusHandlerInstaller()
                        , new RebusInstaller(connectionString, _maxParallelism, _numberOfWorkers)
                        );


                    _bus = _container.Resolve <IBus>();
                }
                Console.WriteLine("RentableItemsPlugin started");
                return(true);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("Start failed " + ex.Message);
                throw ex;
            }
        }