// Create data and category files private async Task <bool> Initialize() { string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var dataController = new StorageController <DataModel>(Path.Combine(assemblyPath, SecureManager.DataFileName)); var dataInitializer = new StorageInitializer <DataModel>(new DataGenerator(), new Cryptographer(SecureManager.Key)); try { List <DataModel> dataList = await dataInitializer.GetDataAsync(); await dataController.CreateStorageAsync(dataList); } catch (InvalidOperationException ex) { MessageBox.Show($"Can't write data to {ex.Source}"); return(false); } var categoriesController = new StorageController <CategoryModel>(Path.Combine(assemblyPath, SecureManager.CategoriesFileName)); try { await categoriesController.CreateStorageAsync(new List <CategoryModel>()); } catch (InvalidOperationException ex) { MessageBox.Show($"Can't write data to {ex.Source}"); return(false); } return(true); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); } else { //app.Use(async (context, next) => //{ // if (context.Request.IsHttps) // { // await next(); // } // //else //if(bool.Parse(Configuration["Production:UseAlwaysHTTPS"])) // //{ // // var toHttps = "https://" + context.Request.Host + context.Request.Path; // // context.Response.Redirect(toHttps); // //} //}); app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider( Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot", "images")), RequestPath = new PathString("/images") }); app.UseAuthentication(); AutoMapperConfiguration.Configure(Configuration); app.UseAntiforgeryToken(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); StorageInitializer.Initialize(Configuration); DocumentDBInitializer.Initialize(Configuration); AzureSearchInitializer.Initialize(Configuration); }
/// <summary> /// Creates instance of <see cref="IStorageInitializer"/>. /// </summary> /// <param name="fileFsStoragePath">Path to FileFS storage file.</param> /// <param name="logger">Logger instance.</param> /// <returns>Instance of <see cref="IStorageInitializer"/>.</returns> public static IStorageInitializer Create(string fileFsStoragePath, ILogger logger) { var storageStreamProvider = new StorageStreamProvider(fileFsStoragePath, logger); var connection = new StorageConnection(storageStreamProvider, 4096, logger); var filesystemDescriptorSerializer = new FilesystemDescriptorSerializer(logger); var filesystemDescriptorAccessor = new FilesystemDescriptorAccessor(connection, filesystemDescriptorSerializer, logger); var entryDescriptorSerializer = new EntryDescriptorSerializer(filesystemDescriptorAccessor, logger); var entryDescriptorRepository = new EntryDescriptorRepository(connection, filesystemDescriptorAccessor, entryDescriptorSerializer, logger); var operationLocker = new StorageOperationLocker(); var storageInitializer = new StorageInitializer(connection, operationLocker, filesystemDescriptorAccessor, entryDescriptorRepository, logger); return(storageInitializer); }
static Program() { StorageInitializer.Initialize(ConnectionString); }