89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace CMS_SC
|
|
{
|
|
public partial class UpdMan : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
/// <summary>
|
|
/// Eseguo download pacchetti secondo richeista
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtDownload_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lnk = (LinkButton)sender;
|
|
string caller = lnk.CommandArgument;
|
|
string resultsMsg = "";
|
|
// in base al caller scarico il file installazione richiesto...
|
|
if (caller == null)
|
|
{
|
|
caller = "ALL";
|
|
}
|
|
// ora verifico COSA devo scaricare...
|
|
if (updateUrl(caller) != "")
|
|
{
|
|
// se è ALL scarico tutti...
|
|
if (caller == "ALL")
|
|
{
|
|
Stopwatch stopWatch = new Stopwatch();
|
|
stopWatch.Start();
|
|
int done = 0;
|
|
// scarico TUTTI...
|
|
done += UpdateMan.obj.downloadLatest(updateUrl("CMS_SC"), localDownloadPath("CMS_SC"), "CMS_SC");
|
|
stopWatch.Stop();
|
|
// calcolo elapsed time come TimeSpan value.
|
|
TimeSpan ts = stopWatch.Elapsed;
|
|
resultsMsg = string.Format("OK: {0} Package downloaded, {1:0.000} sec", done, ts.TotalSeconds);
|
|
}
|
|
else
|
|
{
|
|
// scarico singolo target...
|
|
UpdateMan.obj.downloadLatest(updateUrl(caller), localDownloadPath(caller), caller);
|
|
resultsMsg = string.Format("OK: {0} DOWNLOADED | {1} --> {2}", caller, updateUrl(caller), localDownloadPath(caller));
|
|
}
|
|
}
|
|
// aggiorno messaggio
|
|
lblOut.Text = resultsMsg;
|
|
}
|
|
|
|
public string Version(object package)
|
|
{
|
|
string answ = "a.b.c.d";
|
|
UpdateInfoEventArgs updArgs = new UpdateInfoEventArgs();
|
|
// Recupero info ADM...
|
|
updArgs = UpdateMan.obj.getUpdateInfo(updateUrl(package.ToString()));
|
|
if (updArgs.IsUpdateAvailable)
|
|
{
|
|
answ = updArgs.CurrentVersion.ToString();
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// URLK stringa di UPDATE...
|
|
/// </summary>
|
|
protected string updateUrl(string package)
|
|
{
|
|
return string.Format("http://seriate.steamware.net:8083/SWS/{0}/{1}/manifest.xml", package, memLayer.ML.CRS("appVers"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Path locale dove scaricare gli installer
|
|
/// </summary>
|
|
protected string localDownloadPath(string package)
|
|
{
|
|
return string.Format(@"{0}{1}\{2}", memLayer.ML.CRS("downloadPath"), package, memLayer.ML.CRS("appVers"));
|
|
}
|
|
}
|
|
} |