Merge: dev to default

This commit is contained in:
ptsurbeleu 2012-08-01 14:09:54 -07:00
commit 8219ae3a68
10 changed files with 483 additions and 382 deletions

View file

@ -1,4 +1,4 @@
// Copyright (c) 2012, Outercurve Foundation.
// Copyright (c) 2012, Outercurve Foundation.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
@ -80,7 +80,7 @@ namespace WebsitePanel.Installer.Core
private WebClient fileLoader;
public BitlyLoader(string remoteFile)
internal BitlyLoader(string remoteFile)
: base(remoteFile)
{
InitFileLoader();
@ -115,7 +115,7 @@ namespace WebsitePanel.Installer.Core
Log.WriteStart("Downloading file");
Log.WriteInfo("Downloading file \"{0}\" to \"{1}\"", remoteFile, tmpFile);
// Attach event handlers to track status of the download process
fileLoader.DownloadProgressChanged += (obj, e) =>
{
@ -145,7 +145,7 @@ namespace WebsitePanel.Installer.Core
fileLoader.DownloadFileAsync(new Uri(remoteFile), tmpFile);
RaiseOnStatusChangedEvent(DownloadingSetupFilesMessage);
autoEvent.WaitOne();
}
}, ct);
@ -175,7 +175,7 @@ namespace WebsitePanel.Installer.Core
public event EventHandler<LoaderEventArgs<Int32>> ProgressChanged;
public event EventHandler<EventArgs> OperationCompleted;
public Loader(string remoteFile)
internal Loader(string remoteFile)
{
this.remoteFile = remoteFile;
}
@ -276,7 +276,7 @@ namespace WebsitePanel.Installer.Core
// Download the file requested
Task downloadFileTask = GetDownloadFileTask(remoteFile, tmpFile, token);
// Move the file downloaded from temporary location to Data folder
var moveFileTask = downloadFileTask.ContinueWith((t) =>
var moveFileTask = downloadFileTask.ContinueWith((t) =>
{
if (File.Exists(tmpFile))
{
@ -312,7 +312,7 @@ namespace WebsitePanel.Installer.Core
{
RaiseOnOperationCompletedEvent();
}, token);
downloadFileTask.Start();
downloadFileTask.Wait();
}
@ -527,4 +527,4 @@ namespace WebsitePanel.Installer.Core
}
}
}
}
}

View file

@ -337,10 +337,13 @@ namespace WebsitePanel.SilentInstaller
string installerPath = Utils.GetDbString(row["InstallerPath"]);
string installerType = Utils.GetDbString(row["InstallerType"]);
// Get appropriate loader to download the app distributive
var loader = LoaderFactory.CreateFileLoader(fileName);
// Mimic synchronous download process for the console app
AutoResetEvent autoEvent = new AutoResetEvent(false);
try
{
// download installer
var loader = new Loader(fileName);
//
loader.OperationCompleted += new EventHandler<EventArgs>((object sender, EventArgs e) =>
{
@ -374,25 +377,26 @@ namespace WebsitePanel.SilentInstaller
Log.WriteEnd("Installer finished");
// Remove temporary directory
FileUtils.DeleteTempDirectory();
// We are done
autoEvent.Set();
});
// TODO: Add cleanup for events.
loader.OperationFailed += new EventHandler<LoaderEventArgs<Exception>>(loader_OperationFailed);
loader.ProgressChanged += new EventHandler<LoaderEventArgs<int>>(loader_ProgressChanged);
loader.StatusChanged += new EventHandler<LoaderEventArgs<string>>(loader_StatusChanged);
//
loader.LoadAppDistributive();
// Wait until the download is complete
autoEvent.WaitOne();
}
catch (Exception ex)
{
Log.WriteError("Installer error", ex);
//AppContext.AppForm.ShowError(ex);
}
finally
{
//this.componentSettingsXml = null;
//this.componentCode = null;
autoEvent.Set();
}
}
static void loader_StatusChanged(object sender, LoaderEventArgs<string> e)