/// <summary> /// 小区管家判断状态 /// </summary> /// <param name="ID">小区ID</param> /// <param name="userid">userid</param> /// <returns></returns> protected string getState(int ID, int Userid) { string result = string.Empty; int iUnixdate = Utils.GetUnixNum(CharString.DateConvert(DateTime.Now.ToString("yyyy-MM-dd"))); using (var db = new shhouseEntities()) { var uservillagesteward = db.user_villagesteward.Where(p => p.villageid == ID && p.userid == Userid).FirstOrDefault(); if (uservillagesteward == null) { result = "未申请"; } else if (uservillagesteward.isapply == 0) { result = "未审核"; } else if (uservillagesteward.isapply == 2) { result = "驳回"; } else if (uservillagesteward.endunixdate >= iUnixdate) { result = "使用中"; } else { result = "已过期"; } return(result); } }
/// <summary> /// 修改基本资料 /// </summary> /// <param name="realname">真实姓名</param> /// <param name="shangquan">商圈</param> /// <param name="photoname">头像照片</param> /// <param name=""></param> /// <returns></returns> public string BasicData(string realname, string company, string photoname, string shangquan = "") { string sql = string.Empty; if (!string.IsNullOrEmpty(shangquan)) { sql = " delete from user_search_countyid_wuxi where userid = " + User.userid; for (int i = 1; i < CharString.Intercept(',', shangquan); i++) { sql += string.Format(" if not exists(select 1 from user_search_countyid_wuxi where userid = {0} and countyshangquan = {1}) insert into user_search_countyid_wuxi (userid, countyshangquan)values({0}, {1})", User.userid, CharString.Intercept(',', shangquan, i)); } } else { sql = " delete from user_search_countyid_wuxi where userid = " + User.userid; } sql = sql + " update user_details set photoname=@photoname where userid = @userid "; using (shhouseEntities db = new shhouseEntities()) { try { var edituser = db.Database.ExecuteSqlCommand(sql, new SqlParameter[] { new SqlParameter("@userid", User.userid), new SqlParameter("@mobile", User.user_details.mobile.ToString()), new SqlParameter("@photoname", photoname), }); return(JsonConvert.SerializeObject(new repmsg { state = 1, msg = "修改成功" })); } catch (Exception e) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "修改失败,请稍后再试!" })); } } }
public CharStringLiteralWord(CharString charString, Environment env) : base("s\"", charString.CharAddress, e => { e.DataStack.Push(charString.CharAddress); e.DataStack.Push(charString.Length); }) { Value = env.Memory.FetchCharString(charString); }
public PrintStringLiteralWord(CharString charString, Environment env) : base(".\"", charString.CharAddress, e => Console.Write(e.Memory.FetchCharString(charString))) { Value = env.Memory.FetchCharString(charString); }
public string FetchCharString(CharString charString) { char[] chars = (from b in FetchBytes(charString.CharAddress, charString.Length) select(char) b).ToArray(); return(new string(chars)); }
/// <summary> /// 注册账号 /// </summary> /// <param name="mobile"></param> /// <param name="smscode"></param> /// <param name="password"></param> /// <returns></returns> public string regist(string username, string password, string mobile, string realname, string smscode) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户名或密码为空,因此无法提交!", data = null })); } if (!Utils.IsSafeSqlString(username)) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您输入的用户名包含不安全的字符,因此无法提交!", data = null })); } if (getJ(username.Trim()) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您所输入的用户名已被使用过, 请输入其他的用户名!", data = null })); } if (getM(mobile.Trim()) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您所输入的手机号码已被使用过, 请输入其他的手机号码!", data = null })); } using (var db = new shhouseEntities()) { var intuser = db.Database.ExecuteSqlCommand(adduser, new SqlParameter[] { new SqlParameter("@parentid", "0"), new SqlParameter("@parentpath", ""), new SqlParameter("@mobile", mobile.Trim()), new SqlParameter("@telfirst", ""), new SqlParameter("@tel", ""), new SqlParameter("@linkman", ""), new SqlParameter("@area", ""), new SqlParameter("@city", 3), new SqlParameter("@storetotal", "0"), new SqlParameter("@housetotal", "5"), new SqlParameter("@agenttotal", "0"), new SqlParameter("@refamount", "7"), new SqlParameter("@userid2", "0"), new SqlParameter("@username", Utils.CheckData(username.Trim())), new SqlParameter("@realname", Utils.CheckData(realname.Trim())), new SqlParameter("@password", Utils.MD5(password.Trim())), new SqlParameter("@addip", Utils.GetRealIP()), new SqlParameter("@roleid", 4), new SqlParameter("@origin", ""), new SqlParameter("@originpath", ""), new SqlParameter("@ismobilelock", "0"), new SqlParameter("@validity_begintime", "1990-1-1"), new SqlParameter("@validity_endtime", "1990-1-1") }); if (intuser.ToString() == "-99") { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户名重复,请重新输入!", data = null })); } else if (CharString.IntConvert(intuser) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "注册成功!", data = null })); } } return(""); }
/// <summary> /// 登录 /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public string login(string username, string password) { string sValue = ""; if (DateTime.Now.Hour != 1) { if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { string sRoleid = "", sCity = "", sName = "", sState = "", sSerieslogin = "", sDeptpath = "", passwords = "", sBegintime = "", sEndtime = "", sLastlogintime = "", sSeriestime = "", sUserid = "", sPermition = "", sMobile = "", roleid = ""; passwords = Utils.MD5(password); using (var db = new shhouseEntities()) { var persons = (from a in db.user_member join b in db.user_details on a.userid equals b.userid into dc from dci in dc.DefaultIfEmpty() join c in db.user_validity on a.userid equals c.userid into ec from eci in ec.DefaultIfEmpty() where (a.username == username || dci.mobile == username) && a.password == passwords && (a.roleid == 3 || a.roleid == 4) select new { a.userid, a.username, a.roleid, a.city, a.deptpath, a.state, a.serieslogin, eci.begintime, eci.endtime, a.lastlogintime, a.seriestime, a.mobile, }).FirstOrDefault(); if (persons != null) { sUserid = persons.userid.ToString(); sName = persons.username; sRoleid = persons.roleid.ToString(); sCity = persons.city.ToString(); sDeptpath = persons.deptpath; sState = persons.state.ToString(); sBegintime = persons.begintime.ToString(); //开始时间 sEndtime = persons.endtime.ToString(); //截止时间 sLastlogintime = persons.lastlogintime.ToString(); sSeriestime = persons.seriestime.ToString(); sMobile = persons.mobile.ToString(); roleid = persons.roleid.ToString(); } else { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户名或密码输入错误。", data = null })); } } if (sState == "-1")//锁定 { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "抱歉,您的账户已被冻结,请联系您的主管或管理员。", data = null })); } else if (sState == "-2") { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "抱歉,您的账户已被删除,请联系您的主管或管理员", data = null })); } if (!string.IsNullOrEmpty(sEndtime) && sBegintime != sEndtime) { if (sRoleid == "4" && !string.IsNullOrEmpty(sDeptpath)) { sDeptpath = "," + sDeptpath; sDeptpath = sDeptpath.Replace(",0,", ""); using (var db = new shhouseEntities()) { var user_validity = db.user_validity.SqlQuery("select * from user_validity where userid = (select top 1 userid from user_member where deptid in(" + sDeptpath + "))").FirstOrDefault(); if (user_validity != null) { sEndtime = user_validity.endtime.ToString(); } } } if (Convert.ToDateTime(CharString.DateConvert(sEndtime)) < Convert.ToDateTime(DateTime.Now.ToShortDateString())) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您的账户服务期已截止,请去续费充值!", data = null })); } } DateTime sdt = DateTime.Now.Date; DateTime dt = DateTime.Now.Date.AddDays(1); //更新用户表 using (var db = new shhouseEntities()) { var user_member = db.user_member.Find(int.Parse(sUserid)); user_member.lastlogintime = user_member.logintime; user_member.lastloginip = user_member.loginip; user_member.logincount = user_member.logincount + 1; user_member.logintime = DateTime.Now; user_member.loginip = Utils.GetRealIP(); var user_details = db.user_details.Find(int.Parse(sUserid)); user_details.logintimenum = Utils.GetUnixNum(DateTime.Now); user_details.logintime = DateTime.Now; db.SaveChanges(); db.Database.ExecuteSqlCommand("UPDATE user_search_all_wuxi set LastLoginTime = (datediff(S,'1970-01-01 00:00:00', getdate()) - 8 * 3600) where userid =@sUserid", new SqlParameter[] { new SqlParameter("@sUserid", sUserid) }); } ////写入token //string token = Utils.MD5(sUserid); //string tokenjson=JsonConvert.SerializeObject(new { userid = sUserid, Lastlogintime = sLastlogintime}); //System.IO.File.WriteAllText(Server.MapPath($"~/tokens/{token}.json"), tokenjson); //return JsonConvert.SerializeObject(new repmsg { state = 1, msg = "登录成功", data = token }); string token = Utils.MD5(sUserid); using (var db = new shhouseEntities()) { //写入token db.Database.ExecuteSqlCommand("delete from user_logintoken where userid = @sUserid", new SqlParameter[] { new SqlParameter("@sUserid", sUserid) }); user_logintoken myuser_Logintoken = new user_logintoken(); myuser_Logintoken.UserID = int.Parse(sUserid); myuser_Logintoken.token = token; myuser_Logintoken.loninTime = DateTime.Now; db.user_logintoken.Add(myuser_Logintoken); db.SaveChanges(); } return(JsonConvert.SerializeObject(new repmsg { state = 1, msg = "登录成功", data = token })); //return JsonConvert.SerializeObject(new repmsg { state = 1, msg = "登录成功", // data = new // { // token = token, // roleid = roleid // } // }); } return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户名或密码不能为空", data = null })); } else { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "凌晨 1:00 - 2:00 数据维护中...", data = null })); } }
/// <summary> /// 注册账号 http://192.168.1.223/GR_Home/RegistByMobile /// </summary> /// <param name="username">用户名</param> /// <param name="password">密码</param> /// <param name="mobile">手机号码</param> /// <param name="realname">真实姓名</param> /// <param name="smscode">验证码</param> /// <returns></returns> public string RegistByMobile(string password, string mobile, string smscode) { if (string.IsNullOrEmpty(password)) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户名或密码为空,提交失败!", data = null })); } if (!Utils.IsSafeSqlString(mobile)) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您输入的手机号码包含不安全的字符,因此无法提交!", data = null })); } if (User_Common.IsHaveMobile(mobile.Trim()) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您所输入的手机号码已被使用过, 请输入其他的手机号码!", data = null })); } using (var db = new shhouseEntities()) { var uservalidityrecord = db.user_validityrecord.SqlQuery(" select top 1 * from user_validityrecord where Mobile = " + mobile + " and codetype = 1 and checkcode = '" + smscode + "'" + " and state = 0 and validity > getdate() order by validity desc ").FirstOrDefault(); if (uservalidityrecord == null) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "验证码错误或已经失效请重新获取!", data = null })); } uservalidityrecord.state = "1"; db.SaveChanges(); var intuser = db.Database.ExecuteSqlCommand(User_Common.GR_adduserbymobile_sql, new SqlParameter[] { new SqlParameter("@parentid", "0"), new SqlParameter("@parentpath", ""), new SqlParameter("@mobile", mobile.Trim()), new SqlParameter("@telfirst", ""), new SqlParameter("@tel", ""), new SqlParameter("@linkman", ""), new SqlParameter("@area", ""), new SqlParameter("@city", 3), new SqlParameter("@storetotal", "0"), new SqlParameter("@housetotal", "5"), new SqlParameter("@agenttotal", "0"), new SqlParameter("@refamount", "7"), new SqlParameter("@userid2", "0"), //new SqlParameter("@username", Utils.CheckData(username.Trim())), //new SqlParameter("@realname", Utils.CheckData(realname.Trim())), new SqlParameter("@password", Utils.MD5(password.Trim())), new SqlParameter("@addip", Utils.GetRealIP()), new SqlParameter("@roleid", 5), //为五的时候为个人会员 new SqlParameter("@origin", ""), new SqlParameter("@originpath", ""), new SqlParameter("@ismobilelock", "0"), new SqlParameter("@validity_begintime", "1990-1-1"), new SqlParameter("@validity_endtime", "1990-1-1"), new SqlParameter("@deptname", ""), new SqlParameter("@company", ""), new SqlParameter("@address", "") }); if (intuser.ToString() == "-99") { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "手机号码重复,请重新输入!", data = null })); } else if (CharString.IntConvert(intuser) > 0) { return(JsonConvert.SerializeObject(new repmsg { state = 1, msg = "注册成功!", data = null })); } else { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "注册失败,网络异常!", data = null })); } } return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "网络异常", data = null })); }
/// <summary> /// 个人会员登录 手机号码+验证码 http://192.168.1.223/GR_Home/LoginBySmscode /// </summary> /// <param name="mobile"></param> /// <param name="smscode"></param> /// <returns></returns> public string LoginBySmscode(string mobile, string smscode) { if (DateTime.Now.Hour != 1) { if (!string.IsNullOrEmpty(mobile) && !string.IsNullOrEmpty(smscode)) { using (var db = new shhouseEntities()) { //先判断验证码正确不正确 var uservalidityrecord = db.user_validityrecord.SqlQuery(" select top 1 * from user_validityrecord where Mobile = " + mobile + " and codetype = 1 and checkcode = '" + smscode + "' and state = 0 and validity > getdate() order by validity desc ").FirstOrDefault(); if (uservalidityrecord == null) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "验证码错误!", data = null })); } uservalidityrecord.state = "1"; db.SaveChanges(); //把这条验证码保存为已经使用过 decimal demobile = Convert.ToDecimal(mobile); var user_details = db.user_member.Where(x => x.mobile == demobile).FirstOrDefault(); if (user_details == null) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户不存在!", data = null })); //用户不存在 就注册一个用户名 并提交 //if (!Utils.IsSafeSqlString(mobile)) //{ // return JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您输入的手机号码包含不安全的字符,因此无法提交!", data = null }); //} //var intuser = db.Database.ExecuteSqlCommand(User_Common.GR_adduserbymobile_sql, // new SqlParameter[]{ //new SqlParameter("@parentid", "0"), //new SqlParameter("@parentpath", ""), //new SqlParameter("@mobile", mobile.Trim()), //new SqlParameter("@telfirst", ""), //new SqlParameter("@tel", ""), //new SqlParameter("@linkman", ""), //new SqlParameter("@area", ""), //new SqlParameter("@city", 3), //new SqlParameter("@storetotal", "0"), //new SqlParameter("@housetotal", "5"), //new SqlParameter("@agenttotal", "0"), //new SqlParameter("@refamount", "7"), //new SqlParameter("@userid2", "0"), ////new SqlParameter("@username", Utils.CheckData(username.Trim())), ////new SqlParameter("@realname", Utils.CheckData(realname.Trim())), //new SqlParameter("@password", ""), //new SqlParameter("@addip", Utils.GetRealIP()), //new SqlParameter("@roleid", 5), //为五的时候为个人会员 //new SqlParameter("@origin", ""), //new SqlParameter("@originpath", ""), //new SqlParameter("@ismobilelock", "0"), //new SqlParameter("@validity_begintime", "1990-1-1"), //new SqlParameter("@validity_endtime", "1990-1-1"), //new SqlParameter("@deptname", ""), //new SqlParameter("@company", ""), //new SqlParameter("@address", "") // }); } } string sRoleid = "", sCity = "", sName = "", sState = "", sDeptpath = "", passwords = "", sBegintime = "", sEndtime = "", sLastlogintime = "", sSeriestime = "", sUserid = "", sMobile = ""; //passwords = Utils.MD5(password); using (var db = new shhouseEntities()) { var persons = (from a in db.user_member join b in db.user_details on a.userid equals b.userid into dc from dci in dc.DefaultIfEmpty() join c in db.user_validity on a.userid equals c.userid into ec from eci in ec.DefaultIfEmpty() where (dci.mobile == mobile) //&& a.roleid == 5 select new { a.userid, a.username, a.roleid, a.city, a.deptpath, a.state, a.serieslogin, eci.begintime, eci.endtime, a.lastlogintime, a.seriestime, a.mobile, }).FirstOrDefault(); if (persons != null) { sUserid = persons.userid.ToString(); sName = persons.username; sRoleid = persons.roleid.ToString(); sCity = persons.city.ToString(); sDeptpath = persons.deptpath; sState = persons.state.ToString(); sBegintime = persons.begintime.ToString(); //开始时间 sEndtime = persons.endtime.ToString(); //截止时间 sLastlogintime = persons.lastlogintime.ToString(); sSeriestime = persons.seriestime.ToString(); sMobile = persons.mobile.ToString(); } else { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "用户不存在。", data = null })); } } if (sState == "-1")//锁定 { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "抱歉,您的账户已被冻结。", data = null })); } else if (sState == "-2") { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "抱歉,您的账户已被删除。", data = null })); } //非个人会员 if (sRoleid != "5") { if (!string.IsNullOrEmpty(sEndtime) && sBegintime != sEndtime) { if (sRoleid == "4" && !string.IsNullOrEmpty(sDeptpath)) { sDeptpath = "," + sDeptpath; sDeptpath = sDeptpath.Replace(",0,", ""); using (var db = new shhouseEntities()) { var user_validity = db.user_validity.SqlQuery("select * from user_validity where userid = (select top 1 userid from user_member where deptid in(" + sDeptpath + "))").FirstOrDefault(); if (user_validity != null) { sEndtime = user_validity.endtime.ToString(); } } } if (Convert.ToDateTime(CharString.DateConvert(sEndtime)) < Convert.ToDateTime(DateTime.Now.ToShortDateString())) { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "您的账户服务期已截止,请去续费充值!", data = null })); } } } DateTime sdt = DateTime.Now.Date; DateTime ndt = DateTime.Now.Date.AddDays(1); //更新用户表 using (var db = new shhouseEntities()) { var user_member = db.user_member.Find(int.Parse(sUserid)); user_member.lastlogintime = user_member.logintime; user_member.lastloginip = user_member.loginip; user_member.logincount = user_member.logincount + 1; user_member.logintime = DateTime.Now; user_member.loginip = Utils.GetRealIP(); var user_details = db.user_details.Find(int.Parse(sUserid)); user_details.logintimenum = Utils.GetUnixNum(DateTime.Now); user_details.logintime = DateTime.Now; int userid = int.Parse(sUserid); //var user_score = db.user_score_wuxi.Where(x => x.userid == userid && x.addtime >= sdt && x.addtime < ndt && x.obtaindirections == "登录积分").FirstOrDefault(); //if (user_score == null) //{ // var user_score_wuxi = new user_score_wuxi // { // userid = int.Parse(sUserid), // addtime = DateTime.Now, // score = userscore.sign,//登陆积分 // obtaindirections = "登录积分" // }; // db.user_score_wuxi.Add(user_score_wuxi); //} db.SaveChanges(); db.Database.ExecuteSqlCommand("UPDATE user_search_all_wuxi set LastLoginTime = (datediff(S,'1970-01-01 00:00:00', getdate()) - 8 * 3600) where userid =@sUserid", new SqlParameter[] { new SqlParameter("@sUserid", sUserid) }); } string token = Utils.MD5(sUserid); using (var db = new shhouseEntities()) { //写入token db.Database.ExecuteSqlCommand("delete from user_logintoken where userid = @sUserid", new SqlParameter[] { new SqlParameter("@sUserid", sUserid) }); user_logintoken myuser_Logintoken = new user_logintoken(); myuser_Logintoken.UserID = int.Parse(sUserid); myuser_Logintoken.token = token; myuser_Logintoken.loninTime = DateTime.Now; db.user_logintoken.Add(myuser_Logintoken); db.SaveChanges(); } return(JsonConvert.SerializeObject(new repmsg { state = 1, msg = "登录成功", data = new { token = token, roleid = sRoleid } })); } return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "手机号或验证码不能为空", data = null })); } else { return(JsonConvert.SerializeObject(new repmsg { state = 2, msg = "凌晨 1:00 - 2:00 数据维护中...", data = null })); } }