Exemple #1
0
 public CallConversor(CallTokenService tokenService)
 {
     if (tokenService != null)
     {
         _token = tokenService.CallTokenConversor();
     }
 }
 public CallApiVirtualPath(CallTokenService tokenService, ConfigUrlService serviceUrl, ICallService serviceApi)
 {
     _serviceUrl = serviceUrl;
     _serviceApi = serviceApi;
     if (tokenService != null)
     {
         bool tokenCargado = false;
         while (!tokenCargado)
         {
             try
             {
                 _token       = tokenService.CallTokenApiDocumentacion();
                 tokenCargado = true;
             }
             catch (Exception ex)
             {
                 tokenCargado = false;
             }
         }
     }
 }
Exemple #3
0
 public TokenController(CallTokenService callTokenService)
 {
     _callTokenService = callTokenService;
 }
Exemple #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            IDictionary environmentVariables = Environment.GetEnvironmentVariables();
            string      casBaseUrl           = "";

            if (environmentVariables.Contains("CasBaseUrl"))
            {
                casBaseUrl = environmentVariables["CasBaseUrl"] as string;
            }
            else
            {
                casBaseUrl = Configuration["CasBaseUrl"];
            }

            string serviceHost = "";

            if (environmentVariables.Contains("ServiceHost"))
            {
                serviceHost = environmentVariables["ServiceHost"] as string;
            }
            else
            {
                serviceHost = Configuration["ServiceHost"];
            }
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(options =>
            {
                options.LoginPath        = new PathString("/login");
                options.AccessDeniedPath = new PathString("/access-denied");
            })
            .AddCAS(options =>
            {
                options.CasServerUrlBase = casBaseUrl;      // Set in `appsettings.json` file.
                options.SignInScheme     = CookieAuthenticationDefaults.AuthenticationScheme;
                options.ServiceHost      = serviceHost;
            });
            bool cargado = false;

            while (!cargado)
            {
                // services.AddMvcRazorRuntimeCompilation();
                try
                {
                    services.AddRazorPages().AddRazorRuntimeCompilation();
                    services.AddControllersWithViews().AddRazorRuntimeCompilation();
                    services.Configure <MvcRazorRuntimeCompilationOptions>(opts =>
                    {
                        CallApiService serviceApi         = new CallApiService();
                        CallTokenService tokenService     = new CallTokenService(new ConfigTokenService());
                        ConfigUrlService serviceUrl       = new ConfigUrlService();
                        CallApiVirtualPath apiVirtualPath = new CallApiVirtualPath(tokenService, serviceUrl, serviceApi);
                        opts.FileProviders.Add(
                            new ApiFileProvider(apiVirtualPath));
                    });
                    cargado = true;
                } catch (Exception ex)
                {
                    cargado = false;
                }
            }
            services.AddEntityFrameworkNpgsql().AddDbContext <EntityContext>(opt =>
            {
                var builder = new NpgsqlDbContextOptionsBuilder(opt);
                builder.SetPostgresVersion(new Version(9, 6));
                IDictionary environmentVariables = Environment.GetEnvironmentVariables();
                if (environmentVariables.Contains("PostgreConnectionmigration"))
                {
                    opt.UseNpgsql(environmentVariables["PostgreConnectionmigration"] as string);
                }
                else
                {
                    opt.UseNpgsql(Configuration.GetConnectionString("PostgreConnectionmigration"));
                }
            });

            services.AddScoped <DiscoverItemBDService, DiscoverItemBDService>();
            services.AddScoped <ProcessDiscoverStateJobBDService, ProcessDiscoverStateJobBDService>();


            services.AddControllersWithViews();
            services.AddSingleton(typeof(ConfigPathLog));
            services.AddSingleton(typeof(ConfigUrlService));
            services.AddSingleton(typeof(ConfigUrlCronService));
            services.AddSingleton(typeof(ConfigUnidataPrefix));
            services.AddScoped <ICallRepositoryConfigService, CallRepositoryConfigApiService>();
            services.AddScoped <ICallUrisFactoryApiService, CallUrisFactoryApiService>();
            services.AddScoped <ICallService, CallApiService>();
            services.AddScoped <ICallEtlService, CallEtlService>();
            services.AddScoped <ICallShapeConfigService, CallShapeConfigApiService>();
            services.AddScoped(typeof(CallCronApiService));
            services.AddScoped(typeof(CheckSystemService));
            services.AddScoped(typeof(CallCronService));
            services.AddScoped(typeof(ConfigTokenService));
            services.AddScoped(typeof(CallTokenService));
            services.AddScoped(typeof(CallApiVirtualPath));
            services.AddScoped(typeof(CallRepositoryJobService));
            services.AddScoped(typeof(ReplaceUsesService));
        }
Exemple #5
0
 public CallApiVirtualPath(CallTokenService tokenService, ConfigUrlService serviceUrl, ICallService serviceApi)
 {
     _serviceUrl   = serviceUrl;
     _serviceApi   = serviceApi;
     _tokenService = tokenService;
 }