Ejemplo n.º 1
0
        public string Delete(string id)
        {
            var stateInfo = GeneralHandler.StateSuccess;

            if (!string.IsNullOrEmpty(id))
            {
                DawnAuthRoleBLL.Delete(int.Parse(id));
            }
            return(stateInfo);
        }
Ejemplo n.º 2
0
        public ActionResult Editor(string id)
        {
            if (string.IsNullOrEmpty(id) || TypeHelper.TypeToInt32(id, -1) < 0)
            {
                return(RedirectToAction("List"));
            }
            var dataInfo = DawnAuthRoleBLL.Select(int.Parse(id));

            return(View(dataInfo));
        }
Ejemplo n.º 3
0
        public ActionResult BindRole(string id)
        {
            if (string.IsNullOrEmpty(id) || TypeHelper.TypeToInt32(id, -1) < 0)
            {
                return(RedirectToAction("List"));
            }
            var dataList = DawnAuthRoleBLL.ISelect();
            var roleList = DawnAuthUserRoleBLL.ISelect(string.Format("user_id='{0}'", int.Parse(id)));

            ViewBag.UserId       = id;
            ViewBag.UserBindRole = roleList;
            return(View(dataList));
        }
Ejemplo n.º 4
0
        public string Authorityed(FormCollection form)
        {
            var    stateInfo  = GeneralHandler.StateSuccess;
            string roleCode   = form["hidRoleCode"];
            string moduleCode = form["moduleCode"];
            string authString = form["authString"];
            var    roleInfo   = DawnAuthRoleBLL.ISelect(string.Format("role_code='{0}'", roleCode)).First();

            if (string.IsNullOrEmpty(roleInfo.RoleAuthority) || string.IsNullOrWhiteSpace(roleInfo.RoleAuthority) || !roleInfo.RoleAuthority.Contains(moduleCode))
            {
                authString  = "|" + authString;
                authString  = moduleCode + authString;
                authString += ";";
                if (!string.IsNullOrWhiteSpace(roleInfo.RoleAuthority))
                {
                    authString = roleInfo.RoleAuthority + authString;
                }
            }
            else
            {
                string[] authArray = GetModuleFunction(roleInfo.RoleAuthority);
                for (int i = 0; i < authArray.Length; i++)
                {
                    if (string.IsNullOrWhiteSpace(authArray[i]))
                    {
                        continue;
                    }
                    if (authArray[i].Contains(moduleCode))
                    {
                        authArray[i] = "|" + authString;
                        authArray[i] = moduleCode + authArray[i];
                        break;
                    }
                }
                authString = null;
                for (int i = 0; i < authArray.Length; i++)
                {
                    if (string.IsNullOrWhiteSpace(authArray[i]))
                    {
                        continue;
                    }
                    authString += authArray[i];
                    authString += ";";
                }
            }
            DawnAuthRoleBLL.Update(roleCode, authString);
            return(stateInfo);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 角色信息数据列表
        /// </summary>
        /// <param name="id">页码</param>
        /// <returns>执行结果</returns>
        public ActionResult List(string id)
        {
            var pager = new PagerHelperCHS();

            pager.PageSize    = GeneralHandler.PageSize;
            pager.PageCurrent = TypeHelper.TypeToInt32(id, 1);
            int pageCount, recordCount;
            var dataList = DawnAuthRoleBLL.SelectPSPisAllPurposeRowNumber(pager.PageSize, pager.PageCurrent, null, out pageCount, out recordCount);

            pager.PageCount       = pageCount;
            pager.RecordCount     = recordCount;
            pager.PageRecordCount = dataList.Count;
            ViewBag.FPager        = pager;
            ViewBag.PageCurrent   = pager.PageCurrent;
            return(View(dataList));
        }
Ejemplo n.º 6
0
        public string Editored(FormCollection form)
        {
            if (TypeHelper.TypeToInt32(form["hidRoleId"], -1) < 0)
            {
                return(GeneralHandler.FBaseInfo);
            }
            var stateInfo = GeneralHandler.StateSuccess;

            if (EditoredByCheck(form, out stateInfo))
            {
                DawnAuthRoleMDL dataInfo = new DawnAuthRoleMDL();
                dataInfo.RoleId   = int.Parse(form["hidRoleId"]);
                dataInfo.RoleName = form["txtName"];
                dataInfo.RoleDesc = form["txtDesc"];
                DawnAuthRoleBLL.UpdateEditor(dataInfo);
            }
            return(stateInfo);
        }
Ejemplo n.º 7
0
        public string Added(FormCollection form)
        {
            var stateInfo = GeneralHandler.StateSuccess;

            if (AddedByCheck(form, out stateInfo))
            {
                DawnAuthRoleMDL dataInfo = new DawnAuthRoleMDL();
                dataInfo.RoleTime = DateTime.Now;
                dataInfo.RoleName = form["txtName"];
                dataInfo.RoleCode = form["txtCode"];
                dataInfo.RoleDesc = form["txtDesc"];
                bool added = DawnAuthRoleBLL.Exists(string.Format("role_code='{0}'", dataInfo.RoleCode));
                if (added)
                {
                    stateInfo = GeneralHandler.StateAdded;
                }
                else
                {
                    DawnAuthRoleBLL.Insert(dataInfo);
                }
            }
            return(stateInfo);
        }
Ejemplo n.º 8
0
        public string Function(FormCollection form)
        {
            int    moduleId   = TypeHelper.TypeToInt32(form["moduleId"], 0);
            string roleCode   = form["roleCode"] as string;
            string moduleCode = form["moduleCode"] as string;
            var    stateInfo  = GeneralHandler.StateFailing;

            if (moduleId > 0 && !string.IsNullOrEmpty(roleCode) && !string.IsNullOrEmpty(moduleCode))
            {
                StringBuilder sb       = new StringBuilder();
                int           indexVal = 0;
                var           roleInfo = DawnAuthRoleBLL.ISelect(string.Format("role_code='{0}'", roleCode)).First();
                int[]         funArray = null;
                if (!string.IsNullOrEmpty(roleInfo.RoleAuthority) && !string.IsNullOrWhiteSpace(roleInfo.RoleAuthority))
                {
                    funArray = GetFunction(moduleCode, roleInfo.RoleAuthority);
                }
                var funList = DawnAuthFunctionBLL.ISelect(string.Format("mdl_id='{0}' and (fun_ident < 1)", moduleId), "fun_mark");
                if (funList == null || funList.Count < 1)
                {
                    sb.Append("<li class=\"field-item bi\">");
                    sb.Append(GeneralHandler.FNoneInfo);
                    sb.Append("</li>");
                }
                else
                {
                    foreach (var item in funList)
                    {
                        indexVal++;
                        sb.Append("<li class=\"field-item bi\">");
                        sb.AppendFormat("<label>{0}</label>", item.FunName);
                        int flag = 0;
                        if (funArray != null && funArray.Length > 0)
                        {
                            int indexValue = item.FunMark - 1;
                            if (indexValue < funArray.Length)
                            {
                                if (funArray[indexValue] == 1)
                                {
                                    flag = 1;
                                }
                            }
                        }
                        if (flag == 1)
                        {
                            sb.AppendFormat("<input class=\"switch-on\" type=\"button\" id=\"btn{0}\" onclick=\"dataSave({0},'{1}','del');\" />", indexVal, moduleCode);
                            sb.AppendFormat("<input type=\"hidden\" id=\"hidAuth{0}\" value=\"1\" />", indexVal);
                        }
                        else
                        {
                            sb.AppendFormat("<input class=\"switch-off\" type=\"button\" id=\"btn{0}\" onclick=\"dataSave({0},'{1}','add');\" />", indexVal, moduleCode);
                            sb.AppendFormat("<input type=\"hidden\" id=\"hidAuth{0}\" value=\"0\" />", indexVal);
                        }
                        sb.Append("</li>");
                    }
                }
                sb.AppendFormat("<input type=\"hidden\" id=\"hidAuthCount\" value=\"{0}\" />", funList.Count);
                stateInfo = sb.ToString();
            }
            return(stateInfo);
        }