переименование классов + перенос errormessanger

This commit is contained in:
kotcheshir73 2021-03-29 12:13:47 +04:00
parent fa5b3abe82
commit 9325f592e1
29 changed files with 70 additions and 72 deletions

View File

@ -1,30 +0,0 @@
using DesktopTools.Forms;
using System.Collections.Generic;
using System.Windows.Forms;
namespace DesktopTools.BusinessLogics
{
/// <summary>
/// Класс, отвечающий за вывод сообщения с ошибками
/// </summary>
public static class ErrorMessanger
{
/// <summary>
/// Вывод сообщения
/// </summary>
/// <param name="text"></param>
/// <param name="result"></param>
public static void PrintErrorMessage(string text, List<KeyValuePair<string, string>> result)
{
if (result.Count == 1)
{
MessageBox.Show(result[0].Value, result[0].Key, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
FormDisplayErrors form = new FormDisplayErrors();
form.LoadData(text, result);
}
}
}
}

View File

@ -1,7 +1,7 @@
 
namespace DesktopTools.Controls namespace DesktopTools.Controls
{ {
partial class ControlViewEntityList partial class BaseControlViewEntityList
{ {
/// <summary> /// <summary>
/// Обязательная переменная конструктора. /// Обязательная переменная конструктора.

View File

@ -4,7 +4,7 @@ using System.Windows.Forms;
namespace DesktopTools.Controls namespace DesktopTools.Controls
{ {
public partial class ControlViewEntityList : UserControl public partial class BaseControlViewEntityList : UserControl
{ {
/// <summary> /// <summary>
/// Событие, вызываемое при закрытии контрола /// Событие, вызываемое при закрытии контрола
@ -34,7 +34,7 @@ namespace DesktopTools.Controls
/// Дубликат контрола /// Дубликат контрола
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public virtual ControlViewEntityList Clone() { return null; } public virtual BaseControlViewEntityList Clone() { return null; }
/// <summary> /// <summary>
/// Идентификатор контрола /// Идентификатор контрола
@ -60,7 +60,7 @@ namespace DesktopTools.Controls
/// <summary> /// <summary>
/// Констркутор /// Констркутор
/// </summary> /// </summary>
public ControlViewEntityList() public BaseControlViewEntityList()
{ {
InitializeComponent(); InitializeComponent();
} }

View File

@ -1,6 +1,6 @@
namespace DesktopTools.Controls namespace DesktopTools.Controls
{ {
partial class AbstractGenerticControlEntityList<G, S, L, E, BL> partial class GenericControlEntityList<G, S, L, E, BL>
{ {
/// <summary> /// <summary>
/// Освободить все используемые ресурсы. /// Освободить все используемые ресурсы.

View File

@ -11,12 +11,12 @@ using System.Windows.Forms;
namespace DesktopTools.Controls namespace DesktopTools.Controls
{ {
public partial class AbstractGenerticControlEntityList<G, S, L, E, BL> : ControlViewEntityList public partial class GenericControlEntityList<G, S, L, E, BL> : BaseControlViewEntityList
where G : GetBindingModel where G : GetBindingModel
where S : SetBindingModel where S : SetBindingModel
where L: ListViewModel<E> where L: ListViewModel<E>
where E : ElementViewModel where E : ElementViewModel
where BL : BusinessLogicCore<G, S, L, E> where BL : GenericBusinessLogic<G, S, L, E>
{ {
/// <summary> /// <summary>
/// Объект бизнес-логики для получения данных /// Объект бизнес-логики для получения данных
@ -26,7 +26,7 @@ namespace DesktopTools.Controls
/// <summary> /// <summary>
/// Констркутор /// Констркутор
/// </summary> /// </summary>
public AbstractGenerticControlEntityList() public GenericControlEntityList()
{ {
InitializeComponent(); InitializeComponent();
InitEvents(); InitEvents();

View File

@ -11,6 +11,6 @@ namespace DesktopTools.Models
public string Title { get; set; } public string Title { get; set; }
public ControlViewEntityList Control { get; set; } public BaseControlViewEntityList Control { get; set; }
} }
} }

View File

@ -15,7 +15,7 @@ namespace ModuleTools.BusinessLogics
/// <typeparam name="S"></typeparam> /// <typeparam name="S"></typeparam>
/// <typeparam name="L"></typeparam> /// <typeparam name="L"></typeparam>
/// <typeparam name="E"></typeparam> /// <typeparam name="E"></typeparam>
public class BusinessLogicCore<G, S, L, E> public class GenericBusinessLogic<G, S, L, E>
where G : GetBindingModel where G : GetBindingModel
where S : SetBindingModel where S : SetBindingModel
where L : ListViewModel<E> where L : ListViewModel<E>
@ -29,7 +29,7 @@ namespace ModuleTools.BusinessLogics
/// <summary> /// <summary>
/// Сервис с хранилищем данных /// Сервис с хранилищем данных
/// </summary> /// </summary>
protected IEntityService<G, S> Service { get; set; } protected IGenerticEntityService<G, S> Service { get; set; }
/// <summary> /// <summary>
/// Менеджер безопасности /// Менеджер безопасности
@ -51,7 +51,7 @@ namespace ModuleTools.BusinessLogics
/// </summary> /// </summary>
protected bool _allowSimpleView = true; protected bool _allowSimpleView = true;
public BusinessLogicCore(IEntityService<G, S> service, string entity, AccessOperation serviceOperation) public GenericBusinessLogic(IGenerticEntityService<G, S> service, string entity, AccessOperation serviceOperation)
{ {
Service = service; Service = service;
Errors = new List<(string Title, string Message)>(); Errors = new List<(string Title, string Message)>();

View File

@ -6,7 +6,7 @@ namespace ModuleTools.Interfaces
/// <summary> /// <summary>
/// Описание логики для хранилища сущности /// Описание логики для хранилища сущности
/// </summary> /// </summary>
public interface IEntityService<G, S> public interface IGenerticEntityService<G, S>
where G : GetBindingModel where G : GetBindingModel
where S : SetBindingModel where S : SetBindingModel
{ {

View File

@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.Windows.Forms;
namespace DepartmentPortalDesctop
{
/// <summary>
/// Класс, отвечающий за вывод сообщения с ошибками
/// </summary>
public static class ErrorMessanger
{
/// <summary>
/// Вывод сообщения
/// </summary>
/// <param name="text"></param>
/// <param name="result"></param>
public static void PrintErrorMessage(string text, List<KeyValuePair<string, string>> result)
{
if (result.Count == 1)
{
MessageBox.Show(result[0].Value, result[0].Key, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
FormDisplayErrors form = new FormDisplayErrors();
form.LoadData(text, result);
}
}
}
}

View File

@ -1,5 +1,5 @@
 
namespace DesktopTools.Forms namespace DepartmentPortalDesctop
{ {
partial class FormDisplayErrors partial class FormDisplayErrors
{ {
@ -53,7 +53,7 @@ namespace DesktopTools.Forms
this.dataGridViewErrors.RowHeadersVisible = false; this.dataGridViewErrors.RowHeadersVisible = false;
this.dataGridViewErrors.RowTemplate.Height = 25; this.dataGridViewErrors.RowTemplate.Height = 25;
this.dataGridViewErrors.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridViewErrors.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridViewErrors.Size = new System.Drawing.Size(588, 450); this.dataGridViewErrors.Size = new System.Drawing.Size(671, 450);
this.dataGridViewErrors.TabIndex = 0; this.dataGridViewErrors.TabIndex = 0;
// //
// ColumnKey // ColumnKey
@ -74,10 +74,10 @@ namespace DesktopTools.Forms
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(588, 450); this.ClientSize = new System.Drawing.Size(671, 450);
this.Controls.Add(this.dataGridViewErrors); this.Controls.Add(this.dataGridViewErrors);
this.Name = "FormDisplayErrors"; this.Name = "FormDisplayErrors";
this.Text = "Ошибки"; this.Text = "FormDisplayErrors";
((System.ComponentModel.ISupportInitialize)(this.dataGridViewErrors)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridViewErrors)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);

View File

@ -1,7 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
namespace DesktopTools.Forms namespace DepartmentPortalDesctop
{ {
public partial class FormDisplayErrors : Form public partial class FormDisplayErrors : Form
{ {

View File

@ -1,5 +1,4 @@
using DesktopTools.BusinessLogics; using ModuleTools.BusinessLogics;
using ModuleTools.BusinessLogics;
using ModuleTools.Extensions; using ModuleTools.Extensions;
using ModuleTools.Interfaces; using ModuleTools.Interfaces;
using System; using System;

View File

@ -9,15 +9,15 @@ namespace DepartmentPortalDesctop
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
private readonly Dictionary<Guid, ControlViewEntityList> _baseControls; private readonly Dictionary<Guid, BaseControlViewEntityList> _baseControls;
private readonly Dictionary<Guid, ControlViewEntityList> _controls; private readonly Dictionary<Guid, BaseControlViewEntityList> _controls;
public FormMain() public FormMain()
{ {
InitializeComponent(); InitializeComponent();
_baseControls = new Dictionary<Guid, ControlViewEntityList>(); _baseControls = new Dictionary<Guid, BaseControlViewEntityList>();
_controls = new Dictionary<Guid, ControlViewEntityList>(); _controls = new Dictionary<Guid, BaseControlViewEntityList>();
var extensions = DesktopLoader.GetWindowDesktopExtensions(); var extensions = DesktopLoader.GetWindowDesktopExtensions();
foreach (var extens in extensions) foreach (var extens in extensions)
@ -28,7 +28,7 @@ namespace DepartmentPortalDesctop
var menu = new ToolStripMenuItem { Text = list[0].Title }; var menu = new ToolStripMenuItem { Text = list[0].Title };
for (int i = 0; i < list.Count; i++) for (int i = 0; i < list.Count; i++)
{ {
if (list[i].Control is ControlViewEntityList control) if (list[i].Control is BaseControlViewEntityList control)
{ {
if (_baseControls.ContainsKey(list[i].Id)) if (_baseControls.ContainsKey(list[i].Id))
{ {

View File

@ -9,7 +9,7 @@ namespace SecurityBusinessLogic.BusinessLogics
/// <summary> /// <summary>
/// Логика работы с доступами /// Логика работы с доступами
/// </summary> /// </summary>
public class AccessBusinessLogic : BusinessLogicCore<AccessGetBindingModel, AccessSetBindingModel, AccessListViewModel, AccessViewModel> public class AccessBusinessLogic : GenericBusinessLogic<AccessGetBindingModel, AccessSetBindingModel, AccessListViewModel, AccessViewModel>
{ {
public AccessBusinessLogic(IAccessService service) : base(service, "Доступы", AccessOperation.Доступы) { } public AccessBusinessLogic(IAccessService service) : base(service, "Доступы", AccessOperation.Доступы) { }
} }

View File

@ -9,7 +9,7 @@ namespace SecurityBusinessLogic.BusinessLogics
/// <summary> /// <summary>
/// Логика работы с общими настройками системы /// Логика работы с общими настройками системы
/// </summary> /// </summary>
public class EnviromentSettingBusinessLogic : BusinessLogicCore<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel, public class EnviromentSettingBusinessLogic : GenericBusinessLogic<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel,
EnviromentSettingListViewModel, EnviromentSettingViewModel> EnviromentSettingListViewModel, EnviromentSettingViewModel>
{ {
public EnviromentSettingBusinessLogic(IEnviromentSettingService service) : base(service, "Настройки Среды", AccessOperation.НастройкиСреды) { } public EnviromentSettingBusinessLogic(IEnviromentSettingService service) : base(service, "Настройки Среды", AccessOperation.НастройкиСреды) { }

View File

@ -9,7 +9,7 @@ namespace SecurityBusinessLogic.BusinessLogics
/// <summary> /// <summary>
/// Логика работы с ролями /// Логика работы с ролями
/// </summary> /// </summary>
public class RoleBusinessLogic : BusinessLogicCore<RoleGetBindingModel, RoleSetBindingModel, RoleListViewModel, RoleViewModel> public class RoleBusinessLogic : GenericBusinessLogic<RoleGetBindingModel, RoleSetBindingModel, RoleListViewModel, RoleViewModel>
{ {
public RoleBusinessLogic(IRoleService service) : base(service, "Роли", AccessOperation.Роли) { } public RoleBusinessLogic(IRoleService service) : base(service, "Роли", AccessOperation.Роли) { }
} }

View File

@ -9,7 +9,7 @@ namespace SecurityBusinessLogic.BusinessLogics
/// <summary> /// <summary>
/// Логика работы с пользователями /// Логика работы с пользователями
/// </summary> /// </summary>
public class UserBusinessLogic : BusinessLogicCore<UserGetBindingModel, UserSetBindingModel, UserListViewModel, UserViewModel> public class UserBusinessLogic : GenericBusinessLogic<UserGetBindingModel, UserSetBindingModel, UserListViewModel, UserViewModel>
{ {
public UserBusinessLogic(IUserService service) : base(service, "Пользователи", AccessOperation.Пользователи) { } public UserBusinessLogic(IUserService service) : base(service, "Пользователи", AccessOperation.Пользователи) { }
} }

View File

@ -6,5 +6,5 @@ namespace SecurityBusinessLogic.Interfaces
/// <summary> /// <summary>
/// Хранение доступов /// Хранение доступов
/// </summary> /// </summary>
public interface IAccessService : IEntityService<AccessGetBindingModel, AccessSetBindingModel> { } public interface IAccessService : IGenerticEntityService<AccessGetBindingModel, AccessSetBindingModel> { }
} }

View File

@ -6,5 +6,5 @@ namespace SecurityBusinessLogic.Interfaces
/// <summary> /// <summary>
/// Хранение общих настроек системы /// Хранение общих настроек системы
/// </summary> /// </summary>
public interface IEnviromentSettingService : IEntityService<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel> { } public interface IEnviromentSettingService : IGenerticEntityService<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel> { }
} }

View File

@ -6,5 +6,5 @@ namespace SecurityBusinessLogic.Interfaces
/// <summary> /// <summary>
/// Хранение ролей /// Хранение ролей
/// </summary> /// </summary>
public interface IRoleService : IEntityService<RoleGetBindingModel, RoleSetBindingModel> { } public interface IRoleService : IGenerticEntityService<RoleGetBindingModel, RoleSetBindingModel> { }
} }

View File

@ -6,5 +6,5 @@ namespace SecurityBusinessLogic.Interfaces
/// <summary> /// <summary>
/// Хранение пользователей /// Хранение пользователей
/// </summary> /// </summary>
public interface IUserService : IEntityService<UserGetBindingModel, UserSetBindingModel> { } public interface IUserService : IGenerticEntityService<UserGetBindingModel, UserSetBindingModel> { }
} }

View File

@ -11,7 +11,7 @@ using System.Linq;
namespace SecurityWindowsDesktop.Controls namespace SecurityWindowsDesktop.Controls
{ {
public partial class AccessesControl : AbstractGenerticControlEntityList<AccessGetBindingModel, AccessSetBindingModel, AccessListViewModel, AccessViewModel, AccessBusinessLogic> public partial class AccessesControl : GenericControlEntityList<AccessGetBindingModel, AccessSetBindingModel, AccessListViewModel, AccessViewModel, AccessBusinessLogic>
{ {
private readonly RoleBusinessLogic _roleBusinessLogic; private readonly RoleBusinessLogic _roleBusinessLogic;
@ -25,7 +25,7 @@ namespace SecurityWindowsDesktop.Controls
AccessOperation = AccessOperation.Доступы; AccessOperation = AccessOperation.Доступы;
} }
public override ControlViewEntityList Clone() => new AccessesControl() { Id = Guid.NewGuid() }; public override BaseControlViewEntityList Clone() => new AccessesControl() { Id = Guid.NewGuid() };
protected override ControlViewEntityListConfiguration GetConfig() => new() protected override ControlViewEntityListConfiguration GetConfig() => new()
{ {

View File

@ -9,7 +9,7 @@ using System;
namespace SecurityWindowsDesktop.Controls namespace SecurityWindowsDesktop.Controls
{ {
public partial class EnviromentSettingControl : AbstractGenerticControlEntityList<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel, EnviromentSettingListViewModel, EnviromentSettingViewModel, EnviromentSettingBusinessLogic> public partial class EnviromentSettingControl : GenericControlEntityList<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel, EnviromentSettingListViewModel, EnviromentSettingViewModel, EnviromentSettingBusinessLogic>
{ {
public EnviromentSettingControl() public EnviromentSettingControl()
{ {
@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls
AccessOperation = AccessOperation.НастройкиСреды; AccessOperation = AccessOperation.НастройкиСреды;
} }
public override ControlViewEntityList Clone() => new EnviromentSettingControl() { Id = Guid.NewGuid() }; public override BaseControlViewEntityList Clone() => new EnviromentSettingControl() { Id = Guid.NewGuid() };
protected override ControlViewEntityListConfiguration GetConfig() => new() protected override ControlViewEntityListConfiguration GetConfig() => new()
{ {

View File

@ -9,7 +9,7 @@ using System;
namespace SecurityWindowsDesktop.Controls namespace SecurityWindowsDesktop.Controls
{ {
public partial class RolesControl : AbstractGenerticControlEntityList<RoleGetBindingModel, RoleSetBindingModel, RoleListViewModel, RoleViewModel, RoleBusinessLogic> public partial class RolesControl : GenericControlEntityList<RoleGetBindingModel, RoleSetBindingModel, RoleListViewModel, RoleViewModel, RoleBusinessLogic>
{ {
public RolesControl() : base() public RolesControl() : base()
{ {
@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls
AccessOperation = AccessOperation.Роли; AccessOperation = AccessOperation.Роли;
} }
public override ControlViewEntityList Clone() => new RolesControl() { Id = Guid.NewGuid() }; public override BaseControlViewEntityList Clone() => new RolesControl() { Id = Guid.NewGuid() };
protected override ControlViewEntityListConfiguration GetConfig() => new() protected override ControlViewEntityListConfiguration GetConfig() => new()
{ {

View File

@ -9,7 +9,7 @@ using System;
namespace SecurityWindowsDesktop.Controls namespace SecurityWindowsDesktop.Controls
{ {
public partial class UsersControl : AbstractGenerticControlEntityList<UserGetBindingModel, UserSetBindingModel, UserListViewModel, UserViewModel, UserBusinessLogic> public partial class UsersControl : GenericControlEntityList<UserGetBindingModel, UserSetBindingModel, UserListViewModel, UserViewModel, UserBusinessLogic>
{ {
public UsersControl() : base() public UsersControl() : base()
{ {
@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls
AccessOperation = AccessOperation.Пользователи; AccessOperation = AccessOperation.Пользователи;
} }
public override ControlViewEntityList Clone() => new UsersControl() { Id = Guid.NewGuid() }; public override BaseControlViewEntityList Clone() => new UsersControl() { Id = Guid.NewGuid() };
protected override ControlViewEntityListConfiguration GetConfig() => new() protected override ControlViewEntityListConfiguration GetConfig() => new()
{ {

View File

@ -31,7 +31,7 @@ namespace SecurityWindowsDesktop
{ {
new WindowDesktopExtensionControlModel { Order = 0, Title = "Администрирование" } new WindowDesktopExtensionControlModel { Order = 0, Title = "Администрирование" }
}; };
List<ControlViewEntityList> _controls = new() List<BaseControlViewEntityList> _controls = new()
{ {
new UsersControl(), new UsersControl(),
new RolesControl(), new RolesControl(),