Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     B_User buser = new B_User();
     buser.CheckIsLogin();
     this.LblSiteName.Text = SiteConfig.SiteInfo.SiteName;
     string UserName = HttpContext.Current.Request.Cookies["UserState"]["LoginName"];
     M_UserInfo info = buser.GetUserByName(UserName);
     if (info.IsNull)
     {
         Response.Redirect("Login.aspx");
     }
     else
     {
         this.LblUserName.Text = info.UserName;
         this.LblEmail.Text = info.Email;
         this.LblGroupName.Text = info.GroupID.ToString();
         this.LblUnreadMsg.Text = B_Message.UserMessCount(UserName).ToString();
         this.LblRegTime.Text = info.RegTime.ToString();
         this.LblLoginTimes.Text = info.LoginTimes.ToString();
         this.LblLastLoginTime.Text = info.LastLoginTimes.ToString();
         this.LblLastLoginIP.Text = info.LastLoginIP;
         this.LblLastLockTime.Text = info.LastLockTime.ToString();
         this.LblChgPswTime.Text = info.LastPwdChangeTime.ToString();
     }
 }
Пример #2
0
 protected void IbtnEnter_Click(object sender, ImageClickEventArgs e)
 {
     B_User bll = new B_User();
     string vCode = this.Session["ValidateCode"].ToString();
     if (string.IsNullOrEmpty(vCode))
     {
         function.WriteErrMsg("<li>验证码无效,请刷新验证码重新登录</li>", "/User/Login.aspx");
     }
     if (string.Compare(this.TxtValidateCode.Text.Trim(), vCode, true) != 0)
     {
         function.WriteErrMsg("<li>验证码不正确</li>", "Login.aspx");
     }
     //根据用户名和密码验证会员身份,并取得会员信息
     string AdminName = this.TxtUserName.Text.Trim();
     string AdminPass = this.TxtPassword.Text.Trim();
     M_UserInfo info = bll.AuthenticateUser(AdminName, AdminPass);
     //如果用户Model是空对象则表明登录失败
     if (info.IsNull)
     {
         function.WriteErrMsg("<li>用户名或密码错误!</li>", "/User/Login.aspx");
     }
     else
     {
         if (SiteConfig.UserConfig.AdminCheckReg)
         {
             if (info.Status != 0)
             {
                 function.WriteErrMsg("<li>你的帐户未通过验证,请与超级管理员联系</li>", "/User/Login.aspx");
             }
         }
         bll.SetLoginState(info);
         HttpContext.Current.Response.Redirect("Default.aspx");
     }
 }
Пример #3
0
 public static void Insert(M_UserExpHis model)
 {
     if (model.UserID == 0)
     {
         M_UserInfo mu = new B_User().GetLogin();
         if (mu != null)
         {
             model.UserID = mu.UserID;
         }
     }
     if (model.Operator == 0)
     {
         M_AdminInfo adminMod = B_Admin.GetLogin();
         if (adminMod != null)
         {
             model.Operator = adminMod.AdminId;
         }
     }
     if (string.IsNullOrEmpty(model.OperatorIP))
     {
         model.OperatorIP = IPScaner.GetUserIP();
     }
     if (string.IsNullOrEmpty(model.Remark) && HttpContext.Current != null)
     {
         model.Remark = HttpContext.Current.Request.RawUrl;
     }
     if (model.HisTime <= DateTime.MinValue)
     {
         model.HisTime = DateTime.Now;
     }
     model.TbName = GetTbName((SType)model.ScoreType);
     DBCenter.Insert(model);
 }
Пример #4
0
        //--------------
        public DataTable SelByRefer(int userID)
        {
            B_User     userBll   = new B_User();
            M_UserInfo userModel = new M_UserInfo();

            userModel = userBll.GetUserByUserID(userID);
            SqlParameter[] sp = new SqlParameter[] { new SqlParameter("UserID", "%," + userID + ",%"), new SqlParameter("GroupID", "%," + userModel.GroupID + ",%") };
            return(SqlHelper.ExecuteTable(CommandType.Text, "Select * From " + strTableName + " Where ReferUser Like @UserID OR ReferGroup Like @GroupID", sp));
        }
Пример #5
0
        //-------------------用户权限验证
        /// <summary>
        /// 对当前登录用户验证权限
        /// </summary>
        /// <param name="auth">需要验证的权限</param>
        /// <returns>True:通过</returns>
        public static void CheckAuthEx(string auth)
        {
            M_UserInfo mu = new B_User().GetLogin();

            if (!new B_Permission().CheckAuth(mu.UserRole, auth))
            {
                throw new Exception("你当前没有访问该页面的权限");
            }
        }
Пример #6
0
        //------------------Tools
        public static string WordFace(object userid, string css, params string[] unames)
        {
            int    uid  = DataConvert.CLng(userid);
            string name = B_User.GetUserName(unames);

            name = name.Length > 0 ? name.Substring(0, 1) : "匿";
            string[] colorArr = "0094ff,FE7906,852b99,74B512,4B7F8C,00CCFF,A43AE3,22AFC2,F874A4,D0427C".Split(',');
            string   color    = "#" + colorArr[(uid % colorArr.Length)];

            return("<div class=\"uword " + css + "\" data-uid=\"" + uid + "\" style=\"background-color:" + color + "\">" + name + "</div>");
        }
Пример #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.Page.IsPostBack)
     {
         B_User buser = new B_User();
         buser.CheckIsLogin();
         this.m_t = DataConverter.CLng(Request.QueryString["t"]);
         if (this.m_t == 0)
             this.m_t = 1;
     }
 }
Пример #8
0
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     if (this.IsValid)
     {
         B_User bll = new B_User();
         int UserID = DataConverter.CLng(this.HdnUserID.Value);
         M_UserInfo info = bll.SeachByID(UserID);
         info.UserPwd = StringHelper.MD5(this.TxtPassword.Text.Trim());
         bll.UpDateUser(info);
         function.WriteSuccessMsg("修改密码成功!", "../User/UserManage.aspx");
     }
 }
Пример #9
0
 //置为正常
 protected void btnNormal_Click(object sender, EventArgs e)
 {
     B_User bll = new B_User();
     for (int i = 0; i <= Egv.Rows.Count - 1; i++)
     {
         CheckBox cbox = (CheckBox)Egv.Rows[i].FindControl("chkSel");
         if (cbox.Checked == true)
         {
             bll.UpUserUnLock(DataConverter.CLng(Egv.DataKeys[i].Value));
         }
     }
     Bind();
 }
Пример #10
0
 //锁定会员
 protected void btnLock_Click(object sender, EventArgs e)
 {
     B_User bll = new B_User();
     for (int i = 0; i <= Egv.Rows.Count - 1; i++)
     {
         CheckBox cbox = (CheckBox)Egv.Rows[i].FindControl("chkSel");
         if (cbox.Checked == true)
         {
             bll.UpUserLock(Convert.ToInt32(Egv.DataKeys[i].Value), DataConverter.CDate(DateTime.Now.ToLongDateString()));
             //将表中状态该为锁定.
         }
     }
     Bind();
 }
Пример #11
0
 //批量删除
 protected void btnDel_Click(object sender, EventArgs e)
 {
     B_User bll = new B_User();
     for (int i = 0; i <= Egv.Rows.Count - 1; i++)
     {
         CheckBox cbox = (CheckBox)Egv.Rows[i].FindControl("chkSel");
         if (cbox.Checked == true)
         {
             btnDel.Attributes.Add("OnClientClick", "return confirm('你确定要删除吗?');");
             bll.DelUserById(DataConverter.CLng(Egv.DataKeys[i].Value));
         }
     }
     Bind();
 }
Пример #12
0
 /// <summary>
 /// 如处理微信浏览器,但未登录,则自动注册或登录(按公众号)
 /// </summary>
 public static void AutoSync(string url, M_WX_APPID appMod = null)
 {
     if (DeviceHelper.GetBrower() == DeviceHelper.Brower.Micro)
     {
         B_User buser = new B_User();
         if (!buser.CheckLogin())
         {
             WxAPI  wxapi        = WxAPI.Code_Get();
             string redirect_uri = SiteConfig.SiteInfo.SiteUrl + "/user/wxuser.aspx";
             string api          = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + wxapi.AppId.APPID + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=" + url + "#wechat_redirect";
             HttpContext.Current.Response.Redirect(api);
         }
     }
 }
Пример #13
0
 /// <summary>
 /// 判断会员名是否已存在
 /// </summary>
 /// <param name="source"></param>
 /// <param name="args"></param>
 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
 {
     B_User bll = new B_User();
     string userName = this.tbUserName.Text;
     if (bll.IsExit(userName))
     {
         args.IsValid = false;
         this.CustomValidator1.Visible = true;
         this.tbUserName.Text = "";
     }
     else
     {
         args.IsValid = true;
     }
 }
Пример #14
0
 /// <summary>
 /// 提交会员信息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     B_User bll = new B_User();
     userInfo.UserName = this.tbUserName.Text;
     userInfo.UserPwd = this.tbPwd.Text;
     userInfo.Question = this.tbQuestion.Text;
     userInfo.Answer = this.tbAnswer.Text;
     userInfo.Email = this.tbEmail.Text;
     userInfo.FaceHeight = Convert.ToInt32(this.tbPhoHeight.Text);
     userInfo.FaceWidth = Convert.ToInt32(this.tbPhoWidth.Text);
     userInfo.UserFace = this.tbPhotoPlace.Text;
     userInfo.RegTime = DataConverter.CDate(DateTime.Now.ToShortTimeString());
     userInfo.Sign = this.tbUserWrite.Text;
     userInfo.PrivacySetting = 0;
     bll.Add(userInfo);
 }
Пример #15
0
 private static M_Log EmptyDeal(Model.ZLEnum.Log type, M_Log model)
 {
     if (string.IsNullOrEmpty(model.Action))
     {
         model.Action = type.ToString();
     }
     if (model.CDate <= DateTime.MinValue)
     {
         model.CDate = DateTime.Now;
     }
     try
     {
         if (string.IsNullOrEmpty(model.IP))
         {
             model.IP = IPScaner.GetUserIP();
         }
         if (string.IsNullOrEmpty(model.Source))
         {
             model.Source = HttpContext.Current.Request.RawUrl;
         }
     }
     catch { }
     if (type == Model.ZLEnum.Log.fileup || type == Model.ZLEnum.Log.safe)
     {
         try
         {
             if (string.IsNullOrEmpty(model.UName))
             {
                 M_UserInfo mu = new B_User().GetLogin(); if (mu != null && mu.UserID != 0)
                 {
                     model.UName = mu.UserName;
                 }
             }
             if (string.IsNullOrEmpty(model.AName))
             {
                 M_AdminInfo adminMod = B_Admin.GetLogin(); if (adminMod != null && adminMod.AdminId > 0)
                 {
                     model.AName = adminMod.AdminName;
                 }
             }
         }
         catch { }
     }
     return(model);
 }
Пример #16
0
 private void BindData(string keyword)
 {
     B_User bll = new B_User();
     IList<string> list = bll.GetUserNameList(this.CurrentPageIndex, this.PageSize, keyword);
     if (list.Count == 0)
     {
         this.DivAdd.Visible = false;
         this.DivUserName.Visible = true;
     }
     else
     {
         this.DivUserName.Visible = false;
     }
     this.RepUser.DataSource = list;
     int RecordCount = bll.GetUserNameListTotal(keyword);
     this.pager1.InnerHtml = function.ShowPage(RecordCount, this.PageSize, this.CurrentPageIndex, true, "个");
     this.RepUser.DataBind();
 }
Пример #17
0
 //最终用于清除的方法,过期与主动都调用其
 public static void ClearByKeys(string keys)
 {
     keys = keys.TrimEnd(',');
     if (!string.IsNullOrEmpty(keys))
     {
         try
         {
             foreach (string key in keys.Split(','))
             {
                 //后期改为缓存事件分发
                 M_Cache model = UserSession[key];
                 B_User.UpdateField("LastActiveTime", (DateTime.Now.AddMinutes(-ActiveSpan)).ToString(), model.UserID, false);
                 UserSession.Remove(key);
             }
         }
         catch (Exception ex) { ZLLog.L(Model.ZLEnum.Log.labelex, "用户缓存出错:" + ex.Message); }
     }
 }
Пример #18
0
 //发送
 protected void BtnSend_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         M_Message messInfo = new M_Message();
         B_User bll = new B_User();
         messInfo.Sender = "admin";
         messInfo.Title = this.TxtTitle.Text;
         messInfo.PostDate = DataConverter.CDate(DateTime.Now.ToShortDateString());
         messInfo.Content = this.EditorContent.Text;
         if (this.RadIncept1.Checked)
         {
             DataTable dt = bll.GetUserInfos();
             foreach (DataRow dr in dt.Rows)
             {
                 //if (dr["UserName"].ToString() != "admin")
                 //{
                 messInfo.Incept = dr["UserName"].ToString();
                 B_Message.Add(messInfo);
                 //}
             }
         }
         if (this.RadIncept3.Checked)
         {
             string uname = this.TxtInceptUser.Text;
             if (!string.IsNullOrEmpty(uname))
             {
                 string[] namearr = uname.Split(new char[] { ',' });
                 for (int i = 0; i < namearr.Length; i++)
                 {
                     messInfo.Incept = namearr[i];
                     B_Message.Add(messInfo);
                 }
             }
         }
     }
 }
Пример #19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     B_User buser = new B_User();
     buser.CheckIsLogin();
 }
Пример #20
0
        public static int IsPlatUser()
        {
            B_User buser = new B_User();

            return(IsPlatUser(buser.GetLogin().UserID));
        }
Пример #21
0
 private IList<string[]> GetUserData()
 {
     B_User bll = new B_User();
     int num;
     string text = string.Empty;
     if (this.RadUserType0.Checked)
     {
         num = 0;
     }
     else if (this.RadUserType2.Checked)
     {
         num = 2;
         text = this.TxtUserName.Text;
         if (string.IsNullOrEmpty(text))
         {
             function.WriteErrMsg("没有输入指定会员名");
             this.TxtUserName.Focus();
             return null;
         }
     }
     else
     {
         num = 3;
         if (string.IsNullOrEmpty(this.TxtEmails.Text))
         {
             function.WriteErrMsg("没有指定收件人邮件地址");
             this.TxtEmails.Focus();
             return null;
         }
         IList<string[]> list = new List<string[]>();
         foreach (string str2 in this.TxtEmails.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
         {
             list.Add(new string[] { "", str2 });
         }
         return list;
     }
     return bll.GetUserNameAndEmailList(num, text);
 }
Пример #22
0
    protected void NextButtonStep5_Click(object sender, EventArgs e)
    {
        B_User buser = new B_User();
        string message=string.Empty;
        string strHostIP = "";
        IPHostEntry oIPHost = Dns.GetHostEntry(Environment.MachineName);
        if (oIPHost.AddressList.Length > 0)
            strHostIP = oIPHost.AddressList[0].ToString();

        string adminname = TxtAdminName.Text.ToString();
        string strtitle =TxtSiteTitle.Text.ToString();

        string Code = TxtSiteManageCode.Text;
        string pwd = TxtAdminPassword.Text.ToString();//管理员密码
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(Server.MapPath("../Config/Site.config"));
        XmlElement xmldocSelect = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("SiteInfo");
        XmlElement xe2 = (XmlElement)xmldocSelect.SelectSingleNode("SiteTitle");
        xe2.InnerText=strtitle;
        XmlNode xe3 = (XmlElement)xmldocSelect.SelectSingleNode("SiteUrl");//.ChildNodes
        xe3.InnerText = TxtSiteUrl.Text.ToString();
        XmlElement xmldocSelect2 = (XmlElement)xmlDoc.DocumentElement.SelectSingleNode("SiteOption");
        XmlElement xe5 = (XmlElement)xmldocSelect2.SelectSingleNode("SiteManageCode");
        xe5.InnerText = Code;
        xmlDoc.Save(Server.MapPath("../Config/Site.config"));

        //WebConfigurationManager.AppSettings["Installed"]="true";

        XmlDocument xmlDoc2 = new XmlDocument();
        xmlDoc2.Load(Server.MapPath("../Config/AppSettings.config"));
        XmlNodeList amde = xmlDoc2.SelectSingleNode("appSettings").ChildNodes;
        foreach (XmlNode xn in amde)
        {
            XmlElement xe = (XmlElement)xn;
            if (xe.GetAttribute("key").ToString() == "Installed")
                xe.SetAttribute("value", "true");
        }
        xmlDoc2.Save(Server.MapPath("../Config/AppSettings.config"));

        if (Install.Add("admin", pwd))
        {
            M_UserInfo muser = new M_UserInfo();
            muser.UserName = "******";
            muser.UserPwd = StringHelper.MD5(pwd);
            muser.RegTime = DateTime.Now;
            muser.LastLockTime = DateTime.MaxValue;
            muser.LastLoginTimes = DateTime.Now;
            muser.LastPwdChangeTime = DateTime.MaxValue;
            muser.Email = TxtEmail.Text;
            muser.Question ="admin";
            muser.Answer = StringHelper.MD5(pwd);
            muser.GroupID = 0;
            muser.UserFace = "";
            muser.Sign = "";
            muser.LastLoginIP = strHostIP;
            muser.CheckNum = new Random().ToString();
            buser.Add(muser);
            message="<script language=javascript> alert('安装完成!');</script>";
        }
        else
        {
            message="<script language=javascript> alert('安装配置失败!请检查后重新操作!');</script>";
        }
        if (!this.IsStartupScriptRegistered("message"))
        {
            Page.RegisterStartupScript("message", message);
        }
    }
Пример #23
0
 private void Bind()
 {
     B_User bll = new B_User();
     DataView dv = bll.GetUserInfo();
     this.Egv.DataSource = dv;
     this.Egv.DataKeyNames = new string[] { "UserID" };
     this.Egv.DataBind();
 }
Пример #24
0
 //删除会员
 protected void delete_Click(object sender, EventArgs e)
 {
     B_User bll = new B_User();
     for (int i = 0; i <= Egv.Rows.Count - 1; i++)
     {
         CheckBox cbox = (CheckBox)Egv.Rows[i].FindControl("chkSel");
         if (cbox.Checked)
         {
             bll.DelUserById(DataConverter.CLng(Egv.DataKeys[i].Value));
         }
     }
     Bind();
 }
Пример #25
0
        /// <summary>
        /// 检测当前登录用户是否有指定权限
        /// </summary>
        /// <returns>True:拥有</returns>
        public static bool CheckAuth(string auth)
        {
            M_UserInfo mu = new B_User().GetLogin();

            return(new B_Permission().CheckAuth(mu.UserRole, auth));
        }
Пример #26
0
        public string GetUpdateHtml(int userid)
        {
            DataTable dt = new B_User().GetUserBaseByuserid(userid.ToString());

            return(GetUpdateHtml(dt));
        }
Пример #27
0
 protected void Lnk_Click(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "ChgPsw")
             Page.Response.Redirect("UserPassModify.aspx?UserID=" + e.CommandArgument.ToString());
         if (e.CommandName == "Del")
         {
             B_User bll = new B_User();
             string Id = e.CommandArgument.ToString();
             bll.DelUserById(DataConverter.CLng(Id));
             Bind();
         }
 }