예제 #1
0
        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(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);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    // 考虑主键是数值类型的,支持Access
                    returnValue = userManager.SetDeleted(ids, true);
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, 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;
        }
예제 #2
0
 /// <summary>
 /// 删除标志
 /// 
 /// 删除员工时,需要把用户也给删除掉
 /// </summary>
 /// <param name="userInfo">当前用户</param>
 /// <param name="id">主键</param>
 /// <returns>影响行数</returns>
 public int SetDeleted(string id)
 {
     // 先把用户设置为删除标记
     string userId = this.GetProperty(id, BaseStaffEntity.FieldUserId);
     if (!String.IsNullOrEmpty(userId))
     {
         BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo);
         userManager.SetDeleted(userId);
     }
     // 再把员工设置为删除标记
     return this.SetProperty(new KeyValuePair<string, object>(BaseBusinessLogic.FieldId, id), new KeyValuePair<string, object>(BaseBusinessLogic.FieldDeletionStateCode, 1));
 }
예제 #3
0
        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(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);
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo);
                    BaseStaffEntity staffEntity = null;
                    for (int i = 0; i < ids.Length; i++)
                    {
                        // 删除相应的用户
                        staffEntity = staffManager.GetEntity(ids[i]);
                        if (staffEntity.UserId != null)
                        {
                            userManager.SetDeleted(staffEntity.UserId);
                        }
                        // 删除职员
                        returnValue = staffManager.SetDeleted(ids[i], true);
                    }
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, 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;
        }
예제 #4
0
 /// <summary>
 /// 删除员工关联的用户
 /// </summary>
 /// <param name="staffId">员工主键</param>
 /// <returns>影响行数</returns>
 public int DeleteUser(string staffId)
 {
     int returnValue = 0;
     string userId = this.GetEntity(staffId).UserId.ToString();
     if (!String.IsNullOrEmpty(userId))
     {
         // 删除用户
         BaseUserManager userManager = new BaseUserManager(DbHelper, UserInfo);
         returnValue += userManager.SetDeleted(userId);
     }
     // 将员工的用户设置为空
     returnValue += this.SetProperty(new KeyValuePair<string, object>(BaseStaffEntity.FieldId, staffId), new KeyValuePair<string, object>(BaseStaffEntity.FieldUserId, null));
     return returnValue;
 }