переименование классов + перенос 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
{
partial class ControlViewEntityList
partial class BaseControlViewEntityList
{
/// <summary>
/// Обязательная переменная конструктора.

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ namespace ModuleTools.Interfaces
/// <summary>
/// Описание логики для хранилища сущности
/// </summary>
public interface IEntityService<G, S>
public interface IGenerticEntityService<G, S>
where G : GetBindingModel
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
{
@ -53,7 +53,7 @@ namespace DesktopTools.Forms
this.dataGridViewErrors.RowHeadersVisible = false;
this.dataGridViewErrors.RowTemplate.Height = 25;
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;
//
// ColumnKey
@ -74,10 +74,10 @@ namespace DesktopTools.Forms
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
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.Name = "FormDisplayErrors";
this.Text = "Ошибки";
this.Text = "FormDisplayErrors";
((System.ComponentModel.ISupportInitialize)(this.dataGridViewErrors)).EndInit();
this.ResumeLayout(false);

View File

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Windows.Forms;
namespace DesktopTools.Forms
namespace DepartmentPortalDesctop
{
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.Interfaces;
using System;

View File

@ -9,15 +9,15 @@ namespace DepartmentPortalDesctop
{
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()
{
InitializeComponent();
_baseControls = new Dictionary<Guid, ControlViewEntityList>();
_controls = new Dictionary<Guid, ControlViewEntityList>();
_baseControls = new Dictionary<Guid, BaseControlViewEntityList>();
_controls = new Dictionary<Guid, BaseControlViewEntityList>();
var extensions = DesktopLoader.GetWindowDesktopExtensions();
foreach (var extens in extensions)
@ -28,7 +28,7 @@ namespace DepartmentPortalDesctop
var menu = new ToolStripMenuItem { Text = list[0].Title };
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))
{

View File

@ -9,7 +9,7 @@ namespace SecurityBusinessLogic.BusinessLogics
/// <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.Доступы) { }
}

View File

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

View File

@ -9,7 +9,7 @@ namespace SecurityBusinessLogic.BusinessLogics
/// <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.Роли) { }
}

View File

@ -9,7 +9,7 @@ namespace SecurityBusinessLogic.BusinessLogics
/// <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.Пользователи) { }
}

View File

@ -6,5 +6,5 @@ namespace SecurityBusinessLogic.Interfaces
/// <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>
public interface IEnviromentSettingService : IEntityService<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel> { }
public interface IEnviromentSettingService : IGenerticEntityService<EnviromentSettingGetBindingModel, EnviromentSettingSetBindingModel> { }
}

View File

@ -6,5 +6,5 @@ namespace SecurityBusinessLogic.Interfaces
/// <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>
public interface IUserService : IEntityService<UserGetBindingModel, UserSetBindingModel> { }
public interface IUserService : IGenerticEntityService<UserGetBindingModel, UserSetBindingModel> { }
}

View File

@ -11,7 +11,7 @@ using System.Linq;
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;
@ -25,7 +25,7 @@ namespace SecurityWindowsDesktop.Controls
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()
{

View File

@ -9,7 +9,7 @@ using System;
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()
{
@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls
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()
{

View File

@ -9,7 +9,7 @@ using System;
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()
{
@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls
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()
{

View File

@ -9,7 +9,7 @@ using System;
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()
{
@ -20,7 +20,7 @@ namespace SecurityWindowsDesktop.Controls
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()
{

View File

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