예제 #1
0
 public HomeController(DapperDBContext context, IUserInfoService _iUserInfoService,
                       AutoMapper.IMapper _modelMapper)
 {
     _context         = context;
     iUserInfoService = _iUserInfoService;
     modelMapper      = _modelMapper;
 }
예제 #2
0
 public DemoService(DapperDBContext context, IDemoRepository _iDemoRepository,
                    AutoMapper.IMapper _modelMapper)
 {
     _context        = context;
     iDemoRepository = _iDemoRepository;
     modelMapper     = _modelMapper;
 }
예제 #3
0
 public IndexModel(DapperDBContext context, IUserInfoService _iUserInfoService,
                   AutoMapper.IMapper _modelMapper)
 {
     _context         = context;
     iUserInfoService = _iUserInfoService;
     modelMapper      = _modelMapper;
 }
예제 #4
0
 public UserInfoService(DapperDBContext context, IUserInfoRepository _iUserInfoRepository,
                        AutoMapper.IMapper _modelMapper)
 {
     _context            = context;
     iUserInfoRepository = _iUserInfoRepository;
     modelMapper         = _modelMapper;
 }
예제 #5
0
 //For PGSQL
 public List <T> GetData <T>(string sql, object obj, DapperDBContext _dbContext)
 {
     using (IDbConnection conn = new NpgsqlConnection(_dbContext.Connection))
     {
         var data = conn.Query <T>(sql, obj, commandTimeout: 1800).ToList();
         return(data);
     }
 }
예제 #6
0
 private readonly IOptions <Infrastructure.Dtos.Config.AppSettings> appSettings; //配置文件数据
 /// <summary>
 /// DemoController
 /// </summary>
 public TestController(DapperDBContext _context
                       , IDemoService _iDemoService,
                       AutoMapper.IMapper _modelMapper, IHostingEnvironment hostingEnv
                       , IOptions <Infrastructure.Dtos.Config.AppSettings> _appSettings)
 {
     context      = _context;
     iDemoService = _iDemoService;
     modelMapper  = _modelMapper;
     this.Log     = LogManager.GetLogger(Startup.Repository.Name, typeof(HomeController));
     appSettings  = _appSettings;
 }
예제 #7
0
 /// <summary>
 /// HomeController
 /// </summary>
 public HomeController(DapperDBContext context, IUserInfoService _iUserInfoService,
                       AutoMapper.IMapper _modelMapper, IHostingEnvironment hostingEnv, IConfiguration configuration
                       , ITokenHelper _tokenHelper)
 {
     _context         = context;
     iUserInfoService = _iUserInfoService;
     modelMapper      = _modelMapper;
     _configuration   = configuration;
     tokenHelper      = _tokenHelper;
     this.Log         = LogManager.GetLogger(Startup.Repository.Name, typeof(HomeController));
 }
예제 #8
0
        public void FixBatchInventory()
        {
            IDBContext db = new DapperDBContext("masterDB");

            // 查询 异常批次数据
            var sql             = @"select p.id,p.`Code`,p.BarCode,s.StoreId,s.Quantity,t.Quantity as bqty,c.Quantity as hqty from storeinventory s left JOIN
(select b.StoreId,b.ProductId,sum(b.Quantity) as Quantity from storeinventorybatch b group by b.StoreId,b.ProductId) t
on s.StoreId = t.StoreId and s.ProductId = t.ProductId
left join 
(select h.StoreId,h.ProductId,sum( h.ChangeQuantity) as Quantity from storeinventoryhistory h GROUP BY h.StoreId,h.ProductId ) c
on  s.StoreId = c.StoreId and s.ProductId = c.ProductId
left join product p on p.id = s.ProductId
where s.Quantity<>c.Quantity or c.Quantity<>t.Quantity or s.Quantity<>t.Quantity ";
            var waitFixProducts = db.Table.FindAll <FixProduct>(sql, null);

            foreach (var item in waitFixProducts)
            {
                if (item.Quantity <= 0)
                {
                    //更新当前所有商品批次库存为0
                    if (item.Bqty > 0)
                    {
                        string sqlUpdate = "update storeinventorybatch set Quantity = 0 where StoreId=@StoreId and ProductId=@ProductId and Quantity>0";
                        db.Command.AddExecute(sqlUpdate, new { StoreId = item.StoreId, ProductId = item.Id });
                    }
                }
                else
                {
                    // 把批次库存数修复成与总库存一致
                    var inventoryBatchs = db.Table.FindAll <StoreInventoryBatch>("select * from storeinventorybatch where  storeId=@StoreId and productId = @ProductIds and Quantity>0", new { StoreId = item.StoreId, ProductIds = item.Id }).OrderBy(n => n.BatchNo).ToList();
                    if (item.Quantity < item.Bqty)
                    {
                        var updateList = MinusInventory(inventoryBatchs, item.Bqty - item.Quantity);
                        if (updateList.Count > 0)
                        {
                            db.Update(updateList.ToArray());
                        }
                    }
                    else
                    {
                    }
                }
            }


            // db.SaveChange();
            Assert.AreEqual(1, 1);
        }
예제 #9
0
        public void TestTimespan_MySql()
        {
            var strConn = ConfigurationManager.ConnectionStrings["ebsdb"].ConnectionString;

            DapperDBContext db    = new DapperDBContext("ebsdb");
            var             model = db.Table <temp_test>().FirstOrDefault(n => n.Id == 1);

            var version1 = model.RowVersion;

            model.Quantity += 100;
            db.Update(model);
            db.SaveChange();
            var model2 = db.Table <temp_test>().FirstOrDefault(n => n.Id == 1);

            Assert.AreNotEqual(version1, model2.RowVersion);
        }
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(options =>
            {
                options.AddPolicy("AllowAll",
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddTransient <IBuildingRepositories, BuildingRepositories>()
            .AddTransient <IObjectRepositories, ObjectRepositories>()
            .AddTransient <IDataFieldRepositories, DataFieldRepositories>()
            .AddTransient <IReadingRepositories, ReadingRepositories>();

            var connection = new DapperDBContext(Configuration.GetConnectionString("DatabaseITEST"));

            services.AddSingleton(connection)
            .Configure <ReadingConfig>(Configuration.GetSection("ReadingConfig"))
            .AddSingleton(r => r.GetRequiredService <IOptions <ReadingConfig> >().Value)
            .AddSingleton <IDocumentExecuter, DocumentExecuter>();

            services.AddSingleton <RootQuery>()
            .AddSingleton <BuildingQuery>()
            .AddSingleton <DataFieldQuery>()
            .AddSingleton <ObjectQuery>()
            .AddSingleton <ReadingQuery>();

            services.AddSingleton <ObjectType>()
            .AddSingleton <DataFieldType>()
            .AddSingleton <BuildingType>()
            .AddSingleton <ReadingType>()
            .AddSingleton <ReadingResponseType>();

            services.AddSingleton <IDependencyResolver>(_ => new FuncDependencyResolver(_.GetRequiredService))
            .AddSingleton <ISchema, S3ITESTSchema>();

            services.AddControllers();
            services.AddMvc(option => option.EnableEndpointRouting = false)
            .SetCompatibilityVersion(CompatibilityVersion.Version_3_0)
            .AddNewtonsoftJson(opt => opt.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
        }
예제 #11
0
 public void Init()
 {
     _db = new DapperDBContext("dbtest");
 }
 public BuildingRepositories(DapperDBContext dbContext)
 {
     _dbContext = dbContext;
 }
예제 #13
0
 public Test1Repository(DapperDBContext context) : base(context)
 {
     _context = context;
 }
예제 #14
0
 public SysKeywordsRepository(DapperDBContext context)
 {
     _context = context;
 }
예제 #15
0
 public MessageBoxRepository(DapperDBContext context)
 {
     _context = context;
 }
예제 #16
0
 public SysRoleAlarmLevelRepository(DapperDBContext context)
 {
     _context = context;
 }
예제 #17
0
 public BaseRepository(DapperDBContext context)
 {
     _context = context;
 }
 public NurseReportRepository(DapperDBContext context) : base(context)
 {
 }
예제 #19
0
 public UowProductRepository(DapperDBContext context)
 {
     _context = context;
 }
예제 #20
0
 private readonly IOptions <Infrastructure.Dtos.Config.AppSettings> appSettings; //配置文件数据
 public DemoRepository(DapperDBContext _context, IOptions <Infrastructure.Dtos.Config.AppSettings> _appSettings)
     : base(_context)
 {
     context     = _context;
     appSettings = _appSettings;
 }
 public DapperUnitOfWorkFactory(DapperDBContext context)
 {
     _context = context;
 }
 public UserInfoRepository(IContext context)
 {
     _context = (DapperDBContext)context;
 }
예제 #23
0
 public SysUserRoleRepository(DapperDBContext context)
 {
     _context = context;
 }
예제 #24
0
 public BaseCurrencyRepository(DefaultEFDBContext context, DapperDBContext dapperCcontext)
     : base(context)
 {
     _context       = context;
     _dapperContext = dapperCcontext;
 }
예제 #25
0
 public UowProductsRepository(DapperDBContext context)
 {
     this._context = context;
 }
예제 #26
0
 public PostRepository(DapperDBContext context)
     : base(context)
 {
     _context = context;
 }
 public UserAddressRepository(IContext context)
 {
     _context = (DapperDBContext)context;
 }
예제 #28
0
 public UowCategoryRepository(DapperDBContext context)
 {
     _context = context;
 }
 public ObjectRepositories(DapperDBContext dbContext)
 {
     _dbContext = dbContext;
 }
예제 #30
0
 public SysRoleMenuRepository(DapperDBContext context)
 {
     _context = context;
 }