diff --git a/DepartmentPortal/Common/ToolsModule/ManagmentMapping/MapConfigurationAttribute.cs b/DepartmentPortal/Common/ToolsModule/ManagmentMapping/MapConfigurationAttribute.cs index 52a5c18..3261421 100644 --- a/DepartmentPortal/Common/ToolsModule/ManagmentMapping/MapConfigurationAttribute.cs +++ b/DepartmentPortal/Common/ToolsModule/ManagmentMapping/MapConfigurationAttribute.cs @@ -16,11 +16,6 @@ namespace ToolsModule.ManagmentMapping /// public string PropertyNameFromModel { get; set; } - /// - /// Сложное свойство (свойствое в другом классе-свойстве) - /// - public bool IsDifficle { get; set; } = false; - /// /// Можно копировать поле даже при доступе без прав /// diff --git a/DepartmentPortal/Common/ToolsModule/ManagmentMapping/Mapper.cs b/DepartmentPortal/Common/ToolsModule/ManagmentMapping/Mapper.cs index 6d4653c..f6ce837 100644 --- a/DepartmentPortal/Common/ToolsModule/ManagmentMapping/Mapper.cs +++ b/DepartmentPortal/Common/ToolsModule/ManagmentMapping/Mapper.cs @@ -105,80 +105,65 @@ namespace ToolsModule.ManagmentMapping private static object GetValueFromCustomAttribute(MapConfigurationAttribute customAttribute, Type typeFrom, object obj) { object value = obj; - if (customAttribute.IsDifficle) + var props = customAttribute.PropertyNameFromModel.Split('.'); + foreach (var prop in props) { - var props = customAttribute.PropertyNameFromModel.Split('.'); - foreach (var prop in props) - { - if (prop == "ToString") - { - value = value.ToString(); - break; - } - else if (prop == "Count") - { - value = (value as ICollection)?.Count; - break; - } - else if (prop == "Method") - { - int index = 0; - while (true) - { - if (props[index++] == "Method") - break; - if (index == props.Length) - { - break; - } - } - var methodName = props[index].Split('[')?[0]; - if (string.IsNullOrEmpty(methodName)) - { - break; - } - var parameters = props[index].Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries)?[1].Split(','); - var objs = new object[parameters.Length]; - for (int i = 0; i < parameters.Length; ++i) - { - var type = parameters[i].Split(':')[0]; - switch (type) - { - case "Enum": - objs[i] = Enum.Parse(customAttribute.MethodParams[i], parameters[i].Split(':')[1]); - break; - } - } - value = typeFrom.InvokeMember(methodName, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, value, objs); - break; - - } - var bindingProperty = value.GetType().GetProperty(prop); - if (bindingProperty != null) - { - value = bindingProperty.GetValue(value); - if (value is null) - { - break; - } - } - else - { - value = null; - break; - } - } - } - else - { - if (customAttribute.PropertyNameFromModel == "ToString") + if (prop == "ToString") { value = value.ToString(); + break; } - var bindingProperty = typeFrom.GetProperty(customAttribute.PropertyNameFromModel); + else if (prop == "Count") + { + value = (value as ICollection)?.Count; + break; + } + else if (prop == "Method") + { + int index = 0; + while (true) + { + if (props[index++] == "Method") + break; + if (index == props.Length) + { + break; + } + } + var methodName = props[index].Split('[')?[0]; + if (string.IsNullOrEmpty(methodName)) + { + break; + } + var parameters = props[index].Split(new char[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries)?[1].Split(','); + var objs = new object[parameters.Length]; + for (int i = 0; i < parameters.Length; ++i) + { + var type = parameters[i].Split(':')[0]; + switch (type) + { + case "Enum": + objs[i] = Enum.Parse(customAttribute.MethodParams[i], parameters[i].Split(':')[1]); + break; + } + } + value = typeFrom.InvokeMember(methodName, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, value, objs); + break; + + } + var bindingProperty = value.GetType().GetProperty(prop); if (bindingProperty != null) { - value = bindingProperty.GetValue(obj); + value = bindingProperty.GetValue(value); + if (value is null) + { + break; + } + } + else + { + value = null; + break; } } return value; diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanRecordTimeNormHourViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanRecordTimeNormHourViewModels.cs index 0fd7fa4..18878af 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanRecordTimeNormHourViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanRecordTimeNormHourViewModels.cs @@ -21,10 +21,10 @@ namespace DepartmentContract.ViewModels public Guid AcademicPlanRecordId { get; set; } [ViewModelControlListProperty("Дисциплина")] - [MapConfiguration("AcademicPlanRecord.Discipline.ToString", IsDifficle = true)] + [MapConfiguration("AcademicPlanRecord.Discipline.ToString")] public string DisciplineName { get; set; } - [MapConfiguration("AcademicPlanRecord.Semester", IsDifficle = true)] + [MapConfiguration("AcademicPlanRecord.Semester")] public Semester Semester { get; set; } [ViewModelControlListProperty("Семестр", ColumnWidth = 80)] @@ -34,7 +34,7 @@ namespace DepartmentContract.ViewModels public Guid TimeNormId { get; set; } [ViewModelControlListProperty("Норма времени")] - [MapConfiguration("TimeNorm.ToString", IsDifficle = true)] + [MapConfiguration("TimeNorm.ToString")] public string TimeNormName { get; set; } [ViewModelControlListProperty("Часы", ColumnWidth = 80)] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanRecordViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanRecordViewModels.cs index 99feea0..4a0c2c9 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanRecordViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanRecordViewModels.cs @@ -26,7 +26,7 @@ namespace DepartmentContract.ViewModels public Guid DisciplineId { get; set; } [ViewModelControlListProperty("Дисциплина")] - [MapConfiguration("Discipline.ToString", IsDifficle = true)] + [MapConfiguration("Discipline.ToString")] public string DisciplineName { get; set; } [ViewModelControlElementProperty("Преподается на кафедре", ControlType.ControlBool, MustHaveValue = true)] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs index b4972a7..3573967 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/AcademicPlanViewModels.cs @@ -22,11 +22,11 @@ namespace DepartmentContract.ViewModels public Guid? EducationDirectionId { get; set; } [ViewModelControlListProperty("Направление")] - [MapConfiguration("EducationDirection.Cipher", IsDifficle = true)] + [MapConfiguration("EducationDirection.Cipher")] public string EducationDirectionCipher { get; set; } [ViewModelControlListProperty("Профиль")] - [MapConfiguration("EducationDirection.Profile", IsDifficle = true)] + [MapConfiguration("EducationDirection.Profile")] public string EducationDirectionProfile { get; set; } [ViewModelControlListProperty("Дата начала", ColumnWidth = 120)] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/ClassroomViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/ClassroomViewModels.cs index 0dd0bfd..30212e2 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/ClassroomViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/ClassroomViewModels.cs @@ -29,7 +29,7 @@ namespace DepartmentContract.ViewModels public Guid EmployeeId { get; set; } [ViewModelControlListProperty("Сотрудник")] - [MapConfiguration("Employee.LastName", IsDifficle = true)] + [MapConfiguration("Employee.LastName")] public string EmployeeName { get; set; } [ViewModelControlElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/EducationDirectionViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/EducationDirectionViewModels.cs index c3d691e..8fc0b62 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/EducationDirectionViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/EducationDirectionViewModels.cs @@ -41,7 +41,7 @@ namespace DepartmentContract.ViewModels public Guid LecturerId { get; set; } [ViewModelControlListProperty("Руководитель ОПОП", ColumnWidth = 120)] - [MapConfiguration("Lecturer.LastName", IsDifficle = true)] + [MapConfiguration("Lecturer.LastName")] public string LecturerName { get; set; } [ViewModelControlElementProperty("Уровень обучения", ControlType.ControlEnum, MustHaveValue = true)] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/EmployeePostViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/EmployeePostViewModels.cs index 2324670..96e8bb4 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/EmployeePostViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/EmployeePostViewModels.cs @@ -20,14 +20,14 @@ namespace DepartmentContract.ViewModels public Guid EmployeeId { get; set; } [ViewModelControlListProperty("Сотрудник")] - [MapConfiguration("Employee.ToString", IsDifficle = true)] + [MapConfiguration("Employee.ToString")] public string EmployeeName { get; set; } [ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlPostList, DepartmentWindowsDesktop")] public Guid PostId { get; set; } [ViewModelControlListProperty("Должность")] - [MapConfiguration("Post.ToString", IsDifficle = true)] + [MapConfiguration("Post.ToString")] public string PostName { get; set; } [ViewModelControlListProperty("Ставка", ColumnWidth = 80, DefaultCellStyleFormat = "N1")] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/LecturerPostViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/LecturerPostViewModels.cs index b96b0a7..a015857 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/LecturerPostViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/LecturerPostViewModels.cs @@ -20,14 +20,14 @@ namespace DepartmentContract.ViewModels public Guid LecturerId { get; set; } [ViewModelControlListProperty("Преподаватель")] - [MapConfiguration("Lecturer.ToString", IsDifficle = true)] + [MapConfiguration("Lecturer.ToString")] public string LecturerName { get; set; } [ViewModelControlElementProperty("Должность", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlPostList, DepartmentWindowsDesktop")] public Guid PostId { get; set; } [ViewModelControlListProperty("Должность")] - [MapConfiguration("Post.ToString", IsDifficle = true)] + [MapConfiguration("Post.ToString")] public string PostName { get; set; } [ViewModelControlListProperty("Ставка", ColumnWidth = 80, DefaultCellStyleFormat = "N1")] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/LecturerViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/LecturerViewModels.cs index 39b35c8..a5d36ad 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/LecturerViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/LecturerViewModels.cs @@ -29,14 +29,14 @@ namespace DepartmentContract.ViewModels public Guid? LecturerAcademicDegreeId { get; set; } [ViewModelControlListProperty("Уч. степень")] - [MapConfiguration("LecturerAcademicDegree.LecturerAcademicDegreeName", IsDifficle = true)] + [MapConfiguration("LecturerAcademicDegree.LecturerAcademicDegreeName")] public string LecturerAcademicDegree { get; set; } [ViewModelControlElementProperty("Уч. звание", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerAcademicRankList, DepartmentWindowsDesktop")] public Guid? LecturerAcademicRankId { get; set; } [ViewModelControlListProperty("Уч. звание")] - [MapConfiguration("LecturerAcademicRank.LecturerAcademicRankName", IsDifficle = true)] + [MapConfiguration("LecturerAcademicRank.LecturerAcademicRankName")] public string LecturerAcademicRank { get; set; } [ViewModelControlListProperty("Фамилия")] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/OrderSyncHistoryRecordViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/OrderSyncHistoryRecordViewModels.cs index 5628e69..9463955 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/OrderSyncHistoryRecordViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/OrderSyncHistoryRecordViewModels.cs @@ -20,7 +20,7 @@ namespace DepartmentContract.ViewModels public Guid OrderSyncHistoryId { get; set; } [ViewModelControlListProperty("Дата", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")] - [MapConfiguration("OrderSyncHistory.SyncDate", IsDifficle = true)] + [MapConfiguration("OrderSyncHistory.SyncDate")] public DateTime SyncDate { get; set; } [ViewModelControlListProperty("Описание")] diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentGroupViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentGroupViewModels.cs index 0b7778a..669ae5f 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentGroupViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentGroupViewModels.cs @@ -23,14 +23,14 @@ namespace DepartmentContract.ViewModels public Guid EducationDirectionId { get; set; } [ViewModelControlListProperty("Шифр", ColumnWidth = 80)] - [MapConfiguration("EducationDirection.Cipher", IsDifficle = true)] + [MapConfiguration("EducationDirection.Cipher")] public string EducationDirectionCipher { get; set; } [ViewModelControlListProperty("Профиль")] - [MapConfiguration("EducationDirection.Profile", IsDifficle = true)] + [MapConfiguration("EducationDirection.Profile")] public string EducationDirectionProfile { get; set; } - [MapConfiguration("EducationDirection.ShortName", IsDifficle = true)] + [MapConfiguration("EducationDirection.ShortName")] public string EducationDirectionShortName { get; set; } [ViewModelControlListProperty("Группа")] @@ -46,10 +46,10 @@ namespace DepartmentContract.ViewModels [ViewModelControlElementProperty("Номер группы", ControlType.ControlInt, MustHaveValue = true, MinValue = 0, MaxValue = 4)] public int GroupNumber { get; set; } - [MapConfiguration("Method.GetStudnetsByState[Enum:Учится]", IsDifficle = true, MethodParams = new Type[] { typeof(StudentState) })] + [MapConfiguration("Method.GetStudnetsByState[Enum:Учится]", MethodParams = new Type[] { typeof(StudentState) })] public int StudentActualCount { get; set; } - [MapConfiguration("Method.GetStudnetsByState[Enum:Академ]", IsDifficle = true, MethodParams = new Type[] { typeof(StudentState) })] + [MapConfiguration("Method.GetStudnetsByState[Enum:Академ]", MethodParams = new Type[] { typeof(StudentState) })] public int StudentAcademCount { get; set; } [ViewModelControlListProperty("Количество студентов")] @@ -59,7 +59,7 @@ namespace DepartmentContract.ViewModels public Guid? LecturerId { get; set; } [ViewModelControlListProperty("Куратор")] - [MapConfiguration("Lecturer.ToString", IsDifficle = true)] + [MapConfiguration("Lecturer.ToString")] public string Lecturer { get; set; } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs index 8482b74..ca77c0a 100644 --- a/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs +++ b/DepartmentPortal/Department/DepartmentContract/ViewModels/StudentViewModels.cs @@ -25,7 +25,7 @@ namespace DepartmentContract.ViewModels [ViewModelControlElementProperty("Группа", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlStudentGroupList, DepartmentWindowsDesktop")] public Guid? StudentGroupId { get; set; } - [MapConfiguration("StudentGroup.ToString", IsDifficle = true)] + [MapConfiguration("StudentGroup.ToString")] public string StudentGroupName { get; set; } [ViewModelControlElementProperty("Идентификатор универа", ControlType.ControlString, MustHaveValue = true, ReadOnly = true)] diff --git a/DepartmentPortal/Security/SecurityContract/ViewModels/AccessViewModels.cs b/DepartmentPortal/Security/SecurityContract/ViewModels/AccessViewModels.cs index ce117b9..81451d9 100644 --- a/DepartmentPortal/Security/SecurityContract/ViewModels/AccessViewModels.cs +++ b/DepartmentPortal/Security/SecurityContract/ViewModels/AccessViewModels.cs @@ -21,7 +21,7 @@ namespace SecurityContract.ViewModels public Guid RoleId { get; set; } [ViewModelControlListProperty("Роль", ColumnWidth = 100)] - [MapConfiguration("Role.ToString", IsDifficle = true, AllowCopyWithoutRigth = false)] + [MapConfiguration("Role.ToString", AllowCopyWithoutRigth = false)] public string RoleName { get; set; } [ViewModelControlElementProperty("Операция", ControlType.ControlEnum, MustHaveValue = true)] diff --git a/DepartmentPortal/Security/SecurityContract/ViewModels/UserRoleViewModels.cs b/DepartmentPortal/Security/SecurityContract/ViewModels/UserRoleViewModels.cs index 70dd412..8409ec6 100644 --- a/DepartmentPortal/Security/SecurityContract/ViewModels/UserRoleViewModels.cs +++ b/DepartmentPortal/Security/SecurityContract/ViewModels/UserRoleViewModels.cs @@ -20,14 +20,14 @@ namespace SecurityContract.ViewModels public Guid UserId { get; set; } [ViewModelControlListProperty("Пользователь")] - [MapConfiguration("User.ToString", IsDifficle = true, AllowCopyWithoutRigth = false)] + [MapConfiguration("User.ToString", AllowCopyWithoutRigth = false)] public string UserName { get; set; } [ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")] public Guid RoleId { get; set; } [ViewModelControlListProperty("Роль")] - [MapConfiguration("Role.ToString", IsDifficle = true, AllowCopyWithoutRigth = false)] + [MapConfiguration("Role.ToString", AllowCopyWithoutRigth = false)] public string RoleName { get; set; } } } \ No newline at end of file