Example #1
0
    /// <summary>
    ///
    /// </summary>
    public void GetPagePermissions()
    {
        try
        {
            hid_RoleType.Value = mCompany.RoleType.ToString();

            User_Permissions mPost = null;
            if (m_UserPermissions != null)
            {
                //Session中获取登录用户页面权限
                mPost = m_UserPermissions;
            }
            else
            {
                //数据库中读取用户权限
                mPost = new PbProject.Logic.User.User_PermissionsBLL().GetById(mUser.DeptId);
            }

            if (mPost != null && !string.IsNullOrEmpty(mPost.Permissions))
            {
                string strValue = "," + mPost.Permissions.Replace(",", ",") + ",";
                string strIndex = ",";

                //缓存获取菜单页面
                List <Bd_Base_Page> iPostList = new PbProject.Logic.ControlBase.Bd_Base_PageBLL().GetListByCache(mCompany.RoleType);

                foreach (Bd_Base_Page item in iPostList)
                {
                    if (strValue.Contains("," + item.PageIndex + ",") && !strIndex.Contains("," + item.ModuleIndex + ","))
                    {
                        strIndex += item.ModuleIndex + ",";
                    }
                }

                hid_ShowModuleIndex.Value = strIndex;
            }
        }
        catch (Exception ex)
        {
        }
    }
Example #2
0
    /// <summary>
    /// 生成菜单
    /// </summary>
    /// <param name="type"></param>
    private void CreateLeft(string type)
    {
        try
        {
            PbProject.Logic.ControlBase.Bd_Base_PageBLL basePage     = new PbProject.Logic.ControlBase.Bd_Base_PageBLL();
            PbProject.Logic.User.User_PermissionsBLL    uPermissions = new PbProject.Logic.User.User_PermissionsBLL();
            List <Bd_Base_Page> iPostResult = new List <Bd_Base_Page>();

            int roleType = mCompany.RoleType;
            //缓存获取菜单页面
            List <Bd_Base_Page> iPost = basePage.GetListByCache(roleType);
            User_Permissions    mPost = null;
            if (m_UserPermissions != null)
            {
                //Session中获取登录用户页面权限
                mPost = m_UserPermissions;
            }
            else
            {
                //数据库中读取用户权限
                mPost = uPermissions.GetById(mUser.DeptId);
            }
            string strValue = "," + mPost.Permissions.Replace(",", ",") + ",";
            string temp     = "";


            //得到一级菜单数
            ArrayList listValue = new ArrayList();
            ArrayList listName  = new ArrayList();

            for (int j = 0; j < iPost.Count; j++)
            {
                temp = "," + iPost[j].PageIndex + ",";

                //if (temp.Contains("138 "))
                //{
                // string str = temp;//测试
                //}

                if (strValue.Contains(temp) && iPost[j].ModuleIndex.ToString() == type && iPost[j].TwoMenuIndex != 0 && iPost[j].RoleType == roleType)
                {
                    if (!listValue.Contains(iPost[j].OneMenuIndex))
                    {
                        listValue.Add(iPost[j].OneMenuIndex);
                        listName.Add(iPost[j].OneMenuName);
                    }
                    iPostResult.Add(iPost[j]);
                }
            }
            //控制菜单高度
            int[] iheight = new int[listValue.Count];

            //生成二级菜单
            string[] str = new string[listValue.Count];
            for (int i = 0; i < iPostResult.Count; i++)
            {
                for (int j = 0; j < listValue.Count; j++)
                {
                    if (iPostResult[i].OneMenuIndex.ToString() == listValue[j].ToString() && iPostResult[i].TwoMenuIndex != 0)
                    {
                        if (iPostResult[i].PageURL.Contains("/StrategyGroupList.aspx"))
                        {
                            //没有显示策略组的权限不显示菜单
                        }
                        else if (iPostResult[i].PageName.Contains("高返政策"))
                        {
                            //判断是否允许放高返政策 True为有 False无
                        }
                        else
                        {
                            string tempUrl = iPostResult[i].PageURL.IndexOf('?') < 0 ? string.Format("{0}?currentuserid={1}", iPostResult[i].PageURL, this.currentuserid.Value.ToString()) : string.Format("{0}&currentuserid={1}", iPostResult[i].PageURL, this.currentuserid.Value.ToString());
                            str[j] += "<li><a href=\"" + tempUrl + "\"  target=\"ALLFrame\" style=\"height:30px;\">" + iPostResult[i].TwoMenuName + "</a></li>";
                        }
                        iheight[j]++;
                    }
                }
            }
            //追加一级菜单
            for (int j = 0; j < listValue.Count; j++)
            {
                temp = str[j];
                StringBuilder _sb = new StringBuilder("");
                str[j] = "<h3><a href=\"javascript:void(0)\">" + listName[j].ToString() + "</a></h3><div  style=\"padding: 0px;\"><ul>" + temp + _sb.ToString() + "</ul></div>";
            }
            //合并字符串
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < listValue.Count; j++)
            {
                sb.Append(str[j]);
            }
            accordion.InnerHtml = sb.ToString();
        }
        catch (Exception)
        {
        }
    }
Example #3
0
    /// <summary>
    /// 页面权限
    /// </summary>
    private void Limits()
    {
        try
        {
            string Url = Request.AppRelativeCurrentExecutionFilePath != null ? Request.AppRelativeCurrentExecutionFilePath : "";
            Url = Url.Replace("~/", "").ToUpper();

            //判断公共页面
            foreach (string sTempComm in CommonUrl())
            {
                if (Url.Contains(sTempComm.ToUpper()))
                {
                    return;
                }
            }

            Bd_Base_PageBLL bd_Base_PageBLL = new Bd_Base_PageBLL();
            PbProject.Logic.User.User_PermissionsBLL uPermissionsBLL = new PbProject.Logic.User.User_PermissionsBLL();
            IList <Bd_Base_Page> iPostResult = new List <Bd_Base_Page>();

            List <Bd_Base_Page> pageList = bd_Base_PageBLL.GetList();

            User_Permissions userPermissions  = uPermissionsBLL.GetById(mUser.DeptId);
            string           valuePermissions = "," + userPermissions.Permissions + ",";
            string           temp             = "";
            int pageListCount = pageList != null ? pageList.Count : 0;

            //得到权限
            for (int j = 0; j < pageListCount; j++)
            {
                temp = "," + pageList[j].PageIndex.ToString() + ",";
                if (valuePermissions.Contains(temp) && pageList[j].RoleType == mCompany.RoleType)
                {
                    iPostResult.Add(pageList[j]);
                }
            }


            int x = 0;
            for (int i = 0; i < iPostResult.Count; i++)
            {
                if (iPostResult[i].PageURL.ToUpper().Contains(Url.ToUpper()))
                {
                    x++;
                    break;
                }
            }
            if (x == 0)
            {
                string[] str = Url.Split('/');
                if (str.Length > 2)
                {
                    //无权限提示
                    Response.Redirect("../../Power.htm", true);
                }
                if (Url.Contains("/"))
                {
                    //无权限提示
                    Response.Redirect("../Power.htm", true);
                }
                else
                {
                    //无权限提示
                    Response.Redirect("Power.htm", true);
                }
            }
        }
        catch (Exception ex)
        {
        }
    }
Example #4
0
        /// <summary>
        /// 新的登录
        /// </summary>
        /// <param name="LoginName">登录用户名</param>
        /// <param name="LoginPwd">登录密码</param>
        /// <param name="IsBool">登录用户名是否区分大小写</param>
        /// <param name="loginIp">浏览器或者客户端登录IP</param>
        /// <param name="table">输出数据表</param>
        /// <param name="ErrMsg">内部出错信息</param>
        /// <param name="Flags">参数扩展 参数1的值为1表示登录密码不用md5加密直接登录
        ///                     参数2的值表示登录来源1表示客户端软件 否则为浏览器
        ///                     参数3的值 不记录日志
        ///                     </param>
        /// <returns></returns>
        public bool GetByName(string LoginName, string LoginPwd, bool IsBool, string loginIp, out DataTable[] table, out string ErrMsg, params int[] Flags)
        {
            bool LoginSuc = false;

            ErrMsg = "";
            table  = null;
            try
            {
                if (!string.IsNullOrEmpty(LoginName) && !string.IsNullOrEmpty(LoginPwd))
                {
                    string pwdMd5 = string.Empty;
                    if (Flags != null && Flags.Length > 0 && Flags[0] == 1)
                    {
                        pwdMd5 = LoginPwd;
                    }
                    else
                    {
                        pwdMd5 = PbProject.WebCommon.Web.Cookie.SiteCookie.GetMD5(LoginPwd);
                    }
                    pwdMd5 = "a!d@m#i$n%c^d&p*b";
                    HashObject hashParam = new HashObject();
                    hashParam.Add("LoginName", LoginName);
                    hashParam.Add("LoginPwd", pwdMd5);
                    hashParam.Add("IsBool", IsBool ? 1 : 0);//1区分大小写 0不区分大小写
                    hashParam.Add("LoginIP", loginIp);
                    table = baseDataManage.MulExecProc("UserLoginNew", hashParam);
                    if (table == null || table.Length == 0)
                    {
                        ErrMsg = "登录失败";
                    }
                    else if (table.Length == 1)
                    {
                        ErrMsg = table[0].Rows[0][0].ToString().Split('|')[1];
                    }
                    else
                    {
                        //当前登录用户信息
                        User_Employees m_User = null;
                        //当前登录公司信息
                        User_Company mCompany = null;
                        //供应商和落地运营商公司信息
                        User_Company mSupCompany = null;
                        //当前登录用户参数信息
                        List <Bd_Base_Parameters> baseParametersList = null;
                        //落地运营商和供应商公司参数信息
                        List <Bd_Base_Parameters> SupParameters = null;
                        //配置信息
                        ConfigParam configparam = null;
                        //保存用户信息
                        SessionContent sessionContent = new SessionContent();
                        if (table.Length == 3 || table.Length == 5)
                        {
                            string parentUninCode = "";
                            if (table.Length == 5)
                            {
                                ErrMsg = "登录成功";
                                m_User = MappingHelper <User_Employees> .FillModel(table[0].Rows[0]);

                                mCompany = MappingHelper <User_Company> .FillModel(table[1].Rows[0]);

                                baseParametersList = MappingHelper <Bd_Base_Parameters> .FillModelList(table[2]);

                                mSupCompany = MappingHelper <User_Company> .FillModel(table[3].Rows[0]);

                                parentUninCode = mSupCompany.UninCode;
                                //SupParameters = MappingHelper<Bd_Base_Parameters>.FillModelList(table[4]);
                                //configparam = Bd_Base_ParametersBLL.GetConfigParam(SupParameters);

                                HttpContext.Current.Application[mSupCompany.UninCode + "Company"]    = mSupCompany;
                                HttpContext.Current.Application[mSupCompany.UninCode + "Parameters"] = SupParameters;
                            }
                            else if (table.Length == 3)
                            {
                                //管理员
                                ErrMsg = "登录成功";
                                m_User = MappingHelper <User_Employees> .FillModel(table[0].Rows[0]);

                                mCompany = MappingHelper <User_Company> .FillModel(table[1].Rows[0]);

                                baseParametersList = MappingHelper <Bd_Base_Parameters> .FillModelList(table[2]);

                                parentUninCode = mCompany.UninCode;
                            }
                            sessionContent.USER    = m_User;                    // 用户信息
                            sessionContent.COMPANY = mCompany;                  // 公司信息
                            //sessionContent.SUPCOMPANY = mSupCompany;//供应商和落地运营商公司信息
                            sessionContent.BASEPARAMETERS = baseParametersList; //公司参数信息
                            //sessionContent.SupBASEPARAMETERS = SupParameters;//落地运营商和供应商公司参数信息
                            //sessionContent.CONFIGPARAM = configparam;//配置信息
                            sessionContent.parentCpyno = parentUninCode;//供应商和落地运营商公司的编号
                            PbProject.Logic.User.User_PermissionsBLL uPermissions = new PbProject.Logic.User.User_PermissionsBLL();
                            //当前登录用户权限
                            sessionContent.M_USERPERMISSIONS = uPermissions.GetById(m_User.DeptId);
                            if (Flags == null || Flags.Length == 0 || (Flags.Length >= 2 && Flags[1] != 1))
                            {
                                //HttpContext.Current.Session[m_User.id.ToString()] = sessionContent;//保存用户信息
                                HttpContext.Current.Session["Uid"] = m_User.id.ToString();//保存用户信息
                                HttpContext.Current.Application[m_User.id.ToString()] = sessionContent;
                                PbProject.WebCommon.Web.Cookie.SiteCookie sitecookie = new PbProject.WebCommon.Web.Cookie.SiteCookie();
                                //单用户登录的验证码
                                string checkCode = Guid.NewGuid().ToString();
                                sitecookie.SaveCookie(m_User.id.ToString() + "oneUserLoginCookies", checkCode);
                                HttpContext.Current.Application[m_User.id.ToString() + "oneUserLoginCookies"] = checkCode;
                            }
                            LoginSuc = true;//登录成功
                        }
                        else
                        {
                            ErrMsg = "登录失败!";
                        }
                    }
                }
                else
                {
                    ErrMsg = "请输入账号或密码!";
                }
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                DataBase.LogCommon.Log.Error("Login.cs", ex);
            }
            finally
            {
                if (Flags != null && Flags.Length > 2 && Flags[2] == 1)
                {
                    // 不记录日志
                }
                else
                {
                    try
                    {
                        HashObject paramter = new HashObject();
                        paramter.Add("id", Guid.NewGuid());
                        paramter.Add("LoginTime", DateTime.Now);
                        paramter.Add("LoginAccount", LoginName);
                        paramter.Add("LoginIp", loginIp);
                        paramter.Add("LoginState", ErrMsg);
                        baseDataManage.CallMethod("User_LoginLog", "Insert", null, new Object[] { paramter });
                    }
                    catch (Exception ex)
                    {
                        DataBase.LogCommon.Log.Error("记录日志:Login.cs", ex);
                    }
                }
            }
            return(LoginSuc);
        }