Ejemplo n.º 1
0
        /// <summary>
        /// 获取变化后的商品信息
        /// </summary>
        /// <returns></returns>
        public List <LocalCommodityCode> GetLocalCommodityCodeChange(InventoryChangesApo pageDataApo, out int totalCount)
        {
            totalCount = 0;
            List <LocalCommodityCode> data;

            //查询语句
            var queryable = SqlSugarHelper.GetInstance().Db.Queryable <LocalCommodityCode>()
                            .Where((lcc) => lcc.operate_type == pageDataApo.operate_type)
                            .WhereIF(pageDataApo.startTime.HasValue, (lcc) => lcc.create_time >= pageDataApo.startTime)
                            .WhereIF(pageDataApo.endTime.HasValue, (lcc) => lcc.create_time <= pageDataApo.endTime)
                            .WhereIF((!string.IsNullOrEmpty(pageDataApo.name) && !string.IsNullOrWhiteSpace(pageDataApo.name)), (lcc) => lcc.CommodityName.Contains(pageDataApo.name))
                            .OrderBy((lcc) => lcc.create_time, OrderByType.Desc)
                            .Select <LocalCommodityCode>();


            //如果小于0,默认查全部
            if (pageDataApo.PageSize > 0)
            {
                data = queryable.ToPageList(pageDataApo.PageIndex, pageDataApo.PageSize, ref totalCount);
            }
            else
            {
                data       = queryable.ToList();
                totalCount = data.Count();
            }
            return(data);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 插入扫描的所有商品信息
        /// </summary>
        /// <param name="currentCommodityEps">当前扫描出来的所有数据</param>
        /// <returns></returns>
        public bool InsertLocalCommodityEpsInfo(HashSet <CommodityEps> currentCommodityEps)
        {
            var result = false;

            if (currentCommodityEps == null)
            {
                return(result);
            }

            //组装最新的扫描结果,一组数据
            var localCommodityEps = new LocalCommodityEps
            {
                commodityEpsList = JsonConvert.SerializeObject(new List <CommodityEps>(currentCommodityEps)),
                create_time      = DateTime.Now
            };

            //事务防止多插入产生脏数据
            result = SqlSugarHelper.GetInstance().Db.Ado.UseTran(() =>
            {
                SqlSugarHelper.GetInstance().Db.Insertable(localCommodityEps).ExecuteCommand();
            }).IsSuccess;


            if (!result)
            {
                LogUtils.Warn("InsertLocalCommodityEpsInfo 失败" + DateTime.Now);
            }

            return(result);
        }
Ejemplo n.º 3
0
 public static void AddRoleMenu()
 {
     using (var db = SqlSugarHelper.GetInstance())
     {
         _funcList = db.Queryable <view_sys_user_role_function>().ToList();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 插入变化后的商品信息
        /// </summary>
        /// <param name="baseDataCommodityCode">所有数据</param>
        /// <param name="sourceBill">业务类型</param>
        /// <returns></returns>
        public bool InsertLocalCommodityCodeInfo(BaseData <CommodityCode> baseDataCommodityCode, string sourceBill)
        {
            var result = false;

            //校验是否含有数据,如果含有数据,有就继续下一步
            baseDataCommodityCode = HttpHelper.GetInstance().ResultCheck(baseDataCommodityCode, out bool isSuccess);

            if (isSuccess)
            {
                List <LocalCommodityCode> localCommodityCodes = baseDataCommodityCode.body.objects.MapToListIgnoreId <CommodityCode, LocalCommodityCode>();

                var createTime = DateTime.Now;
                var operater   = ApplicationState.GetUserInfo().name;

                localCommodityCodes.ForEach(it =>
                {
                    it.sourceBill  = sourceBill;
                    it.create_time = createTime;
                    it.operater    = operater;
                });

                //事务防止多插入产生脏数据
                result = SqlSugarHelper.GetInstance().Db.Ado.UseTran(() =>
                {
                    SqlSugarHelper.GetInstance().Db.Insertable(localCommodityCodes).ExecuteCommand();
                }).IsSuccess;
            }

            if (!result)
            {
                LogUtils.Warn("InsertLocalCommodityCodeInfo" + sourceBill);
            }

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 判断是否是初次使用本地库存上次,如果是则不上传
        /// </summary>
        /// <returns></returns>
        public bool isInitLocalCommodityEpsInfo()
        {
            //查询语句
            var localCommodityEpsCount = SqlSugarHelper.GetInstance().Db.Queryable <LocalCommodityEps>()
                                         .Select <LocalCommodityEps>().Count();

            return(localCommodityEpsCount <= 0);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取变化后的商品信息的名称集合
        /// </summary>
        /// <returns></returns>
        public List <string> GetLocalCommodityName()
        {
            //查询语句
            var queryable = SqlSugarHelper.GetInstance().Db.Queryable <LocalCommodityCode>()
                            .Distinct()
                            .OrderBy((lcc) => lcc.create_time, OrderByType.Desc)
                            .Select(it => it.CommodityName).ToList();


            return(queryable);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 获取上次扫描记录的商品信息
        /// </summary>
        /// <returns></returns>
        public HashSet <CommodityEps> GetLastLocalCommodityEpsInfo()
        {
            var ret = new HashSet <CommodityEps>();

            //查询语句
            var localCommodityEps = SqlSugarHelper.GetInstance().Db.Queryable <LocalCommodityEps>()
                                    .OrderBy((lcc) => lcc.create_time, OrderByType.Desc)
                                    .Select <LocalCommodityEps>().First();

            if (localCommodityEps.commodityEpsList != null)
            {
                ret = new HashSet <CommodityEps>(JsonConvert.DeserializeObject <List <CommodityEps> >(localCommodityEps.commodityEpsList));
            }

            return(ret);
        }
Ejemplo n.º 8
0
 // 定义私有构造函数,使外界不能创建该类实例
 private ReplenishDal()
 {
     Db = SqlSugarHelper.GetInstance().Db;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Action 执行之前 发生
 /// </summary>
 /// <param name="filterContext"></param>
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (IsExecutePowerLogic || MenuID == "Home")
     {
         Console.WriteLine(filterContext.HttpContext.Request.Path.Value);
         var token   = string.Empty;
         var cktoken = filterContext.HttpContext.Request.Cookies["authtoken"];
         var attoken = filterContext.HttpContext.Request.Headers["authtoken"].ToString();
         if (!string.IsNullOrEmpty(cktoken))
         {
             //Console.WriteLine(cktoken);
             token = cktoken;
         }
         if (!string.IsNullOrEmpty(attoken))
         {
             token = attoken;
         }
         if (!string.IsNullOrEmpty(token))
         {
             var userid  = string.Empty;
             var handers = new JwtSecurityTokenHandler().ReadJwtToken(token.Replace("Bearer ", ""));
             foreach (var item in handers.Claims)
             {
                 if (item.Type == "ID")
                 {
                     userid = item.Value;
                 }
                 //Console.WriteLine(item.Type);
                 //Console.WriteLine(item.Value);
             }
             //if (!string.IsNullOrEmpty(Convert.ToString(CacheHelper.Get(userid))))
             //{
             //    CacheHelper.Set(userid, "1", DateTime.Now.AddMinutes(120));
             using (var db = SqlSugarHelper.GetInstance())
             {
                 var model = db.Queryable <sys_user, sys_userrole>((u, ur) => new object[] {
                     JoinType.Inner, u.User_ID == ur.UserRole_UserID
                 }
                                                                   ).Where((u) => u.User_ID == userid)
                             .Select((u, ur) => new { u.User_ID, u.User_Name, ur.UserRole_RoleID }).First();
                 if (model != null)
                 {
                     account.RoleID        = model.UserRole_RoleID;
                     account.UserID        = model.User_ID;
                     account.UserName      = model.User_Name;
                     account.IsSuperManage = model.UserRole_RoleID.ToStr().ToLower() == AppConfig.Admin_RoleID;
                     filterContext.RouteData.Values.Add("account", account);
                     base.OnActionExecuting(filterContext);
                 }
                 else
                 {
                     throw new MessageBox("请重新登陆", EMsgStatus.无效权限401);
                 }
             }
         }
         else
         {
             throw new MessageBox("请重新登陆", EMsgStatus.无效权限401);
         }
     }
     else
     {
         base.OnActionExecuting(filterContext);
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 权限逻辑
        /// </summary>
        /// <param name="context"></param>
        private void PowerLogic(ActionExecutedContext context)
        {
            if (MenuID != "Home")
            {
                //Console.WriteLine(context.HttpContext.Request.Headers["X-Requested-With"].ToString());
                if (!(context.HttpContext.Request.Headers["X-Requested-With"].ToString() == "XMLHttpRequest"))
                {
                    using (var db = SqlSugarHelper.GetInstance())
                    {
                        var _RouteValues = context.ActionDescriptor.RouteValues;
                        var _Area        = _RouteValues["area"];
                        var _Controller  = _RouteValues["controller"];
                        var _Action      = _RouteValues["action"];

                        var _func_list  = db.Queryable <sys_function>().OrderBy("Function_Num asc").ToList();
                        var _power_list = new Dictionary <string, object>();
                        //这里得判断一下是否是查找带回调用页面
                        string findback = context.HttpContext.Request.Query["findback"];

                        if (string.IsNullOrEmpty(findback))
                        {
                            //dynamic model = new ExpandoObject();
                            if (string.IsNullOrEmpty(MenuID))
                            {
                                throw new MessageBox("区域(" + _Area + "),控制器(" + _Controller + "):的程序中缺少菜单ID");
                            }

                            var _Menu = db.Queryable <sys_menu>().First(p => p.Menu_Num == MenuID);
                            //if (!_Menu.Menu_Url.ToStr().StartsWith("/" + _Area + "/" + _Controller + "/"))
                            //{
                            //    throw new MessageBox("区域(" + _Area + "),控制器(" + _Controller + "):的程序中缺少菜单ID与该页面不匹配");
                            //}


                            if (!account.IsSuperManage)
                            {
                                var _role_menu_func_list = db.Queryable <sys_rolemenufunction>().ToList();
                                _power_list = new Dictionary <string, object>();
                                _func_list.ForEach(item =>
                                {
                                    var ispower = _role_menu_func_list.FindAll(x =>
                                                                               x.RoleMenuFunction_RoleID == account.RoleID &&
                                                                               x.RoleMenuFunction_MenuID == _Menu.Menu_ID &&
                                                                               x.RoleMenuFunction_FunctionID == item.Function_ID);

                                    _power_list.Add(item.Function_ByName, (ispower.Count > 0));
                                });
                            }
                            else
                            {
                                var _menu_func_list = db.Queryable <sys_menufunction>().ToList();
                                _func_list.ForEach(item =>
                                {
                                    //_power_list.Add(item.Function_ByName, true);
                                    var ispower = _menu_func_list.FindAll(x => x.MenuFunction_MenuID == _Menu.Menu_ID && x.MenuFunction_FunctionID == item.Function_ID);
                                    if (ispower.Count > 0)
                                    {
                                        _power_list.Add(item.Function_ByName, true);
                                    }
                                    else
                                    {
                                        _power_list.Add(item.Function_ByName, false);
                                    }
                                });
                            }
                        }
                        else
                        {
                            _power_list = new Dictionary <string, object>();
                            _func_list.ForEach(item =>
                            {
                                _power_list.Add(item.Function_ByName, false);
                            });
                            _power_list["Have"]   = true;
                            _power_list["Search"] = true;
                        }
                        this.ViewData["PowerModel"] = _power_list.SerializeObject();
                    }
                }
            }
        }
Ejemplo n.º 11
0
 // 定义私有构造函数,使外界不能创建该类实例
 private FetchOrderDal()
 {
     Db = SqlSugarHelper.GetInstance().Db;
 }
Ejemplo n.º 12
0
 // 定义私有构造函数,使外界不能创建该类实例
 private UserDal()
 {
     Db = SqlSugarHelper.GetInstance().Db;
 }
Ejemplo n.º 13
0
 // 定义私有构造函数,使外界不能创建该类实例
 private GoodsDal()
 {
     Db = SqlSugarHelper.GetInstance().Db;
 }
Ejemplo n.º 14
0
 // 定义私有构造函数,使外界不能创建该类实例
 private PickingDal()
 {
     Db = SqlSugarHelper.GetInstance().Db;
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            var option = new ConfigurationOptions();
            ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost:6379,password=redis123");

            //IDatabase dbr = redis.GetDatabase(0);
            //var batch = dbr.CreateBatch();
            //sub.Publish("test1", "2222");

            ISubscriber sub = redis.GetSubscriber();

            sub.Publish("95", "JCZQ1211101950191836176274");
            string vs = string.Empty;
            string ss = string.Empty;

            sub.Subscribe("messages", (channel, message) => {
                Console.WriteLine((string)message);
            });
            Console.ReadKey();
            return;

            //var db = getdb();
            //var list = db.Queryable<blast_count>().ToList();
            ////var model = list.Find(a => a.id == 1038);
            ////var model1 = list.Find(a => a.id == 1039);
            //blast_count model = new blast_count();
            //blast_count model1 = new blast_count();
            //model.typeid = 1000;
            //model.playedId = 10000;
            //model.createdate = DateTime.Now;
            //model.betCount = 1;
            //model.betAmount = 100;
            //model.zjAmount = 100;
            //try
            //{
            //    db.Ado.BeginTran();
            //    model1.id = 1000000;
            //    db.Insertable<blast_count>(model).ExecuteCommand();
            //    //db.Insertable<blast_count>(model1).ExecuteCommand();
            //    //throw new Exception("3333");
            //    db.Ado.CommitTran();
            //}
            //catch (Exception exp)
            //{

            //    db.Ado.RollbackTran();
            //}
            SqlSugarClient db    = SqlSugarHelper.GetInstance();
            var            list  = db.Queryable <blast_count>().ToList();
            var            model = list.Find(a => a.id == 225);

            //var result = db.Ado.UseTran(() =>
            //{
            //    model.betCount = 2;
            //    db.Updateable<blast_count>(model).ExecuteCommand();
            //    db.Ado.ExecuteCommand("delete student");
            //    throw new Exception("error haha");
            //});



            //SqlSugarClient db1 = SqlSugarHelper.GetInstance();
            //blast_admin_log model1 = new blast_admin_log();
            //SqlSugarHelper.TranInvok(() =>
            //{
            //    model.betCount = 2;
            //    db.Updateable<blast_count>(model).ExecuteCommand();
            //    db.Updateable<blast_admin_log>(model1).ExecuteCommand();
            //    return true;
            //}, db, db1);

            Console.WriteLine("Hello World!");
            Console.ReadKey();
        }