示例#1
0
        /// <summary>
        /// 验证用户是否具有指定的模块与功能权限
        /// <para>验证方式:</para>
        /// <para>模块识别码及功能识别码</para>
        /// </summary>
        /// <param name="identModule">模块识别码</param>
        /// <param name="identFunction">功能识别码</param>
        /// <returns>执行结果</returns>
        public static bool VerifyRealtime(int identModule, int identFunction)
        {
            if (UserId < 1 || identModule < 1 || identFunction < 1)
            {
                return(false);
            }
            string cmdSql = string.Format("user_id='{0}' and map_module='{1}' and charindex(',{2},',map_function)>0", UserId, identModule, identFunction);

            return(DawnAuthUserPowerBLL.Exists(cmdSql));
        }
示例#2
0
        public string BindPowered(FormCollection form)
        {
            var    stateInfo   = GeneralHandler.StateSuccess;
            int    userId      = TypeHelper.TypeToInt32(form["userId"], -1);
            int    mapModule   = TypeHelper.TypeToInt32(form["mapModule"], -1);
            int    mapFunction = TypeHelper.TypeToInt32(form["mapFunction"], -1);
            string opFlag      = form["opFlag"] as string;

            if (userId > 0 && mapModule > 0 && mapFunction > 0)
            {
                var powList = DawnAuthUserPowerBLL.ISelect(string.Format("user_id='{0}' and map_module='{1}'", userId, mapModule));
                if (powList == null || powList.Count < 1)
                {
                    var upFun = string.Format(",{0},", mapFunction);
                    if (opFlag == "add")
                    {
                        DawnAuthUserPowerMDL dataInfo = new DawnAuthUserPowerMDL();
                        dataInfo.UserId      = userId;
                        dataInfo.MapTime     = DateTime.Now;
                        dataInfo.MapModule   = mapModule;
                        dataInfo.MapFunction = upFun;
                        DawnAuthUserPowerBLL.Insert(dataInfo);
                    }
                }
                else
                {
                    var upFun  = string.Format("{0},", mapFunction);
                    var strFun = powList.First().MapFunction;
                    if (string.IsNullOrEmpty(strFun))
                    {
                        strFun = ",";
                    }
                    if (opFlag == "add")
                    {
                        if (!strFun.Contains(upFun))
                        {
                            strFun += upFun;
                            DawnAuthUserPowerBLL.UpdateFunction(userId, mapModule, strFun);
                        }
                    }
                    else if (opFlag == "del")
                    {
                        upFun  = string.Format(",{0},", mapFunction);
                        strFun = strFun.Replace(upFun, ",");
                        DawnAuthUserPowerBLL.UpdateFunction(userId, mapModule, strFun);
                    }
                }
            }
            else
            {
                stateInfo = GeneralHandler.FBaseInfo;
            }
            return(stateInfo);
        }
示例#3
0
        public string GetPower(FormCollection form)
        {
            int moduleId = TypeHelper.TypeToInt32(form["moduleId"], 0);
            int userId   = TypeHelper.TypeToInt32(form["userId"], 0);

            if (moduleId < 1 || userId < 1)
            {
                return(GeneralHandler.FNoneInfo);
            }
            var dataList = DawnAuthFunctionBLL.ISelect("fun_ident > 0", "fun_ident");

            if (dataList == null || dataList.Count < 1)
            {
                return(GeneralHandler.FNoneInfo);
            }
            var    mapList     = DawnAuthUserPowerBLL.ISelect(string.Format("user_id='{0}' and map_module='{1}'", userId, moduleId));
            string mapFunction = null;

            if (mapList.Count > 0)
            {
                mapFunction = mapList.First().MapFunction;
            }
            int           indexVal = 0;
            StringBuilder sb       = new StringBuilder();

            foreach (var item in dataList)
            {
                indexVal++;
                sb.Append("<li class=\"field-item bi\">");
                sb.AppendFormat("<label>{0}</label>", item.FunName);
                var findFun = string.Format(",{0},", item.FunIdent);
                if (mapFunction != null && mapFunction.Contains(findFun))
                {
                    sb.AppendFormat("<input class=\"switch-on\" type=\"button\" id=\"btn{0}\" onclick=\"dataUnSave({0},{1},{2},{3});\" />", indexVal, userId, moduleId, item.FunIdent);
                }
                else
                {
                    sb.AppendFormat("<input class=\"switch-off\" type=\"button\" id=\"btn{0}\" onclick=\"dataSave({0},{1},{2},{3});\" />", indexVal, userId, moduleId, item.FunIdent);
                }
                sb.AppendFormat("<span class=\"margin-left-10\">{0}</span>", item.FunDesc);
                sb.Append("</li>");
            }
            return(sb.ToString());
        }