Exemplo n.º 1
0
        public Avatar GetAvatarById(int id)
        {
            var avatarList = DBInit.GetAllAvatars();
            var avatar     = avatarList.Find(x => x.Id == id);

            return(avatar);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                loggerFactory.AddFile("Logs/FAQLog.txt");
                DBInit.Initialize(app);
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseRouting();

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

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseReactDevelopmentServer(npmScript: "start");
                }
            });
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IAvatarRepository, AvatarRepo>();
            serviceCollection.AddScoped <IAvatarService, AvatarService>();
            serviceCollection.AddScoped <IPrinter, Printer>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var avatarRepo      = serviceProvider.GetRequiredService <IAvatarRepository>();
            var Printer         = serviceProvider.GetRequiredService <IPrinter>();

            new DBInit(avatarRepo).InitData();



            IAvatarRepository aRepo = new AvatarRepo();

            DBInit db = new DBInit(aRepo);

            db.InitData(); // Mock data
            IAvatarService aService = new AvatarService(aRepo);
            IPrinter       print    = new Printer(aService);

            Console.WriteLine("Hello fellow Seven Deadly Sins maniac!");

            Console.WriteLine("Welcome to SDS\nBegin your adventure by choosing an option in the menu");
            print.StartUI();
        }
Exemplo n.º 4
0
        public AvatarType GetTypeById(int id)
        {
            var typeList   = DBInit.GetAvatarTypes();
            var avatarType = typeList.Find(x => x.Id == id);

            return(avatarType);
        }
Exemplo n.º 5
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();
                using (var scope = app.ApplicationServices.CreateScope())
                {
                    var ctx = scope.ServiceProvider.GetService <PetShopContext>();
                    ctx.Database.EnsureDeleted();
                    ctx.Database.EnsureCreated();
                    DBInit.StartUp(ctx);
                }
            }
            else
            {
                app.UseDeveloperExceptionPage();
                using (var scope = app.ApplicationServices.CreateScope())
                {
                    var ctx = scope.ServiceProvider.GetService <PetShopContext>();
                    ctx.Database.EnsureCreated();
                }
                app.UseHsts();
            }

            app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            app.UseHttpsRedirection();
            app.UseAuthentication();
            app.UseMvc();
        }
Exemplo n.º 6
0
        private void OnStarted()
        {
            var dbInit = new DBInit(Configuration);

            dbInit.InitializeUserRoles();
            dbInit.CreateSuperAdmin();
        }
Exemplo n.º 7
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, DBContext context)
        {
            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=Cars}/{action=Index}/{id?}");
            });

            //Runs DB initialisation, checking if it exists, else creating it and adding content
            DBInit.Init(context);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 抓取
        /// </summary>
        public static void Handler(Action <List <Category> > action = null)
        {
            //  Console.WriteLine("请输入Y/N进行类别表初始化确认! Y 删除Category表然后重新创建,然后抓取类型数据,N(或者其他)跳过");
            //string input = Console.ReadLine();
            //if (input.Equals("Y", StringComparison.OrdinalIgnoreCase))
            {
                DBInit.InitCategoryTable(sourcename);
                CrawlerCategory(action);
            }
            //else
            //{
            //    Console.WriteLine("你选择不初始化类别数据");
            //}
            //Console.WriteLine("*****************^_^**********************");



            // Console.WriteLine("请输入Y/N进行商品数据初始化确认! Y 删除全部商品表表然后重新创建,然后抓取商品数据,N(或者其他)跳过");
            //input = Console.ReadLine();
            //if (input.Equals("Y", StringComparison.OrdinalIgnoreCase))
            {
                DBInit.InitCommodityTable(sourcename);
                CrawlerCommodity();
            }
            Console.WriteLine("*****************^_^**********************");
        }
Exemplo n.º 9
0
        public void Init()
        {
            IoC.InitializeWith(new WindsorContainer());
            ApplicationInit.InitializeRepositories();
            base.SetUp();
            DBInit.RegisterDocumentStore(Store);
            using (var tran = RepositoryFactory.StartTransaction())
            {
                _setting1 = new AppSetting
                {
                    Id    = "setting1",
                    Value = "val1"
                };
                _setting2 = new AppSetting
                {
                    Id    = "setting2",
                    Value = "val2"
                };
                _emptySetting = new AppSetting
                {
                    Id    = "empty_setting",
                    Value = null
                };

                SessionFactory <AppSetting> .Store(_setting1);

                SessionFactory <AppSetting> .Store(_setting2);

                SessionFactory <AppSetting> .Store(_emptySetting);

                tran.Commit();
                var items = SessionFactory <AppSetting> .FindAll();
            }
        }
Exemplo n.º 10
0
        public Owner GetOwnerById(int id)
        {
            var ownerList = DBInit.GetOwners();
            var owner     = ownerList.Find(x => x.Id == id);

            return(owner);
        }
        public PatientMedicationPageViewModel()
        {
            var db = new DBInit();

            ptdetails = db.GetDetails();
            Debug.WriteLine("Debug string split: ");
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            /**
             * env: environment.
             * Setningen under er kommentert ut.
             * DBInit.Initialize(app). App kommer fra grensesnittet over (IApplica....)
             * Vi kunne godt ha gjort utenfor metoden if-setningen, men det betyr at hvis
             * vi switcher ofer til produksjonsmodus, s? kan man unng? ? initialisere
             * databasen, mens hvis vi legger den utenfor if (DBInit.Ini...), s?
             * vil vi kj?re den bestandig. Hvis vi kj?rer appen og f?r med DBInit..
             * s? f?r vi inn de initializerte kundene standard inn i appen.
             **/
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                DBInit.Initialize(app); // denne m? fjernes dersom vi vil beholde dataene i databasen og ikke initialisere
            }

            app.UseRouting();

            app.UseStaticFiles();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Exemplo n.º 13
0
 private static void InitializeMigrations(IApplicationBuilder app)
 {
     using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
     {
         DBInit.Initialize(serviceScope);
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// 抓取
        /// </summary>
        private static void Crawl()
        {
            DBInit             dbInit             = new DBInit();
            CategoryRepository categoryRepository = new CategoryRepository();

            Console.WriteLine("请输入Y/N进行类别表初始化确认! Y 删除Category表然后重新创建,然后抓取类型数据,N(或者其他)跳过");
            string input = Console.ReadLine();

            if (input.Equals("Y", StringComparison.OrdinalIgnoreCase))
            {
                dbInit.InitCategoryTable();
                //  List<Category> categoryList = CategorySearch.Crawler("http://www.jd.com/allSort.aspx");
                List <Category> categoryList = CategorySearch.Crawler("https://www.alibaba.com/?spm=a2700.icbuShop.scGlobalHeaderSmall.1.684142aeD461tx");

                categoryRepository.Save(categoryList);
                Console.WriteLine("类型数据初始化完成,共抓取类别{0}个", categoryList.Count);
            }
            else
            {
                Console.WriteLine("你选择不初始化类别数据");
            }
            Console.WriteLine("*****************^_^**********************");

            Console.WriteLine("请输入Y/N进行商品数据初始化确认! Y 删除全部商品表表然后重新创建,然后抓取商品数据,N(或者其他)跳过");
            input = Console.ReadLine();
            if (input.Equals("Y", StringComparison.OrdinalIgnoreCase))
            {
                dbInit.InitCommodityTable();
                CrawlerCommodity();
            }
            Console.WriteLine("*****************^_^**********************");
            //CleanAll();
        }
Exemplo n.º 15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            using (var scope = app.ApplicationServices.CreateScope())
                if (Environment.IsDevelopment())
                {
                    var ctx = scope.ServiceProvider.GetService<AeldrePlejeContext>();
                    ctx.Database.EnsureDeleted();
                    ctx.Database.EnsureCreated();
                    DBInit.SeedDB(ctx);
                }
                else
                {
                    var ctx = scope.ServiceProvider.GetService<AeldrePlejeContext>();
                    if(ctx.Database.EnsureCreated())
                    {
                        DBInit.SeedDB(ctx);
                    }
                    app.UseHsts();
                }

            // Enable middleware to serve generated Swagger as a JSON endpoint.
            app.UseSwagger();

            // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
            // specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            });

            app.UseHttpsRedirection();
            app.UseCors(monkey => monkey.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
            app.UseAuthentication();
            app.UseMvc();
        }
Exemplo n.º 16
0
        public Avatar Create(Avatar avatar)
        {
            avatar.Id = DBInit.GetNextIdAvatar();
            var list = DBInit.GetAllAvatars();

            list.Add(avatar);
            return(avatar);
        }
Exemplo n.º 17
0
        public static void Main(string[] args)
        {
            var    host   = CreateHostBuilder(args).Build();
            DBInit dbInit = new DBInit();

            dbInit.Initialization(host);
            host.Run();
        }
Exemplo n.º 18
0
 protected void Application_Start()
 {
     DBInit.InitializeDatabase();
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
Exemplo n.º 19
0
        public Owner CreateOwner(Owner owner)
        {
            owner.Id = DBInit.GetNextIdOwner();
            var list = DBInit.GetOwners();

            list.Add(owner);
            return(owner);
        }
Exemplo n.º 20
0
        private void LuceneBuild_Load(object sender, EventArgs e)
        {
            float size = DBInit.GetDBSize();

            Size_Label.Text       = $"{size.ToString()}MB";
            Finish_Label.Text     = StopWatchHelper.formatDuring(0);
            Lucenepath_Label.Text = StaticConst.LucenePath;
        }
Exemplo n.º 21
0
    public DataTable ReturnTable(string sql)
    {
        DBInit    db  = new DBInit(DbConnectionString);
        DbCommand cmd = db.GetSqlStringCommand(sql);
        DataTable dt  = db.ExecuteDataTable(cmd);

        return(dt);
    }
Exemplo n.º 22
0
        public AvatarType CreateType(AvatarType avatarType)
        {
            avatarType.Id = DBInit.GetNextIdAvatarType();
            var list = DBInit.GetAvatarTypes();

            list.Add(avatarType);
            return(avatarType);
        }
Exemplo n.º 23
0
 public void Init()
 {
     IoC.InitializeWith(new WindsorContainer());
     ApplicationInit.InitializeRepositories();
     base.SetUp();
     DBInit.RegisterDocumentStore(Store);
     DBInit.RegisterIndexes(Store);
 }
Exemplo n.º 24
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                using (IServiceScope scope = app.ApplicationServices.CreateScope())
                {
                    DBContext ctx = scope.ServiceProvider.GetService <DBContext>();
                    ctx.Database.EnsureCreated();
                    DBInit.SeedDB(ctx);
                }
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                using (var scope = app.ApplicationServices.CreateScope())
                {
                    var ctx = scope.ServiceProvider.GetService <DBContext>();
                    ctx.Database.EnsureCreated();
                    DBInit.SeedDB(ctx);
                }
                // 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.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub <ChatHub>("/chathub");

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

                endpoints.MapControllerRoute(
                    name: null,
                    pattern: "Chat",
                    defaults: new { controller = "Chat", action = "Index" });

                endpoints.MapControllerRoute(
                    name: null,
                    pattern: "task/{id}",
                    defaults: new { controller = "Tasks", action = "TaskById" });

                endpoints.MapControllerRoute(
                    name: null,
                    pattern: "register",
                    defaults: new { controller = "Login", action = "Register" });

                endpoints.MapControllerRoute(
                    name: null,
                    pattern: "login",
                    defaults: new { controller = "Login", action = "Index" });
            });
        }
Exemplo n.º 25
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddScoped <IAddressService, AddressService>();
            services.AddScoped <IColourService, ColourService>();
            services.AddScoped <IOrderService, OrderService>();
            services.AddScoped <IPersonService, PersonService>();
            services.AddScoped <IPetService, PetService>();
            services.AddScoped <IPetTypeService, PetTypeService>();
            services.AddScoped <IRepository <Address>, AddressDBRepository>();
            services.AddScoped <IRepository <Colour>, ColourDBRepository>();
            services.AddScoped <IRepository <Order>, OrderDBRepository>();
            services.AddScoped <IPersonRepository, PersonDBRepository>();
            services.AddScoped <IRepository <Pet>, PetDBRepository>();
            services.AddScoped <IRepository <PetType>, PetTypeDBRepository>();

            if (Environment.IsDevelopment())
            {
                // In-memory database:
                services.AddDbContext <PetshopContext>(opt => opt.UseSqlite("Data Source = Petshop.db", b => b.MigrationsAssembly("Bamz.Petshop.RestApi")).EnableSensitiveDataLogging());
            }
            else
            {
                // SQL Server on Azure:
                services.AddDbContext <PetshopContext>(opt =>
                                                       opt.UseSqlServer(Configuration.GetConnectionString("defaultConnection"), b => b.MigrationsAssembly("Bamz.Petshop.RestApi")));
            }

            // Add JWT based authentication
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateAudience         = false,
                    ValidateIssuer           = false,
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = JwtSecurityKey.Key,
                    ValidateLifetime         = true,    //validate the expiration and not before values in the token
                    ClockSkew = TimeSpan.FromMinutes(5) //5 minute tolerance for the expiration date
                };
            });

            services.AddMvc().AddJsonOptions(options => {
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

            // Add CORS
            services.AddCors();

            ServiceProvider sp        = services.BuildServiceProvider();
            var             dbContext = sp.GetService <PetshopContext>();

            dbContext.Database.Migrate();

            if (Environment.IsDevelopment())
            {
                DBInit.Initialize(dbContext);
            }
        }
Exemplo n.º 26
0
        public MDIMain(DBInit db, IModelMapper mapper, frmPortfolio frmPortfolio, frmAddTrade frmAddTrade)
        {
            InitializeComponent();

            this.frmPortfolio = frmPortfolio;
            this.frmAddTrade  = frmAddTrade;

            ShowPortfolioForm(null, null);
        }
Exemplo n.º 27
0
 public void OnTimeSetup()
 {
     _dbInit = new DBInit(this.GetType().Name);
     _dbInit.InitDB();
     _serviceProvider = Substitute.For <IServiceProvider>();
     _serviceProvider
     .GetService(Arg.Is(typeof(IConditionAdapter <TestSelectRequestStruct>)))
     .Returns((callback) => _adapter);
 }
Exemplo n.º 28
0
        private void button5_Click(object sender, EventArgs e)
        {
            var digResult = MessageBox.Show("您是否确认初始化?", "提示", MessageBoxButtons.YesNo);

            if (digResult == DialogResult.OK)
            {
                FormHelper.Show(DBInit.InitDb());
            }
        }
Exemplo n.º 29
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string connString = PPMS.WIN.Properties.Settings.Default.connString;

            DBInit.InitDatabase(connString);

            Application.Run(new Form1());
        }
        public PatientActivitiesPageViewModel()
        {
            var db = new DBInit();

            ptdetails = db.GetDetails();

            patientActivites = spliter(db.GetDetails());

            foreach (var pa in patientActivites)
            {
                Debug.WriteLine("Debug string split: " + pa);
            }
        }