Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Model.Angel_Admin admin_info = GetAdminInfo(); //管理员信息
                //登录信息
                if (admin_info != null)
                {
                    Business.Angel_Admin_log bll = new Business.Angel_Admin_log();
                    //Model.Angel_Admin_log model1 = bll.GetModel(admin_info.UserName, 1, AngelActionName.ActionName.Login.ToString());
                    //if (model1 != null)
                    //{
                    //    //本次登录
                    //    litIP.Text = model1.user_ip;
                    //}
                    //Age_manager_log model2 = bll.GetModel(admin_info.user_name, 2, AgeEnums.ActionEnum.Login.ToString());
                    //if (model2 != null)
                    //{
                    //    //上一次登录
                    //    litBackIP.Text = model2.user_ip;
                    //    litBackTime.Text = model2.add_time.ToString();
                    //}
                }


                //LitUpgrade.Text = Utils.GetDomainStr(AgeKeys.CACHE_OFFICIAL_UPGRADE, DESEncrypt.Decrypt(AgeKeys.FILE_URL_UPGRADE_CODE, "Age"));
                //NewsNotice.Text = Utils.GetDomainStr(AgeKeys.CACHE_OFFICIAL_NOTICE, DESEncrypt.Decrypt(AgeKeys.FILE_URL_NOTICE_CODE, "Age"));
                //Utils.GetDomainStr("Age_cache_domain_info", "http://www.angelasp.com/upangelcms.asp?u=" + Request.Url.DnsSafeHost + "&i=" + Request.ServerVariables["LOCAL_ADDR"]);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 判断管理员是否已经登录(解决Session超时问题)
 /// </summary>
 public bool IsAdminLogin()
 {
     //如果Session为Null
     if (Session[AngelConst.ANGEL_SESSION_ADMIN] != null)
     {
         return(true);
     }
     else
     {
         //检查Cookies
         string adminname = AngelUtils.GetCookie("AdminName", "AngelRM");
         string adminpwd  = AngelUtils.GetCookie("AdminPwd", "AngelRM");
         if (adminname != "" && adminpwd != "")
         {
             Business.Angel_Admin bll   = new Business.Angel_Admin();
             Model.Angel_Admin    model = bll.GetModel(adminname, adminpwd);
             if (model != null)
             {
                 Session[AngelConst.ANGEL_SESSION_ADMIN] = model;
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 /// <summary>
 /// 取得管理员信息
 /// </summary>
 public Model.Angel_Admin GetAdminInfo()
 {
     if (IsAdminLogin())
     {
         Model.Angel_Admin model = Session[AngelConst.ANGEL_SESSION_ADMIN] as Model.Angel_Admin;
         if (model != null)
         {
             return(model);
         }
     }
     return(null);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 检查管理员权限
        /// </summary>
        /// <param name="nav_name">菜单名称</param>
        /// <param name="action_type">操作类型</param>
        public void ChkAdminLevel(string nav_name, string action_type)
        {
            Model.Angel_Admin         model = GetAdminInfo();
            Business.Angel_Admin_Role bll   = new Business.Angel_Admin_Role();
            //bool result = bll.Exists(model.role_id, nav_name, action_type);

            //if (!result)
            //{
            //    string msgbox = "parent.jsdialog(\"错误提示\", \"您没有管理该页面的权限,请勿非法进入!\", \"back\", \"Error\")";
            //    Response.Write("<script type=\"text/javascript\">" + msgbox + "</script>");
            //    Response.End();
            //}
        }
Exemplo n.º 5
0
        /// <summary>
        /// 用户名和密码返回实体
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        public Model.Angel_Admin GetModel(string UserName, string Password)
        {
            string Md5string = AngelDESEncrypt.Encrypt(Password);

            Adal.SetConditionString(string.Format(" LoginName='{0}' and Password='******'", UserName, Md5string));
            if (Adal.Condition_DataExist())
            {
                DataTable         table = Adal.GetDataTable();
                Model.Angel_Admin model = new Model.Angel_Admin();
                foreach (DataRow row in table.Rows)
                {
                    if (row["ID"] != null && row["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(row["ID"].ToString());
                    }
                    if (row["RoleId"] != null && row["RoleId"].ToString() != "")
                    {
                        model.RoleId = int.Parse(row["RoleId"].ToString());
                    }
                    if (row["LoginName"] != null)
                    {
                        model.LoginName = row["LoginName"].ToString();
                    }
                    if (row["Password"] != null)
                    {
                        model.Password = row["Password"].ToString();
                    }
                    if (row["UserName"] != null)
                    {
                        model.UserName = row["UserName"].ToString();
                    }
                    if (row["UserEmail"] != null)
                    {
                        model.UserEmail = row["UserEmail"].ToString();
                    }
                    if (row["IsWorking"] != null && row["IsWorking"].ToString() != "")
                    {
                        model.IsWorking = int.Parse(row["IsWorking"].ToString());
                    }
                    if (row["AddTime"] != null && row["AddTime"].ToString() != "")
                    {
                        model.AddTime = DateTime.Parse(row["AddTime"].ToString());
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 写入管理日志
 /// </summary>
 /// <param name="action_type"></param>
 /// <param name="remark"></param>
 /// <returns></returns>
 public bool AddAdminLog(string action_type, string remark)
 {
     if (AngelSiteconfig.Islogstatus > 0)
     {
         Model.Angel_Admin     model    = GetAdminInfo();
         Model.Angel_Admin_log adminlog = new Model.Angel_Admin_log();
         adminlog.AdminId       = model.ID;
         adminlog.AdminName     = model.LoginName;
         adminlog.OperateIP     = AngelRequest.GetIP();
         adminlog.Operate_Value = action_type;
         adminlog.Explain       = remark;
         bool issuccess = new Business.Angel_Admin_log().Add(adminlog);
         if (issuccess)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.Angel_Admin model)
 {
     return(Adal.UpdateObject <Model.Angel_Admin>(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Model.Angel_Admin model)
 {
     return(Adal.InsertObject <Model.Angel_Admin>(model));
 }
Exemplo n.º 9
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string userPwd  = txtPassword.Text.Trim();

            if (userName.Equals("") || userPwd.Equals(""))
            {
                msgtip.InnerHtml = "请输入用户名或密码";
                return;
            }
            if (Session["AdminLoginCount"] == null)
            {
                Session["AdminLoginCount"] = 1;
            }
            else
            {
                Session["AdminLoginCount"] = Convert.ToInt32(Session["AdminLoginCount"]) + 1;
            }
            //判断登录错误次数
            if (Session["AdminLoginCount"] != null && Convert.ToInt32(Session["AdminLoginCount"]) > 5)
            {
                msgtip.InnerHtml = "错误超过5次,关闭浏览器重新登录!";
                return;
            }


            Business.Angel_Admin bll = new Business.Angel_Admin();

            Model.Angel_Admin model = bll.GetModel(userName, userPwd);
            if (model == null)
            {
                msgtip.InnerHtml = "用户名或密码有误,请重试!";
                return;
            }
            Session[AngelConst.ANGEL_SESSION_ADMIN] = model;
            Session.Timeout = 45;
            //写入登录日志
            Model.Angel_Siteconfig SiteconfigInfo = new Business.Angel_Siteconfig().loadConfig();
            if (SiteconfigInfo.Islogstatus > 0)
            {
                Model.Angel_Admin_log adminlog = new Model.Angel_Admin_log();
                adminlog.AdminId       = model.ID;
                adminlog.AdminName     = model.LoginName;
                adminlog.OperateIP     = AngelRequest.GetIP();
                adminlog.Operate_Value = AngelActionName.ActionName.Login.ToString();
                adminlog.Explain       = "用户登录";
                adminlog.AddTime       = DateTime.Now;
                Business.Angel_Admin_log blllog = new Business.Angel_Admin_log();
                bool aaa = blllog.Add(adminlog);
                // new Business.Angel_Admin_log().Add(adminlog);
            }
            //写入Cookies记住用户名
            if (this.Issavepwd.Checked == true)
            {
                AngelUtils.WriteCookie("AgeRememberName", model.UserName, 16000);
            }
            else
            {
                AngelUtils.WriteCookie("AgeRememberName", "", 16000);
            }
            AngelUtils.WriteCookie("AgeRememberName", model.UserName, 16000);
            AngelUtils.WriteCookie("AdminName", "AngelRM", model.UserName);
            Response.Redirect("MainFrame/Main.aspx");
            return;
        }
Exemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            AngelRM.Business.Angel_Admin ObjectBLL = new Business.Angel_Admin();
            string ActionName = context.Request.Params["action"];

            //根据相应的表进行操作
            switch (ActionName)
            {
            case "SaveDB":
                Model.Angel_Admin modeobj = new Model.Angel_Admin();
                modeobj.RoleId    = Convert.ToInt32(context.Request.Params["RoleId"]);
                modeobj.LoginName = context.Request.Params["LoginName"];
                modeobj.Password  = AngelDESEncrypt.Encrypt(context.Request.Params["Password"]);
                modeobj.UserName  = context.Request.Params["UserName"];
                modeobj.UserEmail = context.Request.Params["UserEmail"];
                modeobj.AddTime   = DateTime.Now;
                modeobj.IsWorking = Convert.ToInt32(context.Request.Params["IsWorking"]);

                if (modeobj.LoginName == "" || modeobj.LoginName == null || modeobj.RoleId == null || modeobj.AddTime == null || modeobj.IsWorking == null)
                {
                    context.Response.Write("{\"success\":false}");
                }

                if (context.Request.Params["method"] == "add")
                {
                    bool iscount = ObjectBLL.Add(modeobj);
                    if (iscount)
                    {
                        context.Response.Write("{\"success\":true}");
                        return;
                    }
                    else
                    {
                        context.Response.Write("{\"success\":false}");
                    }
                }

                if (context.Request.Params["method"] == "modify")
                {
                    modeobj.ID = Convert.ToInt32(context.Request.Params["id"]);

                    if (ObjectBLL.Update(modeobj))
                    {
                        context.Response.Write("{\"success\":true}");
                    }
                    else
                    {
                        context.Response.Write("{\"success\":false}");
                    }
                }
                break;

            //修改管理员密码
            case "UpPwd":
                AdminPage         admininfo   = new AdminPage();
                Model.Angel_Admin modelpwd    = admininfo.GetAdminInfo();
                string            OldPassword = AngelDESEncrypt.Encrypt(context.Request.Params["OldPasswrod"]);
                string            NewPassword = AngelDESEncrypt.Encrypt(context.Request.Params["NewPassword"]);

                if (context.Request.Params["OldPasswrod"] == "" || context.Request.Params["OldPasswrod"] == null || context.Request.Params["NewPassword"] == "" || context.Request.Params["NewPassword"] == null)
                {
                    context.Response.Write("{\"success\":false}");
                    return;
                }
                if (OldPassword == modelpwd.Password)
                {
                    modelpwd.Password = NewPassword;

                    if (ObjectBLL.Update(modelpwd))
                    {
                        context.Response.Write("{\"success\":true}");
                    }
                    else
                    {
                        context.Response.Write("{\"success\":false}");
                    }
                }
                else
                {
                    context.Response.Write("{\"success\":false}");
                }
                break;

            //删除信息
            case "DelDB":

                string id = context.Request.Params["id"];
                if (ObjectBLL.Delete(id))
                {
                    context.Response.Write("{\"success\":true}");
                }
                else
                {
                    context.Response.Write("{\"success\":false}");
                }
                break;

            case "List":

                break;


            default:
                context.Response.Write("{\"success\":false}");
                break;
            }
        }
Exemplo n.º 11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     model          = GetAdminInfo(); //取得当前管理员信息
     NavigationList = loadColumn3(model.RoleId.ToString());
 }