Exemple #1
0
        private static void Main(string[] args)
        {
            var db = new MyDbUtil();

            var dd = db.QueryByTable("SENSOR");
            var a  = 1;
        }
Exemple #2
0
        public JsonResult Delete(int id)
        {
            var db     = new MyDbUtil();
            var row    = db.Delete <StockItem>(id);
            var result = row > 0 ? ResultUtil.Success() : ResultUtil.Do(ResultCodes.数据库操作失败, "操作失败");

            return(Json(result));
        }
Exemple #3
0
 public BaseService(string sectionName = "")
 {
     if (!string.IsNullOrWhiteSpace(sectionName))
     {
         db = new MyDbUtil(sectionName);
     }
     else
     {
         db = new MyDbUtil();
     }
 }
Exemple #4
0
        public JsonResult GetAssets(AssetSearchParam param, int stockId, int pageIndex = 1, int pageSize = 50)
        {
            var util = param.ToSearchUtil();

            util.And("Id NOT IN (SELECT AssetId FROM Asset_StockItem WHERE StockId=" + stockId.ToString() + ")");

            var db   = new MyDbUtil();
            var list = db.Query <AssetDto>(util, pageIndex, pageSize, "AssetView");

            return(Json(ResultUtil.PageList(list)));
        }
Exemple #5
0
        public void ConfigureServices(IServiceCollection services)
        {
            // 使用分布式缓存
            // services.AddDistributedMemoryCache();

            // 启用Session
            services.AddSession();

            // 初始化数据库工具
            MyDbUtil.Init(Configuration);

            // 初始化并添加AutoMapper
            Mapper.Initialize(cfg =>
            {
                cfg.AddProfile <ServicesProfile>();
            });
            services.AddAutoMapper();

            // 压缩输出
            services.AddResponseCompression();

            // cookie身份验证
            services
            .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie(opts =>
            {
                opts.Cookie.Name     = "Taoxue.Training.Core";
                opts.Cookie.HttpOnly = true;
                opts.LoginPath       = "/Login";
                opts.LogoutPath      = "/Home/Logout";
            });
            services
            .AddAuthorization(opts =>
            {
                opts.AddPolicy("AdminOnly", policy => policy.RequireRole("admin"));
                opts.AddPolicy("ManagerOnly", policy => policy.RequireRole("manager"));
            });

            // senparc使用本地缓存必须注册此服务
            services.AddMemoryCache();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }