Ejemplo n.º 1
0
    /// <summary>
    /// 更新信息
    /// </summary>
    public void SaveData()
    {
        var json = Request["data"];
        var rows = (ArrayList)PluSoft.Utils.JSON.Decode(json);

        foreach (Hashtable row in rows)
        {
            var id = row["ID"] != null ? row["ID"].ToString() : "";

            //根据记录状态,进行不同的增加、删除、修改操作
            var state = row["_state"] != null ? row["_state"].ToString() : "";
            if (state == "added" || id == "")           //新增:id为空,或_state为added
            {
                model.Abstract   = row["Abstract"] == null ? "" : row["Abstract"].ToString();
                model.Content    = PageRequest.GetString("Content");
                model.CreateIp   = PageRequest.GetIP();
                model.CreateTime = DateTime.Now;
                model.NewsTitle  = row["NewsTitle"] == null ? "" : row["NewsTitle"].ToString();
                model.Publisher  = Admin.GetRealName();
                model.Source     = row["Source"] == null ? "" : row["Source"].ToString();
                model.TotalClick = 0;
                model.TypeId     = Utils.StrToInt(row["TypeId"], 0);
                model.UpdateIp   = model.CreateIp;
                model.UpdateTime = model.CreateTime;

                BllNews.Add(model);
            }
            else if (state == "modified" || state == "") //更新:_state为空或modified
            {
                model = BllNews.GetModel(Utils.StrToInt(row["ID"], 0));
                if (model != null)
                {
                    #region 基础字段
                    model.Abstract  = row["Abstract"] == null ? "" : row["Abstract"].ToString();
                    model.Content   = PageRequest.GetString("Content");
                    model.NewsTitle = row["NewsTitle"] == null ? "" : row["NewsTitle"].ToString();
                    model.Publisher = row["Publisher"] == null ? "" : row["Publisher"].ToString();
                    model.Source    = row["Source"] == null ? "" : row["Source"].ToString();

                    model.TypeId     = Utils.StrToInt(row["TypeId"], 0);
                    model.UpdateIp   = PageRequest.GetIP();
                    model.UpdateTime = DateTime.Now;
                    #endregion

                    BllNews.Update(model);
                }
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 更新信息
    /// </summary>
    public void SaveData()
    {
        var json = Request["data"];
        var rows = (ArrayList)PluSoft.Utils.JSON.Decode(json);
        var bllNewsType = new Sys.BLL.NewsType();
        Sys.Model.NewsType model;
        foreach (Hashtable row in rows)
        {
            var id = row["ID"] != null ? row["ID"].ToString() : "";
            //根据记录状态,进行不同的增加、删除、修改操作
            var state = row["_state"] != null ? row["_state"].ToString() : "";
            if (state == "added" || id == "")           //新增:id为空,或_state为added
            {
                model = new Sys.Model.NewsType
                            {
                                Count = 0,
                                CreateIp = PageRequest.GetIP(),
                                CreateTime = DateTime.Now,
                                PId = Utils.StrToInt(row["PId"], 0),
                                TypeAction = row["TypeAction"] == null ? "" : row["TypeAction"].ToString(),
                                TypeName = row["TypeName"] == null ? "" : row["TypeName"].ToString()
                            };


                bllNewsType.Add(model);
            }
            else if (state == "modified" || state == "") //更新:_state为空或modified
            {
                model = bllNewsType.GetModel(Utils.StrToInt(row["ID"], 0));
                if (model != null)
                {
                    model.PId = Utils.StrToInt(row["PId"], 0);
                    model.TypeAction = row["TypeAction"] == null ? "" : row["TypeAction"].ToString();
                    model.TypeName = row["TypeName"] == null ? "" : row["TypeName"].ToString();
                    bllNewsType.Update(model);
                }

            }
        }

    }
Ejemplo n.º 3
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");
        }
    }
Ejemplo n.º 4
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);
                }
            }
        }
    }