Exemple #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, ReservasContext context, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            InicializaBD.Initialize(context);

            app.UseCors((cfg) => {
                cfg.AllowAnyHeader();
                cfg.AllowAnyOrigin();
                cfg.AllowAnyMethod();
            });
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            // Serve my app-specific default file, if present.
            DefaultFilesOptions options = new DefaultFilesOptions();

            options.DefaultFileNames.Clear();
            options.DefaultFileNames.Add("index.html");
            app.UseDefaultFiles(options);
            app.UseStaticFiles();


            //app.UseCors("AllowAllHeaders");
            app.UseMvc();
        }
Exemple #2
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CidadesContexto contexto)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Cidades}/{action=Index}/{id?}");
            });

            InicializaBD.Initialize(contexto);
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            IConfigurationRoot configuration = new
                                               ConfigurationBuilder().AddJsonFile("appsettings.json",
                                                                                  optional: false, reloadOnChange: true).Build();

            Log.Logger = new LoggerConfiguration().ReadFrom.Configuration
                             (configuration).CreateLogger();

            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    InicializaBD.Initialize(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "Ocorreu um erro ao povoar a base de dados");
                }
            }

            host.Run();
        }
Exemple #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, Context contexto, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();

            //ENABLING MIDDLEWARE FOR USE BY SWAGGER
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json",
                                  "Teste Acesso");
            });

            InicializaBD.Initialize(contexto);

            //SERILOG
            loggerFactory.AddSerilog();
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, BTContexto contexto)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();
            app.UseSwagger();
            app.UseSwaggerUI(c => {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "businesstechapi V1");
            });
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });


            InicializaBD.Initialize(contexto);
        }
Exemple #6
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, EntidadesContexto contexto)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug( );

            if (env.IsDevelopment( ))
            {
                app.UseDeveloperExceptionPage( );
                app.UseBrowserLink( );
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles( );

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

            /*
             * GLPKInput teste = new GLPKInput( );
             *
             * teste.Variables.Add( "x" );
             * teste.Variables.Add( "y" );
             *
             * GLPKRestriction r1 = new GLPKRestriction( );
             * r1.Values.Add( 10 );
             * r1.Values.Add( 20 );
             * r1.Operation = GLPKRestriction.Operator.GreaterOrEqual;
             * r1.Disponibility = 2;
             *
             * GLPKRestriction r2 = new GLPKRestriction( );
             * r2.Values.Add( 40 );
             * r2.Values.Add( 60 );
             * r2.Operation = GLPKRestriction.Operator.GreaterOrEqual;
             * r2.Disponibility = 64;
             *
             * GLPKRestriction r3 = new GLPKRestriction( );
             * r3.Values.Add( 50 );
             * r3.Values.Add( 20 );
             * r3.Operation = GLPKRestriction.Operator.GreaterOrEqual;
             * r3.Disponibility = 34;
             *
             * teste.Restrictions.Add( r1 );
             * teste.Restrictions.Add( r2 );
             * teste.Restrictions.Add( r3 );
             *
             * teste.Objective.Values.Add( 0.6 );
             * teste.Objective.Values.Add( 0.8 );
             *
             * var hy = JsonConvert.SerializeObject( teste );
             * Console.Write( hy );*/

            //string path = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.User) + ";" + Directory.GetCurrentDirectory();
            //Environment.SetEnvironmentVariable("Path", path, EnvironmentVariableTarget.User);

            //var model = new Model();
            //var x = new Variable("x");
            //var y = new Variable("y");
            //model.AddConstraint(10 * x + 20 * y >= 2);
            //model.AddConstraint(40 * x + 60 * y >= 64);
            //model.AddConstraint(50 * x + 20 * y >= 34);
            //model.AddObjective(new Objective(0.6 * x + 0.8 * y));

            //var solver = new GLPKSolver();
            //solver.Solve(model);
            //var solution = solver.Solve(model);


            InicializaBD.Initialize(contexto);
        }