Пример #1
0
        public static async Task Main(string[] args)
        {
            // Use args in application
            new ArgsHelper().SetEnvironmentByArgs(args);

            var services = new ServiceCollection();

            // Setup AppSettings
            services = await SetupAppSettings.FirstStepToAddSingleton(services);

            // Inject services
            RegisterDependencies.Configure(services);
            var serviceProvider = services.BuildServiceProvider();
            var appSettings     = serviceProvider.GetRequiredService <AppSettings>();

            services.AddMonitoringWorkerService(appSettings, AppSettings.StarskyAppType.Importer);
            services.AddApplicationInsightsLogging(appSettings);

            new SetupDatabaseTypes(appSettings, services).BuilderDb();
            serviceProvider = services.BuildServiceProvider();

            var import           = serviceProvider.GetService <IImport>();
            var console          = serviceProvider.GetRequiredService <IConsole>();
            var exifToolDownload = serviceProvider.GetRequiredService <IExifToolDownload>();
            var webLogger        = serviceProvider.GetRequiredService <IWebLogger>();

            // Migrations before importing
            await RunMigrations.Run(serviceProvider.GetService <ApplicationDbContext>(), webLogger, appSettings);

            // Help and other Command Line Tools args are included in the ImporterCli
            await new ImportCli(import, appSettings, console, exifToolDownload).Importer(args);

            await new FlushApplicationInsights(serviceProvider, appSettings, webLogger).FlushAsync();
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //Registrar as Intenções de dependência
            //RegisterDependencies.RegisterData(services, "Data Source = 10.222.181.93; User ID = preprod; password = Sage@2019; Initial Catalog = ProductContextDb");
            RegisterDependencies.RegisterData(services, @"Data Source=localhost\SQLEXPRESS;User ID=sa;password=Caiubao2003@;Initial Catalog=ProductContextDb");

            RegisterDependencies.RegisterDomain(services);

            //Adicionar O API Versioning
            services.AddApiVersioning();

            // Adicionar o Swagger
            services.AddSwaggerGen(swagger =>
            {
                swagger.SwaggerDoc("v1", new Info
                {
                    Title   = "Service API do domínio Produto",
                    Version = "v1"
                });

                string xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                String xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                swagger.IncludeXmlComments(xmlPath);
            });
        }
Пример #3
0
        public static async Task Main(string[] args)
        {
            // Use args in application
            new ArgsHelper().SetEnvironmentByArgs(args);

            var services = new ServiceCollection();

            // Setup AppSettings
            services = await SetupAppSettings.FirstStepToAddSingleton(services);

            // Inject services
            RegisterDependencies.Configure(services);
            var serviceProvider = services.BuildServiceProvider();
            var appSettings     = serviceProvider.GetRequiredService <AppSettings>();

            serviceProvider = services.BuildServiceProvider();
            var selectorStorage = serviceProvider.GetRequiredService <ISelectorStorage>();

            var console = serviceProvider.GetRequiredService <IConsole>();
            var metaExifThumbnailService = serviceProvider.GetRequiredService <IMetaExifThumbnailService>();

            // Help and other Command Line Tools args are included in the Geo tools
            await new MetaThumbnailCommandLineHelper(selectorStorage,
                                                     appSettings, console, metaExifThumbnailService).CommandLineAsync(args);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            RegisterDependencies.Register(services);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "TrabalhoIHM.Api", Version = "v1.1"
                });
            });

            services.AddDbContext <EscolaContext>(options =>
                                                  options.UseSqlServer(Configuration.GetConnectionString("Escola")));

            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll", p =>
                {
                    p.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddMvc();
        }
Пример #5
0
        public static async Task Main(string[] args)
        {
            // Use args in application
            new ArgsHelper().SetEnvironmentByArgs(args);

            var services = new ServiceCollection();

            // Setup AppSettings
            services = await SetupAppSettings.FirstStepToAddSingleton(services);

            // Inject services
            RegisterDependencies.Configure(services);
            var serviceProvider = services.BuildServiceProvider();
            var appSettings     = serviceProvider.GetRequiredService <AppSettings>();

            services.AddMonitoringWorkerService(appSettings, AppSettings.StarskyAppType.Thumbnail);
            services.AddApplicationInsightsLogging(appSettings);

            new SetupDatabaseTypes(appSettings, services).BuilderDb();
            serviceProvider = services.BuildServiceProvider();

            var thumbnailService = serviceProvider.GetService <IThumbnailService>();
            var thumbnailCleaner = serviceProvider.GetService <IThumbnailCleaner>();

            var console         = serviceProvider.GetRequiredService <IConsole>();
            var selectorStorage = serviceProvider.GetRequiredService <ISelectorStorage>();

            // Help and other Command Line Tools args are included in the ThumbnailCLI
            await new ThumbnailCli(appSettings, console, thumbnailService, thumbnailCleaner, selectorStorage).Thumbnail(args);

            await new FlushApplicationInsights(serviceProvider).FlushAsync();
        }
Пример #6
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews()
            .AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);

            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });

            RegisterDependencies.InjectDependencies(services, Configuration);
            services.AddAutoMapper(typeof(Config).Assembly);
        }
Пример #7
0
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            //register platform dependencies and all mobile dependencies
            RegisterDependencies.BuildDependencies(RegisterMobileDependencies);

            //register navigations
            RegisterNavigations(containerRegistry);

            //create database
            Injector.Resolver <IDatabaseHelper>().CreateDatabase();

            //create tables
            Injector.Resolver <IDatabaseHelper>().CreateTables();
        }
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            MappersBootstrap.Initialize();


            var container = RegisterDependencies.Initialize();

            container.RegisterWebApiControllers(GlobalConfiguration.Configuration);

            container.Verify();

            GlobalConfiguration.Configuration.DependencyResolver =
                new SimpleInjectorWebApiDependencyResolver(container);
        }
Пример #9
0
        /// <summary>
        /// Starsky Admin CLI to manage user admin tasks
        /// </summary>
        /// <param name="args">use -h to see all options</param>
        internal static async Task Main(string[] args)
        {
            // Use args in application
            new ArgsHelper().SetEnvironmentByArgs(args);

            var services = new ServiceCollection();

            // Setup AppSettings
            services = await SetupAppSettings.FirstStepToAddSingleton(services);

            // Inject services
            RegisterDependencies.Configure(services);
            var serviceProvider = services.BuildServiceProvider();
            var appSettings     = serviceProvider.GetRequiredService <AppSettings>();

            services.AddMonitoringWorkerService(appSettings, AppSettings.StarskyAppType.Geo);
            services.AddApplicationInsightsLogging(appSettings);

            var webLogger = serviceProvider.GetRequiredService <IWebLogger>();

            new SetupDatabaseTypes(appSettings, services).BuilderDb();
            serviceProvider = services.BuildServiceProvider();

            // Use args in application
            appSettings.Verbose = ArgsHelper.NeedVerbose(args);

            var userManager = serviceProvider.GetService <IUserManager>();

            appSettings.ApplicationType = AppSettings.StarskyAppType.Admin;

            if (new ArgsHelper().NeedHelp(args))
            {
                new ArgsHelper(appSettings).NeedHelpShowDialog();
                return;
            }

            await RunMigrations.Run(serviceProvider.GetService <ApplicationDbContext>(),
                                    webLogger, appSettings);

            await new ConsoleAdmin(userManager, new ConsoleWrapper()).Tool(
                ArgsHelper.GetName(args), ArgsHelper.GetUserInputPassword(args));

            await new FlushApplicationInsights(serviceProvider).FlushAsync();
        }
Пример #10
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSwaggerGen(s =>
            {
                s.SwaggerDoc("v1", new Info
                {
                    Version     = "v1",
                    Title       = "Task List API",
                    Description = "API do projeto Task List"
                });
            });

            services.AddWebApi();


            ConfigContextAccessor(services);


            RegisterDependencies.Register(services, Configuration);
        }
Пример #11
0
        public static async Task Main(string[] args)
        {
            // Use args in application
            new ArgsHelper().SetEnvironmentByArgs(args);

            // Setup AppSettings
            var services = await SetupAppSettings.FirstStepToAddSingleton(new ServiceCollection());

            // Inject services
            RegisterDependencies.Configure(services);
            var serviceProvider = services.BuildServiceProvider();
            var appSettings     = serviceProvider.GetRequiredService <AppSettings>();

            serviceProvider = services.BuildServiceProvider();

            var storageSelector   = serviceProvider.GetService <ISelectorStorage>();
            var console           = serviceProvider.GetRequiredService <IConsole>();
            var webRequestFactory = serviceProvider.GetRequiredService <IFtpWebRequestFactory>();

            new WebFtpCli(appSettings, storageSelector, console, webRequestFactory).Run(args);
        }
Пример #12
0
        public static async Task Main(string[] args)
        {
            // Use args in application
            new ArgsHelper().SetEnvironmentByArgs(args);
            var services = new ServiceCollection();

            services = await SetupAppSettings.FirstStepToAddSingleton(services);

            // Inject services
            RegisterDependencies.Configure(services);
            var serviceProvider = services.BuildServiceProvider();
            var appSettings     = serviceProvider.GetRequiredService <AppSettings>();

            serviceProvider = services.BuildServiceProvider();

            var publishPreflight = serviceProvider.GetService <IPublishPreflight>();
            var publishService   = serviceProvider.GetService <IWebHtmlPublishService>();
            var storageSelector  = serviceProvider.GetService <ISelectorStorage>();
            var console          = serviceProvider.GetRequiredService <IConsole>();

            // Help and args selectors are defined in the PublishCli
            await new PublishCli(storageSelector, publishPreflight, publishService, appSettings, console).Publisher(args);
        }
Пример #13
0
        public static async Task Main(string[] args)
        {
            // Use args in application
            new ArgsHelper().SetEnvironmentByArgs(args);

            var services = new ServiceCollection();

            // Setup AppSettings
            services = await SetupAppSettings.FirstStepToAddSingleton(services);

            // Inject services
            RegisterDependencies.Configure(services);
            var serviceProvider = services.BuildServiceProvider();
            var appSettings     = serviceProvider.GetRequiredService <AppSettings>();

            services.AddMonitoringWorkerService(appSettings, AppSettings.StarskyAppType.Geo);
            services.AddApplicationInsightsLogging(appSettings);

            new SetupDatabaseTypes(appSettings, services).BuilderDb();
            serviceProvider = services.BuildServiceProvider();

            var geoReverseLookup = serviceProvider.GetService <IGeoReverseLookup>();
            var geoLocationWrite = serviceProvider.GetRequiredService <IGeoLocationWrite>();
            var geoFileDownload  = serviceProvider.GetRequiredService <IGeoFileDownload>();

            var selectorStorage = serviceProvider.GetRequiredService <ISelectorStorage>();

            var console          = serviceProvider.GetRequiredService <IConsole>();
            var exifToolDownload = serviceProvider.GetRequiredService <IExifToolDownload>();

            // Help and other Command Line Tools args are included in the Geo tools
            await new GeoCli(geoReverseLookup, geoLocationWrite, selectorStorage,
                             appSettings, console, geoFileDownload, exifToolDownload).CommandLineAsync(args);

            await new FlushApplicationInsights(serviceProvider).FlushAsync();
        }
Пример #14
0
 public void RaiseRegisterDependencies(ObjectContainer objectContainer)
 {
     RegisterDependencies?.Invoke(this, new RegisterDependenciesEventArgs(objectContainer));
 }
Пример #15
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            _appSettings = SetupAppSettings.ConfigurePoCoAppSettings(services, _configuration);

            // before anything else
            EnableCompression(services);

            services.AddMemoryCache();
            // this is ignored here: appSettings.AddMemoryCache; but implemented in cache

            // Detect Application Insights (used in next SetupDatabaseTypes)
            services.AddMonitoring(_appSettings);

            // LoggerFactory
            services.AddApplicationInsightsLogging(_appSettings);

            var foundationDatabaseName = typeof(ApplicationDbContext).Assembly.FullName?.Split(",").FirstOrDefault();

            new SetupDatabaseTypes(_appSettings, services).BuilderDb(foundationDatabaseName);
            new SetupHealthCheck(_appSettings, services).BuilderHealth();

            // Enable Dual Authentication
            services
            .AddAuthentication(sharedOptions =>
            {
                sharedOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                sharedOptions.DefaultSignInScheme       = CookieAuthenticationDefaults.AuthenticationScheme;
                sharedOptions.DefaultChallengeScheme    = CookieAuthenticationDefaults.AuthenticationScheme;
            })
            .AddCookie(options =>
            {
                options.Cookie.Name              = "_id";
                options.ExpireTimeSpan           = TimeSpan.FromDays(60);
                options.SlidingExpiration        = false;
                options.Cookie.HttpOnly          = true;
                options.Cookie.IsEssential       = true;
                options.Cookie.Path              = "/";
                options.Cookie.SameSite          = SameSiteMode.Lax; // allow links from non-domain sites
                options.LoginPath                = "/account/login";
                options.LogoutPath               = "/account/logout";
                options.Events.OnRedirectToLogin = ReplaceReDirector(HttpStatusCode.Unauthorized, options.Events.OnRedirectToLogin);
            }
                       );

            // There is a base-cookie and in index controller there is an method to generate a token that is used to send with the header: X-XSRF-TOKEN
            services.AddAntiforgery(
                options =>
            {
                options.Cookie.Name         = "_af";
                options.Cookie.HttpOnly     = true; // only used by .NET, there is a separate method to generate a X-XSRF-TOKEN cookie
                options.Cookie.SameSite     = SameSiteMode.Lax;
                options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
                options.Cookie.Path         = "/";
                options.Cookie.IsEssential  = true;
                options.HeaderName          = "X-XSRF-TOKEN";
            }
                );

            // to add support for swagger
            new SwaggerSetupHelper(_appSettings).Add01SwaggerGenHelper(services);

            // Now only for dev
            services.AddCors(options =>
            {
                options.AddPolicy("CorsDevelopment",
                                  builder => builder
                                  .WithOrigins("http://localhost:4200",
                                               "http://localhost:8080")
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .AllowCredentials());

                options.AddPolicy("CorsProduction",
                                  builder => builder
                                  .AllowCredentials());
            });



            services.AddMvcCore().AddApiExplorer().AddAuthorization().AddViews();

            ConfigureForwardedHeaders(services);

            // Application Insights
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();

            RegisterDependencies.Configure(services);

            // Reference due missing links between services
            services.AddSingleton <PackageTelemetryBackgroundService>();
        }
 static void Main(string[] args)
 {
     RegisterDependencies.Register();
 }