Пример #1
0
    private void UpDateLevels(int userId, int parentUserId, int i)
    {
        var mm = new Sys.Model.Admin();

        mm.UserId = userId;
        var partentMod = BllAdmin.GetModel(parentUserId);

        mm.ParentUserIDs = partentMod.ParentUserIDs + "," + parentUserId;
        mm.ParentUserID  = parentUserId;
        //去除前后逗号 以防万一
        if (mm.ParentUserIDs.IndexOf(',') == 0)
        {
            mm.ParentUserIDs = mm.ParentUserIDs.Substring(1, mm.ParentUserIDs.Length - 1);
        }
        if (mm.ParentUserIDs.LastIndexOf(',') == (mm.ParentUserIDs.Length - 1))
        {
            mm.ParentUserIDs.Substring(0, mm.ParentUserIDs.Length - 1);
        }
        if (i == 0)
        {
            model.ParentUserID  = mm.ParentUserID;
            model.ParentUserIDs = mm.ParentUserIDs;
        }
        BllAdmin.UpDateLeave(mm);
        var childAdminModel = BllAdmin.GetList("ParentUserID=" + mm.UserId);

        foreach (var mmm in childAdminModel)
        {
            UpDateLevels(mmm.UserId, mm.UserId, 1);
        }
    }
Пример #2
0
    /// <summary>
    /// 订单分配查询,
    /// </summary>
    ///
    public void SearchDataDistrbution()
    {
        Loginadmin = BllAdmin.GetModel(Account.GetLoginUserID());
        if (Loginadmin == null)
        {
            return;
        }

        //查询条件
        var key = Utils.SqlStringFormat(PageRequest.GetString("key"), 2);
        //分页
        var pageIndex = PageRequest.GetInt("pageIndex", 1);
        var pageSize  = PageRequest.GetInt("pageSize", 1);
        //字段排序
        var sortField = PageRequest.GetString("sortField");
        var sortOrder = PageRequest.GetString("sortOrder");
        var order     = "";

        if (String.IsNullOrEmpty(sortField) == false)
        {
            if (sortOrder != "desc")
            {
                sortOrder = "asc";
            }
            order = " " + sortField + " " + sortOrder;
        }
        else
        {
            order += " createtime desc";
        }
        var strWhere = "1=1";

        if (key != "")
        {
            strWhere += " and charIndex('" + key + "',UserName) > 0";
        }

        // strWhere += "  and charIndex('" + Loginadmin.UserId + "',parentUserIDs) > 0  or UserId=" + Loginadmin.UserId + "";
        strWhere += " and RoleIDs='89'";

        var dt      = new Admin().GetTable(-1, -1, strWhere, order);
        var dataAll = MyDBUtils.DataTable2ArrayList(dt);
        var result  = new Hashtable();

        result["data"] = dataAll;
        var json = PluSoft.Utils.JSON.Encode(dataAll);

        Response.Write(json);
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var methodName = PageRequest.GetString("method");

        Loginadmin = BllAdmin.GetModel(Account.GetLoginUserID());
        if (Loginadmin == null)
        {
            return;
        }
        var type   = this.GetType();
        var method = type.GetMethod(methodName);

        if (method == null)
        {
            throw new Exception("method is null");
        }
        method.Invoke(this, null);
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ManageHelper.CheckAdminLogin();


        switch (act)
        {
        case "editsave":
            Save();
            break;

        default:
            break;
        }
        Loginadmin = BllAdmin.GetModel(Account.GetLoginUserID());
        Modeladmin = BllAdmin.GetModel(UserId);

        Html = GetRoleFlagList(Modeladmin.RoleFlags, Modeladmin.PlusFlag);
    }
Пример #5
0
    /// <summary>
    /// 检测管理员是否有当前模块权限
    /// </summary>
    /// <param name="Flag"></param>
    /// <returns></returns>
    public static bool CheckAdminHavePower1(string FlagAct)
    {
        bool flag = false;
        //admin
        int userID = Sys.BLL.Account.GetLoginAdminID();

        Sys.BLL.Admin   bllAdmin   = new Sys.BLL.Admin();
        Sys.Model.Admin modelAdmin = bllAdmin.GetModel(userID);
        //adminFlag
        Sys.BLL.AdminFlag          bllFlag = new Sys.BLL.AdminFlag();
        List <Sys.Model.AdminFlag> list    = bllFlag.GetList(0, -1, -1, FlagAct);

        foreach (Sys.Model.AdminFlag model in list)
        {
            modelAdmin.UserFlag = "," + modelAdmin.UserFlag + ",";
            if (modelAdmin.UserFlag.IndexOf("," + model.Flag + ",") != -1)
            {
                flag = true;
            }
        }
        return(flag);
    }
Пример #6
0
    /// <summary>
    /// 检测管理员是否有当前模块权限
    /// </summary>
    /// <param name="Flag"></param>
    /// <returns></returns>
    public static bool CheckAdminHavePower(string Flag)
    {
        bool flag   = false;
        int  userID = Sys.BLL.Account.GetLoginAdminID();
        var  bll    = new Sys.BLL.Admin();

        Sys.Model.Admin model = bll.GetModel(userID);
        model.UserFlag = "," + model.UserFlag + ",";

        //Flag = Flag.Substring(Flag.IndexOf("_") + 1, Flag.Length - Flag.IndexOf("_") - 1);

        //if (model.UserFlag.ToLower().IndexOf("_" + Flag + ",") != -1)
        //{
        //    flag = true;
        //}

        if (model.UserFlag.ToLower().IndexOf(Flag) != -1)//ZJY
        {
            flag = true;
        }
        return(flag);
    }
Пример #7
0
    /// <summary>
    /// 登陆
    /// </summary>
    private void UserLogin()
    {
        //URL登陆定向,涉及SSO登陆
        if (url.Length > 7 && url.Substring(0, 7) == "http://")
        {
            url = "";
        }
        else
        {
            url = Utils.UrlEncode(url);
        }

        //用户名字段判断
        if (username == "")
        {
            Response.Redirect("login.aspx?url=" + url + "&errmsg=帐户为空,请重新输入!&username="******"")
        {
            Response.Redirect("login.aspx?url=" + url + "&errmsg=密码为空,请重新输入!&username="******"")
        //    Response.Redirect("login.aspx?url=" + url + "&errmsg=验证码为空,请重新输入!&username="******"ValidateCode"].Value.ToLower())
        //    Response.Redirect("login.aspx?url=" + url + "&errmsg=验证码不正确,请重新输入!&username="******"WebConfig", "AdminIpBlockType", 0);
        switch (AdminIpBlockType)
        {
        case 0:
            break;

        case 1:
        {
            var bllIpBlock = new Sys.BLL.SysIpBlock();
            if (bllIpBlock.Exists(0, 1, Utils.GetRealIP()))
            {
                Response.Redirect("login.aspx?url=" + url + "&errmsg=当前IP被限制登录系统后台!&username="******"login.aspx?url=" + url + "&errmsg=当前IP被限制登录系统后台!&username="******"login.aspx?url=" + url + "&errmsg=帐户不存在!&username="******"login.aspx?url=" + url + "&errmsg=密码不正确!&username="******"login.aspx?url=" + url + "&errmsg=该账户无权登陆系统!&username="******"login.aspx?url=" + url + "&errmsg=该账户禁止登陆系统!&username="******"login.aspx?url=" + url + "&errmsg=该账户无权登陆系统后台!&username="******"login.aspx?url=" + url + "&errmsg=该账户禁止登陆系统后台!&username="******"managelogin", "登陆成功");

        //Cookie保存-帐户
        Sys.BLL.Admin.SetUsername(modelAdmin.Username);
        //Cookie保存-姓名
        Sys.BLL.Admin.SetRealName(modelAdmin.RealName);

        //Cookie保存-rememberme
        if (PageRequest.GetInt("rememberme", 0) == 1)
        {
            Utils.WriteCookie("manage_LoginName", Utils.UrlEncode(username), 518400, ConfigHelper.GetConfigString("CookieDomain"));
        }

        if (modelAdmin.Username == modelAdmin.RealName)
        {
            Response.Redirect("main.aspx?url=" + Utils.UrlEncode("user/profile.aspx"));
        }
        else if (url != "")
        {
            Response.Redirect("main.aspx?url=" + Utils.UrlEncode(url));
        }
        else
        {
            Response.Redirect("main.aspx");
        }
    }
Пример #8
0
    /// <summary>
    /// 更新信息
    /// </summary>
    public void SaveData()
    {
        var msg      = "yes";
        var json     = Request["data"];
        var rows     = (ArrayList)PluSoft.Utils.JSON.Decode(json);
        var bllAdmin = new Admin();

        foreach (Hashtable row in rows)
        {
            var id       = row["UserID"] != null ? row["UserID"].ToString() : "";
            var password = row["Password"] == null ? "" : row["Password"].ToString();
            //根据记录状态,进行不同的增加、删除、修改操作
            var state = row["_state"] != null ? row["_state"].ToString() : "";
            if (state == "added" || id == "")           //新增:id为空,或_state为added
            {
                if (model != null)
                {
                    model.RealName   = row["RealName"] == null ? "" : row["RealName"].ToString();
                    model.CreateIP   = PageRequest.GetIP();
                    model.CreateTime = DateTime.Now;
                    model.Username   = row["Username"] == null ? "" : row["Username"].ToString();
                    model.IsPublic   = Utils.StrToInt(row["IsPublic"], 0);
                    model.RoleIDs    = row["RoleIDs"] == null ? "" : row["RoleIDs"].ToString();
                    model.State      = Utils.StrToInt(row["State"], 0);
                    model.OfficeTel  = row["OfficeTel"] == null ? "" : row["OfficeTel"].ToString();
                }

                var listrole = new List <Sys.Model.AdminRole>();
                if (!string.IsNullOrEmpty(model.RoleIDs))
                {
                    listrole = new AdminRole().GetList(-1, -1, "RoleId in (" + model.RoleIDs + ")", "createtime desc");
                }
                foreach (var sysRole in listrole)
                {
                    if (sysRole.RoleFlag != "")
                    {
                        model.RoleFlags += sysRole.RoleFlag + ",";
                    }
                    if (sysRole.RoleName != "")
                    {
                        model.RoleNames += sysRole.RoleName + ",";
                    }
                }
                if (model.RoleFlags != "")
                {
                    model.UserFlag = model.RoleFlags + "," + model.PlusFlag;
                }

                var modelPartent = BllAdmin.GetModel(Utils.StrToInt(row["ParentUserID"], 0));
                if (modelPartent != null)
                {
                    if (modelPartent.ParentUserIDs == "")
                    {
                        model.ParentUserIDs = modelPartent.UserId.ToString();
                    }
                    else
                    {
                        model.ParentUserIDs = modelPartent.ParentUserIDs + "," + modelPartent.UserId;
                    }
                    model.ParentUserID = modelPartent.UserId;
                }


                model.RoleNames = Utils.Strquotes(model.RoleNames);
                bllAdmin.Add(model, Utils.MD5(password));

                Response.Write(msg);
            }
            else if (state == "modified" || state == "") //更新:_state为空或modified
            {
                model = bllAdmin.GetModel(Utils.StrToInt(row["UserID"], 0));
                if (model != null)
                {
                    #region 基础字段
                    model.RealName     = row["RealName"] == null ? "" : row["RealName"].ToString();
                    model.CreateIP     = PageRequest.GetIP();
                    model.CreateTime   = DateTime.Now;
                    model.Username     = row["Username"] == null ? "" : row["Username"].ToString();
                    model.IsPublic     = Utils.StrToInt(row["IsPublic"], 0);
                    model.RoleIDs      = row["RoleIDs"] == null ? "" : row["RoleIDs"].ToString();
                    model.ParentUserID = Utils.StrToInt(row["ParentUserID"], 0);
                    model.State        = Utils.StrToInt(row["State"], 0);
                    model.OfficeTel    = row["OfficeTel"] == null ? "" : row["OfficeTel"].ToString();
                    #endregion
                    password = password == "" ? new Account().GetModel(model.UserId).Password : Utils.MD5(password);
                    #region 角色权限
                    var listrole = new List <Sys.Model.AdminRole>();
                    if (!string.IsNullOrEmpty(model.RoleIDs))
                    {
                        listrole = new AdminRole().GetList(-1, -1, "RoleId in (" + model.RoleIDs + ")", "createtime desc");
                    }

                    model.RoleFlags = "";
                    model.RoleNames = "";
                    foreach (var sysRole in listrole)
                    {
                        if (sysRole.RoleFlag != "")
                        {
                            model.RoleFlags += sysRole.RoleFlag + ",";
                        }
                        if (sysRole.RoleName != "")
                        {
                            model.RoleNames += sysRole.RoleName + ",";
                        }
                    }
                    if (model.RoleFlags != "")
                    {
                        model.UserFlag = model.RoleFlags + "," + model.PlusFlag;
                    }
                    #endregion



                    #region 账号层次修改
                    if (bllAdmin.GetList(-1, -1, "(CHARINDEX('" + Loginadmin.UserId + "',parentUserIDs)>0 or userid=" + Loginadmin.UserId + ") and parentUserID=" + model.UserId, "createtime desc").Count > 0)
                    {
                        if (model.ParentUserID > 0)
                        {
                            UpDtaeParentUserIds(model.UserId, model.ParentUserID);
                        }
                    }

                    #endregion

                    bllAdmin.Update(model, password);
                    Response.Write(msg);
                }
            }
        }
    }
Пример #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ManageHelper.CheckAdminLogin();
     model = new Admin().GetModel(Account.GetLoginUserID()) ?? new Sys.Model.Admin();
     Flag  = model.UserFlag.IndexOf("system_allot_role") != -1;
 }