/// <summary>
        /// 按日期获取日志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="beginDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <param name="userId">用户主键</param>
        /// <param name="moduleId">模块主键</param>
        /// <returns>数据表</returns>
        public DataTable GetDTByDate(UserInfo userInfo, string beginDate, string endDate, string userId, string moduleId)
        {
            var dataTable = new DataTable(CiLogTable.TableName);
            var parameter = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.LogService_GetDTByDate);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                var logManager = new LogManager(dbProvider, userInfo);
                if (!string.IsNullOrEmpty(userId))
                {
                    dataTable = logManager.GetDTByDateByUserIds(new[] { userId }, CiLogTable.FieldProcessId, moduleId, beginDate, endDate);
                }
                else
                {
                    if (userInfo.IsAdministrator)
                    {
                        dataTable = logManager.GetDTByDate(CiLogTable.FieldProcessId, moduleId, beginDate, endDate);
                    }
                    else
                    {
                        var piPermissionScopeManager = new PiPermissionScopeManager(dbProvider, userInfo);
                        string[] userIds             = piPermissionScopeManager.GetUserIds(userInfo.Id, "Resource.ManagePermission");
                        dataTable = logManager.GetDTByDateByUserIds(userIds, CiLogTable.FieldProcessId, moduleId, beginDate, endDate);
                    }
                }
                dataTable.TableName = CiLogTable.TableName;
            });

            return(dataTable);
        }
Beispiel #2
0
        /// <summary>
        /// 按某个权限范围获取特定用户可访问的用户主键数组
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="permissionItemCode">操作权限编号</param>
        /// <returns>主键数组</returns>
        public string[] GetUserIdsByPermissionScope(UserInfo userInfo, string userId, string permissionItemCode)
        {
            string[] returnValue = null;
            var      parameter   = ParameterUtil.CreateWithMessage(userInfo, MethodBase.GetCurrentMethod(), this.serviceName, RDIFrameworkMessage.PermissionService_GetUserIdsByPermissionScope);

            ServiceUtil.ProcessRDIReadDb(userInfo, parameter, dbProvider =>
            {
                // 若权限是空的,直接返回所有数据
                if (!String.IsNullOrEmpty(permissionItemCode))
                {
                    var permissionScopeManager = new PiPermissionScopeManager(dbProvider, userInfo);
                    returnValue = permissionScopeManager.GetUserIds(userId, permissionItemCode);
                }
            });
            return(returnValue);
        }
Beispiel #3
0
        private string GetSearchConditional(string permissionScopeCode, string search, string[] roleIds, bool?enabled, string auditStates, string departmentId)
        {
            search = StringHelper.GetSearchString(search);
            string whereConditional = PiUserTable.TableName + "." + PiUserTable.FieldDeleteMark + " = 0 "
                                      + " AND " + PiUserTable.TableName + "." + PiUserTable.FieldIsVisible + " = 1 ";

            if (enabled != null)
            {
                whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldEnabled + " = " + ((bool)enabled ? 1 : 0) + ")";
            }
            if (!String.IsNullOrEmpty(search))
            {
                whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldUserName + " LIKE '" + search + "'"
                                    + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldCode + " LIKE '" + search + "'"
                                    + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldRealName + " LIKE '" + search + "'"
                                    + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldQuickQuery + " LIKE '" + search + "'"
                                    + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldDepartmentName + " LIKE '" + search + "'"
                                    + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldDescription + " LIKE '" + search + "')";
            }
            if (!string.IsNullOrEmpty(departmentId))
            {
                var      organizeManager = new PiOrganizeManager(this.DBProvider, this.UserInfo);
                string[] organizeIds     = organizeManager.GetChildrensId(PiOrganizeTable.FieldId, departmentId, PiOrganizeTable.FieldParentId);
                if (organizeIds != null && organizeIds.Length > 0)
                {
                    whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldCompanyId + " IN (" + StringHelper.ArrayToList(organizeIds, "'") + ")"
                                        + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldSubCompanyId + " IN (" + StringHelper.ArrayToList(organizeIds, "'") + ")"
                                        + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldDepartmentId + " IN (" + StringHelper.ArrayToList(organizeIds, "'") + ")"
                                        + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldSubDepartmentId + " IN (" + StringHelper.ArrayToList(organizeIds, "'") + ")"
                                        + " OR " + PiUserTable.TableName + "." + PiUserTable.FieldWorkgroupId + " IN (" + StringHelper.ArrayToList(organizeIds, "'") + "))";

                    // 从兼职表读取用户
                    whereConditional += " OR " + PiUserTable.TableName + "." + PiUserTable.FieldId + " IN ("
                                        + " SELECT " + PiUserOrganizeTable.FieldUserId
                                        + "   FROM " + PiUserOrganizeTable.TableName
                                        + "  WHERE (" + PiUserOrganizeTable.TableName + "." + PiUserOrganizeTable.FieldDeleteMark + " = 0 ) "
                                        + "       AND ("
                                        + PiUserOrganizeTable.TableName + "." + PiUserOrganizeTable.FieldCompanyId + " = '" + departmentId + "' OR "
                                        + PiUserOrganizeTable.TableName + "." + PiUserOrganizeTable.FieldSubCompanyId + " = '" + departmentId + "' OR "
                                        + PiUserOrganizeTable.TableName + "." + PiUserOrganizeTable.FieldDepartmentId + " = '" + departmentId + "' OR "
                                        + PiUserOrganizeTable.TableName + "." + PiUserOrganizeTable.FieldSubDepartmentId + " = '" + departmentId + "' OR "
                                        + PiUserOrganizeTable.TableName + "." + PiUserOrganizeTable.FieldWorkgroupId + " = '" + departmentId + "')) ";
                }
            }
            if (!String.IsNullOrEmpty(auditStates))
            {
                whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldAuditStatus + " = '" + auditStates + "')";
            }

            if ((roleIds != null) && (roleIds.Length > 0))
            {
                string roles = StringHelper.ArrayToList(roleIds, "'");
                whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldId + " IN (" + "SELECT " + PiUserRoleTable.FieldUserId + " FROM " + PiUserRoleTable.TableName + " WHERE " + PiUserRoleTable.FieldRoleId + " IN (" + roles + ")" + "))";
            }

            // 是否过滤用户, 获得组织机构列表
            if ((!UserInfo.IsAdministrator) && (SystemInfo.EnableUserAuthorizationScope))
            {
                // string permissionScopeCode = "Resource.ManagePermission";
                var    permissionItemManager = new PiPermissionItemManager(this.DBProvider, this.UserInfo);
                string permissionScopeItemId = permissionItemManager.GetId(new KeyValuePair <string, object>(PiPermissionItemTable.FieldCode, permissionScopeCode));
                if (!string.IsNullOrEmpty(permissionScopeItemId))
                {
                    // 从小到大的顺序进行显示,防止错误发生
                    var      userPermissionScopeManager = new UserScopeManager(this.DBProvider, this.UserInfo);
                    string[] organizeIds = userPermissionScopeManager.GetOrganizeIds(this.UserInfo.Id, permissionScopeCode);

                    // 没有任何数据权限
                    if (StringHelper.Exists(organizeIds, ((int)PermissionScope.None).ToString()))
                    {
                        whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldId + " = NULL ) ";
                    }
                    // 按详细设定的数据
                    if (StringHelper.Exists(organizeIds, ((int)PermissionScope.Detail).ToString()))
                    {
                        var      permissionScopeManager = new PiPermissionScopeManager(DBProvider, UserInfo);
                        string[] userIds = permissionScopeManager.GetUserIds(UserInfo.Id, permissionScopeCode);
                        whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldId + " IN (" + BusinessLogic.ObjectsToList(userIds) + ")) ";
                    }
                    // 自己的数据,仅本人
                    if (StringHelper.Exists(organizeIds, ((int)PermissionScope.User).ToString()))
                    {
                        whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldId + " = '" + this.UserInfo.Id + "') ";
                    }
                    // 用户所在工作组数据
                    if (StringHelper.Exists(organizeIds, ((int)PermissionScope.UserWorkgroup).ToString()))
                    {
                        whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldWorkgroupId + " = '" + this.UserInfo.WorkgroupId + "') ";
                    }
                    // 用户所在部门数据
                    if (StringHelper.Exists(organizeIds, ((int)PermissionScope.UserDepartment).ToString()))
                    {
                        whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldDepartmentId + " = '" + this.UserInfo.DepartmentId + "') ";
                    }
                    // 用户所在公司数据
                    if (StringHelper.Exists(organizeIds, ((int)PermissionScope.UserCompany).ToString()))
                    {
                        whereConditional += " AND (" + PiUserTable.TableName + "." + PiUserTable.FieldCompanyId + " = '" + this.UserInfo.CompanyId + "') ";
                    }
                    // 全部数据,这里就不用设置过滤条件了
                    if (StringHelper.Exists(organizeIds, ((int)PermissionScope.All).ToString()))
                    {
                    }
                }
            }
            return(whereConditional);
        }