Example #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
            , DataSeed dataSeed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

            // Seed SuperUser
            dataSeed.CreateSuperUser();

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #2
0
        public void CreateNewFlight(DataSeed ds, int userId)
        {
            var flight = new Flight
            {
                Date     = DateTime.Today,
                Number   = FlightNumber,
                StatusId = (int)Enums.FlightStatus.Open,
                SchoolId = SchoolId
            };

            flight.Id = ds.CreateFlight(flight);
            Flights.Add(flight);
            var lanes2Fights = ds.GetLanes2FlightsByFlightId(SchoolId, flight.Id, userId);

            foreach (var item in lanes2Fights)
            {
                ScannerFlights.Add(new ScannerFlight {
                    FlightId        = flight.Id,
                    FlightNumber    = flight.Number,
                    Flight2LaneId   = item.Id,
                    LaneId          = item.LaneId,
                    LaneStatusId    = item.StatusId,
                    CountCarsInLane = ds.GetCountCardsByLane2FlightId(item.Id)
                });
            }

            FlightNumber++;
        }
Example #3
0
        public void DeleteTables()
        {
            this.StartConnection(Constants.AlessaConnectionString);
            var seed = new DataSeed(this._connection);

            seed.DeleteTables();
        }
Example #4
0
        public static void ConfigureServices(IServiceCollection services)
        {
            _configuration = new ConfigurationBuilder()
                             .SetBasePath(Directory.GetCurrentDirectory())
                             .AddJsonFile("appsettings.json")
                             .Build();

            var connectionString = _configuration.GetConnectionString("AppConnection");

            services.AddDbContext <AppDbContext>(options =>
                                                 options
                                                 .UseLoggerFactory(LoggerFactory.Create(builder => { builder.AddConsole(); }))
                                                 .UseSqlServer(connectionString, b => b.MigrationsAssembly("ORMPerformance")));

            services.Configure <ConnectionStringsOptions>(_configuration.GetSection(ConnectionStringsOptions.ConnectionStrings));
            services.AddAutoMapper(typeof(MappingProfile).GetTypeInfo().Assembly);
            services.AddTransient <AppDbContext, AppDbContext>();
            services.AddTransient <UnitOfWork, UnitOfWork>();
            services.AddTransient <EntityFrameworkPerfomanceTest>();
            services.AddTransient <DapperPerfomanceTest>();
            services.AddTransient <ADONETPerfomanceTest>();


            using (var serviceScope = services.BuildServiceProvider().GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = serviceScope.ServiceProvider.GetService <AppDbContext>())
                {
                    context.Database.Migrate();
                    DataSeed.Seed(context).Wait();
                }
            }
        }
Example #5
0
 public BaseController(ILogger <BaseController> logger, IUserIdentity _userIdentity)
 {
     result       = new BaseResponseModel();
     ds           = new DataSeed(logger);
     _logger      = logger;
     userIdentity = _userIdentity;
 }
Example #6
0
        public IActionResult Seed()
        {
            DataSeed.Seed(dataContext);
            DataSeed.Seed(customerContext);

            return(Ok());
        }
Example #7
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);

            using (var scope = host.Services.CreateScope())
            {
                try
                {
                    var services = scope.ServiceProvider;
                    //var context = services.GetRequiredService<ApplicationDbContext>();
                    //context.Database.Migrate();

                    var config = host.Services.GetRequiredService <IConfiguration>();
                    var tempPW = config[MiscConstants.SEED_TEMP_PW];

                    Console.WriteLine("[Program] tempPW: " + tempPW);
                    DataSeed.Initialize(services, tempPW).Wait();
                }
                catch (Exception ex)
                {
                    Console.Write(ex.StackTrace);
                }
            }
            host.Run();
        }
Example #8
0
        public async Task Patch_Enable(bool enabled, string patchPropertyName, string patchPropertyValue, HttpStatusCode expectedStatusCode, string assertMessage)
        {
            //Arrange
            var toggle = new MongoDbFeatureToggleModel {
                Name = "ft1", Enabled = enabled
            };

            DataSeed.SeedFeatureToggles(new[] { toggle });
            var patchRequest = new PatchFeatureToggleRequest
            {
                Operation = patchPropertyName,
                Value     = patchPropertyValue
            };

            //Act
            var response = await Client.PatchAsync($"{ApiUrl}/{toggle.Id}", CreateHttpContent(new[] { patchRequest }));

            //Assert
            AssertResponse(response, expectedStatusCode);

            var expectedStatusCodeAsInt = (int)expectedStatusCode;
            var isSuccessStatusCode     = expectedStatusCodeAsInt >= 200 && expectedStatusCodeAsInt <= 299;
            var expectedEnabledValue    = isSuccessStatusCode ? !enabled : enabled;

            var models = await GetToggles();

            Assert.AreEqual(1, models.Count);
            var model = models[0];

            Assert.AreEqual(expectedEnabledValue, model.Enabled, assertMessage);
        }
Example #9
0
        public async Task Delete()
        {
            //Arrange
            var toggleToDelete = new MongoDbFeatureToggleModel {
                Name = "ft1", Enabled = true
            };
            var toggleThatRemains = new MongoDbFeatureToggleModel {
                Name = "ft2", Enabled = true
            };

            DataSeed.SeedFeatureToggles(new[] { toggleToDelete, toggleThatRemains });

            //Act
            var response = await Client.DeleteAsync($"{ApiUrl}/{toggleToDelete.Id}");

            //Assert
            AssertNoContentResponse(response);

            var models = await GetToggles();

            Assert.AreEqual(1, models.Count);
            var model = models[0];

            Assert.AreEqual(toggleThatRemains.Id, model.Id);
        }
        protected override void SeedData(ObjectConfigContext context, MockUserProvider userProvider)
        {
            Application app1 = DataSeed.Application1;
            Application app2 = DataSeed.Application2;

            ObjectConfig.Data.User viewer = DataSeed.UserViewer1;
            ObjectConfig.Data.User admin  = DataSeed.UserAdmin1;

            context.UsersApplications.Add(new UsersApplications(viewer, app1, ApplicationRole.Viewer));
            context.UsersApplications.Add(new UsersApplications(userProvider.User, app1, ApplicationRole.Administrator));
            context.UsersApplications.Add(new UsersApplications(userProvider.User, app2, ApplicationRole.Viewer));

            ObjectConfig.Data.Environment env1 = DataSeed.Environment1(app1);
            ObjectConfig.Data.Environment env2 = DataSeed.Environment2(app1);
            ForUpdateEnv = DataSeed.Environment3(app1);

            context.UsersEnvironments.Add(new UsersEnvironments(admin, env1, EnvironmentRole.Editor));
            context.UsersEnvironments.Add(new UsersEnvironments(admin, env2, EnvironmentRole.Editor));
            context.UsersEnvironments.Add(new UsersEnvironments(admin, ForUpdateEnv, EnvironmentRole.Editor));

            context.UsersEnvironments.Add(new UsersEnvironments(userProvider.User, env1, EnvironmentRole.TargetEditor));
            context.UsersEnvironments.Add(new UsersEnvironments(userProvider.User, env2, EnvironmentRole.TargetEditor));
            context.UsersEnvironments.Add(new UsersEnvironments(userProvider.User, ForUpdateEnv, EnvironmentRole.TargetEditor));

            _app2Env1 = DataSeed.Environment1(app2);
            context.UsersEnvironments.Add(new UsersEnvironments(admin, _app2Env1, EnvironmentRole.Editor));
        }
Example #11
0
        public async static Task Main(string[] args)
        {
            // https://github.com/dotnet-architecture/eShopOnWeb/blob/master/src/Web/Program.cs
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services      = scope.ServiceProvider;
                var loggerFactory = services.GetRequiredService <ILoggerFactory>();
                try
                {
                    var applicationDbContext = services.GetRequiredService <ApplicationDbContext>();
                    applicationDbContext.Database.Migrate();

                    var userManager = services.GetRequiredService <UserManager <AppUser> >();
                    var roleManager = services.GetRequiredService <RoleManager <IdentityRole> >();
                    await DataSeed.SeedUsersAndRolesAsync(userManager, roleManager);

                    await DataSeed.SeedSampleExamAsync(applicationDbContext, userManager);
                }
                catch (Exception ex)
                {
                    var logger = loggerFactory.CreateLogger <Program>();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }

            host.Run();
        }
Example #12
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RoleManager <IdentityRole> roleManager, UserManager <User> userManager, LibraryDbContext _context)
        {
            app.UseCors(options => options.AllowAnyOrigin()
                        .AllowAnyHeader().AllowAnyMethod());

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

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

            app.UseSwagger();
            app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "LibraryAPI-v1"));

            DataSeed.SeedRoles(roleManager); // Add roles
            DataSeed.SeedAdmin(userManager); // Add one user - admin [login: [email protected], password: Admin!23]
            DataSeed.SeedBooks(_context);
            DataSeed.SeedAuthors(_context);
            DataSeed.SeedBookAuthor(_context);
        }
Example #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataSeed seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            Thread.Sleep(10000);
            seeder.SeedData();

            app.UseCors("MyPolicy");

            app.UseOpenApi();
            app.UseSwaggerUi3();

            //app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #14
0
    public async Task InitializeAsync(bool removeFirst = false, bool initializeDatabaseWithTestData = false, CancellationToken cancel = default)
    {
        try
        {
            if (removeFirst)
            {
                await DeleteAsync(cancel).ConfigureAwait(false);
            }

            var pendingMigrations = await _db.Database.GetPendingMigrationsAsync(cancel).ConfigureAwait(false);

            if (pendingMigrations.Any())
            {
                _logger.LogInformation("Database migration is in progress...");
                await _db.Database.MigrateAsync(cancel).ConfigureAwait(false);

                _logger.LogInformation("Database migration is completed");
            }

            if (initializeDatabaseWithTestData)
            {
                await DataSeed.SeedDataAsync(_db, _userManager, cancel).ConfigureAwait(false);
            }
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Database initialization error");
            throw;
        }
    }
Example #15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              UserManager <ApplicationUser> userManager,
                              RoleManager <IdentityRole> roleManager)
        {
            DataSeed.SeedData(userManager, roleManager);
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "web_final v1"));
            }

            // app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Example #16
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            // DB migrations and Data seeding
            using (var scope = host.Services.CreateScope())
            {
                var serviceProvider = scope.ServiceProvider;

                var hostingEnv = serviceProvider.GetRequiredService <IWebHostEnvironment>();

                using (var context = serviceProvider.GetRequiredService <DfESurveyToolDbContext>())
                {
                    context.Database.Migrate();

                    await DataSeed.AddRequiredData(context);

                    if (hostingEnv.IsDevelopment())
                    {
                        await DataSeed.AddData(context);
                    }
                }
            }

            host.Run();
        }
        //for classroom and dismissalTeacher role
        public async Task SetClassroomTeacher(int userId, string scId)
        {
            //needs to add implimintation for superAdmin -> schoolId

            int schoolId = 0;

            using (var ds = new DataSeed())
            {
                schoolId = Convert.ToInt32(ds.GetUserSchoolId(userId));
            };

            var currentUser = Users.Where(p => p.ConnectionId == Context.ConnectionId).FirstOrDefault();

            if (currentUser == null)
            {
                currentUser = new UserSignalR {
                    ConnectionId = Context.ConnectionId, SchoolId = Convert.ToInt32(schoolId), UserId = userId, Role = HubRole.Teacher
                };
                Users.Add(currentUser);
            }
            else
            {
                currentUser.SchoolId = Convert.ToInt32(schoolId);
                currentUser.UserId   = userId;
                currentUser.Role     = HubRole.Teacher;
            }

            await Groups.AddAsync(Context.ConnectionId, currentUser.UserGroup);

            // await this.Clients.Client(currentUser.ConnectionId).InvokeAsync("SetClassroomTeacher", currentUser);
        }
Example #18
0
 public static void SeedClients(this IApplicationBuilder app)
 {
     using (var scope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
     {
         DataSeed.SeedClients(scope.ServiceProvider).ConfigureAwait(false).GetAwaiter().GetResult();
     }
 }
Example #19
0
        public static void Main(string[] args)
        {
            var globalsInstance = Globals.GetInstance();

            var abi = @"[{'constant':true,'inputs':[],'name':'name','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':false,'inputs':[{'name':'_spender','type':'address'},{'name':'_value','type':'uint256'}],'name':'approve','outputs':[{'name':'','type':'bool'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':true,'inputs':[],'name':'totalSupply','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':false,'inputs':[{'name':'_from','type':'address'},{'name':'_to','type':'address'},{'name':'_value','type':'uint256'}],'name':'transferFrom','outputs':[{'name':'','type':'bool'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':true,'inputs':[],'name':'INITIAL_SUPPLY','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'decimals','outputs':[{'name':'','type':'uint8'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':false,'inputs':[{'name':'_spender','type':'address'},{'name':'_subtractedValue','type':'uint256'}],'name':'decreaseApproval','outputs':[{'name':'','type':'bool'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':true,'inputs':[{'name':'_owner','type':'address'}],'name':'balanceOf','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':false,'inputs':[],'name':'renounceOwnership','outputs':[],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':true,'inputs':[{'name':'','type':'uint256'}],'name':'payments','outputs':[{'name':'Customer','type':'address'},{'name':'Driver','type':'address'},{'name':'value','type':'uint256'},{'name':'status','type':'uint8'},{'name':'refundApproved','type':'bool'},{'name':'isValue','type':'bool'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'owner','outputs':[{'name':'','type':'address'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':true,'inputs':[],'name':'symbol','outputs':[{'name':'','type':'string'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':false,'inputs':[{'name':'_to','type':'address'},{'name':'_value','type':'uint256'}],'name':'transfer','outputs':[{'name':'','type':'bool'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[{'name':'_spender','type':'address'},{'name':'_addedValue','type':'uint256'}],'name':'increaseApproval','outputs':[{'name':'','type':'bool'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':true,'inputs':[{'name':'_owner','type':'address'},{'name':'_spender','type':'address'}],'name':'allowance','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'view','type':'function'},{'constant':false,'inputs':[{'name':'_newOwner','type':'address'}],'name':'transferOwnership','outputs':[],'payable':false,'stateMutability':'nonpayable','type':'function'},{'inputs':[],'payable':false,'stateMutability':'nonpayable','type':'constructor'},{'payable':true,'stateMutability':'payable','type':'fallback'},{'anonymous':false,'inputs':[{'indexed':true,'name':'owner','type':'address'},{'indexed':true,'name':'spender','type':'address'},{'indexed':false,'name':'value','type':'uint256'}],'name':'Approval','type':'event'},{'anonymous':false,'inputs':[{'indexed':true,'name':'from','type':'address'},{'indexed':true,'name':'to','type':'address'},{'indexed':false,'name':'value','type':'uint256'}],'name':'Transfer','type':'event'},{'anonymous':false,'inputs':[{'indexed':true,'name':'previousOwner','type':'address'}],'name':'OwnershipRenounced','type':'event'},{'anonymous':false,'inputs':[{'indexed':true,'name':'previousOwner','type':'address'},{'indexed':true,'name':'newOwner','type':'address'}],'name':'OwnershipTransferred','type':'event'},{'constant':false,'inputs':[{'name':'_newComission','type':'uint256'}],'name':'setComission','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[{'name':'_orderId','type':'uint256'},{'name':'_value','type':'uint256'}],'name':'createPayment','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[{'name':'_orderId','type':'uint256'}],'name':'getOrder','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[{'name':'_orderId','type':'uint256'}],'name':'completeOrder','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[{'name':'_orderId','type':'uint256'}],'name':'refund','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[{'name':'_orderId','type':'uint256'}],'name':'disApproveRefund','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[{'name':'_orderId','type':'uint256'}],'name':'approveRefund','outputs':[{'name':'','type':'uint256'}],'payable':false,'stateMutability':'nonpayable','type':'function'},{'constant':false,'inputs':[],'name':'deposit','outputs':[],'payable':true,'stateMutability':'payable','type':'function'},{'constant':false,'inputs':[{'name':'receiver','type':'address'},{'name':'amount','type':'uint256'}],'name':'sendFunds','outputs':[],'payable':false,'stateMutability':'nonpayable','type':'function'}]";

            var byteCode = @"0x60806040526040805190810160405280600881526020017f54617869436f696e00000000000000000000000000000000000000000000000081525060049080519060200190620000519291906200016b565b506040805190810160405280600381526020017f5458430000000000000000000000000000000000000000000000000000000000815250600590805190602001906200009f9291906200016b565b506000600660006101000a81548160ff021916908360ff1602179055506201d4c06007556000600855348015620000d557600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600754600281905550600754600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506200021a565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001ae57805160ff1916838001178555620001df565b82800160010185558215620001df579182015b82811115620001de578251825591602001919060010190620001c1565b5b509050620001ee9190620001f2565b5090565b6200021791905b8082111562000213576000816000905550600101620001f9565b5090565b90565b612ac2806200022a6000396000f300608060405260043610610149576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610153578063080bee44146101e3578063095ea7b3146102245780630be80f391461028957806318160ddd146102ca57806323b872dd146102f5578063278ecde11461037a5780632ff2e9dc146103bb578063313ce567146103e6578063348a71a61461041757806366188463146104585780636f64234e146104bd57806370a082311461050a578063715018a61461056157806387d81789146105785780638da5cb5b1461064a57806395d89b41146106a1578063a6e7ed7a14610731578063a9059cbb1461077c578063b6adaaff146107e1578063d09ef24114610822578063d0e30db014610863578063d73dd6231461086d578063dd62ed3e146108d2578063f2fde38b14610949575b61015161098c565b005b34801561015f57600080fd5b506101686109db565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101a857808201518184015260208101905061018d565b50505050905090810190601f1680156101d55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101ef57600080fd5b5061020e60048036038101908080359060200190929190505050610a79565b6040518082815260200191505060405180910390f35b34801561023057600080fd5b5061026f600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610ceb565b604051808215151515815260200191505060405180910390f35b34801561029557600080fd5b506102b460048036038101908080359060200190929190505050610ddd565b6040518082815260200191505060405180910390f35b3480156102d657600080fd5b506102df610e69565b6040518082815260200191505060405180910390f35b34801561030157600080fd5b50610360600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610e73565b604051808215151515815260200191505060405180910390f35b34801561038657600080fd5b506103a560048036038101908080359060200190929190505050611232565b6040518082815260200191505060405180910390f35b3480156103c757600080fd5b506103d061154c565b6040518082815260200191505060405180910390f35b3480156103f257600080fd5b506103fb611552565b604051808260ff1660ff16815260200191505060405180910390f35b34801561042357600080fd5b5061044260048036038101908080359060200190929190505050611565565b6040518082815260200191505060405180910390f35b34801561046457600080fd5b506104a3600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506117f4565b604051808215151515815260200191505060405180910390f35b3480156104c957600080fd5b50610508600480360381019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611a85565b005b34801561051657600080fd5b5061054b600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050611b2b565b6040518082815260200191505060405180910390f35b34801561056d57600080fd5b50610576611b74565b005b34801561058457600080fd5b506105a360048036038101908080359060200190929190505050611c76565b604051808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815260200184600381111561061d57fe5b60ff1681526020018315151515815260200182151515158152602001965050505050505060405180910390f35b34801561065657600080fd5b5061065f611d19565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156106ad57600080fd5b506106b6611d3e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156106f65780820151818401526020810190506106db565b50505050905090810190601f1680156107235780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561073d57600080fd5b506107666004803603810190808035906020019092919080359060200190929190505050611ddc565b6040518082815260200191505060405180910390f35b34801561078857600080fd5b506107c7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506120b0565b604051808215151515815260200191505060405180910390f35b3480156107ed57600080fd5b5061080c600480360381019080803590602001909291905050506122d4565b6040518082815260200191505060405180910390f35b34801561082e57600080fd5b5061084d60048036038101908080359060200190929190505050612542565b6040518082815260200191505060405180910390f35b61086b61098c565b005b34801561087957600080fd5b506108b8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061267d565b604051808215151515815260200191505060405180910390f35b3480156108de57600080fd5b50610933600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612879565b6040518082815260200191505060405180910390f35b34801561095557600080fd5b5061098a600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612900565b005b34600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550565b60048054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a715780601f10610a4657610100808354040283529160200191610a71565b820191906000526020600020905b815481529060010190602001808311610a5457829003601f168201915b505050505081565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ad757600080fd5b600960008481526020019081526020016000209050600015158160030160019054906101000a900460ff161515141515610b1057600080fd5b60026003811115610b1d57fe5b8160030160009054906101000a900460ff166003811115610b3a57fe5b141515610b4657600080fd5b8060020154600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515610bb957600080fd5b8060020154600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508060020154600160008360010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060018160030160006101000a81548160ff02191690836003811115610cc157fe5b02179055508060030160009054906101000a900460ff166003811115610ce357fe5b915050919050565b600081600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610e3a57600080fd5b606482101515610e4957600080fd5b600082111515610e5857600080fd5b816008819055506008549050919050565b6000600254905090565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614151515610eb057600080fd5b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610efe57600080fd5b600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211151515610f8957600080fd5b610fdb82600160008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461296790919063ffffffff16565b600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061107082600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298090919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061114282600360008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461296790919063ffffffff16565b600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b6000806009600084815260200190815260200160002090506000600381111561125757fe5b8160030160009054906101000a900460ff16600381111561127457fe5b14806112a6575060038081111561128757fe5b8160030160009054906101000a900460ff1660038111156112a457fe5b145b15156112b157600080fd5b3373ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561130f57600080fd5b6000600381111561131c57fe5b8160030160009054906101000a900460ff16600381111561133957fe5b1415611500578060020154600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156113b257600080fd5b8060020154600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508060020154600160008360000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060018160030160016101000a81548160ff02191690831515021790555060018160030160006101000a81548160ff021916908360038111156114d757fe5b02179055508060030160009054906101000a900460ff1660038111156114f957fe5b9150611546565b60028160030160006101000a81548160ff0219169083600381111561152157fe5b02179055508060030160009054906101000a900460ff16600381111561154357fe5b91505b50919050565b60075481565b600660009054906101000a900460ff1681565b6000806000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156115c357600080fd5b600960008481526020019081526020016000209050600015158160030160019054906101000a900460ff1615151415156115fc57600080fd5b6002600381111561160957fe5b8160030160009054906101000a900460ff16600381111561162657fe5b14151561163257600080fd5b8060020154600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156116a557600080fd5b8060020154600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508060020154600160008360000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060018160030160016101000a81548160ff02191690831515021790555060018160030160006101000a81548160ff021916908360038111156117ca57fe5b02179055508060030160009054906101000a900460ff1660038111156117ec57fe5b915050919050565b600080600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905080831115611905576000600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550611999565b611918838261296790919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a3600191505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611ae057600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015611b26573d6000803e3d6000fd5b505050565b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611bcf57600080fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482060405160405180910390a260008060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b60096020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020154908060030160009054906101000a900460ff16908060030160019054906101000a900460ff16908060030160029054906101000a900460ff16905086565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60058054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611dd45780601f10611da957610100808354040283529160200191611dd4565b820191906000526020600020905b815481529060010190602001808311611db757829003601f168201915b505050505081565b60006009600084815260200190815260200160002060030160029054906101000a900460ff16151515611e0e57600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515611e5c57600080fd5b81600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060c0604051908101604052803373ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200183815260200160006003811115611f6f57fe5b8152602001600015158152602001600115158152506009600085815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506040820151816002015560608201518160030160006101000a81548160ff0219169083600381111561205357fe5b021790555060808201518160030160016101000a81548160ff02191690831515021790555060a08201518160030160026101000a81548160ff021916908315150217905550905050600060038111156120a857fe5b905092915050565b60008073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16141515156120ed57600080fd5b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054821115151561213b57600080fd5b61218d82600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461296790919063ffffffff16565b600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061222282600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298090919063ffffffff16565b600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b60008060006009600085815260200190815260200160002091503373ffffffffffffffffffffffffffffffffffffffff168260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614151561234c57600080fd5b60038081111561235857fe5b8260030160009054906101000a900460ff16600381111561237557fe5b14151561238157600080fd5b8160020154600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101515156123f457600080fd5b606460085483600201540281151561240857fe5b04905080826002015403600160008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555080826002015403600160008460010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060018260030160006101000a81548160ff0219169083600381111561251757fe5b02179055508160030160009054906101000a900460ff16600381111561253957fe5b92505050919050565b600080600960008481526020019081526020016000209050600073ffffffffffffffffffffffffffffffffffffffff168160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156125b957600080fd5b600060038111156125c657fe5b8160030160009054906101000a900460ff1660038111156125e357fe5b1415156125ef57600080fd5b60038160030160006101000a81548160ff0219169083600381111561261057fe5b0217905550338160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060030160009054906101000a900460ff16600381111561267557fe5b915050919050565b600061270e82600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461298090919063ffffffff16565b600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925600360003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546040518082815260200191505060405180910390a36001905092915050565b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561295b57600080fd5b6129648161299c565b50565b600082821115151561297557fe5b818303905092915050565b6000818301905082811015151561299357fe5b80905092915050565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515156129d857600080fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550505600a165627a7a72305820387ad0f585e9085f90837efc849614edcf0daa8081b0d4a831ff290dff7fcd0e0029";

            globalsInstance.ContractFunctions = new ContractFunctions(abi, byteCode);

            var res = Deploy.GetApiFromContractAddress(new DeployControllerPattern()
            {
                Address = "0xebbfeb4242b3710057304fcb3a762aac5913a448"
            });
            //var res = Deploy.DeployContract(new DefaultControllerPattern() { Gas = 4000000 }, new User() { PrivateKey = "90467FCD1A14CEE777EF5D86FE1947BC48171F78D41395CCA9CF5C1189EA6E08" }).Result;

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

            using (var scope = host.Services.CreateScope())
            {
                var serviceProvider = scope.ServiceProvider;
                try
                {
                    var userManager = serviceProvider.
                                      GetRequiredService <UserManager <AppUser> >();

                    DataSeed.Initialize(serviceProvider, userManager);
                }
                catch
                {
                }
            }
            host.Run();
        }
Example #20
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

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

            seed.SeedData();
        }
Example #21
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataSeed seed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            var option = new RewriteOptions();

            option.AddRedirect("^$", "swagger");
            app.UseRewriter(option);

            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
            app.UseOpenApi();
            app.UseSwaggerUi3(c => {
                c.SwaggerRoutes.Add(new SwaggerUi3Route("v1", "swagger/apidocs/swagger.json"));
            });

            //seed.InitializeData().Wait();
        }
Example #22
0
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationContext applicationContext, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     else
     {
         applicationContext.Database.Migrate();
         app.UseHsts();
         app.UseForwardedHeaders(new ForwardedHeadersOptions
         {
             ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
         });
     }
     app.UseHttpsRedirection();
     app.UseAuthentication();
     DataSeed.SeedDefaultDatas(roleManager, userManager);
     app.UseStaticFiles();
     app.UseSwagger();
     app.UseSwaggerUI(c =>
     {
         c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1");
     });
     app.UseFileServer();
     app.UseSignalR(routes =>
     {
         routes.MapHub <GameHub>("/game");
     });
     app.UseMvc();
 }
Example #23
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeed seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // a global middleware pipline handles errors
                app.UseExceptionHandler(builder =>
                                        builder.Run(async context => {
                    context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;

                    var error = context.Features.Get <IExceptionHandlerFeature>();

                    if (error != null)
                    {
                        // add error info to header
                        context.Response.AddErrorToHeader(error.Error.Message);
                        await context.Response.WriteAsync(error.Error.Message);
                    }
                })
                                        );
                // app.UseHsts();
            }

            // app.UseHttpsRedirection();
            // seeder.SeedUsers();
            // service http cors policy
            app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            app.UseAuthentication();
            app.UseMvc(); // go to controller folder, find the right routes based on request
        }
        public async Task Consumer()
        {
            var firstArticle = DataSeed.GetFirstArticle();

            _mockProviderService
            .Given("Existing article id")
            .UponReceiving("Valid GET Article")
            .With(new ProviderServiceRequest
            {
                Method = HttpVerb.Get,
                Path   = _path,
            })
            .WillRespondWith(new ProviderServiceResponse
            {
                Status  = (int)HttpStatusCode.OK,
                Headers = new Dictionary <string, object> {
                    { "Content-Type", "application/json; charset=utf-8" }
                },
                Body = firstArticle
            });

            var result = await _consumerPactClassFixture.GetAsync(_path);

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            JsonSerializer.Deserialize <Article>(await result.Content.ReadAsStringAsync());
        }
Example #25
0
        protected override void SeedData(ObjectConfigContext context, MockUserProvider userProvider)
        {
            Application app1   = DataSeed.Application1;
            Application app2   = DataSeed.Application2;
            User        viewer = DataSeed.UserViewer1;
            User        admin  = DataSeed.UserAdmin1;

            context.UsersApplications.Add(new UsersApplications(viewer, app1, ApplicationRole.Viewer));
            context.UsersApplications.Add(new UsersApplications(userProvider.User, app1,
                                                                ApplicationRole.Administrator));
            context.UsersApplications.Add(new UsersApplications(userProvider.User, app2, ApplicationRole.Viewer));

            _env1 = DataSeed.Environment1(app1);
            _env2 = DataSeed.Environment2(app1);

            context.UsersEnvironments.Add(new UsersEnvironments(admin, _env1, EnvironmentRole.Editor));
            context.UsersEnvironments.Add(new UsersEnvironments(admin, _env2, EnvironmentRole.Editor));

            context.UsersEnvironments.Add(new UsersEnvironments(userProvider.User, _env1, EnvironmentRole.TargetEditor));
            context.UsersEnvironments.Add(new UsersEnvironments(userProvider.User, _env2, EnvironmentRole.Editor));

            _env1.CreateConfig("conf1");
            _env1.CreateConfig("conf2");
            _env1.CreateConfig("conf3");
        }
Example #26
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext applicationDbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

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

            applicationDbContext.Database.Migrate();

            DataSeed.Seed(app.ApplicationServices).Wait();
        }
Example #27
0
        //by laneId
        private ScannedStudent AddStudentToLane(DataSeed ds, Dismissal dismissal, int laneId, ScannedStudent scannedStudent)
        {
            var lane2FlightObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);

            lane2FlightObj = CheckIsLane(ds, dismissal.UserId, laneId, lane2FlightObj);
            //check isLanefull
            if (CountCarInLane(ds, dismissal.UserId, lane2FlightObj, scannedStudent.ParentLicense))
            {
                lane2FlightObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);
            }

            if (ds.IsCarExistInPrevLane(lane2FlightObj.Flight2LaneId, scannedStudent.ParentLicense))
            {
                lane2FlightObj.CountCarsInLane -= 1;
            }

            dismissal.FlightLaneId          = lane2FlightObj.Flight2LaneId;
            scannedStudent.FlightNumber     = lane2FlightObj.FlightNumber;
            scannedStudent.FligthId         = lane2FlightObj.FlightId;
            lane2FlightObj.CountCarsInLane += 1;
            dismissal.CarNumber             = lane2FlightObj.CountCarsInLane;
            scannedStudent.CardId           = ds.AddStudentToDismissal(dismissal);
            if (scannedStudent.CardId == 0)
            {
                lane2FlightObj.CountCarsInLane -= 1;
                Status = "Barcode did not save. Please, try to scanne again!";
                return(null);
            }
            scannedStudent.Lane = Lanes.Where(p => p.Id == lane2FlightObj.LaneId).FirstOrDefault();

            return(scannedStudent);
        }
Example #28
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, DataSeed dataSeed)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            //Seed Database
            //dataSeed.SeedSuperUser();

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #29
0
        public void SeedTestData()
        {
            this.StartConnection(Constants.AlessaConnectionString);
            var seed = new DataSeed(this._connection);

            seed.SeedAllTables();
        }
Example #30
0
        public async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lblInfoStatus.Text = "Підключаємося до БД-----";
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            await Task.Run(() =>
            {
                _context.Cats.Count(); //jніціалуємо підклчюення
            });

            stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                               ts.Hours, ts.Minutes, ts.Seconds,
                                               ts.Milliseconds / 10);

            //Debug.WriteLine("Сідер 1 закінчив свою роботу: " + elapsedTime);
            lblCursorPosition.Text = elapsedTime;
            lblInfoStatus.Text     = "Підключення до БД успішно";

            await DataSeed.SeedDataAsync(_context);

            stopWatch = new Stopwatch();
            stopWatch.Start();
            var list = _context.Cats.AsQueryable()//.AsParallel()
                       .Select(x => new CatVM()
            {
                Name     = x.Name,
                Birthday = x.Birthday,
                Details  = x.Details,
                ImageUrl = x.Image,
                Price    = x.AppCatPrices
                           .OrderByDescending(x => x.DateCreate)
                           .FirstOrDefault().Price
            })
                       .OrderBy(x => x.Name)
                       .Skip(0)
                       .Take(20)
                       .ToList();

            stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                        ts.Hours, ts.Minutes, ts.Seconds,
                                        ts.Milliseconds / 10);
            //Debug.WriteLine("Сідер 1 закінчив свою роботу: " + elapsedTime);
            lblCursorPosition.Text = elapsedTime;
            lblInfoStatus.Text     = "Читання даних із БД успішно";

            _cats = new ObservableCollection <CatVM>(list);
            dgSimple.ItemsSource = _cats;
        }