public DownloadController( OSSDbContext dbContext, IConfiguration configuration) { _dbContext = dbContext; _configuration = configuration; }
public async Task DeleteInvalidFiles(OSSDbContext dbContext) { var allFiles = await dbContext.OSSFile.ToListAsync(); // Delete files that not in record foreach (var bucket in await dbContext.Bucket.ToListAsync()) { var bucketPath = $@"{Configuration["StoragePath"]}{_}Storage{_}{bucket.BucketName}{_}"; if (!Directory.Exists(bucketPath)) { Directory.CreateDirectory(bucketPath); } foreach (var item in new DirectoryInfo(bucketPath).GetFiles()) { try { var fileid = Convert.ToInt32(Path.GetFileNameWithoutExtension(item.Name)); // If file is not exist in the database if (!allFiles.Where(t => t.BucketId == bucket.BucketId).Any(t => t.FileKey == fileid)) { _logger.LogWarning($"Deleted the file in disk: {item.FullName} because it was not found in database."); File.Delete(item.FullName); } } catch (Exception e) { _logger.LogWarning($"An error occured while analysing the file {item.FullName} because {e.Message}. We will delete it directly!"); File.Delete(item.FullName); } } } }
public SecretController( OSSDbContext dbContext, ACTokenManager tokenManager) { _dbContext = dbContext; _tokenManager = tokenManager; }
public SecretController( OSSDbContext dbContext, CoreApiService coreApiService) { _dbContext = dbContext; _coreApiService = coreApiService; }
public ApiController( OSSDbContext dbContext, ImageCompresser imageCompresser, IConfiguration configuration) { _dbContext = dbContext; _imageCompresser = imageCompresser; _configuration = configuration; }
public DownloadController( OSSDbContext dbContext, ImageCompressor imageCompressor, IConfiguration configuration) { _dbContext = dbContext; _imageCompressor = imageCompressor; _configuration = configuration; }
public AuthController( UserManager<OSSUser> userManager, SignInManager<OSSUser> signInManager, OSSDbContext _context) { _userManager = userManager; _signInManager = signInManager; _dbContext = _context; }
public TimedCleaner( IConfiguration configuration, ILogger <TimedCleaner> logger, OSSDbContext dbContext) { Configuration = configuration; _logger = logger; _dbContext = dbContext; }
public ApiController( OSSDbContext dbContext, IConfiguration configuration, ServiceLocation serviceLocation, ACTokenManager tokenManager) { _dbContext = dbContext; _configuration = configuration; _serviceLocation = serviceLocation; _tokenManager = tokenManager; }
public static void SeedHostDb(OSSDbContext context) { context.SuppressAutoSetTenantId = true; // Host seed new InitialHostDbBuilder(context).Create(); // Default tenant seed (in host database). new DefaultTenantBuilder(context).Create(); new TenantRoleAndUserBuilder(context, 1).Create(); }
public ApiController( OSSDbContext dbContext, ImageCompresser imageCompresser, IConfiguration configuration, ServiceLocation serviceLocation, CoreApiService coreApiService) { _dbContext = dbContext; _imageCompresser = imageCompresser; _configuration = configuration; _serviceLocation = serviceLocation; _coreApiService = coreApiService; }
public async Task DeleteInvalidRecords(OSSDbContext dbContext) { // Delete records that not in storage. foreach (var file in await dbContext.OSSFile.ToListAsync()) { var path = $@"{Configuration["StoragePath"]}{_}Storage{_}{file.BelongingBucket.BucketName}{_}{file.FileKey}.dat"; if (!File.Exists(path)) { dbContext.Remove(file); _logger.LogWarning($"Deleted the file record in database: {file.BelongingBucket.BucketName}.{file.FileKey} because it was not found in storage."); } } await dbContext.SaveChangesAsync(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, OSSDbContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseEnforceHttps(); } app.UseStaticFiles(); app.UseLanguageSwitcher(); app.UseMvcWithDefaultRoute(); }
private async Task AllClean(OSSDbContext _dbContext) { var outdatedFiles = (await _dbContext.OSSFile.Include(t => t.BelongingBucket).ToListAsync()) .Where(t => t.UploadTime + new TimeSpan(t.AliveDays, 0, 0, 0) < DateTime.Now) .ToList(); foreach (var file in outdatedFiles) { var path = $@"{Configuration["StoragePath"]}{_}Storage{_}{file.BelongingBucket.BucketName}{_}{file.FileKey}.dat"; if (File.Exists(path)) { File.Delete(path); } _dbContext.OSSFile.Remove(file); } await _dbContext.SaveChangesAsync(); _logger.LogInformation("Successfully cleaned all trash."); }
public TenantRoleAndUserBuilder(OSSDbContext context, int tenantId) { _context = context; _tenantId = tenantId; }
public ApiController(OSSDbContext dbContext) { this._dbContext = dbContext; }
public DefaultTenantBuilder(OSSDbContext context) { _context = context; }
public DefaultEditionCreator(OSSDbContext context) { _context = context; }
public InitialHostDbBuilder(OSSDbContext context) { _context = context; }
public DefaultSettingsCreator(OSSDbContext context) { _context = context; }
public HostRoleAndUserCreator(OSSDbContext context) { _context = context; }
public DefaultLanguagesCreator(OSSDbContext context) { _context = context; }
public SecretController( OSSDbContext dbContext) { this._dbContext = dbContext; }