Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConnectionSettings connectionSettings = new ConnectionSettings();

            services.Configure <ConnectionSettings>(Configuration.GetSection(typeof(ConnectionSettings).Name));

            DBProviderType dataStoreType = (DBProviderType)Enum.Parse(typeof(DBProviderType), Configuration.GetSection($"{typeof(ConnectionSettings).Name}:DataStoreType").Value.ToString());

            services.AddMvc();
            switch (dataStoreType)
            {
            case DBProviderType.MySQLProvider:
                services.AddSingleton <IDataService, MySqlDataClient>();
                break;

            case DBProviderType.SQLiteProvider:
                services.AddSingleton <IDataService, SQLiteClient>();
                break;

            default:
                throw new Exception(msgDataStoreTypeError);
            }


            services.AddSingleton <IConfigService, ConfigService>();
            services.AddSingleton <IFolderService, FolderService>();
            services.AddSingleton <IUserService, UserService>();
            services.AddSingleton <IMemoryCache, MemoryCache>();

            services.AddScoped <IFileProcessorService, FileProcessorService>();
            services.AddScoped <IVideoService, VideoService>();
            services.AddScoped <IVideoGalleryService, VideoGalleryService>();
            services.AddScoped <IVideoStreamService, VideoStreamService>();

            services.AddScoped <IImageService, ImageService>();
            services.AddScoped <IImageGalleryService, ImageGalleryService>();
            services.AddScoped <IImageComparisonService, ImageComparisonService.Services.ImageComparisonService>();

            services.AddScoped <ILibraryManagerService, LibraryManagerService>();

            services.AddControllers();

            services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "My API", Version = "v1"
                });
            });

            services.AddCors(options => {
                options.AddPolicy(AllowAllCors, builder => {
                    builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
                });
            });
            services.AddApplicationInsightsTelemetry();
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //Init DB provider
            ConnectionSettings connectionSettings = new ConnectionSettings();

            services.Configure <ConnectionSettings>(Configuration.GetSection(typeof(ConnectionSettings).Name));

            DBProviderType dataStoreType = (DBProviderType)Enum.Parse(typeof(DBProviderType), Configuration.GetSection($"{typeof(ConnectionSettings).Name}:DataStoreType").Value.ToString());

            switch (dataStoreType)
            {
            case DBProviderType.SQLiteProvider:
                services.AddSingleton <IDataService, SQLiteClient>();
                break;

            default:
                throw new Exception(msgDataStoreTypeError);
            }

            //services.AddScoped<IGoogleSheetsService, GoogleSheetsService>();
            services.AddScoped <ILoginService, LoginService>();
            services.AddScoped <IInventoryService, InventoryService>();
            services.AddScoped <IPersonnelService, PersonnelService>();
            services.AddScoped <IGanttDataService, GanttDataService>();
            services.AddScoped <IStartupService, StartupService>();
            services.AddScoped <ICustomerService, CustomerService>();
            services.AddScoped <IQuoteService, QuoteService>();
            services.AddScoped <IProjectService, ProjectService>();

            services.AddMvc().AddJsonOptions(options => options.JsonSerializerOptions.PropertyNameCaseInsensitive = true);

            services.AddControllers()
            .AddJsonOptions(options =>
            {
                options.JsonSerializerOptions.PropertyNamingPolicy = null;
            });

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Alveo Management API V1", Version = "v1"
                });
            });

            services.AddCors(options =>
            {
                options.AddPolicy(AllowAllCors, builder =>
                {
                    builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
                });
            });
        }
Example #3
0
        /// <summary>
        /// Creates provider type data based on an enumerated value
        /// </summary>
        /// <param name="provider">The type of provider</param>
        /// <returns>Initialized type data</returns>
        internal static DatabaseTypeData GetTypeFromProvider(DBProviderType provider)
        {
            switch (provider)
            {
            case DBProviderType.SqlServer:
                return(SqlTypeData());

            case DBProviderType.Oracle:
                return(OracleTypeData());

            default:
                return(null);
            }
        }
Example #4
0
 /// <summary>
 /// Creates the default database instance using integrated security for the given provider type
 /// </summary>
 /// <param name="connectString">A connect string for the database</param>
 /// <param name="userID">User ID to connect with</param>
 /// <param name="password">Password to connect with</param>
 /// <param name="provider">The type of provider</param>
 /// <returns>An initialized database provider</returns>
 public static Database CreateDatabaseFromConnectString(string connectString, string userID, string password, DBProviderType provider)
 {
     return(CreateDatabase(_defaultInstanceName, GetConnectionStringData(connectString, userID, password), GetTypeFromProvider(provider)));
 }
Example #5
0
 /// <summary>
 /// Creates a named database instance using integrated security for the given provider type
 /// </summary>
 /// <param name="instanceName">The instance name to use for the database</param>
 /// <param name="connectString">A connect string for the database</param>
 /// <param name="provider">The type of provider</param>
 /// <returns>An initialized database provider</returns>
 public static Database CreateDatabaseFromConnectString(string instanceName, string connectString, DBProviderType provider)
 {
     return(CreateDatabase(instanceName, GetConnectionStringData(connectString), GetTypeFromProvider(provider)));
 }
Example #6
0
 /// <summary>
 /// Creates a named database instance using username and password for the given provider type
 /// </summary>
 /// <param name="instanceName">The instance name to use for the database</param>
 /// <param name="server">Name of the server to connect to</param>
 /// <param name="database">Name of the database to connect to</param>
 /// <param name="userID">User Id to connect with</param>
 /// <param name="password">Password to connect with</param>
 /// <param name="provider">The type of provider</param>
 /// <returns>An initialized database provider</returns>
 public static Database CreateDatabase(string instanceName, string server, string database, string userID, string password, DBProviderType provider)
 {
     return(CreateDatabase(instanceName, GetConnectionStringData(server, database, userID, password), GetTypeFromProvider(provider)));
 }
Example #7
0
 /// <summary>
 /// Creates the default database instance using integrated security for the given provider type
 /// </summary>
 /// <param name="server">Name of the server to connect to</param>
 /// <param name="database">Name of the database to connect to</param>
 /// <param name="provider">The type of provider</param>
 /// <returns>An initialized database provider</returns>
 public static Database CreateDatabase(string server, string database, DBProviderType provider)
 {
     return(CreateDatabase(_defaultInstanceName, GetConnectionStringData(server, database), GetTypeFromProvider(provider)));
 }