update
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using RobotApp.Common.Shares;
|
||||
using RobotApp.Common.Shares.Dtos;
|
||||
using RobotApp.Common.Shares.Enums;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Xml.Schema;
|
||||
|
||||
@@ -305,6 +306,33 @@ public partial class RobotConfigManager
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> SaveCertificates(Guid id)
|
||||
{
|
||||
using var content = new MultipartFormDataContent();
|
||||
|
||||
if (RobotVDA5050ConfigRef.CaFile is not null)
|
||||
{
|
||||
var fileContent = new StreamContent(RobotVDA5050ConfigRef.CaFile.OpenReadStream(maxAllowedSize: RobotVDA5050ConfigRef.MaxFileSize));
|
||||
content.Add(fileContent, "CaFile", RobotVDA5050ConfigRef.CaFile.Name);
|
||||
}
|
||||
if (RobotVDA5050ConfigRef.CertFile is not null)
|
||||
{
|
||||
var fileContent = new StreamContent(RobotVDA5050ConfigRef.CertFile.OpenReadStream(maxAllowedSize: RobotVDA5050ConfigRef.MaxFileSize));
|
||||
content.Add(fileContent, "CertFile", RobotVDA5050ConfigRef.CertFile.Name);
|
||||
}
|
||||
if (RobotVDA5050ConfigRef.KeyFile is not null)
|
||||
{
|
||||
var fileContent = new StreamContent(RobotVDA5050ConfigRef.KeyFile.OpenReadStream(maxAllowedSize: RobotVDA5050ConfigRef.MaxFileSize));
|
||||
content.Add(fileContent, "KeyFile", RobotVDA5050ConfigRef.KeyFile.Name);
|
||||
}
|
||||
|
||||
var response = await (await Http.PostAsync($"api/File/certificates/{id}", content)).Content.ReadFromJsonAsync<MessageResult>();
|
||||
if (response is null) Snackbar.Add("Failed to update certificates", Severity.Warning);
|
||||
else if (!response.IsSuccess) Snackbar.Add(response.Message ?? "Failed to update certificates config", Severity.Warning);
|
||||
else return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private async Task SaveConfig()
|
||||
{
|
||||
try
|
||||
@@ -344,9 +372,14 @@ public partial class RobotConfigManager
|
||||
SelectedVda.VDA5050PublishRepeat,
|
||||
SelectedVda.VDA5050EnablePassword,
|
||||
SelectedVda.VDA5050EnableTls,
|
||||
SelectedVda.VDA5050CA,
|
||||
SelectedVda.VDA5050Cer,
|
||||
SelectedVda.VDA5050Key,
|
||||
SelectedVda.Description
|
||||
};
|
||||
result = await (await Http.PutAsJsonAsync($"api/RobotConfigs/vda5050/{id}", updateDto)).Content.ReadFromJsonAsync<MessageResult>();
|
||||
var saveCer = await SaveCertificates(SelectedVda.Id);
|
||||
if (saveCer) result = await (await Http.PutAsJsonAsync($"api/RobotConfigs/vda5050/{id}", updateDto)).Content.ReadFromJsonAsync<MessageResult>();
|
||||
else return;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user