protected void Application_Start()
        {
            //RouteTable.Routes.MapHubs();

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            FilterConfig.RegisterFilterProviders(FilterProviders.Providers);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            BinderConfig.RegisterBinder(ModelBinders.Binders);
            MapperConfig.RegisterMappers();

            //FluentValidationModelValidatorProvider.Configure(x => x.Add(typeof(GreaterThanValidator), (metadata, context, rule, validator) => new GreaterThanValidatorEx(metadata, context, rule, validator)));
            FluentValidationModelValidatorProvider.Configure();
            //JsConfig.DateHandler = DateHandler.ISO8601;

            // NS.Framework configuration
            MailConfig.DefaultCssCompiler           = html => PreMailer.Net.PreMailer.MoveCssInline(html, true, "#ignore").Html;
            MailConfig.DefaultRazorTemplateLocation = HttpContext.Current.Server.MapPath("~/Content/EmailTemplates");

            ////ScheduleHelper.AlertNoPayment("Subaru_AlertNoPayment", "Subaru_AlertNoPayment");
            //ScheduleHelper.BookingPaymentReminder("Subaru_BookingPaymentReminder", "Subaru_BookingPaymentReminder_1");
            //ScheduleHelper.BookingDailyReport("Subaru_BookingDailyReport", "Subaru_BookingDailyReport_1");
            //ScheduleHelper.AllocationReminder("Subaru_AllocationReminder", "Subaru_AllocationReminder");
            //ScheduleHelper.SetPriceScheduleTrigger("UpdatePriceSchedule", "UpdatePriceSchedule");
            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

            MiniProfilerEF.Initialize();
        }
Exemplo n.º 2
0
 private static void MiniProfilerPreStart()
 {
     MiniProfiler.Settings.SqlFormatter = new MvcMiniProfiler.SqlFormatters.SqlServerFormatter();
     MiniProfilerEF.Initialize();
     DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));
     GlobalFilters.Filters.Add(new ProfilingActionFilter());
 }
Exemplo n.º 3
0
        protected void Application_Start()
        {
            MiniProfilerEF.Initialize();
            //Autofac初始化过程
            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly);//注册所有的Controller
            //开发环境下,使用Stub类
            //builder.RegisterAssemblyTypes(typeof (MvcApplication).Assembly).Where(
            //    t => t.Name.EndsWith("Repository") && t.Name.StartsWith("Stub")).AsImplementedInterfaces();
            //发布环境下,使用真实的数据访问层
            builder.RegisterAssemblyTypes(typeof(MvcApplication).Assembly).AsImplementedInterfaces();

            //注册builder, 实现one context per request
            builder.RegisterType <SchoolContext>().As <DbContext>().InstancePerHttpRequest();
            builder.RegisterType <SchoolContext>().InstancePerHttpRequest();

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            //其它的初始化过程
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            ModelBinders.Binders.Add(typeof(Student), new StudentModelBinder());
        }
Exemplo n.º 4
0
        /// <summary>
        /// The application start event.
        /// </summary>
        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);

            InitProfilerSettings();

            // this is only done for testing purposes so we don't check in the db to source control
            // parameter table is only used in this project for sample queries
            ((SqliteMiniProfilerStorage)MiniProfiler.Settings.Storage).RecreateDatabase("create table RouteHits(RouteName,HitCount,unique(RouteName))");

            var entityFrameworkDataPath = HttpContext.Current.Server.MapPath("~/App_Data/SampleWeb.EFCodeFirst.EFContext.sdf");

            if (File.Exists(entityFrameworkDataPath))
            {
                File.Delete(entityFrameworkDataPath);
            }

            // Setup profiler for Controllers via a Global ActionFilter
            GlobalFilters.Filters.Add(new ProfilingActionFilter());

            // initialize automatic view profiling
            var copy = ViewEngines.Engines.ToList();

            ViewEngines.Engines.Clear();
            foreach (var item in copy)
            {
                ViewEngines.Engines.Add(new ProfilingViewEngine(item));
            }

            MiniProfilerEF.Initialize(false);
        }
Exemplo n.º 5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            //初始化数据库、ioc容器、运行初始化任务等操作
            EngineContext.Initialize(false);

            IContainer container = EngineContext.Current.Container;

            //注册MVC使用的Ioc容器
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            //注入自定义的FluentValidation类型提供工厂
            FluentValidationModelValidatorProvider.Configure(x =>
                                                             x.ValidatorFactory = container.Resolve <IValidatorFactory>());

            //MiniProfiler EF性能监视初始化
            MiniProfilerEF.Initialize();

            //初始化EF数据库
            DbContextInitConfig.DbContextInit(this);

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
Exemplo n.º 6
0
        private static void MiniProfilerPreStart()
        {
#if DEBUG
            MiniProfilerEF.Initialize();
            DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));
            GlobalFilters.Filters.Add(new ProfilingActionFilter());
#endif
        }
Exemplo n.º 7
0
        public static void PreStart()
        {
            MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.SqlServerFormatter();
            MiniProfilerEF.Initialize();

            //Make sure the MiniProfiler handles BeginRequest and EndRequest
            DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));

            //Setup profiler for Controllers via a Global ActionFilter
            GlobalFilters.Filters.Add(new ProfilingActionFilter());
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            MiniProfilerEF.Initialize();
            MiniProfiler.Settings.SqlFormatter = new SqlServerFormatter();
        }
Exemplo n.º 9
0
        private void InitProfilerSettings()
        {
            // some things should never be seen
            var ignored = MiniProfiler.Settings.IgnoredPaths.ToList();

            ignored.Add("WebResource.axd");
            ignored.Add("/Styles/");
            ignored.Add("/bundles/");
            MiniProfiler.Settings.IgnoredPaths = ignored.ToArray();
            MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter();
            MiniProfilerEF.Initialize();
        }
Exemplo n.º 10
0
        protected void Application_Start()
        {
            LogHelper.SetConfig();
            MiniProfilerEF.Initialize();

            //Database.SetInitializer<SMSContext>(new SMSIntializer());
            //Database.SetInitializer(new DropCreateDatabaseAlways<UserDBContext>());
            //Database.SetInitializer<SMSContext>(new DropCreateDatabaseIfModelChanges<SMSContext>());

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            //ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory());
        }
Exemplo n.º 11
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            var copy = ViewEngines.Engines.ToList();

            ViewEngines.Engines.Clear();
            foreach (var item in copy)
            {
                ViewEngines.Engines.Add(new ProfilingViewEngine(item));
            }
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
            MiniProfilerEF.Initialize();
        }
        protected void Application_Start()
        {
            MiniProfilerEF.Initialize();

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
            //var container = new UnityContainer().LoadConfiguration();
            //container.RegisterType<ICustomerRepository, CustomerRepository>();

            //If we want ALL types to go through the unity then we enable this.
            //DependencyResolver.SetResolver(new UnityDependencyResolver(container));
            Bootstrapper.Initialise();

            //Automapper
            Mapper.CreateMap <Customer, CustomerCreateViewModel>();
            Mapper.CreateMap <Customer, CustomerEditViewModel>();
        }
Exemplo n.º 13
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            MiniProfiler.Settings.Results_Authorize      = IsUserAllowedToSeeMiniProfilerUI;
            MiniProfiler.Settings.Results_List_Authorize = IsUserAllowedToSeeMiniProfilerUI;

            MiniProfilerEF.Initialize();

            System.Data.Entity.DbConfiguration.Loaded += (sender, e) =>
                                                         e.ReplaceService <System.Data.Entity.Core.Common.DbProviderServices>(
                (services, o) => EFProfiledSqlClientDbProviderServices.Instance);
        }
Exemplo n.º 14
0
        private void InitProfilerSettings()
        {
            MiniProfilerOptions MiniProfilerOptions = new MiniProfilerOptions
            {
                Storage = new MultiStorageProvider(new MemoryCacheStorage(new TimeSpan(1, 0, 0))),

                PopupRenderPosition  = RenderPosition.Left, // defaults to left
                PopupMaxTracesToShow = 10,                  // defaults to 15

                ResultsAuthorize = request =>
                {
                    if ("/home/resultsauthorization".Equals(request.Url.LocalPath, StringComparison.OrdinalIgnoreCase))
                    {
                        return((request.Url.Query).IndexOf("isauthorized", StringComparison.OrdinalIgnoreCase) >= 0);
                    }

                    return(!DisableProfilingResults);
                },

                ResultsListAuthorize = request =>
                {
                    return(true);
                },

                StackMaxLength           = 256,
                TrackConnectionOpenClose = true
            }

            .ExcludeType("SessionFactory")
            .ExcludeAssembly("NHibernate")
            .ExcludeMethod("Flush");

            MiniProfilerOptions.IgnorePath("/__browserLink"); //Ignore browserLink
            MiniProfilerOptions.ShowControls = true;          // "m" and "c" are displayed on the prompt bar
            MiniProfiler.Configure(MiniProfilerOptions);

            MiniProfilerEF.Initialize();
        }
        public static void PreStart()
        {
            // Be sure to restart you ASP.NET Developement server, this code will not run until you do that.

            //TODO: See - _MINIPROFILER UPDATED Layout.cshtml
            //      For profiling to display in the UI you will have to include the line @MvcMiniProfiler.MiniProfiler.RenderIncludes()
            //      in your master layout

            //TODO: Non SQL Server based installs can use other formatters like: new MvcMiniProfiler.SqlFormatters.InlineFormatter()
            MiniProfiler.Settings.SqlFormatter = new SqlServerFormatter();

            //TODO: To profile a standard DbConnection:
            // var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current);

            //TODO: If you are profiling EF code first try:
            MiniProfilerEF.Initialize();

            //Make sure the MiniProfiler handles BeginRequest and EndRequest
            DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));

            //Setup profiler for Controllers via a Global ActionFilter
            GlobalFilters.Filters.Add(new ProfilingActionFilter());
        }
Exemplo n.º 16
0
        public static void PreStart()
        {
            // Be sure to restart you ASP.NET Developement server, this code will not run until you do that.

            //TODO: See - _MINIPROFILER UPDATED Layout.cshtml
            //      For profiling to display in the UI you will have to include the line @StackExchange.Profiling.MiniProfiler.RenderIncludes()
            //      in your master layout

            //TODO: Non SQL Server based installs can use other formatters like: new StackExchange.Profiling.SqlFormatters.InlineFormatter()
            MiniProfiler.Settings.SqlFormatter = new StackExchange.Profiling.SqlFormatters.SqlServerFormatter();

            //TODO: To profile a standard DbConnection:
            // var profiled = new ProfiledDbConnection(cnn, MiniProfiler.Current);

            //TODO: If you are profiling EF code first try:
            MiniProfilerEF.Initialize();

            //Make sure the MiniProfiler handles BeginRequest and EndRequest
            DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));

            //Setup profiler for Controllers via a Global ActionFilter
            GlobalFilters.Filters.Add(new ProfilingActionFilter());

            // You can use this to check if a request is allowed to view results
            //MiniProfiler.Settings.Results_Authorize = (request) =>
            //{
            // you should implement this if you need to restrict visibility of profiling on a per request basis
            //    return !DisableProfilingResults;
            //};

            // the list of all sessions in the store is restricted by default, you must return true to alllow it
            //MiniProfiler.Settings.Results_List_Authorize = (request) =>
            //{
            // you may implement this if you need to restrict visibility of profiling lists on a per request basis
            //return true; // all requests are kosher
            //};
        }
Exemplo n.º 17
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleTable.EnableOptimizations = true;
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            //*********************************
            //Autofac specific code
            var builder = new ContainerBuilder();

            builder.RegisterType <MemoryCacheProvider>().As <ICacheProvider>().InstancePerLifetimeScope();
            builder.RegisterType <StateRepository>().As <IStateRepository>().InstancePerLifetimeScope();

            builder.RegisterControllers(Assembly.GetExecutingAssembly());

            //Register model binders (if you use them)
            builder.RegisterModelBinders(Assembly.GetExecutingAssembly());

            IContainer container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            //*********************************
            //ViewEngines.Engines.Clear();
            var webFormsViewEngine = ViewEngines.Engines.OfType <WebFormViewEngine>().FirstOrDefault();

            if (webFormsViewEngine != null)
            {
                ViewEngines.Engines.Remove(webFormsViewEngine);
            }

            MiniProfilerEF.Initialize();
        }
Exemplo n.º 18
0
 void Application_Start(object sender, EventArgs e)
 {
     // Code that runs on application startup
     MiniProfilerEF.Initialize();
 }