public async Task Save(ItemsPlanningPnDbContext dbContext) { Item item = new Item { Sku = Sku, Name = Name, Description = Description, Enabled = Enabled, ItemNumber = ItemNumber, LocationCode = LocationCode, ItemListId = ItemListId, BuildYear = BuildYear, Type = Type, CreatedAt = DateTime.UtcNow, UpdatedAt = DateTime.UtcNow, Version = 1, WorkflowState = Constants.WorkflowStates.Created, UpdatedByUserId = UpdatedByUserId, CreatedByUserId = CreatedByUserId, }; await dbContext.Items.AddAsync(item); await dbContext.SaveChangesAsync(); await dbContext.ItemVersions.AddAsync(MapItemVersion(item)); await dbContext.SaveChangesAsync(); Id = item.Id; }
public async Task Update(ItemsPlanningPnDbContext dbContext) { Item item = await dbContext.Items.FirstOrDefaultAsync(x => x.Id == Id); if (item == null) { throw new NullReferenceException($"Could not find item with id: {Id}"); } item.Sku = Sku; item.Name = Name; item.Description = Description; item.WorkflowState = WorkflowState; item.ItemNumber = ItemNumber; item.LocationCode = LocationCode; item.BuildYear = BuildYear; item.Type = Type; item.UpdatedAt = UpdatedAt; item.UpdatedByUserId = UpdatedByUserId; if (dbContext.ChangeTracker.HasChanges()) { item.UpdatedAt = DateTime.UtcNow; item.Version += 1; await dbContext.ItemVersions.AddAsync(MapItemVersion(item)); await dbContext.SaveChangesAsync(); } }
private static async Task <PlanningCase> SetFieldValue(ItemsPlanningPnDbContext itemsPlanningContext, Core _sdkCore, PlanningCase planningCase, int caseId, Language language) { var planning = await itemsPlanningContext.Plannings.SingleOrDefaultAsync(x => x.Id == planningCase.PlanningId).ConfigureAwait(false); var caseIds = new List <int> { planningCase.MicrotingSdkCaseId }; var fieldValues = await _sdkCore.Advanced_FieldValueReadList(caseIds, language).ConfigureAwait(false); if (planning == null) { return(planningCase); } if (planning.NumberOfImagesEnabled) { planningCase.NumberOfImages = 0; foreach (var fieldValue in fieldValues) { if (fieldValue.FieldType == Constants.FieldTypes.Picture) { if (fieldValue.UploadedData != null) { planningCase.NumberOfImages += 1; } } } } return(planningCase); }
public PairItemWichSiteHelper( ItemsPlanningPnDbContext dbContext, IEFormCoreService coreService) { _dbContext = dbContext; _coreService = coreService; }
public async Task Update(ItemsPlanningPnDbContext dbContext) { UploadedData uploadedData = await dbContext.UploadedDatas.FirstOrDefaultAsync(x => x.Id == Id); if (uploadedData == null) { throw new NullReferenceException($"Could not find uploadedData with id: {Id}"); } uploadedData.ItemCaseId = ItemCaseId; uploadedData.Checksum = Checksum; uploadedData.Extension = Extension; uploadedData.CurrentFile = CurrentFile; uploadedData.UploaderType = UploaderType; uploadedData.FileLocation = FileLocation; uploadedData.FileName = FileName; uploadedData.WorkflowState = WorkflowState; if (dbContext.ChangeTracker.HasChanges()) { uploadedData.UpdatedAt = DateTime.UtcNow; uploadedData.Version += 1; await dbContext.UploadedDataVersions.AddAsync(MapVersion(uploadedData)); await dbContext.SaveChangesAsync(); } }
public ItemsPlanningCaseService(ItemsPlanningPnDbContext dbContext, ILogger <ItemsPlanningCaseService> logger, IEFormCoreService coreHelper, IItemsPlanningLocalizationService localizationService, IUserService userService) { _dbContext = dbContext; _logger = logger; _coreHelper = coreHelper; _localizationService = localizationService; _userService = userService; }
public ScheduledItemExecutedHandler( DbContextHelper dbContextHelper, IBus bus, eFormCore.Core sdkCore) { _dbContext = dbContextHelper.GetDbContext(); _bus = bus; _sdkCore = sdkCore; }
private void GetContext(string connectionStr) { var contextFactory = new ItemsPlanningPnContextFactory(); DbContext = contextFactory.CreateDbContext(new[] { connectionStr }); DbContext.Database.Migrate(); DbContext.Database.EnsureCreated(); }
public UploadedDataService( ItemsPlanningPnDbContext dbContext, IItemsPlanningLocalizationService itemsPlanningLocalizationService, IEFormCoreService core) { _dbContext = dbContext; _itemsPlanningLocalizationService = itemsPlanningLocalizationService; _core = core; }
public SearchListJob( DbContextHelper dbContextHelper, IBus bus, eFormCore.Core sdkCore) { _dbContext = dbContextHelper.GetDbContext(); _bus = bus; _sdkCore = sdkCore; }
public PlanningExcelService(ILogger <PlanningExcelService> logger, IItemsPlanningLocalizationService localizationService, IEFormCoreService coreHelper, ItemsPlanningPnDbContext dbContext) { _logger = logger; _localizationService = localizationService; _coreHelper = coreHelper; _dbContext = dbContext; }
public PlanningService( ItemsPlanningPnDbContext dbContext, IItemsPlanningLocalizationService itemsPlanningLocalizationService, IUserService userService, IEFormCoreService coreService) { _dbContext = dbContext; _itemsPlanningLocalizationService = itemsPlanningLocalizationService; _coreService = coreService; _userService = userService; }
public ItemsPlanningPnSettingsService(ILogger <ItemsPlanningPnSettingsService> logger, IItemsPlanningLocalizationService itemsPlanningLocalizationService, ItemsPlanningPnDbContext dbContext, IPluginDbOptions <ItemsPlanningBaseSettings> options, IHttpContextAccessor httpContextAccessor) { _logger = logger; _dbContext = dbContext; _options = options; _httpContextAccessor = httpContextAccessor; _itemsPlanningLocalizationService = itemsPlanningLocalizationService; }
public ItemsPlanningTagsService( IItemsPlanningLocalizationService itemsPlanningLocalizationService, ILogger <ItemsPlanningTagsService> logger, ItemsPlanningPnDbContext dbContext, IUserService userService ) { _itemsPlanningLocalizationService = itemsPlanningLocalizationService; _logger = logger; _dbContext = dbContext; _userService = userService; }
public PairingService( ItemsPlanningPnDbContext dbContext, IItemsPlanningLocalizationService itemsPlanningLocalizationService, IEFormCoreService coreService, IUserService userService, IPlanningService planningService) { _dbContext = dbContext; _itemsPlanningLocalizationService = itemsPlanningLocalizationService; _coreService = coreService; _userService = userService; _pairItemWichSiteHelper = new PairItemWichSiteHelper(_dbContext, _coreService); _planningService = planningService; }
public async Task Create(ItemsPlanningPnDbContext dbContext) { WorkflowState = Constants.WorkflowStates.Created; Version = 1; CreatedAt = DateTime.Now; UpdatedAt = DateTime.Now; await dbContext.ItemLists.AddAsync(this); await dbContext.SaveChangesAsync(); await dbContext.ItemListVersions.AddAsync(MapItemListVersion(this)); await dbContext.SaveChangesAsync(); }
public PlanningImportService( ItemsPlanningPnDbContext dbContext, IItemsPlanningLocalizationService itemsPlanningLocalizationService, IEFormCoreService coreService, IUserService userService, IPlanningExcelService planningExcelService, ILogger <PlanningImportService> logger) { _dbContext = dbContext; _itemsPlanningLocalizationService = itemsPlanningLocalizationService; _coreService = coreService; _userService = userService; _planningExcelService = planningExcelService; _logger = logger; }
public async Task Create(ItemsPlanningPnDbContext dbContext) { CreatedAt = DateTime.UtcNow; UpdatedAt = DateTime.UtcNow; Version = 1; WorkflowState = Constants.WorkflowStates.Created; await dbContext.UploadedDatas.AddAsync(this); await dbContext.SaveChangesAsync(); await dbContext.UploadedDataVersions.AddAsync(MapVersion(this)); await dbContext.SaveChangesAsync(); }
public async Task Update(ItemsPlanningPnDbContext dbContext) { ItemCaseSite itemCaseSite = await dbContext.ItemCaseSites.FirstOrDefaultAsync(x => x.Id == Id); if (itemCaseSite == null) { throw new NullReferenceException($"Could not find item with id: {Id}"); } itemCaseSite.MicrotingSdkSiteId = MicrotingSdkSiteId; itemCaseSite.MicrotingSdkeFormId = MicrotingSdkeFormId; itemCaseSite.Status = Status; itemCaseSite.FieldStatus = FieldStatus; itemCaseSite.MicrotingSdkCaseId = MicrotingSdkCaseId; itemCaseSite.ItemId = ItemId; itemCaseSite.MicrotingSdkCaseDoneAt = MicrotingSdkCaseDoneAt; itemCaseSite.WorkflowState = WorkflowState; itemCaseSite.NumberOfImages = NumberOfImages; itemCaseSite.Comment = Comment; itemCaseSite.Location = Location; itemCaseSite.SdkFieldValue1 = SdkFieldValue1; itemCaseSite.SdkFieldValue2 = SdkFieldValue2; itemCaseSite.SdkFieldValue3 = SdkFieldValue3; itemCaseSite.SdkFieldValue4 = SdkFieldValue4; itemCaseSite.SdkFieldValue5 = SdkFieldValue5; itemCaseSite.SdkFieldValue6 = SdkFieldValue6; itemCaseSite.SdkFieldValue7 = SdkFieldValue7; itemCaseSite.SdkFieldValue8 = SdkFieldValue8; itemCaseSite.SdkFieldValue9 = SdkFieldValue9; itemCaseSite.SdkFieldValue10 = SdkFieldValue10; itemCaseSite.DoneByUserId = DoneByUserId; itemCaseSite.DoneByUserName = DoneByUserName; itemCaseSite.ItemCaseId = ItemCaseId; if (dbContext.ChangeTracker.HasChanges()) { itemCaseSite.UpdatedAt = DateTime.UtcNow; itemCaseSite.Version += 1; await dbContext.ItemCaseSiteVersions.AddAsync(MapVersion(itemCaseSite)); await dbContext.SaveChangesAsync(); } }
// ReSharper disable once SuggestBaseTypeForParameter public ItemsPlanningReportService( IItemsPlanningLocalizationService itemsPlanningLocalizationService, ILogger <ItemsPlanningReportService> logger, IEFormCoreService coreHelper, IWordService wordService, IPlanningExcelService excelService, ICasePostBaseService casePostBaseService, ItemsPlanningPnDbContext dbContext, IUserService userService) { _itemsPlanningLocalizationService = itemsPlanningLocalizationService; _logger = logger; _coreHelper = coreHelper; _wordService = wordService; _excelService = excelService; _casePostBaseService = casePostBaseService; _dbContext = dbContext; _userService = userService; }
public async Task Create(ItemsPlanningPnDbContext 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(); } }
public async Task Delete(ItemsPlanningPnDbContext dbContext) { UploadedData uploadedData = await dbContext.UploadedDatas.FirstOrDefaultAsync(x => x.Id == Id); if (uploadedData == null) { throw new NullReferenceException($"Could not find uploadedData with id: {Id}"); } uploadedData.WorkflowState = Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { uploadedData.UpdatedAt = DateTime.UtcNow; uploadedData.Version += 1; await dbContext.UploadedDataVersions.AddAsync(MapVersion(uploadedData)); await dbContext.SaveChangesAsync(); } }
public async Task Delete(ItemsPlanningPnDbContext dbContext) { Item item = await dbContext.Items.FirstOrDefaultAsync(x => x.Id == Id); if (item == null) { throw new NullReferenceException($"Could not find item with id: {Id}"); } item.WorkflowState = Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { item.UpdatedAt = DateTime.UtcNow; item.Version += 1; await dbContext.ItemVersions.AddAsync(MapItemVersion(item)); await dbContext.SaveChangesAsync(); } }
private async Task UpdateInternal(ItemsPlanningPnDbContext 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(); } } }
public PushMessageHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper) { _dbContext = dbContextHelper.GetDbContext(); _sdkCore = sdkCore; }
public SearchListJob(DbContextHelper dbContextHelper, IBus bus) { _dbContext = dbContextHelper.GetDbContext(); _bus = bus; }
public EFormRetrievedHandler(DbContextHelper dbContextHelper) { _dbContext = dbContextHelper.GetDbContext(); }
public static void SeedData(ItemsPlanningPnDbContext 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 = ItemsPlanningPermissionsSeedData.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 } ); if (!dbContext.Languages.Any()) { var languages = new List <Language>() { new Language() { CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, Version = 1, WorkflowState = Constants.WorkflowStates.Created, Name = "Danish", LanguageCode = "da" }, new Language() { CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, Version = 1, WorkflowState = Constants.WorkflowStates.Created, Name = "English", LanguageCode = "en-US" }, new Language() { CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, Version = 1, WorkflowState = Constants.WorkflowStates.Created, Name = "German", LanguageCode = "de-DE" } }; dbContext.Languages.AddRange(languages); } dbContext.PluginPermissions.AddRange(newPermissions); dbContext.SaveChanges(); }
public ItemCaseCreateHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper) { _sdkCore = sdkCore; _dbContext = dbContextHelper.GetDbContext(); }
public EFormCompletedHandler(eFormCore.Core sdkCore, DbContextHelper dbContextHelper) { _dbContext = dbContextHelper.GetDbContext(); _sdkCore = sdkCore; }