Example #1
0
 public UploadedDataService(ItemsGroupPlanningPnDbContext dbContext,
                            IItemsPlanningLocalizationService itemsPlanningLocalizationService,
                            IHttpContextAccessor httpContextAccessor, IEFormCoreService core)
 {
     _dbContext = dbContext;
     _itemsPlanningLocalizationService = itemsPlanningLocalizationService;
     _httpContextAccessor = httpContextAccessor;
     _core = core;
 }
Example #2
0
        private void GetContext(string connectionStr)
        {
            ItemsGroupPlanningPnContextFactory contextFactory = new ItemsGroupPlanningPnContextFactory();

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

            DbContext.Database.Migrate();
            DbContext.Database.EnsureCreated();
        }
Example #3
0
 public ItemsListService(
     ItemsGroupPlanningPnDbContext dbContext,
     IItemsPlanningLocalizationService itemsPlanningLocalizationService,
     IUserService userService,
     IEFormCoreService coreHelper)
 {
     _dbContext = dbContext;
     _itemsPlanningLocalizationService = itemsPlanningLocalizationService;
     _coreHelper  = coreHelper;
     _userService = userService;
 }
 public ItemsPlanningPnSettingsService(ILogger <ItemsPlanningPnSettingsService> logger,
                                       IItemsPlanningLocalizationService itemsPlanningLocalizationService,
                                       ItemsGroupPlanningPnDbContext dbContext,
                                       IPluginDbOptions <ItemsPlanningBaseSettings> options,
                                       IHttpContextAccessor httpContextAccessor)
 {
     _logger              = logger;
     _dbContext           = dbContext;
     _options             = options;
     _httpContextAccessor = httpContextAccessor;
     _itemsPlanningLocalizationService = itemsPlanningLocalizationService;
 }
 // ReSharper disable once SuggestBaseTypeForParameter
 public ItemsPlanningReportService(IItemsPlanningLocalizationService itemsPlanningLocalizationService,
                                   IUserService userService,
                                   ILogger <ItemsPlanningReportService> logger, IExcelService excelService, ItemsGroupPlanningPnDbContext dbContext,
                                   IEFormCoreService coreHelper)
 {
     _itemsPlanningLocalizationService = itemsPlanningLocalizationService;
     _logger       = logger;
     _userService  = userService;
     _excelService = excelService;
     _dbContext    = dbContext;
     _coreHelper   = coreHelper;
 }
Example #6
0
 public ItemListCaseService(
     ItemsGroupPlanningPnDbContext dbContext,
     IUserService userService,
     IItemsPlanningLocalizationService itemsPlanningLocalizationService,
     IExcelService excelService,
     IEFormCoreService core,
     IPluginDbOptions <ItemsPlanningBaseSettings> options)
 {
     _dbContext = dbContext;
     _itemsPlanningLocalizationService = itemsPlanningLocalizationService;
     _core         = core;
     _userService  = userService;
     _excelService = excelService;
     _options      = options;
 }
 public ItemListCaseService(
     ItemsGroupPlanningPnDbContext dbContext,
     IUserService userService,
     IItemsPlanningLocalizationService itemsPlanningLocalizationService,
     IExcelService excelService,
     IHttpContextAccessor httpContextAccessor, IEFormCoreService core,
     IRebusService rebusService)
 {
     _dbContext = dbContext;
     _itemsPlanningLocalizationService = itemsPlanningLocalizationService;
     _httpContextAccessor = httpContextAccessor;
     _core         = core;
     _userService  = userService;
     _excelService = excelService;
     _rebusService = rebusService;
     _bus          = rebusService.GetBus();
 }
Example #8
0
        public static void SeedData(ItemsGroupPlanningPnDbContext dbContext)
        {
            var seedData          = new ItemsPlanningConfigurationSeedData();
            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,
                        UpdatedAt       = DateTime.UtcNow,
                        Version         = 1,
                        WorkflowState   = Constants.WorkflowStates.Created,
                        CreatedByUserId = 1
                    };
                    dbContext.PluginConfigurationValues.Add(newConfigValue);
                    dbContext.SaveChanges();
                }
            }

            // Seed plugin permissions
            var newPermissions = ItemsGroupPlanningPermissionsSeedData.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();
        }
Example #9
0
        public async Task Create(ItemsGroupPlanningPnDbContext dbContext)
        {
            CreatedAt     = DateTime.UtcNow;
            UpdatedAt     = DateTime.UtcNow;
            Version       = 1;
            WorkflowState = Constants.WorkflowStates.Created;

            await dbContext.AddAsync(this);

            await dbContext.SaveChangesAsync();

            var res = MapVersion(this);

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

                await dbContext.SaveChangesAsync();
            }
        }
Example #10
0
        private async Task UpdateInternal(ItemsGroupPlanningPnDbContext 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);

                    await dbContext.SaveChangesAsync();
                }
            }
        }
Example #11
0
 public ItemCaseCreateHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper)
 {
     _sdkCore   = sdkCore;
     _dbContext = dbContextHelper.GetDbContext();
 }
Example #12
0
 public SearchListJob(DbContextHelper dbContextHelper, IBus bus)
 {
     _dbContext = dbContextHelper.GetDbContext();
     _bus       = bus;
 }
 public eFormCaseUpdatedHandler(eFormCore.Core sdkCore, ItemsGroupPlanningPnDbContext dbContext)
 {
     _dbContext = dbContext;
     _sdkCore   = sdkCore;
 }
Example #14
0
 public async Task Delete(ItemsGroupPlanningPnDbContext dbContext)
 {
     await UpdateInternal(dbContext, Constants.WorkflowStates.Removed);
 }
Example #15
0
 public async Task Update(ItemsGroupPlanningPnDbContext dbContext)
 {
     await UpdateInternal(dbContext);
 }
 public ScheduledItemExecutedHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper, IBus bus)
 {
     _sdkCore   = sdkCore;
     _dbContext = dbContextHelper.GetDbContext();
     _bus       = bus;
 }
Example #17
0
        public bool Start(string sdkConnectionString, string serviceLocation)
        {
            Console.WriteLine("ServiceGroupItemsPlanningPlugin 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-items-group-planning-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");
                    }

                    ItemsGroupPlanningPnContextFactory contextFactory = new ItemsGroupPlanningPnContextFactory();

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

                    _dbContextHelper = new DbContextHelper(connectionString);

                    _coreAvailable    = true;
                    _coreStatChanging = false;

                    StartSdkCoreSqlOnly(sdkConnectionString);

                    string temp = _dbContext.PluginConfigurationValues
                                  .SingleOrDefault(x => x.Name == "ItemsPlanningBaseSettings:MaxParallelism")?.Value;
                    _maxParallelism = string.IsNullOrEmpty(temp) ? 1 : int.Parse(temp);

                    temp = _dbContext.PluginConfigurationValues
                           .SingleOrDefault(x => x.Name == "ItemsPlanningBaseSettings:NumberOfWorkers")?.Value;
                    _numberOfWorkers = string.IsNullOrEmpty(temp) ? 1 : int.Parse(temp);

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

                    _bus = _container.Resolve <IBus>();

                    ConfigureScheduler();
                }
                Console.WriteLine("ServiceItemsPlanningPlugin started");
                return(true);
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("Start failed " + ex.Message);
                throw;
            }
        }
 public EFormRetrievedHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper)
 {
     _dbContext = dbContextHelper.GetDbContext();
     _sdkCore   = sdkCore;
 }