示例#1
0
 public SegmentService(TrashInspectionPnDbContext dbContext,
                       IEFormCoreService coreHelper,
                       ITrashInspectionLocalizationService trashInspectionLocalizationService)
 {
     _dbContext  = dbContext;
     _coreHelper = coreHelper;
     _trashInspectionLocalizationService = trashInspectionLocalizationService;
 }
        private void GetContext(string connectionStr)
        {
            var contextFactory = new TrashInspectionPnContextFactory();

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

            DbContext.Database.Migrate();
            DbContext.Database.EnsureCreated();
        }
示例#3
0
 public FractionService(TrashInspectionPnDbContext dbContext,
                        IEFormCoreService coreHelper,
                        IUserService userService,
                        ITrashInspectionLocalizationService trashInspectionLocalizationService)
 {
     _dbContext   = dbContext;
     _coreHelper  = coreHelper;
     _userService = userService;
     _trashInspectionLocalizationService = trashInspectionLocalizationService;
 }
示例#4
0
 public TrashInspectionPnSettingsService(
     ILogger <TrashInspectionPnSettingsService> logger,
     ITrashInspectionLocalizationService trashInspectionLocalizationService,
     TrashInspectionPnDbContext dbContext,
     IPluginDbOptions <TrashInspectionBaseSettings> options,
     IUserService userService)
 {
     _logger      = logger;
     _dbContext   = dbContext;
     _options     = options;
     _userService = userService;
     _trashInspectionLocalizationService = trashInspectionLocalizationService;
 }
 public TrashInspectionService(ILogger <TrashInspectionService> logger,
                               TrashInspectionPnDbContext dbContext,
                               IEFormCoreService coreHelper,
                               IUserService userService,
                               ITrashInspectionLocalizationService trashInspectionLocalizationService,
                               IPluginDbOptions <TrashInspectionBaseSettings> options,
                               IRebusService rebusService)
 {
     _logger     = logger;
     _dbContext  = dbContext;
     _coreHelper = coreHelper;
     _trashInspectionLocalizationService = trashInspectionLocalizationService;
     _userService = userService;
     _bus         = rebusService.GetBus();
     _options     = options;
 }
示例#6
0
        public async Task Create(TrashInspectionPnDbContext dbContext)
        {
            CreatedAt     = DateTime.UtcNow;
            UpdatedAt     = DateTime.UtcNow;
            Version       = 1;
            WorkflowState = eForm.Infrastructure.Constants.Constants.WorkflowStates.Created;

            await dbContext.AddAsync(this).ConfigureAwait(false);

            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            var res = MapVersion(this);

            if (res != null)
            {
                await dbContext.AddAsync(res).ConfigureAwait(false);

                await dbContext.SaveChangesAsync().ConfigureAwait(false);
            }
        }
示例#7
0
        public static void SeedData(TrashInspectionPnDbContext dbContext)
        {
            var seedData          = new TrashInspectionConfigurationSeedData();
            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 = TrashInspectionPermissionsSeedData.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();
        }
示例#8
0
        private async Task UpdateInternal(TrashInspectionPnDbContext dbContext, string state = null)
        {
            if (state != null)
            {
                WorkflowState = state;
            }

            if (dbContext.ChangeTracker.HasChanges())
            {
                Version  += 1;
                UpdatedAt = DateTime.UtcNow;

                await dbContext.SaveChangesAsync();

                var res = MapVersion(this);
                if (res != null)
                {
                    await dbContext.AddAsync(res).ConfigureAwait(false);

                    await dbContext.SaveChangesAsync().ConfigureAwait(false);
                }
            }
        }
示例#9
0
 public EformParsedByServerHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper)
 {
     _dbContext = dbContextHelper.GetDbContext();
     _sdkCore   = sdkCore;
 }
 public TrashInspectionCaseCreatedHandler(Core core, DbContextHelper dbContextHelper)
 {
     _core      = core;
     _dbContext = dbContextHelper.GetDbContext();
 }
示例#11
0
 public TrashInspectionReceivedHandler(Core core, DbContextHelper dbContextHelper, IBus bus)
 {
     _core      = core;
     _dbContext = dbContextHelper.GetDbContext();
     _bus       = bus;
 }
 public eFormRetrievedHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper)
 {
     _dbContext = dbContextHelper.GetDbContext();
     _sdkCore   = sdkCore;
 }
示例#13
0
 public async Task Delete(TrashInspectionPnDbContext dbContext)
 {
     await UpdateInternal(dbContext, eForm.Infrastructure.Constants.Constants.WorkflowStates.Removed);
 }
示例#14
0
 public async Task Update(TrashInspectionPnDbContext dbContext)
 {
     await UpdateInternal(dbContext);
 }
        public bool Start(string sdkConnectionString, string serviceLocation)
        {
            Console.WriteLine("[INF] TrashInspectionPlugin 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-trashinspection-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");
                    }

                    TrashInspectionPnContextFactory contextFactory = new TrashInspectionPnContextFactory();

                    _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("TrashInspectionPlugin started");
                return(true);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("Start failed " + ex.Message);
                throw ex;
            }
        }
 public EformParsingErrorHandler(DbContextHelper dbContextHelper)
 {
     _dbContext = dbContextHelper.GetDbContext();
 }
 public TrashInspectionDeleteHandler(Core core, DbContextHelper dbContextHelper)
 {
     _core      = core;
     _dbContext = dbContextHelper.GetDbContext();
 }