diff --git a/LC_Api/LC_Api.csproj b/LC_Api/LC_Api.csproj
index 9f37b89..ad80c05 100644
--- a/LC_Api/LC_Api.csproj
+++ b/LC_Api/LC_Api.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/LC_Bot/LC_Bot.csproj b/LC_Bot/LC_Bot.csproj
index c03c026..ca708ac 100644
--- a/LC_Bot/LC_Bot.csproj
+++ b/LC_Bot/LC_Bot.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/Strela/Controllers/DeviceController.cs b/Strela/Controllers/DeviceController.cs
index 0002a8a..7ee0f1b 100644
--- a/Strela/Controllers/DeviceController.cs
+++ b/Strela/Controllers/DeviceController.cs
@@ -23,7 +23,7 @@ public class DeviceController : ControllerBase
[HttpGet("GetDeviceById")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
- public IActionResult GetById(int id) // Получить устройство по id
+ public IActionResult GetById(Guid id) // Получить устройство по id
{
using (var db = new SQLiteService())
{
@@ -69,7 +69,7 @@ public class DeviceController : ControllerBase
#region DELETE
[HttpDelete("DelDevice")]
- public IActionResult DelDevice(int id) //Удалить устройство по id
+ public IActionResult DelDevice(Guid id) //Удалить устройство по id
{
using (var db = new SQLiteService())
{
diff --git a/Strela/Controllers/ObjectController.cs b/Strela/Controllers/ObjectController.cs
index 5dd3343..3eb81cb 100644
--- a/Strela/Controllers/ObjectController.cs
+++ b/Strela/Controllers/ObjectController.cs
@@ -29,7 +29,7 @@ public class ObjectController : ControllerBase
[HttpGet("GetObjectById")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
- public IActionResult GetById(int id)
+ public IActionResult GetById(Guid id)
{
using (var db = new SQLiteService())
{
@@ -69,7 +69,7 @@ public class ObjectController : ControllerBase
//========================= DELETE ====================================//
[HttpDelete("DelObject")]
- public IActionResult DelObject(int id)
+ public IActionResult DelObject(Guid id)
{
using (var db = new SQLiteService())
{
diff --git a/Strela/Controllers/TypeController.cs b/Strela/Controllers/TypeController.cs
index 60edd38..f55afff 100644
--- a/Strela/Controllers/TypeController.cs
+++ b/Strela/Controllers/TypeController.cs
@@ -31,7 +31,7 @@ public class TypeController : ControllerBase
[HttpGet("GetTypeById")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
- public IActionResult GetById(int id) // Получить устройство по id
+ public IActionResult GetById(Guid id) // Получить устройство по id
{
using (var db = new SQLiteService())
{
@@ -63,7 +63,7 @@ public class TypeController : ControllerBase
//========================= DELETE ====================================//
#region DELETE
[HttpDelete("DelType")]
- public IActionResult DelType(int id) //Удалить тип устройства по id
+ public IActionResult DelType(Guid id) //Удалить тип устройства по id
{
using (var db = new SQLiteService())
{
diff --git a/Strela/Models/DeviceItem.cs b/Strela/Models/DeviceItem.cs
index 2c3dd65..3aaf15a 100644
--- a/Strela/Models/DeviceItem.cs
+++ b/Strela/Models/DeviceItem.cs
@@ -8,10 +8,10 @@
public string? Description { get; set; }
public string? Name { get; set; }
public string? Location { get; set; }
- public List? ListDevices { get; set; }
- public DeviceType? DeviceType { get; set; }
- public ObjectItem? DeviceObject { get; set; }
- public Guid ConnectedToSwitchId { get; set; }
+ public List? ListDevices { get; set; }
+ public Guid? DeviceType { get; set; }
+ public Guid? DeviceObject { get; set; }
+ public Guid? ConnectedToSwitchId { get; set; }
public int ConnectedToPortOnSwitch { get; set; }
}
diff --git a/Strela/Services/SQLiteService.cs b/Strela/Services/SQLiteService.cs
index 2c93df7..ae7718b 100644
--- a/Strela/Services/SQLiteService.cs
+++ b/Strela/Services/SQLiteService.cs
@@ -14,8 +14,8 @@ namespace Strela.Services
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
- //optionsBuilder.UseNpgsql("Host=172.24.12.201;Port=5432;Database=Notifications;Username=postgres;Password=4NUDZhJ7");
- optionsBuilder.UseSqlite("Data Source=Services/DataBase.db");
+ optionsBuilder.UseNpgsql("Host=172.22.10.39;Port=5432;Database=strela;Username=postgres;Password=4NUDZhJ7");
+ //optionsBuilder.UseSqlite("Data Source=Services/DataBase.db");
}
//protected override void OnModelCreating(ModelBuilder modelBuilder)
diff --git a/Strela/Strela.csproj b/Strela/Strela.csproj
index 373eb7f..586bc39 100644
--- a/Strela/Strela.csproj
+++ b/Strela/Strela.csproj
@@ -23,6 +23,7 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/Visor/Visor/Models/DeviceItems.cs b/Visor/Visor/Models/DeviceItems.cs
index abd3a45..70200ba 100644
--- a/Visor/Visor/Models/DeviceItems.cs
+++ b/Visor/Visor/Models/DeviceItems.cs
@@ -8,10 +8,10 @@
public string? Description { get; set; }
public string? Name { get; set; }
public string? Location { get; set; }
- public List? ListDevices { get; set; }
- public DeviceTypeItems? DeviceType { get; set; }
- public ObjectItems? DeviceObject { get; set; }
- public Guid ConnectedToSwitchId { get; set; }
+ public List? ListDevices { get; set; }
+ public Guid? DeviceType { get; set; }
+ public Guid? DeviceObject { get; set; }
+ public Guid? ConnectedToSwitchId { get; set; }
public int ConnectedToPortOnSwitch { get; set; }
}
diff --git a/Visor/Visor/Pages/Setting/Wizard.razor b/Visor/Visor/Pages/Setting/Wizard.razor
index d420bff..7e1eb26 100644
--- a/Visor/Visor/Pages/Setting/Wizard.razor
+++ b/Visor/Visor/Pages/Setting/Wizard.razor
@@ -44,6 +44,9 @@
+
@@ -142,7 +145,7 @@
IP
-
+
@@ -150,7 +153,7 @@
MAC
-
+
@@ -211,18 +214,18 @@
-
+ @*
-
+ *@
@@ -246,7 +249,6 @@
Имя
Адрес
- Тип
@@ -255,7 +257,6 @@
@item.Name
@item.Ip
- @item.DeviceType.Name
}
@@ -272,7 +273,7 @@
- ОБЪЕКТЫ
+ ОБЪЕКТЫ
Объектов к добавлению - @_list_obj.Count
@@ -372,13 +373,12 @@
return Task.FromResult(true);
}
- private void RefreshListSwitch()
- {
- _list_switch = _list_dev.Where(s => s.DeviceType.Name.Contains("Switch")).ToList();
- }
-
private async void AddNewObject()
{
+ if (obj_name == null)
+ {
+ return;
+ }
obj_item = new()
{
Id = Guid.NewGuid(),
@@ -391,6 +391,10 @@
}
private async void AddNewType()
{
+ if (type_name == null)
+ {
+ return;
+ }
type_item = new()
{
Id = Guid.NewGuid(),
@@ -403,6 +407,8 @@
}
private async void AddNewDev()
{
+ if (dev_ip == null || dev_mac == null || dev_name == null) return;
+
dev_item = new()
{
Id = Guid.NewGuid(),
@@ -411,12 +417,13 @@
Description = dev_desc,
Name = dev_name,
Location = dev_loc,
- DeviceType = _list_type.SingleOrDefault(t => t.Id == id_type),
- DeviceObject = _list_obj.SingleOrDefault(o => o.Id == id_obj),
+ ListDevices = null,
+ DeviceType = _list_type.Single(t => t.Id == id_type).Id,
+ DeviceObject = _list_obj.Single(o => o.Id == id_obj).Id,
ConnectedToPortOnSwitch = num_port
};
_list_dev.Add(dev_item);
- if (dev_item.DeviceType.Name.Contains("Switch")) _list_switch.Add(dev_item);
+ if (list_type.First(d => d.Id == dev_item.DeviceType).Name.Contains("Switch")) _list_switch.Add(dev_item);
dev_ip = string.Empty;
dev_mac = string.Empty;
dev_desc = string.Empty;
@@ -426,41 +433,63 @@
private async void clickSave()
{
- if (nextButton == "Далее") stepsRef.NextStep();
+ if (nextButton == "Далее") await stepsRef.NextStep();
else
{
visibleProgress = Visibility.Visible;
- foreach (var item in _list_obj)
+ try
{
- var p = await AllPubData.http.PostAsJsonAsync("api/Object/AddObject", item);
- if (!p.IsSuccessStatusCode)
+ foreach (var item in _list_obj)
{
- error_group = "ОБЪЕКТ";
- error_msg = $"{item.NameObject} не добавлено.\r\nСтатус код: {p.StatusCode}";
- toastError = true;
+ var p = await AllPubData.http.PostAsJsonAsync("api/Object/AddObject", item);
+ if (!p.IsSuccessStatusCode)
+ {
+ error_group = "ОБЪЕКТ";
+ error_msg = $"{item.NameObject} не добавлено.\r\nСтатус код: {p.StatusCode}";
+ toastError = true;
+ //await Task.Delay(500);
+ }
+ }
+ foreach (var item in _list_type)
+ {
+ var p = await AllPubData.http.PostAsJsonAsync("api/Type/AddType", item);
+ if (!p.IsSuccessStatusCode)
+ {
+ error_group = "ТИП";
+ error_msg = $"{item.Name} не добавлено.\r\nСтатус код: {p.StatusCode}";
+ toastError = true;
+ //await Task.Delay(500);
+ }
+ }
+ foreach (var item in _list_dev)
+ {
+ var p = await AllPubData.http.PostAsJsonAsync("api/Device/AddDevice", item);
+ if (!p.IsSuccessStatusCode)
+ {
+ error_group = "УСТРОЙСТВА";
+ error_msg = $"{item.Name} не добавлено.\r\nСтатус код: {p.StatusCode}";
+ toastError = true;
+ //await Task.Delay(500);
+ }
}
}
- foreach (var item in _list_type)
+ catch (Exception)
{
- var p = await AllPubData.http.PostAsJsonAsync("api/Type/AddType", item);
- if (!p.IsSuccessStatusCode)
- {
- error_group = "ТИП";
- error_msg = $"{item.Name} не добавлено.\r\nСтатус код: {p.StatusCode}";
- toastError = true;
- }
+ error_group = "ПРОЦЕСС";
+ error_msg = $"Во время добавления произошел сбой.";
+ toastError = true;
}
- foreach (var item in _list_dev)
+ finally
{
- var p = await AllPubData.http.PostAsJsonAsync("api/Device/AddDevice", item);
- if (!p.IsSuccessStatusCode)
- {
- error_group = "УСТРОЙСТВА";
- error_msg = $"{item.Name} не добавлено.\r\nСтатус код: {p.StatusCode}";
- toastError = true;
- }
+ visibleProgress = Visibility.Invisible;
}
- visibleProgress = Visibility.Invisible;
}
}
+
+ private void GetCurrentObject()
+ {
+ _list_obj = AllPubData.ListObjectItems;
+ _list_type = AllPubData.ListDeviceTypeItems;
+ _list_dev = AllPubData.ListDeviceItems;
+ }
}
diff --git a/lsSoft.slnx b/lsSoft.slnx
index 3d55c97..1e5299a 100644
--- a/lsSoft.slnx
+++ b/lsSoft.slnx
@@ -29,6 +29,5 @@
-