Update LAND x invio zip a LiMan
This commit is contained in:
+24
-15
@@ -29,6 +29,17 @@ namespace MP.Land.Data
|
||||
public SyncService(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
// sistemo conf secondo Target compilazione
|
||||
|
||||
|
||||
#if DEBUG_LIMANDEBUG
|
||||
apiUrl = "https://localhost:5003/";
|
||||
#else
|
||||
apiUrl = "https://liman.egalware.com/ELM.API/";
|
||||
#endif
|
||||
// fix opzioni base del RestClient
|
||||
restOptStd = new RestClientOptions { Timeout = TimeSpan.FromSeconds(60), BaseUrl = new Uri(apiUrl) };
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
@@ -164,10 +175,12 @@ namespace MP.Land.Data
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
string apiUrl = "/api/filesave/zipbackup";
|
||||
Log.Info($"Inizio chiamata REST | URL: {restOptStd.BaseUrl} | api: {apiUrl}");
|
||||
// client chiamate rest
|
||||
var client = new RestClient(restOptStd);
|
||||
// Chiamo il metodo!
|
||||
var actReq = new RestRequest($"/api/filesave/zipbackup", Method.Post);
|
||||
var actReq = new RestRequest(apiUrl, Method.Post);
|
||||
actReq.AddParameter("CodApp", $"{CodApp}");
|
||||
actReq.AddParameter("CodInst", $"{CodInst}");
|
||||
actReq.AddParameter("DoUnzip", $"{DoUnzip}");
|
||||
@@ -176,20 +189,20 @@ namespace MP.Land.Data
|
||||
actReq.AddHeader("Content-Type", "multipart/form-data");
|
||||
// effettuo vera chiamata
|
||||
var currResp = await client.ExecuteAsync(actReq);
|
||||
if (currResp.StatusCode == System.Net.HttpStatusCode.OK && currResp.Content != null)
|
||||
if ((currResp.StatusCode == System.Net.HttpStatusCode.OK || currResp.StatusCode == System.Net.HttpStatusCode.Created) && currResp.Content != null)
|
||||
{
|
||||
// mi restituisce esito upload
|
||||
var currList = JsonConvert.DeserializeObject<List<UploadResult>>(currResp.Content);
|
||||
var currList = JsonConvert.DeserializeObject<UploadResult>(currResp.Content);
|
||||
if (currList != null)
|
||||
{
|
||||
// se contiene anche la richiesta è ok...
|
||||
var recUpd = currList.FirstOrDefault(x => x.FileName == ZipFile.Name);
|
||||
if (recUpd != null)
|
||||
{
|
||||
answ = recUpd.Uploaded;
|
||||
}
|
||||
answ = currList.Uploaded;
|
||||
Log.Info($"Invio file | ZipName: {ZipFile.Name} | uploaded: {answ}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Errore in invio | StatusCode: {currResp.StatusCode}{Environment.NewLine}{currResp.Content}");
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -231,11 +244,7 @@ namespace MP.Land.Data
|
||||
/// <summary>
|
||||
/// URL dell'API x chiamate gestione licenze
|
||||
/// </summary>
|
||||
#if DEBUG
|
||||
private static string apiUrl = "https://localhost:5003/";
|
||||
#else
|
||||
private static string apiUrl = "https://liman.egalware.com/ELM.API/";
|
||||
#endif
|
||||
private string apiUrl { get; set; } = "https://localhost:5003/";
|
||||
|
||||
/// <summary>
|
||||
/// Classe logger
|
||||
@@ -247,7 +256,7 @@ namespace MP.Land.Data
|
||||
/// - base URI al sito
|
||||
/// - timeout 1 min
|
||||
/// </summary>
|
||||
private static RestClientOptions restOptStd = new RestClientOptions { Timeout = TimeSpan.FromSeconds(60), BaseUrl = new Uri(apiUrl) };
|
||||
private RestClientOptions restOptStd { get; set; } = new RestClientOptions();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user