Пример #1
0
        public int Update(BaseOrganizeEntity organizeEntity, out string statusCode)
        {
            int returnValue = 0;
            // 检查是否已被其他人修改
            //if (DbLogic.IsModifed(DbHelper, BaseOrganizeEntity.TableName, organizeEntity.Id, organizeEntity.ModifiedUserId, organizeEntity.ModifiedOn))
            //{
            //    // 数据已经被修改
            //    statusCode = StatusCode.ErrorChanged.ToString();
            //}
            //else
            //{

            List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();

            parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldParentId, organizeEntity.ParentId));
            parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldFullName, organizeEntity.FullName));
            parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0));

            if (this.Exists(parameters, organizeEntity.Id))
            {
                // 名称已重复
                statusCode = StatusCode.ErrorNameExist.ToString();
            }
            else
            {
                // 检查编号是否重复
                parameters = new List <KeyValuePair <string, object> >();
                parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldCode, organizeEntity.Code));
                parameters.Add(new KeyValuePair <string, object>(BaseOrganizeEntity.FieldDeletionStateCode, 0));

                if (organizeEntity.Code.Length > 0 && this.Exists(parameters, organizeEntity.Id))
                {
                    // 编号已重复
                    statusCode = StatusCode.ErrorCodeExist.ToString();
                }
                else
                {
                    // 1:更新部门的信息
                    returnValue = this.UpdateEntity(organizeEntity);
                    // 2:组织机构修改时,用户表的公司,部门,工作组数据给同步更新。
                    BaseUserManager userManager = new BaseUserManager(this.DbHelper, this.UserInfo);
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyId, organizeEntity.Id), new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyName, organizeEntity.FullName));
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentId, organizeEntity.Id), new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentName, organizeEntity.FullName));
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupId, organizeEntity.Id), new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupName, organizeEntity.FullName));
                    // 03:组织机构修改时,文件夹同步更新
                    BaseFolderManager folderManager = new BaseFolderManager(this.DbHelper, this.UserInfo);
                    folderManager.SetProperty(new KeyValuePair <string, object>(BaseFolderEntity.FieldFolderName, organizeEntity.FullName), new KeyValuePair <string, object>(BaseFolderEntity.FieldId, organizeEntity.Id));
                    if (returnValue == 1)
                    {
                        statusCode = StatusCode.OKUpdate.ToString();
                    }
                    else
                    {
                        statusCode = StatusCode.ErrorDeleted.ToString();
                    }
                }
            }
            //}
            return(returnValue);
        }
Пример #2
0
        public int MoveTo(BaseUserInfo userInfo, string folderId, string parentId)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                result = folderManager.MoveTo(folderId, parentId);
            });
            return(result);
        }
Пример #3
0
        public int BatchSave(BaseUserInfo userInfo, DataTable dt)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                result = folderManager.BatchSave(dt);
            });
            return(result);
        }
Пример #4
0
        public string GetId(BaseUserInfo userInfo, KeyValuePair <string, object> parameter1, KeyValuePair <string, object> parameter2)
        {
            string result = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                result = folderManager.GetId(parameter1, parameter2);
            });
            return(result);
        }
Пример #5
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        public BaseFolderEntity GetObject(BaseUserInfo userInfo, string id)
        {
            BaseFolderEntity folderEntity = null;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                folderEntity = folderManager.GetObject(id);
            });
            return(folderEntity);
        }
Пример #6
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="search">查询</param>
        /// <returns>数据表</returns>
        public DataTable Search(BaseUserInfo userInfo, string searchValue)
        {
            var dt = new DataTable(BaseOrganizeEntity.TableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                dt           = folderManager.Search(searchValue);
                dt.TableName = BaseFolderEntity.TableName;
            });
            return(dt);
        }
Пример #7
0
        /// <summary>
        /// 重命名
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <param name="newName">新名称</param>
        /// <param name="enabled">有效</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>影响行数</returns>
        public int Rename(BaseUserInfo userInfo, string id, string newName, bool enabled, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            statusCode    = string.Empty;
            statusMessage = string.Empty;
            int returnValue = 0;

            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseFolderEntity  folderEntity  = new BaseFolderEntity();
                    BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                    DataTable         dataTable     = folderManager.GetDataTableById(id);
                    folderEntity.GetSingle(dataTable);
                    folderEntity.FolderName = newName;
                    folderEntity.Enabled    = enabled? 1:0;
                    returnValue             = folderManager.Update(folderEntity, out statusCode);
                    statusMessage           = folderManager.GetStateMessage(statusCode);
                    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);
        }
Пример #8
0
        public int BatchMoveTo(BaseUserInfo userInfo, string[] folderIds, string parentId)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                for (int i = 0; i < folderIds.Length; i++)
                {
                    result += folderManager.MoveTo(folderIds[i], parentId);
                }
            });
            return(result);
        }
Пример #9
0
        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int BatchDelete(BaseUserInfo userInfo, string[] ids)
        {
            int result = 0;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseOrganizeManager(dbHelper, userInfo);
                result      = manager.Delete(ids);
                // 把公司文件夹也删除了
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                result = folderManager.Delete(ids);
            });
            return(result);
        }
Пример #10
0
        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        public int SetDeleted(BaseUserInfo userInfo, string[] ids)
        {
            var parameter = ServiceParameter.CreateWithMessage(userInfo
                                                               , MethodBase.GetCurrentMethod()
                                                               , this.serviceName
                                                               , AppMessage.OrganizeService_SetDeleted);
            int result = 0;

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager = new BaseAreaManager(dbHelper, userInfo);
                for (int i = 0; i < ids.Length; i++)
                {
                    // 设置部门为删除状态
                    result += manager.SetDeleted(ids[i]);
                    // 相应的用户也需要处理
                    var userManager = new BaseUserManager(dbHelper, userInfo);
                    List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyId, null));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyName, null));
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldCompanyId, ids[i]), parameters);
                    parameters = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyId, null));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyName, null));
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldSubCompanyId, ids[i]), parameters);
                    parameters = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentId, null));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentName, null));
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldDepartmentId, ids[i]), parameters);
                    parameters = new List <KeyValuePair <string, object> >();
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupId, null));
                    parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupName, null));
                    userManager.SetProperty(new KeyValuePair <string, object>(BaseUserEntity.FieldWorkgroupId, ids[i]), parameters);
                    // 相应的员工也需要处理
                    var staffManager = new BaseStaffManager(dbHelper, userInfo);
                    staffManager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldCompanyId, ids[i]), new KeyValuePair <string, object>(BaseStaffEntity.FieldCompanyId, null));
                    staffManager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldSubCompanyId, ids[i]), new KeyValuePair <string, object>(BaseStaffEntity.FieldSubCompanyId, null));
                    staffManager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldDepartmentId, ids[i]), new KeyValuePair <string, object>(BaseStaffEntity.FieldDepartmentId, null));
                    staffManager.SetProperty(new KeyValuePair <string, object>(BaseStaffEntity.FieldWorkgroupId, ids[i]), new KeyValuePair <string, object>(BaseStaffEntity.FieldWorkgroupId, null));
                }
                var folderManager = new BaseFolderManager(dbHelper, userInfo);
                folderManager.SetDeleted(ids);
            });
            return(result);
        }
Пример #11
0
        public int Update(BaseUserInfo userInfo, BaseFolderEntity entity, out string statusCode, out string statusMessage)
        {
            int result = 0;

            string returnCode    = string.Empty;
            string returnMessage = string.Empty;
            var    parameter     = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                result        = folderManager.Update(entity, out returnCode);
                returnMessage = folderManager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
Пример #12
0
        public string Add(BaseUserInfo userInfo, BaseFolderEntity folderEntity, out string statusCode, out string statusMessage)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            statusCode    = string.Empty;
            statusMessage = string.Empty;
            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                    returnValue   = folderManager.Add(folderEntity, out statusCode);
                    statusMessage = folderManager.GetStateMessage(statusCode);
                    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);
        }
Пример #13
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo)
        {
            var dt = new DataTable(BaseModuleEntity.TableName);

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                // 检查相应的系统必备文件夹
                folderManager.FolderCheck();
                if (userInfo.IsAdministrator)
                {
                    dt = folderManager.GetDataTable(new KeyValuePair <string, object>(BaseFolderEntity.FieldDeletionStateCode, 0), BaseFolderEntity.FieldSortCode);
                }
                else
                {
                    // 数据权限部分,部门的权限部分。
                    BasePermissionScopeManager permissionScopeManager = new BasePermissionScopeManager(dbHelper, userInfo);
                    string[] ids = permissionScopeManager.GetOrganizeIds(userInfo.Id, "File.Admin");
                    // 获取安全等级,比自己小的。
                    string commandText = string.Format(@"SELECT * 
                                                               FROM BaseFolder 
                                                              WHERE (DeletionStateCode = 0 
                                                                    AND Enabled = 1 
                                                                    AND (IsPublic = 1 
                                                                         OR Id = 'UserSpace' 
                                                                         OR Id = 'CompanyFile' 
                                                                         OR Id = '{0}' 
                                                                         OR Id = '{1}' 
                                                                         OR Id = '{2}' 
                                                                         OR CreateUserId = '{3}')) ", userInfo.Id, userInfo.DepartmentId, userInfo.CompanyId, userInfo.Id);
                    if (ids != null && ids.Length > 0)
                    {
                        commandText += " OR ID IN (" + string.Join(",", ids) + ") ";
                    }
                    dt = folderManager.Fill(commandText);
                }
                dt.DefaultView.Sort = BaseFolderEntity.FieldSortCode;
                dt.TableName        = BaseFolderEntity.TableName;
            });
            return(dt);
        }
Пример #14
0
        public int BatchMoveTo(BaseUserInfo userInfo, string[] folderIds, string parentId)
        {
            // 写入调试信息
            #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);
                    BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                    for (int i = 0; i < folderIds.Length; i++)
                    {
                        returnValue += folderManager.MoveTo(folderIds[i], parentId);
                    }
                    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);
        }
Пример #15
0
        public DataTable GetDataTableByParent(BaseUserInfo userInfo, string id)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseOrganizeEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 获得文件夹列表
                    BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                    dataTable           = folderManager.GetDataTableByParent(id);
                    dataTable.TableName = BaseFolderEntity.TableName;
                    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(dataTable);
        }
Пример #16
0
        public int BatchSave(BaseUserInfo userInfo, DataTable dataTable)
        {
            // 写入调试信息
            #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);
                    BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                    returnValue = folderManager.BatchSave(dataTable);
                    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);
        }
Пример #17
0
        public string AddByFolderName(BaseUserInfo userInfo, string parentId, string folderName, bool enabled, out string statusCode, out string statusMessage)
        {
            string result = string.Empty;

            string returnCode    = string.Empty;
            string returnMessage = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderEntity folderEntity   = new BaseFolderEntity();
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                folderEntity.ParentId           = parentId;
                folderEntity.FolderName         = folderName;
                folderEntity.Enabled            = enabled ? 1 : 0;
                result        = folderManager.Add(folderEntity, out returnCode);
                returnMessage = folderManager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="userEntity">用户实体</param>
        /// <param name="statusCode">状态码</param>
        /// <returns>影响行数</returns>
        public int Update(BaseUserEntity userEntity, out string statusCode)
        {
            int returnValue = 0;

            // 检查用户名是否重复
            if (this.Exists(new KeyValuePair <string, object>(BaseUserEntity.FieldUserName, userEntity.UserName), new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, "0"), userEntity.Id))
            {
                // 用户名已重复
                statusCode = StatusCode.ErrorUserExist.ToString();
            }
            else
            {
                if (!string.IsNullOrEmpty(userEntity.Code) && userEntity.Code.Length > 0 && this.Exists(new KeyValuePair <string, object>(BaseUserEntity.FieldCode, userEntity.Code), new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, "0"), userEntity.Id))
                {
                    // 编号已重复
                    statusCode = StatusCode.ErrorCodeExist.ToString();
                }
                else
                {
                    // 01:先更新自己的数据
                    returnValue = this.UpdateEntity(userEntity);
                    // 02:用户修改时,文件夹同步更新
                    BaseFolderManager folderManager = new BaseFolderManager(this.DbHelper, this.UserInfo);
                    folderManager.SetProperty(new KeyValuePair <string, object>(BaseFolderEntity.FieldFolderName, userEntity.RealName), new KeyValuePair <string, object>(BaseFolderEntity.FieldId, userEntity.Id));

                    if (returnValue == 0)
                    {
                        statusCode = StatusCode.ErrorDeleted.ToString();
                    }
                    else
                    {
                        statusCode = StatusCode.OKUpdate.ToString();
                    }
                }
            }
            return(returnValue);
        }
Пример #19
0
        /// <summary>
        /// 重命名
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <param name="newName">新名称</param>
        /// <param name="enabled">有效</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>影响行数</returns>
        public int Rename(BaseUserInfo userInfo, string id, string newName, bool enabled, out string statusCode, out string statusMessage)
        {
            int result = 0;

            string returnCode    = string.Empty;
            string returnMessage = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderEntity folderEntity   = new BaseFolderEntity();
                BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                var dt = folderManager.GetDataTableById(id);
                folderEntity.GetSingle(dt);
                folderEntity.FolderName = newName;
                folderEntity.Enabled    = enabled ? 1 : 0;
                result        = folderManager.Update(folderEntity, out returnCode);
                returnMessage = folderManager.GetStateMessage(returnCode);
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
Пример #20
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="entity">实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        public string Add(BaseUserInfo userInfo, BaseOrganizeEntity entity, out string statusCode, out string statusMessage)
        {
            string result        = string.Empty;
            string returnCode    = string.Empty;
            string returnMessage = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                var manager   = new BaseOrganizeManager(dbHelper, userInfo);
                result        = manager.Add(entity);
                returnMessage = manager.GetStateMessage(returnCode);
                if (returnCode.Equals(Status.OKAdd.ToString()))
                {
                    entity.Id         = result;
                    var folderManager = new BaseFolderManager(dbHelper, userInfo);
                    folderManager.FolderCheck(entity.Id.ToString(), entity.FullName);
                }
            });
            statusCode    = returnCode;
            statusMessage = returnMessage;
            return(result);
        }
Пример #21
0
        /// <summary>
        /// 发送文件
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="fileName">文件名</param>
        /// <param name="file">文件内容</param>
        /// <param name="toUserId">发送给谁主键</param>
        /// <returns>文件主键</returns>
        public string Send(BaseUserInfo userInfo, string fileName, byte[] file, string toUserId)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            string returnValue = string.Empty;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseFolderEntity  folderEntity  = new BaseFolderEntity();
                    BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                    // 检查相应的系统必备文件夹
                    folderManager.FolderCheck();
                    BaseUserEntity userEntity = new BaseUserManager(dbHelper, userInfo).GetEntity(toUserId);
                    if (!string.IsNullOrEmpty(userEntity.Id))
                    {
                        // 04:判断发送者的空间是否存在?
                        // 05:判断已收文件夹是否存在?
                        if (!folderManager.Exists(userEntity.Id.ToString()))
                        {
                            folderEntity.FolderName        = userEntity.RealName + AppMessage.FileService_File;
                            folderEntity.ParentId          = "UserSpace";
                            folderEntity.Id                = userEntity.Id.ToString();
                            folderEntity.Enabled           = 1;
                            folderEntity.DeletionStateCode = 0;
                            folderManager.AddEntity(folderEntity);
                        }
                        // 06:判断来自谁的文件夹是否存在?
                        // 07:判断发给谁的文件夹是否存在?
                        if (!folderManager.Exists(toUserId + "_Receive"))
                        {
                            folderEntity.FolderName        = AppMessage.FileService_ReceiveFile;
                            folderEntity.ParentId          = toUserId;
                            folderEntity.Id                = toUserId + "_Receive";
                            folderEntity.Enabled           = 1;
                            folderEntity.DeletionStateCode = 0;
                            folderManager.AddEntity(folderEntity);
                        }
                        if (!folderManager.Exists(userInfo.Id + "_Send_" + toUserId))
                        {
                            folderEntity.FolderName        = userEntity.RealName + "(" + userEntity.UserName + ")";
                            folderEntity.ParentId          = userInfo.Id + "_Send";
                            folderEntity.Id                = userInfo.Id + "_Send_" + toUserId;
                            folderEntity.Enabled           = 1;
                            folderEntity.DeletionStateCode = 0;
                            folderManager.AddEntity(folderEntity);
                        }
                        if (!folderManager.Exists(toUserId + "_Receive_" + userInfo.Id))
                        {
                            folderEntity.FolderName        = userInfo.RealName + "(" + userInfo.UserName + ")";
                            folderEntity.ParentId          = toUserId + "_Receive";
                            folderEntity.Id                = toUserId + "_Receive_" + userInfo.Id;
                            folderEntity.Enabled           = 1;
                            folderEntity.DeletionStateCode = 0;
                            folderManager.AddEntity(folderEntity);
                        }
                        // 08:已发送文件夹多一个文件。
                        // 09:已接收文件夹多一个文件。
                        BaseFileEntity fileEntity = new BaseFileEntity();
                        fileEntity.FileName  = fileName;
                        fileEntity.Contents  = file;
                        fileEntity.Enabled   = 1;
                        fileEntity.ReadCount = 0;
                        fileEntity.FolderId  = userInfo.Id + "_Send_" + toUserId;
                        // 把修改人显示出来
                        fileEntity.ModifiedBy     = userInfo.RealName;
                        fileEntity.ModifiedUserId = userInfo.Id;
                        fileEntity.ModifiedOn     = DateTime.Now;
                        BaseFileManager fileManager = new BaseFileManager(dbHelper, userInfo);
                        fileManager.AddEntity(fileEntity);
                        fileEntity.FolderId = toUserId + "_Receive_" + userInfo.Id;
                        returnValue         = fileManager.AddEntity(fileEntity);
                        // string webHostUrl = BaseSystemInfo.WebHostUrl;
                        // if (string.IsNullOrEmpty(webHostUrl))
                        // {
                        //    webHostUrl = "WebHostUrl";
                        // }
                        // 10:应该还发一个短信提醒一下才对。
                        BaseMessageEntity messageEntity = new BaseMessageEntity();
                        messageEntity.Id           = Guid.NewGuid().ToString();
                        messageEntity.CategoryCode = MessageCategory.Send.ToString();
                        messageEntity.FunctionCode = MessageFunction.Message.ToString();
                        messageEntity.ObjectId     = returnValue;
                        messageEntity.ReceiverId   = toUserId;
                        // target=\"_blank\"
                        messageEntity.Contents          = AppMessage.FileService_SendFileFrom + " <a href={WebHostUrl}Download.aspx?Id=" + returnValue + ">" + fileName + "</a>" + AppMessage.FileService_CheckReceiveFile;
                        messageEntity.IsNew             = (int)MessageStateCode.New;
                        messageEntity.ReadCount         = 0;
                        messageEntity.DeletionStateCode = 0;
                        messageEntity.Enabled           = 1;
                        BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo);
                        returnValue = messageManager.Add(messageEntity);
                    }
                    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);
        }
Пример #22
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTable(BaseUserInfo userInfo)
        {
            // 写入调试信息
            #if (DEBUG)
            int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
            LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseModuleEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseFolderManager folderManager = new BaseFolderManager(dbHelper, userInfo);
                    // 检查相应的系统必备文件夹
                    folderManager.FolderCheck();
                    if (userInfo.IsAdministrator)
                    {
                        dataTable = folderManager.GetDataTable(BaseFolderEntity.FieldSortCode);
                    }
                    else
                    {
                        // 数据权限部分,部门的权限部分。
                        BasePermissionScopeManager permissionScopeManager = new BasePermissionScopeManager(dbHelper, userInfo);
                        string[] ids = permissionScopeManager.GetOrganizeIds(userInfo.Id, "Resource.ManagePermission");
                        // 获取安全等级,比自己小的。
                        string commandText = string.Format(@"SELECT * 
                                                               FROM BaseFolder 
                                                              WHERE (DeletionStateCode = 0 
                                                                    AND Enabled = 1 
                                                                    AND (IsPublic = 1 
                                                                         OR Id = 'UserSpace' 
                                                                         OR Id = 'CompanyFile' 
                                                                         OR Id = '{0}' 
                                                                         OR Id = '{1}' 
                                                                         OR Id = '{2}' 
                                                                         OR CreateUserId = '{3}')) ", userInfo.Id, userInfo.DepartmentId, userInfo.CompanyId, userInfo.Id);
                        if (ids != null && ids.Length > 0)
                        {
                            commandText += " OR ID IN (" + BaseBusinessLogic.ObjectsToList(ids) + ") ";
                        }
                        dataTable = folderManager.Fill(commandText);
                    }
                    dataTable.DefaultView.Sort = BaseFolderEntity.FieldSortCode;
                    dataTable.TableName        = BaseFolderEntity.TableName;
                    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(dataTable);
        }
Пример #23
0
        /// <summary>
        /// 发送文件
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="fileName">文件名</param>
        /// <param name="file">文件内容</param>
        /// <param name="toUserId">发送给谁主键</param>
        /// <returns>文件主键</returns>
        public string Send(BaseUserInfo userInfo, string fileName, byte[] file, string toUserId)
        {
            string result = string.Empty;

            var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod());

            ServiceUtil.ProcessUserCenterWriteDb(userInfo, parameter, (dbHelper) =>
            {
                BaseFolderEntity folderEntity = new BaseFolderEntity();
                var folderManager             = new BaseFolderManager(dbHelper, userInfo);
                // 检查相应的系统必备文件夹
                folderManager.FolderCheck();
                BaseUserEntity userEntity = new BaseUserManager(dbHelper, userInfo).GetObject(toUserId);
                if (!string.IsNullOrEmpty(userEntity.Id))
                {
                    // 04:判断发送者的空间是否存在?
                    // 05:判断已收文件夹是否存在?
                    if (!folderManager.Exists(userEntity.Id))
                    {
                        folderEntity.FolderName        = userEntity.RealName + AppMessage.FileService_File;
                        folderEntity.ParentId          = "UserSpace";
                        folderEntity.Id                = userEntity.Id;
                        folderEntity.Enabled           = 1;
                        folderEntity.DeletionStateCode = 0;
                        folderManager.AddObject(folderEntity);
                    }
                    // 06:判断来自谁的文件夹是否存在?
                    // 07:判断发给谁的文件夹是否存在?
                    if (!folderManager.Exists(toUserId + "_Receive"))
                    {
                        folderEntity.FolderName        = AppMessage.FileService_ReceiveFile;
                        folderEntity.ParentId          = toUserId;
                        folderEntity.Id                = toUserId + "_Receive";
                        folderEntity.Enabled           = 1;
                        folderEntity.DeletionStateCode = 0;
                        folderManager.AddObject(folderEntity);
                    }
                    if (!folderManager.Exists(userInfo.Id + "_Send_" + toUserId))
                    {
                        folderEntity.FolderName        = userEntity.RealName + "(" + userEntity.UserName + ")";
                        folderEntity.ParentId          = userInfo.Id + "_Send";
                        folderEntity.Id                = userInfo.Id + "_Send_" + toUserId;
                        folderEntity.Enabled           = 1;
                        folderEntity.DeletionStateCode = 0;
                        folderManager.AddObject(folderEntity);
                    }
                    if (!folderManager.Exists(toUserId + "_Receive_" + userInfo.Id))
                    {
                        folderEntity.FolderName        = userInfo.RealName + "(" + userInfo.UserName + ")";
                        folderEntity.ParentId          = toUserId + "_Receive";
                        folderEntity.Id                = toUserId + "_Receive_" + userInfo.Id;
                        folderEntity.Enabled           = 1;
                        folderEntity.DeletionStateCode = 0;
                        folderManager.AddObject(folderEntity);
                    }
                    // 08:已发送文件夹多一个文件。
                    // 09:已接收文件夹多一个文件。
                    BaseFileEntity fileEntity = new BaseFileEntity();
                    fileEntity.FileName       = fileName;
                    fileEntity.Contents       = file;
                    fileEntity.Enabled        = 1;
                    fileEntity.ReadCount      = 0;
                    fileEntity.FolderId       = userInfo.Id + "_Send_" + toUserId;
                    // 把修改人显示出来
                    fileEntity.ModifiedBy     = userInfo.RealName;
                    fileEntity.ModifiedUserId = userInfo.Id;
                    fileEntity.ModifiedOn     = DateTime.Now;
                    var fileManager           = new BaseFileManager(dbHelper, userInfo);
                    fileManager.AddObject(fileEntity);
                    fileEntity.FolderId = toUserId + "_Receive_" + userInfo.Id;
                    result = fileManager.AddObject(fileEntity);
                    // string webHostUrl = BaseSystemInfo.WebHost;
                    // if (string.IsNullOrEmpty(webHostUrl))
                    // {
                    //    webHostUrl = "WebHostUrl";
                    // }
                    // 10:应该还发一个短信提醒一下才对。
                    BaseMessageEntity messageEntity = new BaseMessageEntity();
                    //messageEntity.Id = Guid.NewGuid().ToString("N");
                    messageEntity.CategoryCode = MessageCategory.Send.ToString();
                    messageEntity.FunctionCode = MessageFunction.Message.ToString();
                    messageEntity.ObjectId     = result;
                    messageEntity.ReceiverId   = toUserId;
                    // target=\"_blank\"
                    messageEntity.Contents          = AppMessage.FileService_SendFileFrom + " <a href={WebHostUrl}Download.aspx?Id=" + result + ">" + fileName + "</a>" + AppMessage.FileService_CheckReceiveFile;
                    messageEntity.IsNew             = (int)MessageStateCode.New;
                    messageEntity.ReadCount         = 0;
                    messageEntity.DeletionStateCode = 0;
                    var messageManager      = new BaseMessageManager(dbHelper, userInfo);
                    messageManager.Identity = true;
                    result = messageManager.Add(messageEntity);
                }
            });
            return(result);
        }