예제 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, FleetManagerContext apiContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();

            try
            {
                using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>()
                                          .CreateScope())
                {
                    Installer.Configure(serviceScope);
                    //serviceScope.ServiceProvider.GetService<ISeedService>().SeedDatabase().Wait();
                }
            }
            catch (System.Exception ex)
            {
                // I'm using Serilog here, but use the logging solution of your choice.
                throw ex;
            }
            // for adding some test data
            //AddTestData(apiContext);
        }
예제 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            App.ChangeUserAgent("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)");
            //App.ChangeUserAgent("Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0; MAMD; BOIE9;DEDE)");
            //Here you can specify the MainForm you want to start.
            Installer.Configure("AutoRobo.Makers.exe");
            //if (DateTime.Now > new DateTime(2013,9,10)) {
            //    MessageBox.Show("您使用的是试用版本,请购买正版");
            //    return;
            //}

            new SingleInstanceController().Run(Environment.GetCommandLineArgs());
        }
예제 #3
0
        private static int Execute(string[] args)
        {
            using (var services = Installer.Configure(args))
            {
                var app = services.GetService <CommandLineApplication <MainCmd> >();

                try
                {
                    app.Configure(services);
                    return(app.Execute(args));
                }
                catch (Exception e)
                {
                    HandleException(e, app);
                    return(Constants.EXIT_CODE_GENERAL_ERROR);
                }
            }
        }
예제 #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseCors("CorsPolicy");


            app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot")),
                RequestPath  = new PathString("/Uploads")
            });

            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseSignalR(routes =>
            {
                routes.MapHub <NotifyHub>("/notify");
            });

            app.UseMvc();

            try
            {
                using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>()
                                          .CreateScope())
                {
                    Installer.Configure(serviceScope);
                    //serviceScope.ServiceProvider.GetService<ISeedService>().SeedDatabase().Wait();
                }
            }
            catch (Exception ex)
            {
                // -------------------------------
                // I'm using Serilog here, but use the logging solution of your choice.
                throw ex;
            }
        }