public virtual List <Structures.ResponsibilitiesReport.ResponsibilitiesReportTableLine> GetResponsibilitiesReportData(IEmployee employee) { var result = new List <Structures.ResponsibilitiesReport.ResponsibilitiesReportTableLine>(); // HACK: Получаем отображаемое имя модуля. var moduleGuid = new CompanyModule().Id; var moduleName = Sungero.Metadata.Services.MetadataSearcher.FindModuleMetadata(moduleGuid).GetDisplayName(); var modulePriority = Company.Constants.ResponsibilitiesReport.CompanyPriority; // Должность. result = AppendResponsibilitiesReportResult(result, employee.JobTitle, moduleName, modulePriority, Resources.Jobtitle); // Подразделения. if (Departments.AccessRights.CanRead()) { var employeeDepartments = Departments.GetAll() .Where(d => d.RecipientLinks.Any(e => Equals(e.Member, employee))) .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active); result = AppendResponsibilitiesReportResult(result, employeeDepartments, moduleName, modulePriority, Resources.Departments, employee.Department); } // НОР. if (Departments.AccessRights.CanRead() && BusinessUnits.AccessRights.CanRead()) { var businessUnits = Departments.GetAll() .Where(d => d.RecipientLinks.Any(e => Equals(e.Member, employee))) .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active) .Select(b => b.BusinessUnit) .Where(b => b.Status == Sungero.CoreEntities.DatabookEntry.Status.Active).Distinct(); result = AppendResponsibilitiesReportResult(result, businessUnits, moduleName, modulePriority, Resources.BusinessUnits, employee.Department.BusinessUnit); } // Руководитель подразделений. if (Departments.AccessRights.CanRead()) { var managerOfDepartments = Departments.GetAll().Where(d => Equals(d.Manager, employee)) .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active); result = AppendResponsibilitiesReportResult(result, managerOfDepartments, moduleName, modulePriority, Resources.ManagerOfDepartmens); } // Руководители НОР. if (BusinessUnits.AccessRights.CanRead()) { var businessUnitsCEO = BusinessUnits.GetAll().Where(b => Equals(b.CEO, employee)) .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active); result = AppendResponsibilitiesReportResult(result, businessUnitsCEO, moduleName, modulePriority, Resources.BusinessUnitsCEO); } // Роли. if (Roles.AccessRights.CanRead()) { var roles = Roles.GetAll().Where(r => r.RecipientLinks.Any(e => Equals(e.Member, employee))) .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active); result = AppendResponsibilitiesReportResult(result, roles, moduleName, modulePriority, Resources.Roles); } // Помощники руководителей. if (ManagersAssistants.AccessRights.CanRead()) { var managersAssistants = ManagersAssistants.GetAll() .Where(m => Equals(m.Assistant, employee) || Equals(m.Manager, employee)) .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active) .ToDictionary <IEntity, IEntity, string>(x => x, x => string.Format("{0}: {1}{2}{3}: {4}", Resources.Manager, PublicFunctions.Employee.GetShortName(ManagersAssistants.As(x).Manager, false), Environment.NewLine, Resources.Assistant, PublicFunctions.Employee.GetShortName(ManagersAssistants.As(x).Assistant, false))); result = AppendResponsibilitiesReportResult(result, managersAssistants, moduleName, modulePriority + result.Count, Resources.ManagersAssistants); } // Замещения. if (Substitutions.AccessRights.CanRead()) { var substitutions = Substitutions.GetAll() .Where(s => (Equals(s.Substitute, employee) || Equals(s.User, employee)) && (!s.EndDate.HasValue || s.EndDate >= Calendar.UserToday)) .Where(s => s.IsSystem != true) .ToDictionary <IEntity, IEntity, string>(x => x, x => CreateSubstitutionPresentation(Substitutions.As(x))); result = AppendResponsibilitiesReportResult(result, substitutions, moduleName, modulePriority + result.Count, Resources.Substitutions); } return(result); }