public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger logger)
        {
            app.UseAbp(); //Initializes ABP framework.

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                DbContextOptionsConfigurer.Logger = logger;
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseSwagger();
            //Enable middleware to serve swagger - ui assets(HTML, JS, CSS etc.)
            app.UseSwaggerUI(options =>
            {
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "Kraken API V1");
                //options.RoutePrefix = string.Empty;
            }); //URL: /swagger

            app.UseStaticFiles();
            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            });
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger)
        {
            if (env.IsDevelopment())
            {
                app.UseExceptionHandler(a =>
                                        a.Run(async context =>
                {
                    var e = context.Features.Get <IExceptionHandlerFeature>().Error;
                    logger.LogError(message: $"Exception throw in :{e.StackTrace} says : {e.Message}", exception: e);
                    context.Response.ContentType = "application/json";
                    context.Response.StatusCode  = 200;

                    await context.Response.WriteAsync(JsonSerializer.Serialize(new
                    {
                        ServerError = e.Message
                    }));
                    return;
                }));
            }
            else
            {
                app.UseExceptionHandler(a => a.Run(async context =>
                {
                    var e = context.Features.Get <IExceptionHandlerFeature>().Error;
                    logger.LogError(message: $"Exception throw in : {e.Source} says : {e.Message}", exception: e);
                    context.Response.StatusCode  = 500;
                    context.Response.ContentType = "application/json";
                    await context.Response.WriteAsync(JsonSerializer.Serialize(new
                    {
                        Error = e.Message
                    }));
                }));
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseRouting();
            app.UseCors(cors => cors.AllowAnyMethod().AllowAnyHeader());
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseSwagger();
            app.UseSwaggerUI(options =>
            {
                options.RoutePrefix = string.Empty;
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "E Commerce");
            });
            app.UseWhen(
                context => context.User.GetUserId().HasValue&& context.User.GetUserRole().HasValue,
                a => a.UseVerifyTokenNotRevoked()
                );

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/seed", async context =>
                {
                });
                endpoints.MapControllers();
            });
        }
Example #3
0
 public UserManager(
     RoleManager roleManager,
     UserStore store,
     IOptions <IdentityOptions> optionsAccessor,
     IPasswordHasher <User> passwordHasher,
     IEnumerable <IUserValidator <User> > userValidators,
     IEnumerable <IPasswordValidator <User> > passwordValidators,
     ILookupNormalizer keyNormalizer,
     IdentityErrorDescriber errors,
     IServiceProvider services,
     ILogger <UserManager <User> > logger,
     IPermissionManager permissionManager,
     IUnitOfWorkManager unitOfWorkManager,
     ICacheManager cacheManager,
     IRepository <OrganizationUnit, long> organizationUnitRepository,
     IRepository <UserOrganizationUnit, long> userOrganizationUnitRepository,
     IOrganizationUnitSettings organizationUnitSettings,
     ISettingManager settingManager)
     : base(
         roleManager,
         store,
         optionsAccessor,
         passwordHasher,
         userValidators,
         passwordValidators,
         keyNormalizer,
         errors,
         services,
         logger,
         permissionManager,
         unitOfWorkManager,
         cacheManager,
         organizationUnitRepository,
         userOrganizationUnitRepository,
         organizationUnitSettings,
         settingManager)
 {
     _unitOfWorkManager = unitOfWorkManager;
     Logger             = NullLogger.Instance;
 }
Example #4
0
        protected void Application_Start()
        {
            DefaultModelBinder.ResourceClassKey = "Messages";
            ValidationExtensions.ResourceClassKey = "Messages";
            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
            // Remove the item that validates fields are numeric!
            ModelValidatorProviders.Providers.Remove(ModelValidatorProviders.Providers.FirstOrDefault(prov => prov.GetType() == typeof(ClientDataTypeModelValidatorProvider)));
            // Add our own of the above with a custom message!
            ModelValidatorProviders.Providers.Add(new CustomDataTypeModelValidatorProvider());
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequeridoAttribute), typeof(RequiredAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RangoAttribute), typeof(RangeAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RegularExpressionAttribute), typeof(RegularExpressionAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LargoCadenaAttribute), typeof(StringLengthAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(LargoCadenaPorDefectoAttribute), typeof(StringLengthAttributeAdapter));
            DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(CorreoAttribute), typeof(EmailAttributeAdapter));

            var binderProvider = new InheritanceAwareModelBinderProvider
                            {
                                { typeof(ICustomBindeableProperties), new CustomBindeablePropertiesModelBinder() },
                                { typeof(DateTime), new DateTimeCurrentCultureModelBinder() },
                                { typeof(DateTime?), new DateTimeCurrentCultureModelBinder() },
                                { typeof(SearchFiltersViewModel), new SearchFiltersModelBinder()}
                            };

            ModelBinderProviders.BinderProviders.Add(binderProvider);

            RegisterGlobalFilters(GlobalFilters.Filters);

            _container = new WindsorContainer();
            _container.AddFacility<TypedFactoryFacility>();
            _container.Install(FromAssembly.This());

            ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(_container));

            DataAnnotationsModelValidatorProviderExtensions.RegisterValidationExtensions();

            _logger = ServiceLocator.Current.GetInstance<ILogger>();
            ServiceLocator.Current.GetInstance<IApplicationInstaller>().Install(
                NHibernateFacility.BuildDatabaseConfiguration());
            ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(_container.Kernel));
            FilterProviders.Providers.Add(new WindsorFilterAttributeFilterProvider(_container));

            //Automapper
            AutoMapperConfiguration.Configure();

            //MetadataProvider
            ModelMetadataProviders.Current = new EnhancedModelMetadataProvider();

            //Cargar la clinica
            CargarClinica();

            RegisterRoutes(RouteTable.Routes);
        }
Example #5
0
 public HelloJob(ILogger logger, IDummy dummy)
 {
     this.logger = logger;
     this.dummy  = dummy;
 }
Example #6
0
 public ReservationService(EDziekanatDbContext context, IMapper mapper, ILogger <ReservationService> logger)
 {
     _context = context;
     _mapper  = mapper;
     _logger  = logger;
 }
Example #7
0
 private void WriteTestLogs(Castle.Core.Logging.ILogger logger)
 {
     logger.Debug("Testing debug");
     logger.Warn("Testing warning");
     logger.Info("Testing info");
 }
Example #8
0
 public SmsService()
 {
     Logger = NullLogger.Instance;
 }
Example #9
0
        /// <summary>
        /// Same as ILogger.Debug, except this automatically prepends calling method's name
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="message"></param>
        public static void D(this Castle.Core.Logging.ILogger logger, string message)
        {
            var method = LogManager.GetMethod();

            logger.Debug(method.Name + ": " + message);
        }
Example #10
0
        /// <summary>
        /// Same as ILogger.Warn, except this automatically prepends calling method's name
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="message"></param>
        public static void W(this Castle.Core.Logging.ILogger logger, string message, Exception exception)
        {
            var method = LogManager.GetMethod();

            logger.Warn(method.Name + ": " + message, exception);
        }