diff --git a/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs b/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs
index e31ad93..8380231 100644
--- a/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs
+++ b/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs
@@ -3,7 +3,10 @@ using ModelTools.Enums;
using ModelTools.Interfaces;
using ModelTools.Models;
using SecurityBusinessLogic.BusinessLogics;
+using System;
using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
namespace DatabaseCore
{
@@ -60,5 +63,63 @@ namespace DatabaseCore
return false;
}
}
+
+ public void CheckStartDataSource()
+ {
+ using var context = DatabaseManager.GetContext;
+ using var transaction = context.Database.BeginTransaction();
+ var role = context.Roles.FirstOrDefault(x => x.RoleName == "Администратор");
+ if (role == null)
+ {
+ role = new Role
+ {
+ RoleName = "Администратор",
+ RolePriority = 100
+ };
+ context.Roles.Add(role);
+ context.SaveChanges();
+ }
+
+ var accesses = context.Accesses.Where(x => x.RoleId == role.Id);
+ foreach (AccessOperation operation in Enum.GetValues(typeof(AccessOperation)))
+ {
+ if (!accesses.Any(x => x.AccessOperation == operation && x.AccessType == AccessType.Delete))
+ {
+ context.Accesses.Add(new Access
+ {
+ AccessOperation = operation,
+ AccessType = AccessType.Delete,
+ RoleId = role.Id
+ });
+ }
+ }
+ context.SaveChanges();
+
+ var md5 = new MD5CryptoServiceProvider();
+ var user = context.Users.FirstOrDefault(x => x.UserName == "admin");
+ if (user == null)
+ {
+ user = new User
+ {
+ UserName = "admin",
+ PasswordHash = Encoding.ASCII.GetString(md5.ComputeHash(Encoding.ASCII.GetBytes("qwerty"))),
+ CountAttempt = 0
+ };
+ context.Users.Add(user);
+ context.SaveChanges();
+ }
+ var link = context.UserRoles.FirstOrDefault(x => x.RoleId == role.Id && x.UserId == user.Id);
+ if (link == null)
+ {
+ context.UserRoles.Add(new UserRole
+ {
+ RoleId = role.Id,
+ UserId = user.Id
+ });
+ context.SaveChanges();
+ }
+
+ transaction.Commit();
+ }
}
}
\ No newline at end of file
diff --git a/DepartmentPortal/Common/ModelTools/Enums/AccessType.cs b/DepartmentPortal/Common/ModelTools/Enums/AccessType.cs
index 6482bbe..6dc2a14 100644
--- a/DepartmentPortal/Common/ModelTools/Enums/AccessType.cs
+++ b/DepartmentPortal/Common/ModelTools/Enums/AccessType.cs
@@ -8,27 +8,21 @@
///
/// Простой просомтр
///
- SimpleView = 0,
+ SimpleView = 1,
///
/// Полный просомтр
///
- FullView = 1,
+ FullView = 2,
///
/// Добавление/Изменение
///
- Change = 2,
+ Change = 4,
///
/// Удаление
///
- Delete = 4,
-
- // TODO убрать
- ///
- /// Доступ к меню
- ///
- Menu = 8
+ Delete = 8
}
}
\ No newline at end of file
diff --git a/DepartmentPortal/Common/ModelTools/Interfaces/ISecurityManager.cs b/DepartmentPortal/Common/ModelTools/Interfaces/ISecurityManager.cs
index cce0ac4..60d5726 100644
--- a/DepartmentPortal/Common/ModelTools/Interfaces/ISecurityManager.cs
+++ b/DepartmentPortal/Common/ModelTools/Interfaces/ISecurityManager.cs
@@ -15,5 +15,10 @@ namespace ModelTools.Interfaces
/// Данные по операции
///
bool CheckAccess(SecurityManagerCheckAccessModel model);
+
+ ///
+ /// Проверка наличия старотвых данных для работы с ситемой
+ ///
+ void CheckStartDataSource();
}
}
\ No newline at end of file
diff --git a/DepartmentPortal/DepartmentPortalDesctop/Program.cs b/DepartmentPortal/DepartmentPortalDesctop/Program.cs
index 7a80e1d..1f9d016 100644
--- a/DepartmentPortal/DepartmentPortalDesctop/Program.cs
+++ b/DepartmentPortal/DepartmentPortalDesctop/Program.cs
@@ -1,5 +1,4 @@
using DatabaseCore;
-using DesktopTools.Controls;
using ModelTools.BusinessLogics;
using ModelTools.Interfaces;
using SecurityBusinessLogic.BusinessLogics;
@@ -19,6 +18,9 @@ namespace DepartmentPortalDesctop
UnityContainerConfigurator.PublishService();
UnityContainerConfigurator.InitServices();
+ var securityManager = UnityContainerConfigurator.Resolve();
+ securityManager.CheckStartDataSource();
+
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
diff --git a/DepartmentPortal/ImplementationExtensions/net5.0/DatabaseCore.dll b/DepartmentPortal/ImplementationExtensions/net5.0/DatabaseCore.dll
index 5dd1257..d5e5315 100644
Binary files a/DepartmentPortal/ImplementationExtensions/net5.0/DatabaseCore.dll and b/DepartmentPortal/ImplementationExtensions/net5.0/DatabaseCore.dll differ
diff --git a/DepartmentPortal/ImplementationExtensions/net5.0/ModelTools.dll b/DepartmentPortal/ImplementationExtensions/net5.0/ModelTools.dll
index aeed428..78f408e 100644
Binary files a/DepartmentPortal/ImplementationExtensions/net5.0/ModelTools.dll and b/DepartmentPortal/ImplementationExtensions/net5.0/ModelTools.dll differ
diff --git a/DepartmentPortal/ImplementationExtensions/net5.0/SecurityBusinessLogic.dll b/DepartmentPortal/ImplementationExtensions/net5.0/SecurityBusinessLogic.dll
index e65d9c8..469e9d4 100644
Binary files a/DepartmentPortal/ImplementationExtensions/net5.0/SecurityBusinessLogic.dll and b/DepartmentPortal/ImplementationExtensions/net5.0/SecurityBusinessLogic.dll differ
diff --git a/DepartmentPortal/ImplementationExtensions/net5.0/SecurityImplementation.dll b/DepartmentPortal/ImplementationExtensions/net5.0/SecurityImplementation.dll
index 515f3eb..c87212d 100644
Binary files a/DepartmentPortal/ImplementationExtensions/net5.0/SecurityImplementation.dll and b/DepartmentPortal/ImplementationExtensions/net5.0/SecurityImplementation.dll differ
diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs
index 5289215..db2d128 100644
--- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs
+++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs
@@ -32,7 +32,25 @@ namespace SecurityBusinessLogic.ViewModels
public AccessType AccessType { get; set; }
[ViewModelOnListProperty("Тип", 150)]
- public string AccessTypeTitle => AccessType.ToString("G");
+ public string AccessTypeTitle
+ {
+ get
+ {
+ switch (AccessType)
+ {
+ case AccessType.Delete:
+ return "Полные права";
+ case AccessType.Change:
+ return "Просмотр, Редактирование";
+ case AccessType.FullView:
+ return "Просмотр";
+ case AccessType.SimpleView:
+ return "Частичный просмотр";
+ default:
+ return "Неопределено";
+ }
+ }
+ }
public override string ToString() => $"{RoleName}-{AccessOperationTitle}({AccessTypeTitle})";
}
diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs
index 912ac96..e74d6f8 100644
--- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs
+++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/EnviromentSettingViewModels.cs
@@ -17,9 +17,9 @@ namespace SecurityBusinessLogic.ViewModels
[MapConfiguration("Key")]
public string Key { get; set; }
- [ViewModelOnListProperty("Значение", 100)]
+ [ViewModelOnListProperty("Значение")]
[MapConfiguration("Value")]
- public int Value { get; set; }
+ public string Value { get; set; }
public override string ToString() => Key;
}
diff --git a/DepartmentPortal/WindowDestopExtensions/net5.0-windows/DesktopTools.dll b/DepartmentPortal/WindowDestopExtensions/net5.0-windows/DesktopTools.dll
index 3b55ff0..64a76a6 100644
Binary files a/DepartmentPortal/WindowDestopExtensions/net5.0-windows/DesktopTools.dll and b/DepartmentPortal/WindowDestopExtensions/net5.0-windows/DesktopTools.dll differ
diff --git a/DepartmentPortal/WindowDestopExtensions/net5.0-windows/ModelTools.dll b/DepartmentPortal/WindowDestopExtensions/net5.0-windows/ModelTools.dll
index aeed428..78f408e 100644
Binary files a/DepartmentPortal/WindowDestopExtensions/net5.0-windows/ModelTools.dll and b/DepartmentPortal/WindowDestopExtensions/net5.0-windows/ModelTools.dll differ
diff --git a/DepartmentPortal/WindowDestopExtensions/net5.0-windows/SecurityBusinessLogic.dll b/DepartmentPortal/WindowDestopExtensions/net5.0-windows/SecurityBusinessLogic.dll
index e65d9c8..469e9d4 100644
Binary files a/DepartmentPortal/WindowDestopExtensions/net5.0-windows/SecurityBusinessLogic.dll and b/DepartmentPortal/WindowDestopExtensions/net5.0-windows/SecurityBusinessLogic.dll differ
diff --git a/DepartmentPortal/WindowDestopExtensions/net5.0-windows/SecurityWindowsDesktop.dll b/DepartmentPortal/WindowDestopExtensions/net5.0-windows/SecurityWindowsDesktop.dll
index 58b2dd7..e88a3dd 100644
Binary files a/DepartmentPortal/WindowDestopExtensions/net5.0-windows/SecurityWindowsDesktop.dll and b/DepartmentPortal/WindowDestopExtensions/net5.0-windows/SecurityWindowsDesktop.dll differ