public async Task Update(InstallationCheckingPnDbContext dbContext) { Meter meter = await dbContext.Meters.FirstOrDefaultAsync(x => x.Id == Id); if (meter == null) { throw new NullReferenceException($"Could not find item with id: {Id}"); } meter.Num = Num; meter.QR = QR; meter.RoomType = RoomType; meter.Floor = Floor; meter.RoomName = RoomName; meter.InstallationId = InstallationId; if (dbContext.ChangeTracker.HasChanges()) { meter.Version += 1; meter.UpdatedAt = DateTime.UtcNow; meter.UpdatedByUserId = UpdatedByUserId; dbContext.MeterVersions.Add(MapVersion(meter)); await dbContext.SaveChangesAsync(); } }
private void GetContext(string connectionStr) { InstallationCheckingPnContextFactory contextFactory = new InstallationCheckingPnContextFactory(); DbContext = contextFactory.CreateDbContext(new[] { connectionStr }); DbContext.Database.Migrate(); DbContext.Database.EnsureCreated(); }
public InstallationCheckingPnSettingsService(ILogger <InstallationCheckingPnSettingsService> logger, IInstallationCheckingLocalizationService localizationService, InstallationCheckingPnDbContext dbContext, IPluginDbOptions <InstallationCheckingBaseSettings> options, IHttpContextAccessor httpContextAccessor) { _logger = logger; _dbContext = dbContext; _options = options; _httpContextAccessor = httpContextAccessor; _localizationService = localizationService; }
public async Task Create(InstallationCheckingPnDbContext dbContext) { CreatedAt = DateTime.UtcNow; UpdatedAt = DateTime.UtcNow; Version = 1; WorkflowState = Constants.WorkflowStates.Created; dbContext.Meters.Add(this); await dbContext.SaveChangesAsync(); dbContext.MeterVersions.Add(MapVersion(this)); await dbContext.SaveChangesAsync(); }
public InstallationsService( InstallationCheckingPnDbContext installationCheckingContext, CustomersPnDbAnySql customersContext, IPluginDbOptions <InstallationCheckingBaseSettings> options, IInstallationCheckingLocalizationService localizationService, IUserService userService, IEFormCoreService coreHelper ) { _installationCheckingContext = installationCheckingContext; _customersContext = customersContext; _options = options; _localizationService = localizationService; _userService = userService; _coreHelper = coreHelper; }
public async Task Update(InstallationCheckingPnDbContext dbContext) { Installation installation = await dbContext.Installations.FirstOrDefaultAsync(x => x.Id == Id); if (installation == null) { throw new NullReferenceException($"Could not find item with id: {Id}"); } installation.CadastralNumber = CadastralNumber; installation.CadastralType = CadastralType; installation.PropertyNumber = PropertyNumber; installation.ApartmentNumber = ApartmentNumber; installation.LivingFloorsNumber = LivingFloorsNumber; installation.YearBuilt = YearBuilt; installation.CompanyName = CompanyName; installation.CompanyAddress = CompanyAddress; installation.CompanyAddress2 = CompanyAddress2; installation.CityName = CityName; installation.CountryCode = CountryCode; installation.ZipCode = ZipCode; installation.Type = Type; installation.State = State; installation.DateInstall = DateInstall; installation.DateRemove = DateRemove; installation.DateActRemove = DateActRemove; installation.InstallationEmployeeId = InstallationEmployeeId; installation.RemovalEmployeeId = RemovalEmployeeId; installation.CustomerId = CustomerId; installation.InstallationSdkCaseId = InstallationSdkCaseId; installation.RemovalSdkCaseId = RemovalSdkCaseId; installation.WorkflowState = WorkflowState; installation.UpdatedAt = UpdatedAt; installation.UpdatedByUserId = UpdatedByUserId; installation.Meters = Meters; if (dbContext.ChangeTracker.HasChanges()) { installation.UpdatedAt = DateTime.UtcNow; installation.Version += 1; dbContext.InstallationVersions.Add(MapInstallationVersion(installation)); await dbContext.SaveChangesAsync(); } }
public async Task Delete(InstallationCheckingPnDbContext dbContext) { Installation installation = await dbContext.Installations.FirstOrDefaultAsync(x => x.Id == Id); if (installation == null) { throw new NullReferenceException($"Could not find Installation with id: {Id}"); } installation.WorkflowState = Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { installation.UpdatedAt = DateTime.UtcNow; installation.Version += 1; dbContext.InstallationVersions.Add(MapInstallationVersion(installation)); await dbContext.SaveChangesAsync(); } }
public async Task Delete(InstallationCheckingPnDbContext dbContext) { Meter meter = await dbContext.Meters.FirstOrDefaultAsync(x => x.Id == Id); if (meter == null) { throw new NullReferenceException($"Could not find item with id: {Id}"); } meter.WorkflowState = Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { meter.Version += 1; meter.UpdatedAt = DateTime.UtcNow; meter.UpdatedByUserId = UpdatedByUserId; dbContext.MeterVersions.Add(MapVersion(meter)); await dbContext.SaveChangesAsync(); } }
public static void SeedData(InstallationCheckingPnDbContext dbContext) { var seedData = new InstallationCheckingConfigurationSeedData(); 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); } } // Seed plugin permissions var newPermissions = InstallationCheckingPermissionsSeedData.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(); }
public Job(InstallationCheckingPnDbContext dbContext) { _dbContext = dbContext; }
public EFormCompletedHandler(eFormCore.Core sdkCore, InstallationCheckingPnDbContext dbContext) { _dbContext = dbContext; _sdkCore = sdkCore; }
public bool Start(string sdkConnectionString, string serviceLocation) { Console.WriteLine("ServiceInstallationCheckingPlugin 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; } var pluginDbName = $"Initial Catalog={dbPrefix}_eform-angular-installationchecking-plugin;"; var 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"); } InstallationCheckingPnContextFactory contextFactory = new InstallationCheckingPnContextFactory(); _dbContext = contextFactory.CreateDbContext(new[] { connectionString }); _dbContext.Database.Migrate(); _coreAvailable = true; _coreStatChanging = false; StartSdkCoreSqlOnly(sdkConnectionString); _container = new WindsorContainer(); _container.Register(Component.For <IWindsorContainer>().Instance(_container)); _container.Register(Component.For <InstallationCheckingPnDbContext>().Instance(_dbContext)); _container.Register(Component.For <eFormCore.Core>().Instance(_sdkCore)); _container.Install( new RebusHandlerInstaller() , new RebusInstaller(connectionString, MaxParallelism, NumberOfWorkers) ); _container.Register(Component.For <Job>()); _bus = _container.Resolve <IBus>(); ConfigureScheduler(); } Console.WriteLine("ServiceInstallationCheckingPlugin started"); return(true); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Start failed " + ex.Message); throw; } }