/// <summary> /// 是否有绑定DeviceID /// </summary> /// <returns></returns> public static SnsCenterUser GetUserByDeviceID(string deviceID) { if (deviceID.Length == 0 || deviceID.StartsWith("00:00:00:00:00:")) { deviceID = Guid.NewGuid().ToString(); } var command = ConnectManager.Provider.CreateCommandStruct("SnsUserInfo", CommandMode.Inquiry); command.OrderBy = "USERID ASC"; command.Columns = "PassportId,PassportPwd,PwdType,RegType"; command.Filter = ConnectManager.Provider.CreateCommandFilter(); command.Filter.Condition = command.Filter.FormatExpression("DeviceID"); command.Filter.AddParam("DeviceID", deviceID); command.Parser(); using (var aReader = ConnectManager.Provider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters)) { if (aReader.Read()) { PwdType pwdType = (PwdType)Enum.ToObject(typeof(PwdType), Convert.ToInt32(aReader["PwdType"])); string password = Convert.ToString(aReader["PassportPwd"]); //if (pwdType == PwdType.MD5) //{ // password = CryptoHelper.DES_Encrypt(password, GameEnvironment.Setting.ProductDesEnKey); //} SnsCenterUser user = new SnsCenterUser(Convert.ToString(aReader["PassportId"]), password, deviceID); user.RegType = (RegType)Enum.ToObject(typeof(RegType), Convert.ToInt32(aReader["RegType"])); return(user); } } return(null); }
/// <summary> /// Sets the type of the login. /// </summary> /// <param name="regType">Reg type.</param> /// <param name="pwdType">Pwd type.</param> /// <param name="passportId">Passport identifier.</param> public static void SetLoginType(ref RegType regType, ref PwdType pwdType, string passportId) { var command = ConnectManager.Provider.CreateCommandStruct("SnsUserInfo", CommandMode.Inquiry); command.OrderBy = "USERID ASC"; command.Columns = "RegType,DeviceID,PwdType"; command.Filter = ConnectManager.Provider.CreateCommandFilter(); command.Filter.Condition = command.Filter.FormatExpression("PassportId"); command.Filter.AddParam("PassportId", passportId); command.Parser(); using (var aReader = ConnectManager.Provider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters)) { if (aReader.Read()) { string deviceID = Convert.ToString(aReader["DeviceID"]); RegType rt = (RegType)Enum.ToObject(typeof(RegType), Convert.ToInt32(aReader["RegType"])); pwdType = (PwdType)Enum.ToObject(typeof(PwdType), Convert.ToInt32(aReader["PwdType"])); if (rt == RegType.Other && regType != RegType.Other) { //渠道登陆的用户允许更换包登陆 regType = string.IsNullOrEmpty(deviceID) ? RegType.Normal : rt; } else { regType = rt; } } } }
/// <summary> /// 是否有绑定DeviceID /// </summary> /// <returns></returns> public static SnsCenterUser GetUserByDeviceID(string deviceID) { if (deviceID.Length == 0 || deviceID.StartsWith("00:00:00:00:00:")) { deviceID = Guid.NewGuid().ToString(); } string sGetSql = "select top 1 PassportId, PassportPwd,PwdType, RegType from SnsUserInfo where DeviceID=@DeviceID"; List <SqlParameter> listTmp = new List <SqlParameter>(); listTmp.Add(SqlParamHelper.MakeInParam("@DeviceID", SqlDbType.VarChar, 0, deviceID)); SqlParameter[] paramsGet = listTmp.ToArray(); using (SqlDataReader aReader = SqlHelper.ExecuteReader(config.connectionString, CommandType.Text, sGetSql, paramsGet)) { if (aReader.Read()) { PwdType pwdType = (PwdType)Enum.ToObject(typeof(PwdType), Convert.ToInt32(aReader["PwdType"])); string password = Convert.ToString(aReader["PassportPwd"]); if (pwdType == PwdType.MD5) { password = CryptoHelper.DES_Encrypt(password, GameEnvironment.ProductDesEnKey); } SnsCenterUser user = new SnsCenterUser(Convert.ToString(aReader["PassportId"]), password, deviceID); user.RegType = (RegType)Enum.ToObject(typeof(RegType), Convert.ToInt32(aReader["RegType"])); return(user); } } return(null); }
public static void SetLoginType(ref RegType regType, ref PwdType pwdType, string passportId) { string sGetSql = "select top 1 RegType,DeviceID,PwdType from SnsUserInfo where PassportId=@aPassportId"; List <SqlParameter> listTmp = new List <SqlParameter>(); listTmp.Add(SqlParamHelper.MakeInParam("@aPassportId", SqlDbType.VarChar, 0, passportId)); SqlParameter[] paramsGet = listTmp.ToArray(); using (SqlDataReader aReader = SqlHelper.ExecuteReader(config.connectionString, CommandType.Text, sGetSql, paramsGet)) { if (aReader.Read()) { string deviceID = Convert.ToString(aReader["DeviceID"]); RegType rt = (RegType)Enum.ToObject(typeof(RegType), Convert.ToInt32(aReader["RegType"])); pwdType = (PwdType)Enum.ToObject(typeof(PwdType), Convert.ToInt32(aReader["PwdType"])); if (rt == RegType.Other && regType != RegType.Other) { //渠道登陆的用户允许更换包登陆 regType = string.IsNullOrEmpty(deviceID) ? RegType.Normal : rt; } else { regType = rt; } } } }
public static void SetLoginType(ref RegType regType, ref PwdType pwdType, string passportId) { string sGetSql = "select top 1 RegType,DeviceID,PwdType from SnsUserInfo where PassportId=@aPassportId"; List<SqlParameter> listTmp = new List<SqlParameter>(); listTmp.Add(SqlParamHelper.MakeInParam("@aPassportId", SqlDbType.VarChar, 0, passportId)); SqlParameter[] paramsGet = listTmp.ToArray(); using (SqlDataReader aReader = SqlHelper.ExecuteReader(config.connectionString, CommandType.Text, sGetSql, paramsGet)) { if (aReader.Read()) { string deviceID = Convert.ToString(aReader["DeviceID"]); RegType rt = (RegType)Enum.ToObject(typeof(RegType), Convert.ToInt32(aReader["RegType"])); pwdType = (PwdType)Enum.ToObject(typeof(PwdType), Convert.ToInt32(aReader["PwdType"])); if (rt == RegType.Other && regType != RegType.Other) { //渠道登陆的用户允许更换包登陆 regType = string.IsNullOrEmpty(deviceID) ? RegType.Normal : rt; } else { regType = rt; } } } }
/// <summary> /// 增加空密码处理 /// 修改:伍张发 /// </summary> /// <returns></returns> public int GetUserId() { RegType regType = RegType; PwdType pwdType = PwdType.DES; SetLoginType(ref regType, ref pwdType, PassportId); var command = ConnectManager.Provider.CreateCommandStruct("SnsUserInfo", CommandMode.Inquiry); command.OrderBy = "USERID ASC"; command.Columns = "USERID,PASSPORTID,DEVICEID,REGTYPE,RETAILID,RETAILUSER,WEIXINCODE"; command.Filter = ConnectManager.Provider.CreateCommandFilter(); string password = _PassportPwd; if (regType == RegType.Normal) { if (pwdType == PwdType.MD5) { password = PasswordEncryptMd5(_PassportPwd); } command.Filter.Condition = string.Format("{0} AND {1}", command.Filter.FormatExpression("PassportId"), command.Filter.FormatExpression("PassportPwd") ); command.Filter.AddParam("PassportId", _PassportId); command.Filter.AddParam("PassportPwd", password); } else if (regType == RegType.Guest) { if (pwdType == PwdType.MD5) { if (password.Length != 32) { //判断是否已经MD5加密 password = PasswordEncryptMd5(_PassportPwd); } } command.Filter.Condition = string.Format("{0} AND {1} AND {2} AND {3}", command.Filter.FormatExpression("DeviceID"), command.Filter.FormatExpression("PassportPwd"), command.Filter.FormatExpression("PassportId"), command.Filter.FormatExpression("RegType") ); command.Filter.AddParam("DeviceID", _deviceID); command.Filter.AddParam("PassportPwd", password); command.Filter.AddParam("PassportId", _PassportId); command.Filter.AddParam("RegType", (int)regType); } else { command.Filter.Condition = string.Format("{0} AND {1}", command.Filter.FormatExpression("RetailID"), command.Filter.FormatExpression("RetailUser") ); command.Filter.AddParam("RetailID", RetailID); command.Filter.AddParam("RetailUser", RetailUser); } command.Parser(); using (var aReader = ConnectManager.Provider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters)) { SnsCenterUser user = new SnsCenterUser(); if (aReader.Read()) { try { _userid = Convert.ToInt32(aReader["userid"]); _PassportId = aReader["PassportId"].ToString(); _deviceID = aReader["DeviceID"].ToNotNullString(); RegType = aReader["RegType"].ToEnum <RegType>(); RetailID = aReader["RetailID"].ToNotNullString(); RetailUser = aReader["RetailUser"].ToNotNullString(); WeixinCode = aReader["WeixinCode"].ToNotNullString(); } catch (Exception ex) { TraceLog.WriteError("GetUserId method error:{0}, sql:{0}", ex, command.Sql); } return(_userid); } else { return(0); } } }
/// <summary> /// 增加空密码处理 /// 修改:伍张发 /// </summary> /// <returns></returns> public int GetUserId() { RegType regType = RegType; PwdType pwdType = PwdType.DES; SetLoginType(ref regType, ref pwdType, PassportId); List <SqlParameter> listTmp = new List <SqlParameter>(); string sGetSql = "select top 1 userid,PassportId,DeviceID,RegType,RetailID,RetailUser,WeixinCode from SnsUserInfo "; string password = _PassportPwd; if (regType == RegType.Normal) { if (pwdType == PwdType.MD5) { password = CryptoHelper.DES_Decrypt(password, GameEnvironment.ProductDesEnKey); password = PasswordEncryptMd5(password); } sGetSql += "where PassportId=@aPassportId and PassportPwd=@PassportPwd"; listTmp.Add(SqlParamHelper.MakeInParam("@aPassportId", SqlDbType.VarChar, 0, _PassportId)); listTmp.Add(SqlParamHelper.MakeInParam("@PassportPwd", SqlDbType.VarChar, 0, password)); } else if (regType == RegType.Guest) { if (pwdType == PwdType.MD5) { password = CryptoHelper.DES_Decrypt(password, GameEnvironment.ProductDesEnKey); if (password.Length != 32) { //判断是否已经MD5加密 password = PasswordEncryptMd5(password); } } sGetSql += "where (DeviceID=@DeviceID and PassportPwd=@PassportPwd ) and PassportId=@aPassportId and RegType=@RegType"; listTmp.Add(SqlParamHelper.MakeInParam("@aPassportId", SqlDbType.VarChar, 0, _PassportId)); listTmp.Add(SqlParamHelper.MakeInParam("@DeviceID", SqlDbType.VarChar, 0, _deviceID)); listTmp.Add(SqlParamHelper.MakeInParam("@PassportPwd", SqlDbType.VarChar, 0, password)); listTmp.Add(SqlParamHelper.MakeInParam("@RegType", SqlDbType.Int, 0, (int)regType)); } else { sGetSql += "where RetailID=@RetailID and RetailUser=@RetailUser"; listTmp.Add(SqlParamHelper.MakeInParam("@RetailID", SqlDbType.VarChar, 0, RetailID)); listTmp.Add(SqlParamHelper.MakeInParam("@RetailUser", SqlDbType.VarChar, 0, RetailUser)); } SqlParameter[] paramsGet = listTmp.ToArray(); using (SqlDataReader aReader = SqlHelper.ExecuteReader(config.connectionString, CommandType.Text, sGetSql, paramsGet)) { SnsCenterUser user = new SnsCenterUser(); if (aReader.Read()) { try { _userid = Convert.ToInt32(aReader["userid"]); _PassportId = aReader["PassportId"].ToString(); _deviceID = aReader["DeviceID"].ToNotNullString(); RegType = aReader["RegType"].ToEnum <RegType>(); RetailID = aReader["RetailID"].ToNotNullString(); RetailUser = aReader["RetailUser"].ToNotNullString(); WeixinCode = aReader["WeixinCode"].ToNotNullString(); } catch (Exception ex) { TraceLog.WriteError("GetUserId method error:{0}, sql:{0}", ex, sGetSql); } return(_userid); } else { return(0); } } }