Example #1
0
        public ActionResult SetUserAction(int id, string checkActName, string checkIsTrue)
        {
            string result = "ok";

            try {
                if (!string.IsNullOrEmpty(checkActName))
                {
                    List <UserActionInfo> selModel = userActService.Find(c => c.UserID == id).ToList();
                    if (selModel != null)//如果存在对应关系则删除 然后添加新的对应关系
                    {
                        for (int i = 0; i < selModel.Count; i++)
                        {
                            userActService.Delete(selModel[i]);
                        }
                        userActService.Save();
                    }
                    string[] checkActNameSum = checkActName.Split(',');
                    string[] checkIsTrueSum  = checkIsTrue.Split(',');
                    for (int j = 0; j < checkActNameSum.Length; j++)
                    {
                        UserActionInfo model = new UserActionInfo();
                        model.UserID   = id;
                        model.ActionID = int.Parse(checkActNameSum[j]);
                        model.IsTrue   = Convert.ToBoolean(checkIsTrueSum[j]);
                        userActService.Insert(model);
                    }
                    userActService.Save();
                }
            }
            catch
            {
                result = "no";
            }
            return(Content(result));
        }
Example #2
0
 private NfaCell(SYMBOL_ENUM lhs, int rhsSeen, IEnumerable <SYMBOL_ENUM> recovery, int productionMark, string coords,
                 HashSet <int>[] taboo, UserActionInfo <TREE_NODE> action)
 {
     this.LhsSymbol              = lhs;
     this.RhsSeenCount           = rhsSeen;
     this.recoveryTerminals      = (recovery ?? new SYMBOL_ENUM[] { }).ToHashSet();
     this.ProductionMark         = productionMark;
     this.ProductionCoordinates  = coords;
     this.ProductionTabooSymbols = taboo;
     this.ProductionUserAction   = action;
 }
Example #3
0
 // todo: retire this constructor
 public NfaCell(SYMBOL_ENUM lhs, int rhsSeen, SYMBOL_ENUM?recovery, int productionMark, string coords, HashSet <int>[] taboo,
                UserActionInfo <TREE_NODE> action)
 {
     this.LhsSymbol              = lhs;
     this.RhsSeenCount           = rhsSeen;
     this.recoveryTerminals      = (recovery.HasValue ? new[] { recovery.Value } : new SYMBOL_ENUM[] { }).ToHashSet();
     this.ProductionMark         = productionMark;
     this.ProductionCoordinates  = coords;
     this.ProductionTabooSymbols = taboo;
     this.ProductionUserAction   = action;
 }
Example #4
0
        /// <summary>
        /// 设置否决权限
        /// </summary>
        /// <param name="uId">用户Id</param>
        /// <param name="aId">要设置否决的权限</param>
        /// <param name="isAllow">是否允许</param>
        public void SetAction(long uId, long aId, int isAllow)
        {
            UserInfo userInfo = GetById(uId);

            //通过导航属性判断是否已经有这个权限
            UserActionInfo userAction = userInfo.UserActionInfo.Where(ua => ua.ActionId == aId).FirstOrDefault();

            //进行否决判断
            if (userAction != null)
            {
                //有此权限
                if (isAllow == 1)
                {
                    //允许
                    userAction.IsAllow = (byte)1;
                }
                else if (isAllow == -1)
                {
                    //拒绝
                    userAction.IsAllow = (byte)0;
                }
                else
                {
                    //不设置
                    userInfo.UserActionInfo.Remove(userAction);
                }
            }
            else
            {
                //无此权限
                if (isAllow != 0)
                {
                    //新创建一个userAction对象加入到数据库
                    userAction = new UserActionInfo()
                    {
                        UserId   = uId,
                        ActionId = aId
                    };
                    if (isAllow == 1)
                    {
                        //允许
                        userAction.IsAllow = (byte)1;
                    }
                    else if (isAllow == -1)
                    {
                        //拒绝
                        userAction.IsAllow = (byte)0;
                    }
                    //加入到数据库
                    userInfo.UserActionInfo.Add(userAction);
                }
            }
        }
Example #5
0
        public override bool TakeAction()
        {
            int happyPointFromClient = requestPack.happyPoint;

            if (happyPointFromClient < 0)
            {
                responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.error_data;
                return(true);
            }

            var           cache = new PersonalCacheStruct <HappyModeData>();
            int           keyid = utils.KeyUInt2Int(requestPack.the3rdUserID);
            HappyModeData hmd   = cache.FindKey(keyid.ToString());

            if (null == hmd)
            {
                responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.not_find_data;
                return(true);
            }

            int happyPointIndex = requestPack.index;

            if (false == hmd.ActionEnterHappyPoint.ContainsKey(happyPointIndex))
            {
                responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.error_userActionIndex;
                return(true);
            }
            UserActionInfo uai = hmd.ActionEnterHappyPoint[happyPointIndex];

            if (0 != uai.status)
            {
                responsePack.errorCode = (byte)Response1008Pack.EnumErrorCode.error_has_sendThis;
                return(true);
            }

            // check
            if (false == check())
            {
                return(true);
            }



            hmd.ModifyLocked(() => {
                hmd.HappyPoint += happyPointFromClient;
                uai.status      = 1;
            });
            responsePack.errorCode  = (byte)Response1008Pack.EnumErrorCode.ok;
            responsePack.happyPoint = hmd.HappyPoint;
            return(true);
        }
Example #6
0
        public ActionResult SetUserAction(int userId, int ActionId, int Value)
        {
            var UserAction = UserActionInfoService.GetEntity(r => r.ActionInfoID == ActionId && r.UserInfoID == userId && r.DelFlag == true).FirstOrDefault();
            var item       = Value == 1 ? 1 : 0;

            if (UserAction != null)
            {
                UserAction.HasPermissin = (short)item;
                UserActionInfoService.Update(UserAction);
            }
            else
            {
                UserActionInfo ruserActionInfo = new UserActionInfo();
                ruserActionInfo.ActionInfoID = ActionId;
                ruserActionInfo.UserInfoID   = userId;
                ruserActionInfo.HasPermissin = (short)item;
                ruserActionInfo.DelFlag      = true;
                UserActionInfoService.Add(ruserActionInfo);
            }
            return(Json(new { status = 1, errorMsg = "操作成功!!" }));
        }
Example #7
0
        void test()
        {
            HappyModeData   hmd = new HappyModeData();
            PayOrderPersion pop = new PayOrderPersion();

            pop.Index            = 1;
            pop.UserId           = 2;
            pop.Identify         = "1";
            pop.typeUser         = "******"; // 360Pay..maybe
            pop.ProductId        = "1";
            pop.num              = 1;
            pop.the3rdUsrID      = 1;// utils.KeyUInt2Int(requestPack.the3rdUserId);
            pop.strThe3rdOrderId = "1";
            pop.ServerOrderId    = "1";
            pop.the3rdOrderId    = "1";
            hmd.PayInfoDic.Add("1", pop);
            HappyModeData d = new HappyModeData();

            persionRealItemInfo prii = new persionRealItemInfo();

            prii.Index = 1;
            hmd.RealItemInfoLst.Add(prii);

            UserActionInfo uai = new UserActionInfo();

            uai.index = 1;
            hmd.ActionEnterHappyPoint.Add(1, uai);

            RefleshCacheInfo rci = new RefleshCacheInfo();

            rci.itemId = 1;
            hmd.realItemBuyCntInRefleshTime.Add(1, rci);


            d.realItemBuyCntInRefleshTime = clone <CacheDictionary <int, RefleshCacheInfo> >(hmd.realItemBuyCntInRefleshTime);
            d.ActionEnterHappyPoint       = clone <CacheDictionary <int, UserActionInfo> >(hmd.ActionEnterHappyPoint);
            d.RealItemInfoLst             = clone <CacheList <persionRealItemInfo> >(hmd.RealItemInfoLst);
            d.PayInfoDic = clone <CacheDictionary <string, PayOrderPersion> >(hmd.PayInfoDic);
        }
Example #8
0
        public override bool TakeAction()
        {
            if (false == GameConfigMgr.Instance().ActivityIsOpen(requestPack.version, 106))
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_open;
                return(true);
            }

            int opt = requestPack.actionID;

            if (opt != (int)Request1010Pack.EnumOptType.use_enterNum &&
                opt != (int)Request1010Pack.EnumOptType.use_happyRelive)
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.error_actionid;
                return(true);
            }

            var           cache = new PersonalCacheStruct <HappyModeData>();
            int           keyId = utils.KeyUInt2Int(requestPack.the3rdUserID);
            HappyModeData hmd   = cache.FindKey(keyId.ToString());

            if (null == hmd)
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_find_happyModeData;
                return(true);
            }

            int actionIndexForHappy = -1;

            if (opt == (int)Request1010Pack.EnumOptType.use_enterNum)
            {
                if (hmd.EnterNum <= 0)
                {
                    responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_enought_enterNum;
                    return(true);
                }
                hmd.ModifyLocked(() =>
                {
                    hmd.EnterNum      -= 1;
                    int cnt            = hmd.ActionEnterHappyPoint.Count;
                    UserActionInfo uai = new UserActionInfo();
                    uai.index          = cnt;
                    uai.type           = 0;
                    hmd.ActionEnterHappyPoint.Add(cnt, uai);
                    actionIndexForHappy = cnt;
                });
            }

            if (opt == (int)Request1010Pack.EnumOptType.use_happyRelive)
            {
                if (hmd.HappyReliveNum <= 0)
                {
                    responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_enought_happyReliveNum;
                    return(true);
                }
                hmd.ModifyLocked(() => {
                    hmd.HappyReliveNum -= 1;
                });
            }

            responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.ok;
            responsePack.actionId  = (int)requestPack.actionID;
            responsePack.index     = actionIndexForHappy;
            return(true);
        }
Example #9
0
        public override bool TakeAction()
        {
            if(false == GameConfigMgr.Instance().ActivityIsOpen(requestPack.version,106))
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_open;
                return true;
            }

            int opt = requestPack.actionID;
            if (opt != (int)Request1010Pack.EnumOptType.use_enterNum &&
                opt != (int)Request1010Pack.EnumOptType.use_happyRelive)
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.error_actionid;
                return  true;
            }

            var cache = new PersonalCacheStruct<HappyModeData>();
            int keyId = utils.KeyUInt2Int(requestPack.the3rdUserID);
            HappyModeData hmd = cache.FindKey(keyId.ToString());
            if(null == hmd)
            {
                responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_find_happyModeData;
                return true;
            }

            int actionIndexForHappy = -1;
            if (opt == (int)Request1010Pack.EnumOptType.use_enterNum)
            {
                if(hmd.EnterNum<=0)
                {
                    responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_enought_enterNum;
                    return true;
                }
                hmd.ModifyLocked(() =>
                {
                    hmd.EnterNum -= 1;
                    int cnt = hmd.ActionEnterHappyPoint.Count;
                    UserActionInfo uai = new UserActionInfo();
                    uai.index = cnt;
                    uai.type = 0;
                    hmd.ActionEnterHappyPoint.Add(cnt,uai);
                    actionIndexForHappy = cnt;
                });
            }

            if (opt == (int)Request1010Pack.EnumOptType.use_happyRelive)
            {
                if(hmd.HappyReliveNum<=0)
                {
                    responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.not_enought_happyReliveNum;
                    return true;
                }
                hmd.ModifyLocked(() => {
                    hmd.HappyReliveNum -= 1;
                });
            }

            responsePack.errorCode = (byte)Response1010Pack.EnumErrorCode.ok;
            responsePack.actionId  = (int)requestPack.actionID;
            responsePack.index     = actionIndexForHappy;
            return true;
        }
Example #10
0
 public static NfaCell <SYMBOL_ENUM, TREE_NODE> Create(SYMBOL_ENUM lhs, int rhsSeen, IEnumerable <SYMBOL_ENUM> recovery,
                                                       int productionMark, string coords, HashSet <int>[] taboo, UserActionInfo <TREE_NODE> action)
 {
     return(new NfaCell <SYMBOL_ENUM, TREE_NODE>(lhs, rhsSeen, recovery, productionMark, coords, taboo, action));
 }
Example #11
0
        //行为前过滤
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            #region 验证是否有访问权限
            ////留个后门,给管理方便,发布时删除
            //if (UserLogin.UserName.Equals("admin123"))
            //{
            //    return;
            //}

            //获取用户以及要访问的url
            UserInfo userInfo       = UserInfoBll.GetById(UserLogin.UserId);
            string   controllerName = RouteData.GetRequiredString("controller");
            string   actionName     = RouteData.GetRequiredString("action");
            if (actionName == "CheckExist" || actionName == "GetSelect" || actionName == "CheckPwdRight")
            {
                //默认所有人都有验证字段名是否存在、获取下拉列表数据和判断密码是否正确的权限
                return;
            }
            ActionInfo actionInfo = ActionInfoBll.GetList <int>(a =>
                                                                (a.ControllerName.ToLower().Equals(controllerName.ToLower()))
                                                                &&
                                                                (a.ActionName.ToLower().Equals(actionName.ToLower()))
                                                                &&
                                                                a.IsDeleted == 0)
                                    .FirstOrDefault();
            if (actionInfo == null)
            {
                //访问url有误
                filterContext.Result = new RedirectResult("/Error.html");
                return;
            }

            //查询否决,看有无数据
            UserActionInfo userActionInfo = UserActionInfoBll.GetList <int>(ua =>
                                                                            (ua.UserId == userInfo.UserId)
                                                                            &&
                                                                            (ua.ActionId == actionInfo.ActionId)).FirstOrDefault();
            if (userActionInfo != null)
            {
                //否决表中有数据
                if (userActionInfo.IsAllow == 1)
                {
                    //允许
                    return;
                }
                else
                {
                    //拒绝,跳转到无权限页面
                    filterContext.Result = new RedirectResult("/NoAccess.html");
                }
            }
            else
            {
                //否决表中无数据,则通过用户找角色,通过角色找权限
                var result = from r in userInfo.RoleInfo
                             from a in r.ActionInfo
                             where a.ActionId == actionInfo.ActionId
                             select a;
                if (result.Count() > 0)
                {
                    //有权限
                    return;
                }
                else
                {
                    //无权限,跳转到无权限页面
                    filterContext.Result = new RedirectResult("/NoAccess.html");
                }
            }
            #endregion
        }