Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            LoggingHelper.ConfigureLogger();
            if (ConfigManager.GetSetting("FirstRun") == "true")
            {
                FirstTimeInit();
                ConfigManager.UpdateSetting("FirstRun", "false");
            }

            string credentials = ConfigManager.GetSetting("CredentialsPath");

            if (!File.Exists(credentials))
            {
                Logger.Fatal($"No credentials exists at: \"{credentials}\". Cannot proceed");
                InputManager.GetStringInput("Press Enter to exit");
                Environment.Exit(1);
            }

            Logger.Info("Initializing Google Drive API");
            GoogleDriveHandler googleDriveHandler =
                new GoogleDriveHandler(credentials, ConfigManager.GetSetting("TokenPath"));

            Logger.Info("Google Drive Initialized");

            SyncHandler syncHandler = new SyncHandler(googleDriveHandler);

            syncHandler.SyncLoop();
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            //from https://stackify.com/net-core-loggerfactory-use-correctly/
            //call ConfigureLogger in a centralized place in the code
            LoggingHelper.ConfigureLogger(loggerFactory);
            //set it as the primary LoggerFactory to use everywhere
            LoggingHelper.LoggerFactory = loggerFactory;

            app.UseInstrumentationMiddleware();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            using (var scope = app.ApplicationServices.CreateScope())
            {
                var businessLogicSeeder = scope.ServiceProvider.GetService <BusinessLogicDataSeeder>();
                try
                {
                    businessLogicSeeder.Seed();
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Unable execute BusinessLogicSeeder.Seed()", ex);
                }
            }

            if (AppInfoModel.Current.DisableSSL == false)
            {
                app.UseRewriter(new RewriteOptions().AddRedirectToHttps(400, 666));
            }

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Index}/{action=Index}/{id?}");
            });

            AppInfoModel.Current.SetAppInitiCompleteDT();
        }