/// <summary> /// Job that runs when File Store is enabled /// </summary> private void AutomatedFileStoreJob() { //Does the EventNotification table exist? If not, create it. VerifyEventNotificationTableExists(); //Does the EventProperty table exist? If not, create it. VerifyEventPropertyTableExists(); bool?filestoreEnabled = campusLogicSection.FileStoreSettings.FileStoreEnabled; //Have to explicitly check for true. This value could be null if setup preferences have never been saved. if (filestoreEnabled == true) { if (string.IsNullOrWhiteSpace(campusLogicSection.FileStoreSettings.FileStorePath)) { NotificationService.ErrorNotification("Automated File Store Job", $"The following path is either unavailable or does not have the appropriate permissions: {campusLogicSection.FileStoreSettings.FileStorePath}"); } else { string minutes = campusLogicSection.FileStoreSettings.FileStoreMinutes; RecurringJob.AddOrUpdate(() => FileStoreService.ProcessFileStore(), GetCronExpressionByMinutes(minutes)); } } else { RecurringJob.RemoveIfExists("FileStoreService.ProcessFileStore"); } }
public static void AddMAUIService(this IServiceCollection services) { var store = FileStoreService.FromMd5Default(Path.Combine(Workstation, XComicConst.CacheFolderName)); services.AddSingleton <ProposalEngine>(); services.AddSingleton <IComicSaver>(store); services.AddSingleton <IStoreService>(store); services.AddSingleton <IPlatformService, PlatformService>(); services.AddScoped <IComicVisiting <ImageSource>, ComicVisiting <ImageSource> >(); services.AddSingleton <IStreamImageConverter <ImageSource>, StreamImageConverter>(); services.AddSingleton <IStreamImageConverter <ImageResource>, StreamResourceConverter>(); services.AddSingleton <IResourceFactoryCreator <ImageSource>, PlatformResourceCreatorFactory <ImageResource, ImageSource> >(); services.AddSingleton <ExceptionService>(); services.AddScoped <StoreComicVisiting <ImageSource> >(); var storeSer = new WithImageComicStoreService <ImageResource, ImageSource>(new DirectoryInfo(Path.Combine(Workstation, XComicConst.CacheFolderName, XComicConst.StoreFolderName))); services.AddSingleton(storeSer); services.AddSingleton <IObservableCollectionFactory>(new DefaultObservableCollectionFactory()); services.AddSingleton <ComicStoreService <WithImageComicStoreBox <ImageResource, ImageSource> > >(storeSer); var configRoot = BuildConfiguration(); services.AddSingleton(CreateSettings); services.AddSingleton(configRoot); services.AddSingleton <IConfiguration>(configRoot); services.AddSingleton <IConfigurationRoot>(configRoot); //LogManager.Configuration = new XmlLoggingConfiguration(XmlReader.Create(logXml)); //services.AddLogging(x => x.ClearProviders().AddNLog()); }
private void InitServices() { AppEngine.Reset(); AppEngine.AddServices(NetworkAdapterTypes.WebRequest); //var store = new GzipFileStoreService(new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, XComicConst.CacheFolderName)), MD5AddressToFileNameProvider.Instance); var store = FileStoreService.FromMd5Default(Path.Combine(Workstation, XComicConst.CacheFolderName)); AppEngine.Services.AddSingleton(x => new BookManager(new DirectoryInfo(Path.Combine(Workstation, XComicConst.BookFolderName)), x.GetRequiredService <RecyclableMemoryStreamManager>())); //AppEngine.Services.AddSingleton<IViewActiver<IControl>>(va); AppEngine.Services.AddScoped <RemoteEngine>(); AppEngine.Services.AddSingleton(new UnoThemeService()); AppEngine.Services.AddSingleton <IComicSaver>(store); AppEngine.Services.AddSingleton <IStoreService>(store); AppEngine.Services.AddSingleton <IPlatformService, PlatformService>(); AppEngine.Services.AddSingleton <IStreamImageConverter <ImageBox>, StreamImageConverter>(); AppEngine.Services.AddSingleton <IResourceFactoryCreator <ImageBox> >(new PlatformResourceCreatorFactory <ImageBox, ImageBox> { EnableCache = true, StoreFetchSettings = StoreFetchSettings.DefaultNoDisposeStream.Clone() }); AppEngine.Services.AddSingleton <ExceptionService>(); var storeSer = new WithImageComicStoreService <ImageBox, ImageBox>(new DirectoryInfo(Path.Combine(Workstation, XComicConst.CacheFolderName, XComicConst.StoreFolderName))); AppEngine.Services.AddSingleton(storeSer); AppEngine.Services.AddSingleton <IObservableCollectionFactory>(new UnoObservableCollectionFactory()); AppEngine.Services.AddSingleton <ComicStoreService <WithImageComicStoreBox <ImageBox, ImageBox> > >(storeSer); AppEngine.Services.AddSingleton(HistoryService.FromFile(Path.Combine(Workstation, HistoryService.HistoryFileName))); AppEngine.Services.AddSingleton <ProposalEngine>(); AppEngine.Services.AddScoped <IComicVisiting <ImageBox>, UnoStoreComicVisiting>(); AppEngine.Services.AddScoped <StoreComicVisiting <ImageBox> >(); var configRoot = BuildConfiguration(); AppEngine.Services.AddSingleton(CreateSettings); AppEngine.Services.AddSingleton(configRoot); AppEngine.Services.AddSingleton <IConfiguration>(configRoot); AppEngine.Services.AddSingleton <IConfigurationRoot>(configRoot); AppEngine.Services.AddSingleton(new UnoRuntime()); AppEngine.Services.AddSingleton <UnoNavigationService>(); AppEngine.Services.AddSingleton <IComicTurnPageService>(x => x.GetRequiredService <UnoNavigationService>()); AppEngine.Services.AddLogging(x => { x.ClearProviders(); #if HAS_UNO_SKIA_WPF x.AddConsole(); #endif }); AppEngine.Services.AddSingleton <UnoHomeViewModel>(); var appBarSer = new AppBarService(); appBarSer.GetAsDefault() .Rights.Add(new DefaultControlView()); AppEngine.Services.AddSingleton(appBarSer); AppEngine.Services.AddSingleton(new UnoTtileService()); }
private void InitServices() { AppEngine.Reset(); AppEngine.AddServices(NetworkAdapterTypes.WebRequest); //var store = new GzipFileStoreService(new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, XComicConst.CacheFolderName)), MD5AddressToFileNameProvider.Instance); var store = FileStoreService.FromMd5Default(Path.Combine(Workstation, XComicConst.CacheFolderName)); var hp = new Lazy <HomePage>(() => new HomePage()); var cv = new Lazy <ComicView>(() => new ComicView()); var bv = new Lazy <BookshelfView>(() => new BookshelfView()); var va = new ViewActiver <IControl> { [typeof(HomePage)] = () => hp.Value, [typeof(ComicView)] = () => cv.Value, [typeof(BookshelfView)] = () => bv.Value }; var nav = new MainNavigationService(new Border(), va); AppEngine.Services.AddSingleton(x => new BookManager(new DirectoryInfo(Path.Combine(Workstation, XComicConst.BookFolderName)), x.GetRequiredService <RecyclableMemoryStreamManager>())); AppEngine.Services.AddSingleton <IViewActiver <IControl> >(va); AppEngine.Services.AddSingleton <ThemeService>(); AppEngine.Services.AddSingleton <TitleService>(); AppEngine.Services.AddSingleton <IComicTurnPageService>(nav); AppEngine.Services.AddSingleton(nav); AppEngine.Services.AddScoped <RemoteEngine>(); AppEngine.Services.AddSingleton <IComicSaver>(store); AppEngine.Services.AddSingleton <IStoreService>(store); AppEngine.Services.AddSingleton <IPlatformService, PlatformService>(); AppEngine.Services.AddSingleton <IStreamImageConverter <Bitmap>, StreamImageConverter>(); AppEngine.Services.AddSingleton <IResourceFactoryCreator <Bitmap>, PlatformResourceCreatorFactory <Bitmap, Bitmap> >(); AppEngine.Services.AddSingleton <ExceptionService>(); var storeSer = new WithImageComicStoreService <Bitmap, Bitmap>(new DirectoryInfo(Path.Combine(Workstation, XComicConst.CacheFolderName, XComicConst.StoreFolderName))); AppEngine.Services.AddSingleton(storeSer); AppEngine.Services.AddSingleton <IObservableCollectionFactory>(new AvaloniaObservableCollectionFactory()); AppEngine.Services.AddSingleton <ComicStoreService <WithImageComicStoreBox <Bitmap, Bitmap> > >(storeSer); AppEngine.Services.AddSingleton(HistoryService.FromFile(Path.Combine(Workstation, HistoryService.HistoryFileName))); AppEngine.Services.AddSingleton <ProposalEngine>(); AppEngine.Services.AddScoped <IComicVisiting <Bitmap>, DesktopStoreComicVisiting>(); AppEngine.Services.AddScoped <StoreComicVisiting <Bitmap> >(); var configRoot = BuildConfiguration(); AppEngine.Services.AddSingleton(CreateSettings); AppEngine.Services.AddSingleton(configRoot); AppEngine.Services.AddSingleton <IConfiguration>(configRoot); AppEngine.Services.AddSingleton <IConfigurationRoot>(configRoot); AppEngine.Services.AddLogging(x => { x.ClearProviders(); x.AddNLog("NLog.config"); }); }
private void InitServices() { AppEngine.Reset(); AppEngine.AddServices(NetworkAdapterTypes.WebRequest); //var store = new GzipFileStoreService(new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, XComicConst.CacheFolderName)), MD5AddressToFileNameProvider.Instance); var store = FileStoreService.FromMd5Default(Path.Combine(Workstation, XComicConst.CacheFolderName)); AppEngine.Services.AddSingleton(x => new BookManager(new DirectoryInfo(Path.Combine(Workstation, XComicConst.BookFolderName)), x.GetRequiredService <RecyclableMemoryStreamManager>())); //AppEngine.Services.AddSingleton<IViewActiver<IControl>>(va); AppEngine.Services.AddScoped <RemoteEngine>(); AppEngine.Services.AddSingleton(new UnoThemeService()); AppEngine.Services.AddSingleton <IComicSaver>(store); AppEngine.Services.AddSingleton <IStoreService>(store); AppEngine.Services.AddSingleton <IPlatformService, PlatformService>(); AppEngine.Services.AddSingleton <IStreamImageConverter <ImageSource>, StreamImageConverter>(); AppEngine.Services.AddSingleton <IResourceFactoryCreator <ImageSource>, PlatformResourceCreatorFactory <ImageSource, ImageSource> >(); AppEngine.Services.AddSingleton <ExceptionService>(); var storeSer = new WithImageComicStoreService <ImageSource, ImageSource>(new DirectoryInfo(Path.Combine(Workstation, XComicConst.CacheFolderName, XComicConst.StoreFolderName))); AppEngine.Services.AddSingleton(storeSer); AppEngine.Services.AddSingleton <IObservableCollectionFactory>(new UnoObservableCollectionFactory()); AppEngine.Services.AddSingleton <ComicStoreService <WithImageComicStoreBox <ImageSource, ImageSource> > >(storeSer); AppEngine.Services.AddSingleton(HistoryService.FromFile(Path.Combine(Workstation, HistoryService.HistoryFileName))); AppEngine.Services.AddSingleton <ProposalEngine>(); AppEngine.Services.AddScoped <IComicVisiting <ImageSource>, UnoStoreComicVisiting>(); AppEngine.Services.AddScoped <StoreComicVisiting <ImageSource> >(); var configRoot = BuildConfiguration(); AppEngine.Services.AddSingleton(CreateSettings); AppEngine.Services.AddSingleton(configRoot); AppEngine.Services.AddSingleton <IConfiguration>(configRoot); AppEngine.Services.AddSingleton <IConfigurationRoot>(configRoot); AppEngine.Services.AddLogging(x => { x.ClearProviders(); }); }
public Md5StoreSeviceTest() : base(() => FileStoreService.FromMd5Default(AppDomain.CurrentDomain.BaseDirectory)) { }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { AppEngine.Reset(services); AppEngine.AddServices(NetworkAdapterTypes.HttpClient); var store = FileStoreService.FromMd5Default(Path.Combine(Environment.CurrentDirectory, XComicConst.CacheFolderName)); services.AddSingleton <IComicSaver>(store); services.AddSingleton <IStoreService>(store); services.AddSingleton <IResourceFactoryCreator <Stream>, WebResourceFactoryCreator>(); services.AddSingleton <ProposalEngine>(); services.AddScoped <IComicVisiting <Stream>, WebComicVisiting>(); services.AddKnowEngines(); services.AddControllersWithViews(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); services.AddApplicationInsightsTelemetry(Configuration["APPINSIGHTSCONNECTIONSTRING"]); services.AddSignalR() .AddAzureSignalR(opt => { opt.ConnectionString = Configuration["ConnectionStrings:Signalr"]; }); services.AddDbContext <AnfDbContext>((x, y) => { var config = x.GetRequiredService <IConfiguration>(); y.UseSqlServer(config["ConnectionStrings:anfdb"]); }, optionsLifetime: ServiceLifetime.Singleton) .AddDbContextPool <AnfDbContext>((x, y) => { var config = x.GetRequiredService <IConfiguration>(); y.UseSqlServer(config["ConnectionStrings:anfdb"]); }).AddIdentity <AnfUser, AnfRole>(x => { x.Password.RequireDigit = false; x.Password.RequiredUniqueChars = 0; x.Password.RequireLowercase = false; x.Password.RequireNonAlphanumeric = false; x.Password.RequireUppercase = false; }) .AddEntityFrameworkStores <AnfDbContext>(); services.AddSingleton <IDistributedCache, RedisCache>(); services.AddOptions <RedisCacheOptions>() .Configure(x => x.Configuration = Configuration["ConnectionStrings:CacheConnection"]); services.AddResponseCompression(); services.AddScoped <UserService>(); services.AddScoped <UserIdentityService>(); services.AddSwaggerGen(c => { c.SwaggerDoc("Anf", new OpenApiInfo { Version = "v1", Title = "Anf API" }); // Set the comments path for the Swagger JSON and UI. var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); services.AddMemoryCache(); services.AddAuthorization(); services.AddAuthentication(options => { options.AddScheme <AnfAuthenticationHandler>(AnfAuthenticationHandler.SchemeName, "default scheme"); options.DefaultAuthenticateScheme = AnfAuthenticationHandler.SchemeName; options.DefaultChallengeScheme = AnfAuthenticationHandler.SchemeName; }); services.AddScoped <AnfAuthenticationHandler>(); services.AddScoped <ComicRankService>(); services.AddScoped <ComicRankSaver>(); services.AddScoped <BookshelfService>(); services.AddScoped <HotSearchService>(); services.AddOptions <BookshelfOptions>(); services.AddOptions <ComicRankOptions>(); services.AddOptions <FetchOptions>(); services.AddOptions <ResourceLockOptions>(); services.AddFetcherProvider() .AddRedisFetcherProvider() .AddMssqlResourceFetcher() .AddDefaultFetcherProvider(); services.AddResourceFetcher() .AddMssqlResourceFetcher() .AddRedisFetcherProvider(); services.AddScoped <IDbContextTransfer, AnfDbContextTransfer>(); services.AddRedis(); services.AddScoped <ReadingManager>(); AddQuartzAsync(services).GetAwaiter().GetResult(); }
public DefaultStoreSeviceTest() : base(() => FileStoreService.FromDefault(AppDomain.CurrentDomain.BaseDirectory, MD5AddressToFileNameProvider.Instance)) { }