Compare commits

..

3 Commits

Author SHA1 Message Date
Samuele Locatelli 8c5fc8b838 Merge branch 'release/FixHttpsDownloadNexus' 2021-09-17 16:43:39 +02:00
Samuele Locatelli 84d4df2329 mODIFICA METODO DOWNLOAD X HTTP --> HTTPS IN NEXUS 2021-09-17 16:43:08 +02:00
Samuele Locatelli 91ffbbe8dd Merge tag 'FixDWrap' into develop
Fix mnetodo init DWrap
2021-09-17 13:07:49 +02:00
2 changed files with 40 additions and 13 deletions
+39 -12
View File
@@ -111,27 +111,54 @@ namespace SteamWare
}
string localFile = "";
string localLast = "";
string DownloadURL = "";
try
{
// in primis scarico update info...
UpdateInfoEventArgs updateData = getUpdateInfo(remoteUrl);
if (updateData.IsUpdateAvailable)
{
string DownloadURL = updateData.DownloadURL;
DownloadURL = updateData.DownloadURL;
localFile = string.Format(@"{0}\{1}_Build_{2}.zip", localRepo, packName, updateData.CurrentVersion);
localLast = string.Format(@"{0}\{1}.zip", localRepo, packName);
// scarica file e salva in directory locale...
var client = new WebClient();
bool doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
if (doAuth)
using (var http = new HttpClient())
{
client.Credentials = new System.Net.NetworkCredential(userName, passwd);
//var client = new WebClient();
bool doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
if (doAuth)
{
//client.Credentials = new System.Net.NetworkCredential(userName, passwd);
http.DefaultRequestHeaders.Accept.Clear();
var byteArray = System.Text.ASCIIEncoding.UTF8.GetBytes($"{userName}:{passwd}");
http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
}
//client.DownloadFile(updateData.DownloadURL, localFile);
// url da chiamare
http.BaseAddress = new Uri(DownloadURL);
// lettura
var data = http.GetAsync(DownloadURL).Result;
using (var myReader = data.Content.ReadAsStreamAsync())
{
//var myReader = data.Content.ReadAsStreamAsync();
if (data.StatusCode != HttpStatusCode.OK)
{
logger.lg.scriviLog($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}", tipoLog.INFO);
}
else
{
using (Stream outStream = File.OpenWrite(localFile))
{
myReader.Result.CopyTo(outStream);
}
// ora lo copio come latest...
File.Copy(localFile, localLast, true);
// indico come fatto!
done = 1;
}
}
}
client.DownloadFile(updateData.DownloadURL, localFile);
// ora lo copio come latest...
File.Copy(localFile, localLast, true);
// indico come fatto!
done = 1;
}
else
{
@@ -139,7 +166,7 @@ namespace SteamWare
// scrivo file in area target...
using (StreamWriter sw = File.AppendText(localFile))
{
sw.WriteLine(string.Format("{0:yyyy-MM-dd HH:mm:ss} ATTENZIONE! Installer NON disponibile | {1}", DateTime.Now, remoteUrl));
sw.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ATTENZIONE! Installer NON disponibile | {remoteUrl}");
}
}
}
@@ -149,7 +176,7 @@ namespace SteamWare
// scrivo file in area target...
using (StreamWriter sw = File.AppendText(localFile))
{
sw.WriteLine(string.Format("{0:yyyy-MM-dd HH:mm:ss} Errore in fase di download installers per {1}", DateTime.Now, remoteUrl));
sw.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} Errore in fase di download installers{Environment.NewLine}XML: {remoteUrl}{Environment.NewLine}URL: {DownloadURL}");
sw.WriteLine(exc.ToString());
}
}
+1 -1
View File
@@ -64,7 +64,7 @@ namespace TestBench
private void btnDownload_Click(object sender, EventArgs e)
{
var currUpdMan = new UpdateMan(txtUser.Text.Trim(), txtPass.Text.Trim());
currUpdMan.downloadLatest(txtRemoteUrl.Text.Trim(), "c:\\Temp", "MP-STATS");
currUpdMan.downloadLatest(txtRemoteUrl.Text.Trim(), "c:\\Temp", "TEST-FILE");
}
private void btnReadUpdMan_Click(object sender, EventArgs e)