/// <summary> /// 下移记录的方法 /// </summary> /// <param name="dbHelper">当前数据库连接</param> /// <param name="tableName">表名</param> /// <param name="categoryId">类别主键</param> /// <param name="id">当前主键</param> /// <returns>目标主键</returns> public static int SetDown(IDbHelper dbHelper, string tableName, string categoryId, string id) { string downId = string.Empty; string sortCode = string.Empty; string downSortCode = string.Empty; int returnValue = 0; downId = GetDownId(dbHelper, tableName, categoryId, id); if (downId.Length == 0) { return(returnValue); } List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, id)); sortCode = DbLogic.GetProperty(dbHelper, tableName, parameters, BaseBusinessLogic.FieldSortCode); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, downId)); downSortCode = DbLogic.GetProperty(dbHelper, tableName, parameters, BaseBusinessLogic.FieldSortCode); List <KeyValuePair <string, object> > whereParameters = new List <KeyValuePair <string, object> >(); whereParameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, downId)); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldSortCode, sortCode)); DbLogic.SetProperty(dbHelper, tableName, whereParameters, parameters); whereParameters = new List <KeyValuePair <string, object> >(); whereParameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, id)); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldSortCode, downSortCode)); returnValue = DbLogic.SetProperty(dbHelper, tableName, whereParameters, parameters); return(returnValue); }
public virtual string GetId(KeyValuePair <string, object> parameter) { List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(parameter); return(DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameters, BaseBusinessLogic.FieldId)); }
/// <summary> /// 获取主键 /// </summary> /// <param name="openId">编号</param> /// <returns>主键</returns> public string GetIdByOpenId(string openId) { List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldOpenId, openId)); return(DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameters, BaseUserLogOnEntity.FieldId)); }
public virtual string GetProperty(KeyValuePair <string, object> parameter, string targetField) { List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(parameter); return(DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameters, targetField)); }
// // 读取属性 // public virtual string GetProperty(object id, string targetField) { List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, id)); return(DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameters, targetField)); }
/// <summary> /// 按名称获取主键 /// </summary> /// <param name="realName">名称</param> /// <returns>主键</returns> public string GetIdByRealName(string realName) { List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>(); parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldRealName, realName)); parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldDeletionStateCode, 0)); parameters.Add(new KeyValuePair<string, object>(BaseRoleEntity.FieldEnabled, 1)); return DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameters, BaseBusinessLogic.FieldId); }
/// <summary> /// 获取主键 /// </summary> /// <param name="code">编号</param> /// <returns>主键</returns> public virtual string GetIdByCode(string code) { List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldCode, code)); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldDeletionStateCode, 0)); return(DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameters, BaseBusinessLogic.FieldId)); }
public virtual string GetId(params KeyValuePair <string, object>[] parameters) { List <KeyValuePair <string, object> > parameterList = new List <KeyValuePair <string, object> >(); foreach (var parameter in parameters) { parameterList.Add(parameter); } return(DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameterList, BaseBusinessLogic.FieldId)); }
/// <summary> /// 验证openId是否合法性 /// </summary> /// <param name="openId">key</param> /// <param name="userId">用户主键</param> /// <returns>合法</returns> public bool ValidateOpenId(string openId, out string userId) { bool result = false; userId = string.Empty; List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldOpenId, openId)); userId = DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameters, BaseUserLogOnEntity.FieldId); result = !string.IsNullOrEmpty(userId); return(result); }
public string GetExternalUserName(string id) { string result = null; string connectionString = ConfigurationHelper.AppSettings("WeChatDbConnection", BaseSystemInfo.EncryptDbConnection); if (!string.IsNullOrEmpty(connectionString)) { List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>("Id", id)); IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.Oracle, connectionString); result = DbLogic.GetProperty(dbHelper, "ExternalUser", parameters, "NICKNAME"); } return(result); }
public string GetUserOpenId(BaseUserInfo userInfo, string cachingSystemCode = null) { string result = string.Empty; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType, BaseSystemInfo.UserCenterReadDbConnection)) { // 需要能支持多个业务子系统的登录方法、多密码、多终端登录 string userLogOnEntityTableName = "BaseUserLogOn"; if (!string.IsNullOrEmpty(cachingSystemCode)) { userLogOnEntityTableName = cachingSystemCode + "UserLogOn"; } List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldId, userInfo.Id)); result = DbLogic.GetProperty(dbHelper, userLogOnEntityTableName, parameters, BaseUserLogOnEntity.FieldOpenId); dbHelper.Close(); } return(result); }
/// <summary> /// 交换排序方法 /// </summary> /// <param name="dbHelper">当前数据库连接</param> /// <param name="tableName">表名</param> /// <param name="id">记录主键</param> /// <param name="targetId">目标记录主键</param> /// <returns>影响行数</returns> public static int Swap(IDbHelper dbHelper, string tableName, string id, string targetId) { int returnValue = 0; // 要移动的主键的排序码 List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, id)); string sortCode = DbLogic.GetProperty(dbHelper, tableName, parameters, BaseBusinessLogic.FieldSortCode); // 目标主键的排序码 parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, targetId)); string targetSortCode = DbLogic.GetProperty(dbHelper, tableName, parameters, BaseBusinessLogic.FieldSortCode); // 以下方法,在MySQL里不能正常运行,虽然效率是很高 // 设置要移动的主键的排序码(注:少读取数据库一次,提高主键运行效率) // string sqlQuery = " UPDATE " + tableName // + " SET " + BaseBusinessLogic.FieldSortCode + " = (SELECT " + BaseBusinessLogic.FieldSortCode // + " FROM " + tableName // + " WHERE " + BaseBusinessLogic.FieldId + " = '" + targetId + "') " // + " WHERE " + BaseBusinessLogic.FieldId + " = '" + Id + "' "; // returnValue = DbHelper.ExecuteNonQuery(sqlQuery); List <KeyValuePair <string, object> > whereParameters = new List <KeyValuePair <string, object> >(); whereParameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, id)); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldSortCode, targetSortCode)); // 设置目标主键的排序码 returnValue += DbLogic.SetProperty(dbHelper, tableName, whereParameters, parameters); whereParameters = new List <KeyValuePair <string, object> >(); whereParameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldId, targetId)); parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseBusinessLogic.FieldSortCode, sortCode)); // 设置目标主键的排序码 returnValue += DbLogic.SetProperty(dbHelper, tableName, whereParameters, parameters); return(returnValue); }
// // 获取用户的最新 OpenId 的方法 // public static string GetUserOpenId(BaseUserInfo userInfo) { string result = string.Empty; if (userInfo != null && !string.IsNullOrWhiteSpace(userInfo.Id)) { using (var redis = new PooledRedisClientManager(Port, new string[] { Url }).GetClient()) { result = redis.Get <string>("userId" + userInfo.Id); if (string.IsNullOrWhiteSpace(result)) { userInfo.OpenId = result; HttpContext.Current.Session[DotNet.Business.Utilities.SessionName] = userInfo; HttpContext.Current.Session["openId"] = userInfo.OpenId; } } // 从数据库获取,这里要考虑读写分离的做法 if (string.IsNullOrWhiteSpace(result)) { using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType, BaseSystemInfo.UserCenterReadDbConnection)) { List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserLogOnEntity.FieldId, userInfo.Id)); result = DbLogic.GetProperty(dbHelper, BaseUserLogOnEntity.TableName, parameters, BaseUserLogOnEntity.FieldOpenId); if (string.IsNullOrWhiteSpace(result)) { userInfo.OpenId = result; HttpContext.Current.Session[DotNet.Business.Utilities.SessionName] = userInfo; HttpContext.Current.Session["openId"] = userInfo.OpenId; SetUserOpenId(userInfo.Id, userInfo.OpenId); } } } } return(result); }
public virtual string GetProperty(List <KeyValuePair <string, object> > parameters, string targetField) { return(DbLogic.GetProperty(DbHelper, this.CurrentTableName, parameters, targetField)); }