/// <summary> /// 批量重置序列 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">主键数组</param> /// <returns>影响行数</returns> public int Reset(BaseUserInfo userInfo, string[] ids) { int result = 0; var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) => { var sequenceManager = new BaseSequenceManager(dbHelper); result = sequenceManager.Reset(ids); }); return(result); }
// // 排序操作针对数据库的运算方式定义(好用高效的排序顺序设定方法) // #region 置顶排序(SortCode变小) /// <summary> /// 置顶排序(SortCode变小) /// </summary> /// <param name="dbHelper">当前数据库连接</param> /// <param name="tableName">表名</param> /// <param name="id">主键</param> /// <returns>影响行数</returns> public static int SetTop(IDbHelper dbHelper, string tableName, string id) { var managerSequence = new BaseSequenceManager(dbHelper); //先重置一下,避免手动添加的数据造成功能无效 managerSequence.Reset(tableName); var sequence = managerSequence.GetReduction(tableName); var whereParameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(BaseUtil.FieldId, id) }; var parameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(BaseUtil.FieldSortCode, sequence) }; return(DbUtil.SetProperty(dbHelper, tableName, whereParameters, parameters)); }
/// <summary> /// 批量重置序列 /// </summary> /// <param name="userInfo">用户</param> /// <param name="ids">主键数组</param> /// <returns>影响行数</returns> public int Reset(BaseUserInfo userInfo, string[] ids) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) LogOnService.UserIsLogOn(userInfo); #endif int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseSequenceManager sequenceManager = new BaseSequenceManager(dbHelper); returnValue = sequenceManager.Reset(ids); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.SequenceService_Reset, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 上移 /// </summary> /// <param name="dbHelper"></param> /// <param name="tableName"></param> /// <param name="id"></param> /// <param name="sequenceName"></param> /// <returns></returns> public static int SetTop(IDbHelper dbHelper, string tableName, string id, string sequenceName) { if (string.IsNullOrEmpty(sequenceName)) { sequenceName = tableName; } var managerSequence = new BaseSequenceManager(dbHelper); //先重置一下,避免手动添加的数据造成功能无效 managerSequence.Reset(sequenceName); var sequence = managerSequence.Increment(sequenceName); var whereParameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(BaseUtil.FieldId, id) }; var parameters = new List <KeyValuePair <string, object> > { new KeyValuePair <string, object>(BaseUtil.FieldSortCode, sequence) }; return(DbUtil.SetProperty(dbHelper, tableName, whereParameters, parameters)); }