public async Task <UserLoginModelOut> GetUserAsync(UserLoginModelIn modelIn) { GeneralDbContext db = new GeneralDbContext(); var ret = db.Database.SqlQuery <UserLoginModelOut>("SELECT Id,AccessCode,Name FROM v_user WHERE AccessCode=@AccessCode AND Pass=@Password", new SqlParameter("AccessCode", modelIn.AccessCode), new SqlParameter("Password", modelIn.Password.ToBase64())); if (ret == null) { return(null); } var _list = await ret.ToListAsync(); if (_list.Count == 0) { return(null); } else { return(_list[0]); } }
/// <summary> /// 获取当前数据上下文 /// </summary> /// <returns>返回 数据上下文</returns> public static GeneralDbContext GetCurrentContext() { GeneralDbContext context = CallContext.GetData("General") as GeneralDbContext; if (context == null) { context = new GeneralDbContext(); CallContext.SetData("General", context); } return context; }
static void Main(string[] args) { var ctx = new GeneralDbContext(); var entes = ctx.Entes.ToList(); var choferes = ctx.Choferes.ToList(); var personas = ctx.Personas.ToList(); }
public static void Initialize(GeneralDbContext context) { context.Database.Migrate(); if (!context.Users.Any(i => i.LoginName == "admin")) { context.Users.Add(new User() { LoginName = "admin", Name = "admin", Password = CryptoHelper.Crypto.HashPassword("admin"), IsAdmin = true }); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new GeneralDbContext(serviceProvider.GetRequiredService <DbContextOptions <GeneralDbContext> >())) { if (context.librarySeats.Any()) { return; } context.librarySeats.AddRange(CreateLibrarySeat(1, 10)); context.librarySeats.AddRange(CreateLibrarySeat(2, 10)); context.librarySeats.AddRange(CreateLibrarySeat(0, 95)); context.SaveChanges(); } }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new GeneralDbContext(serviceProvider.GetRequiredService <DbContextOptions <GeneralDbContext> >())) { if (context.SysUsers.Any()) { return; } var salt = EncryptorHelper.CreateSaltKey(); context.SysUsers.AddRange( new Entities.SysUser { Id = Guid.NewGuid(), Account = "41606217", Name = "吴宗锦", Salt = salt, Password = EncryptorHelper.GetMD5("15160296867" + salt), IsAdmin = true, Email = "*****@*****.**", MobilePhone = "18229065977", Sex = "男", Enabled = true, CreationTime = DateTime.Now, LoginFailedNum = 0, AllowLoginTime = null, LoginLock = false, LastLoginTime = null, LastIpAddress = "", LastActivityTime = DateTime.Now, IsDeleted = false, DeletedTime = null, ModifiedTime = null, Modifier = null, Creator = null, Avatar = new byte[0], } ); context.SaveChanges(); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); Database.SetInitializer(new DbInitializer()); GeneralDbContext gen_db = new GeneralDbContext(); gen_db.Database.Initialize(true); Database.SetInitializer(new ApplicationDbInitializer()); ApplicationDbContext db = new ApplicationDbContext(); db.Database.Initialize(true); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
public UomController(GeneralDbContext context) { this.context = context; }
public BannerService(GeneralDbContext db) { this._generalDbContext = db; }
public NewService(GeneralDbContext db) { this._generalDbContext = db; }
public BannerRepository(GeneralDbContext context) : base(context) { }
public EfRepository(GeneralDbContext generalDbContext) { this._dbContext = generalDbContext; }
/// <summary> /// Configures the services. /// </summary> /// <param name="services">Services.</param> // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { using (var deviceDbContext = new GeneralDbContext()) { deviceDbContext.Database.EnsureCreated(); } services.AddMvc() .AddJsonOptions( options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore ).AddJsonOptions(options => { options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore; }); JsonConvert.DefaultSettings = () => new JsonSerializerSettings { Formatting = Formatting.Indented, ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "MobileManager API", Version = "v1" }); //Set the comments path for the swagger json and ui. var basePath = AppContext.BaseDirectory; var xmlPath = Path.Combine(basePath, "MobileManager.xml"); c.IncludeXmlComments(xmlPath); }); services.AddReact(); services.AddMvc(); services.AddEntityFrameworkMultiDb() .AddDbContext <GeneralDbContext>(); services.AddCors(options => { options.AddPolicy("AllowAllHeaders", builder => { builder.AllowAnyOrigin() .AllowAnyHeader() .AllowAnyMethod(); }); }); services.AddTransient <IRepository <Device>, DeviceRepository>() .AddTransient <IRepository <Reservation>, ReservationQueueRepository>() .AddTransient <IRepository <ReservationApplied>, ReservationAppliedRepository>() .AddTransient <IRepository <AppiumProcess>, AppiumRepository>() .AddTransient <IRepository <LogMessage>, LoggerRepository>(); //services.AddSingleton<IManagerConfiguration, ManagerConfiguration>(); services.AddSingleton <IRestClient, RestClient>() .AddSingleton <IAppiumService, AppiumService>() .AddSingleton <IAdbController, AdbController>() .AddSingleton <IHttpContextAccessor, HttpContextAccessor>() .AddSingleton(typeof(IManagerConfiguration), AppConfigurationProvider.Get <ManagerConfiguration>()) .AddSingleton <IManagerLogger, ManagerLogger>() .AddSingleton <IDeviceUtils, DeviceUtils>() .AddSingleton <IScreenshotService, ScreenshotService>() .AddSingleton <IExternalProcesses, ExternalProcesses>(); services.AddMvcCore().AddApiExplorer(); // Run hosted services var configuration = AppConfigurationProvider.Get <ManagerConfiguration>(); if (configuration.AndroidServiceEnabled) { services.AddHostedService <AndroidDeviceService>(); } if (configuration.IosServiceEnabled) { services.AddHostedService <IosDeviceService>(); } services.AddHostedService <ReservationService>(); }
public VehPermitController(GeneralDbContext context) { this.context = context; }
public pimcategoryController(GeneralDbContext context) { this.context = context; }
public EmployeeController(IHostingEnvironment hostingEnvironment, GeneralDbContext context) { this.hostingEnvironment = hostingEnvironment; _context = context; }
public VehicleLicenceTypesController(GeneralDbContext context) { _context = context; }
public CountryController(GeneralDbContext context) { _context = context; }
public UnitOfWork(GeneralDbContext context) { _context = context; }
public CategoryService(GeneralDbContext generalDbContext) { this.generalDbContext = generalDbContext; }
public WarehouseController(GeneralDbContext context) { this.context = context; }
public binareaController(GeneralDbContext context) { this.context = context; }
public OrderService() { this.db = new GeneralDbContext(); }
public CompanyDetController(GeneralDbContext context, IHostingEnvironment env) { this.context = context; hostingEnvironment = env; }
public DgClassDangerousController(GeneralDbContext context) { _context = context; }
public UserRepo(GeneralDbContext context) { this.context = context; }
public RepositoryBase(GeneralDbContext context) { this._context = context; this._dbSet = context.Set <T>(); }
public CustomerService() { this.db = new GeneralDbContext(); }
public BrandController(GeneralDbContext context) { _context = context; }
public ReOrderingFlowFreqController(GeneralDbContext context) { _context = context; }
public HumanRepository(GeneralDbContext context) { _context = context; }