Added bit.ly support for distiributives download; Updated year in copyright text;
This commit is contained in:
parent
8b7b150da7
commit
2dc3ced5cf
12 changed files with 1210 additions and 955 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -211,7 +211,7 @@ namespace WebsitePanel.Installer.Controls
|
|||
{
|
||||
Log.WriteInfo(string.Format("Updating {0}", componentName));
|
||||
//download installer
|
||||
Loader form = new Loader(this.AppContext, fileName);
|
||||
Loader form = new Loader(fileName, (e) => AppContext.AppForm.ShowError(e));
|
||||
DialogResult result = form.ShowDialog(this);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
|
@ -273,7 +273,7 @@ namespace WebsitePanel.Installer.Controls
|
|||
{
|
||||
Log.WriteInfo(string.Format("Uninstalling {0}", componentName));
|
||||
//download installer
|
||||
Loader form = new Loader(this.AppContext, installer, componentCode, release);
|
||||
Loader form = new Loader(installer, componentCode, release, (e) => AppContext.AppForm.ShowError(e));
|
||||
DialogResult result = form.ShowDialog(this);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
|
@ -326,15 +326,15 @@ namespace WebsitePanel.Installer.Controls
|
|||
string path = element.GetStringSetting("InstallerPath");
|
||||
string type = element.GetStringSetting("InstallerType");
|
||||
string componentId = element.ID;
|
||||
string componentCode = element.GetStringSetting("ComponentCode");
|
||||
string ccode = element.GetStringSetting("ComponentCode");
|
||||
string componentName = element.GetStringSetting("ComponentName");
|
||||
string release = element.GetStringSetting("Release");
|
||||
string cversion = element.GetStringSetting("Release");
|
||||
|
||||
try
|
||||
{
|
||||
Log.WriteInfo(string.Format("Setup {0} {1}", componentName, release));
|
||||
//download installer
|
||||
Loader form = new Loader(this.AppContext, installer, componentCode, release);
|
||||
Log.WriteInfo(string.Format("Setup {0} {1}", componentName, cversion));
|
||||
//download installer
|
||||
Loader form = new Loader(installer, ccode, cversion, (e) => AppContext.AppForm.ShowError(e));
|
||||
DialogResult result = form.ShowDialog(this);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -45,273 +45,273 @@ using WebsitePanel.Installer.Configuration;
|
|||
|
||||
namespace WebsitePanel.Installer.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Components control
|
||||
/// </summary>
|
||||
internal partial class ComponentsControl : ResultViewControl
|
||||
{
|
||||
delegate void SetGridDataSourceCallback(object dataSource, string dataMember);
|
||||
/// <summary>
|
||||
/// Components control
|
||||
/// </summary>
|
||||
internal partial class ComponentsControl : ResultViewControl
|
||||
{
|
||||
delegate void SetGridDataSourceCallback(object dataSource, string dataMember);
|
||||
|
||||
private string componentCode = null;
|
||||
private string componentVersion = null;
|
||||
private string componentSettingsXml = null;
|
||||
private string componentCode = null;
|
||||
private string componentVersion = null;
|
||||
private string componentSettingsXml = null;
|
||||
|
||||
public ComponentsControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
grdComponents.AutoGenerateColumns = false;
|
||||
}
|
||||
public ComponentsControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
grdComponents.AutoGenerateColumns = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action on click Install link
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnInstallLinkClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex == grdComponents.Columns.IndexOf(colLink))
|
||||
{
|
||||
DataRowView row = grdComponents.Rows[e.RowIndex].DataBoundItem as DataRowView;
|
||||
if (row != null)
|
||||
{
|
||||
StartInstaller(row);
|
||||
StartLoadingComponents();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Action on click Install link
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnInstallLinkClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex == grdComponents.Columns.IndexOf(colLink))
|
||||
{
|
||||
DataRowView row = grdComponents.Rows[e.RowIndex].DataBoundItem as DataRowView;
|
||||
if (row != null)
|
||||
{
|
||||
StartInstaller(row);
|
||||
StartLoadingComponents();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
private void StartInstaller(DataRowView row)
|
||||
{
|
||||
string applicationName = Utils.GetDbString(row[Global.Parameters.ApplicationName]);
|
||||
string componentName = Utils.GetDbString(row[Global.Parameters.ComponentName]);
|
||||
string componentCode = Utils.GetDbString(row[Global.Parameters.ComponentCode]);
|
||||
string componentDescription = Utils.GetDbString(row[Global.Parameters.ComponentDescription]);
|
||||
string component = Utils.GetDbString(row[Global.Parameters.Component]);
|
||||
string version = Utils.GetDbString(row[Global.Parameters.Version]);
|
||||
string fileName = row[Global.Parameters.FullFilePath].ToString();
|
||||
string installerPath = Utils.GetDbString(row[Global.Parameters.InstallerPath]);
|
||||
string installerType = Utils.GetDbString(row[Global.Parameters.InstallerType]);
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckForInstalledComponent(componentCode))
|
||||
{
|
||||
AppContext.AppForm.ShowWarning(Global.Messages.ComponentIsAlreadyInstalled);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
// download installer
|
||||
Loader form = new Loader(this.AppContext, fileName);
|
||||
DialogResult result = form.ShowDialog(this);
|
||||
private void StartInstaller(DataRowView row)
|
||||
{
|
||||
string applicationName = Utils.GetDbString(row[Global.Parameters.ApplicationName]);
|
||||
string componentName = Utils.GetDbString(row[Global.Parameters.ComponentName]);
|
||||
string componentCode = Utils.GetDbString(row[Global.Parameters.ComponentCode]);
|
||||
string componentDescription = Utils.GetDbString(row[Global.Parameters.ComponentDescription]);
|
||||
string component = Utils.GetDbString(row[Global.Parameters.Component]);
|
||||
string version = Utils.GetDbString(row[Global.Parameters.Version]);
|
||||
string fileName = row[Global.Parameters.FullFilePath].ToString();
|
||||
string installerPath = Utils.GetDbString(row[Global.Parameters.InstallerPath]);
|
||||
string installerType = Utils.GetDbString(row[Global.Parameters.InstallerType]);
|
||||
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
string tmpFolder = FileUtils.GetTempDirectory();
|
||||
string path = Path.Combine(tmpFolder, installerPath);
|
||||
Update();
|
||||
string method = "Install";
|
||||
Log.WriteStart(string.Format("Running installer {0}.{1} from {2}", installerType, method, path));
|
||||
if (CheckForInstalledComponent(componentCode))
|
||||
{
|
||||
AppContext.AppForm.ShowWarning(Global.Messages.ComponentIsAlreadyInstalled);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
// download installer
|
||||
Loader form = new Loader(fileName, (e) => AppContext.AppForm.ShowError(e));
|
||||
DialogResult result = form.ShowDialog(this);
|
||||
|
||||
//prepare installer args
|
||||
Hashtable args = new Hashtable();
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
string tmpFolder = FileUtils.GetTempDirectory();
|
||||
string path = Path.Combine(tmpFolder, installerPath);
|
||||
Update();
|
||||
string method = "Install";
|
||||
Log.WriteStart(string.Format("Running installer {0}.{1} from {2}", installerType, method, path));
|
||||
|
||||
args[Global.Parameters.ComponentName] = componentName;
|
||||
args[Global.Parameters.ApplicationName] = applicationName;
|
||||
args[Global.Parameters.ComponentCode] = componentCode;
|
||||
args[Global.Parameters.ComponentDescription] = componentDescription;
|
||||
args[Global.Parameters.Version] = version;
|
||||
args[Global.Parameters.InstallerFolder] = tmpFolder;
|
||||
args[Global.Parameters.InstallerPath] = installerPath;
|
||||
args[Global.Parameters.InstallerType] = installerType;
|
||||
args[Global.Parameters.Installer] = Path.GetFileName(fileName);
|
||||
args[Global.Parameters.ShellVersion] = AssemblyLoader.GetShellVersion();
|
||||
args[Global.Parameters.BaseDirectory] = FileUtils.GetCurrentDirectory();
|
||||
args[Global.Parameters.ShellMode] = Global.VisualInstallerShell;
|
||||
args[Global.Parameters.IISVersion] = Global.IISVersion;
|
||||
args[Global.Parameters.SetupXml] = this.componentSettingsXml;
|
||||
args[Global.Parameters.ParentForm] = FindForm();
|
||||
//prepare installer args
|
||||
Hashtable args = new Hashtable();
|
||||
|
||||
//run installer
|
||||
DialogResult res = (DialogResult)AssemblyLoader.Execute(path, installerType, method, new object[] { args });
|
||||
Log.WriteInfo(string.Format("Installer returned {0}", res));
|
||||
Log.WriteEnd("Installer finished");
|
||||
Update();
|
||||
if (res == DialogResult.OK)
|
||||
{
|
||||
AppContext.AppForm.ReloadApplication();
|
||||
}
|
||||
FileUtils.DeleteTempDirectory();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError("Installer error", ex);
|
||||
AppContext.AppForm.ShowError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.componentSettingsXml = null;
|
||||
this.componentCode = null;
|
||||
}
|
||||
args[Global.Parameters.ComponentName] = componentName;
|
||||
args[Global.Parameters.ApplicationName] = applicationName;
|
||||
args[Global.Parameters.ComponentCode] = componentCode;
|
||||
args[Global.Parameters.ComponentDescription] = componentDescription;
|
||||
args[Global.Parameters.Version] = version;
|
||||
args[Global.Parameters.InstallerFolder] = tmpFolder;
|
||||
args[Global.Parameters.InstallerPath] = installerPath;
|
||||
args[Global.Parameters.InstallerType] = installerType;
|
||||
args[Global.Parameters.Installer] = Path.GetFileName(fileName);
|
||||
args[Global.Parameters.ShellVersion] = AssemblyLoader.GetShellVersion();
|
||||
args[Global.Parameters.BaseDirectory] = FileUtils.GetCurrentDirectory();
|
||||
args[Global.Parameters.ShellMode] = Global.VisualInstallerShell;
|
||||
args[Global.Parameters.IISVersion] = Global.IISVersion;
|
||||
args[Global.Parameters.SetupXml] = this.componentSettingsXml;
|
||||
args[Global.Parameters.ParentForm] = FindForm();
|
||||
|
||||
}
|
||||
//run installer
|
||||
DialogResult res = (DialogResult)AssemblyLoader.Execute(path, installerType, method, new object[] { args });
|
||||
Log.WriteInfo(string.Format("Installer returned {0}", res));
|
||||
Log.WriteEnd("Installer finished");
|
||||
Update();
|
||||
if (res == DialogResult.OK)
|
||||
{
|
||||
AppContext.AppForm.ReloadApplication();
|
||||
}
|
||||
FileUtils.DeleteTempDirectory();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError("Installer error", ex);
|
||||
AppContext.AppForm.ShowError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.componentSettingsXml = null;
|
||||
this.componentCode = null;
|
||||
}
|
||||
|
||||
private bool CheckForInstalledComponent(string componentCode)
|
||||
{
|
||||
bool ret = false;
|
||||
List<string> installedComponents = new List<string>();
|
||||
foreach (ComponentConfigElement componentConfig in AppConfigManager.AppConfiguration.Components)
|
||||
{
|
||||
string code = componentConfig.Settings["ComponentCode"].Value;
|
||||
installedComponents.Add(code);
|
||||
if (code == componentCode)
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (componentCode == "standalone")
|
||||
{
|
||||
if (installedComponents.Contains("server") ||
|
||||
installedComponents.Contains("enterprise server") ||
|
||||
installedComponents.Contains("portal"))
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays component description when entering grid row
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnRowEnter(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
DataRowView row = grdComponents.Rows[e.RowIndex].DataBoundItem as DataRowView;
|
||||
if (row != null)
|
||||
{
|
||||
lblDescription.Text = Utils.GetDbString(row["ComponentDescription"]);
|
||||
}
|
||||
}
|
||||
private bool CheckForInstalledComponent(string componentCode)
|
||||
{
|
||||
bool ret = false;
|
||||
List<string> installedComponents = new List<string>();
|
||||
foreach (ComponentConfigElement componentConfig in AppConfigManager.AppConfiguration.Components)
|
||||
{
|
||||
string code = componentConfig.Settings["ComponentCode"].Value;
|
||||
installedComponents.Add(code);
|
||||
if (code == componentCode)
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (componentCode == "standalone")
|
||||
{
|
||||
if (installedComponents.Contains("server") ||
|
||||
installedComponents.Contains("enterprise server") ||
|
||||
installedComponents.Contains("portal"))
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start new thread to load components
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnLoadComponentsClick(object sender, EventArgs e)
|
||||
{
|
||||
StartLoadingComponents();
|
||||
}
|
||||
/// <summary>
|
||||
/// Displays component description when entering grid row
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnRowEnter(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
DataRowView row = grdComponents.Rows[e.RowIndex].DataBoundItem as DataRowView;
|
||||
if (row != null)
|
||||
{
|
||||
lblDescription.Text = Utils.GetDbString(row["ComponentDescription"]);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartLoadingComponents()
|
||||
{
|
||||
//load list of available components in the separate thread
|
||||
AppContext.AppForm.StartAsyncProgress("Connecting...", true);
|
||||
ThreadStart threadDelegate = new ThreadStart(LoadComponents);
|
||||
Thread newThread = new Thread(threadDelegate);
|
||||
newThread.Start();
|
||||
}
|
||||
/// <summary>
|
||||
/// Start new thread to load components
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnLoadComponentsClick(object sender, EventArgs e)
|
||||
{
|
||||
StartLoadingComponents();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads list of available components via web service
|
||||
/// </summary>
|
||||
private void LoadComponents()
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.WriteStart("Loading list of available components");
|
||||
lblDescription.Text = string.Empty;
|
||||
//load components via web service
|
||||
var webService = ServiceProviderProxy.GetInstallerWebService();
|
||||
DataSet dsComponents = webService.GetAvailableComponents();
|
||||
//remove already installed components
|
||||
foreach (DataRow row in dsComponents.Tables[0].Rows)
|
||||
{
|
||||
string componentCode = Utils.GetDbString(row["ComponentCode"]);
|
||||
if (CheckForInstalledComponent(componentCode))
|
||||
{
|
||||
row.Delete();
|
||||
}
|
||||
}
|
||||
dsComponents.AcceptChanges();
|
||||
Log.WriteEnd("Available components loaded");
|
||||
SetGridDataSource(dsComponents, dsComponents.Tables[0].TableName);
|
||||
AppContext.AppForm.FinishProgress();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError("Web service error", ex);
|
||||
AppContext.AppForm.FinishProgress();
|
||||
AppContext.AppForm.ShowServerError();
|
||||
}
|
||||
}
|
||||
private void StartLoadingComponents()
|
||||
{
|
||||
//load list of available components in the separate thread
|
||||
AppContext.AppForm.StartAsyncProgress("Connecting...", true);
|
||||
ThreadPool.QueueUserWorkItem(o => LoadComponents());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Thread safe grid binding.
|
||||
/// </summary>
|
||||
/// <param name="dataSource">Data source</param>
|
||||
/// <param name="dataMember">Data member</param>
|
||||
private void SetGridDataSource(object dataSource, string dataMember)
|
||||
{
|
||||
// InvokeRequired required compares the thread ID of the
|
||||
// calling thread to the thread ID of the creating thread.
|
||||
// If these threads are different, it returns true.
|
||||
if (this.grdComponents.InvokeRequired)
|
||||
{
|
||||
SetGridDataSourceCallback callBack = new SetGridDataSourceCallback(SetGridDataSource);
|
||||
this.grdComponents.Invoke(callBack, new object[] { dataSource, dataMember });
|
||||
}
|
||||
else
|
||||
{
|
||||
this.grdComponents.DataSource = dataSource;
|
||||
this.grdComponents.DataMember = dataMember;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Loads list of available components via web service
|
||||
/// </summary>
|
||||
private void LoadComponents()
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.WriteStart("Loading list of available components");
|
||||
lblDescription.Text = string.Empty;
|
||||
//load components via web service
|
||||
var webService = ServiceProviderProxy.GetInstallerWebService();
|
||||
DataSet dsComponents = webService.GetAvailableComponents();
|
||||
//remove already installed components
|
||||
foreach (DataRow row in dsComponents.Tables[0].Rows)
|
||||
{
|
||||
string componentCode = Utils.GetDbString(row["ComponentCode"]);
|
||||
if (CheckForInstalledComponent(componentCode))
|
||||
{
|
||||
row.Delete();
|
||||
}
|
||||
}
|
||||
dsComponents.AcceptChanges();
|
||||
Log.WriteEnd("Available components loaded");
|
||||
SetGridDataSource(dsComponents, dsComponents.Tables[0].TableName);
|
||||
AppContext.AppForm.FinishProgress();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.WriteError("Web service error", ex);
|
||||
AppContext.AppForm.FinishProgress();
|
||||
AppContext.AppForm.ShowServerError();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Installs component during unattended setup
|
||||
/// </summary>
|
||||
/// <param name="componentCode"></param>
|
||||
internal void InstallComponent(string componentCode, string componentVersion, string settingsXml)
|
||||
{
|
||||
//load list of available components in the separate thread
|
||||
this.componentCode = componentCode;
|
||||
this.componentVersion = componentVersion;
|
||||
this.componentSettingsXml = settingsXml;
|
||||
AppContext.AppForm.StartAsyncProgress("Connecting...", true);
|
||||
ThreadStart threadDelegate = new ThreadStart(Install);
|
||||
Thread newThread = new Thread(threadDelegate);
|
||||
newThread.Start();
|
||||
}
|
||||
/// <summary>
|
||||
/// Thread safe grid binding.
|
||||
/// </summary>
|
||||
/// <param name="dataSource">Data source</param>
|
||||
/// <param name="dataMember">Data member</param>
|
||||
private void SetGridDataSource(object dataSource, string dataMember)
|
||||
{
|
||||
// InvokeRequired required compares the thread ID of the
|
||||
// calling thread to the thread ID of the creating thread.
|
||||
// If these threads are different, it returns true.
|
||||
if (this.grdComponents.InvokeRequired)
|
||||
{
|
||||
SetGridDataSourceCallback callBack = new SetGridDataSourceCallback(SetGridDataSource);
|
||||
this.grdComponents.Invoke(callBack, new object[] { dataSource, dataMember });
|
||||
}
|
||||
else
|
||||
{
|
||||
this.grdComponents.DataSource = dataSource;
|
||||
this.grdComponents.DataMember = dataMember;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads list of available components via web service and install specified component
|
||||
/// during unattended setup
|
||||
/// </summary>
|
||||
private void Install()
|
||||
{
|
||||
LoadComponents();
|
||||
foreach (DataGridViewRow gridRow in grdComponents.Rows)
|
||||
{
|
||||
DataRowView row = gridRow.DataBoundItem as DataRowView;
|
||||
if (row != null)
|
||||
{
|
||||
string code = Utils.GetDbString(row["ComponentCode"]);
|
||||
string version = Utils.GetDbString(row["Version"]);
|
||||
if (code == componentCode)
|
||||
{
|
||||
//check component version if specified
|
||||
if (!string.IsNullOrEmpty(componentVersion))
|
||||
{
|
||||
if (version != componentVersion)
|
||||
continue;
|
||||
}
|
||||
StartInstaller(row);
|
||||
AppContext.AppForm.ProceedUnattendedSetup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Installs component during unattended setup
|
||||
/// </summary>
|
||||
/// <param name="componentCode"></param>
|
||||
internal void InstallComponent(string componentCode, string componentVersion, string settingsXml)
|
||||
{
|
||||
//load list of available components in the separate thread
|
||||
this.componentCode = componentCode;
|
||||
this.componentVersion = componentVersion;
|
||||
this.componentSettingsXml = settingsXml;
|
||||
AppContext.AppForm.StartAsyncProgress("Connecting...", true);
|
||||
ThreadPool.QueueUserWorkItem(o => Install());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads list of available components via web service and install specified component
|
||||
/// during unattended setup
|
||||
/// </summary>
|
||||
private void Install()
|
||||
{
|
||||
LoadComponents();
|
||||
foreach (DataGridViewRow gridRow in grdComponents.Rows)
|
||||
{
|
||||
DataRowView row = gridRow.DataBoundItem as DataRowView;
|
||||
if (row != null)
|
||||
{
|
||||
string code = Utils.GetDbString(row["ComponentCode"]);
|
||||
string version = Utils.GetDbString(row["Version"]);
|
||||
if (code == componentCode)
|
||||
{
|
||||
//check component version if specified
|
||||
if (!string.IsNullOrEmpty(componentVersion))
|
||||
{
|
||||
if (version != componentVersion)
|
||||
continue;
|
||||
}
|
||||
StartInstaller(row);
|
||||
AppContext.AppForm.ProceedUnattendedSetup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2011, Outercurve Foundation.
|
||||
// Copyright (c) 2012, Outercurve Foundation.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
|
@ -39,118 +39,156 @@ using Ionic.Zip;
|
|||
|
||||
using WebsitePanel.Installer.Services;
|
||||
using WebsitePanel.Installer.Common;
|
||||
using WebsitePanel.Installer.Core;
|
||||
|
||||
namespace WebsitePanel.Installer.Controls
|
||||
{
|
||||
public delegate void OperationProgressDelegate(int percentage);
|
||||
public delegate void OperationProgressDelegate(int percentage);
|
||||
|
||||
/// <summary>
|
||||
/// Loader form.
|
||||
/// </summary>
|
||||
internal partial class Loader : Form
|
||||
{
|
||||
private AppContext appContext;
|
||||
private Core.Loader appLoader;
|
||||
/// <summary>
|
||||
/// Loader form.
|
||||
/// </summary>
|
||||
internal partial class Loader : Form
|
||||
{
|
||||
private Core.Loader appLoader;
|
||||
|
||||
public Loader()
|
||||
{
|
||||
InitializeComponent();
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
public Loader()
|
||||
{
|
||||
InitializeComponent();
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
public Loader(AppContext context, string remoteFile)
|
||||
: this()
|
||||
{
|
||||
this.appContext = context;
|
||||
//
|
||||
appLoader = new Core.Loader(remoteFile);
|
||||
//
|
||||
Start();
|
||||
}
|
||||
public Loader(string remoteFile, Action<Exception> callback)
|
||||
: this()
|
||||
{
|
||||
Start(remoteFile, callback);
|
||||
}
|
||||
|
||||
public Loader(AppContext context, string localFile, string componentCode, string version)
|
||||
: this()
|
||||
{
|
||||
this.appContext = context;
|
||||
//
|
||||
appLoader = new Core.Loader(localFile, componentCode, version);
|
||||
//
|
||||
Start();
|
||||
}
|
||||
public Loader(string localFile, string componentCode, string version, Action<Exception> callback)
|
||||
: this()
|
||||
{
|
||||
Start(componentCode, version, callback);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//
|
||||
appLoader.OperationFailed += new EventHandler<Core.LoaderEventArgs<Exception>>(appLoader_OperationFailed);
|
||||
appLoader.ProgressChanged += new EventHandler<Core.LoaderEventArgs<Int32>>(appLoader_ProgressChanged);
|
||||
appLoader.StatusChanged += new EventHandler<Core.LoaderEventArgs<String>>(appLoader_StatusChanged);
|
||||
appLoader.OperationCompleted += new EventHandler<EventArgs>(appLoader_OperationCompleted);
|
||||
//
|
||||
appLoader.LoadAppDistributive();
|
||||
}
|
||||
/// <summary>
|
||||
/// Resolves URL of the component's distributive and initiates download process.
|
||||
/// </summary>
|
||||
/// <param name="componentCode">Component code to resolve</param>
|
||||
/// <param name="version">Component version to resolve</param>
|
||||
private void Start(string componentCode, string version, Action<Exception> callback)
|
||||
{
|
||||
string remoteFile = Utils.GetDistributiveLocationInfo(componentCode, version);
|
||||
|
||||
void appLoader_OperationCompleted(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
Start(remoteFile, callback);
|
||||
}
|
||||
|
||||
void appLoader_StatusChanged(object sender, Core.LoaderEventArgs<String> e)
|
||||
{
|
||||
lblProcess.Text = e.StatusMessage;
|
||||
lblValue.Text = e.EventData;
|
||||
// Adjust Cancel button availability for an operation being performed
|
||||
if (btnCancel.Enabled != e.Cancellable)
|
||||
{
|
||||
btnCancel.Enabled = e.Cancellable;
|
||||
}
|
||||
// This check allows to avoid extra form redrawing operations
|
||||
if (ControlBox != e.Cancellable)
|
||||
{
|
||||
ControlBox = e.Cancellable;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes and starts the app distributive download process.
|
||||
/// </summary>
|
||||
/// <param name="remoteFile">URL of the file to be downloaded</param>
|
||||
private void Start(string remoteFile, Action<Exception> callback)
|
||||
{
|
||||
appLoader = Core.LoaderFactory.CreateFileLoader(remoteFile);
|
||||
|
||||
void appLoader_ProgressChanged(object sender, Core.LoaderEventArgs<Int32> e)
|
||||
{
|
||||
progressBar.Value = e.EventData;
|
||||
// Adjust Cancel button availability for an operation being performed
|
||||
if (btnCancel.Enabled != e.Cancellable)
|
||||
{
|
||||
btnCancel.Enabled = e.Cancellable;
|
||||
}
|
||||
// This check allows to avoid extra form redrawing operations
|
||||
if (ControlBox != e.Cancellable)
|
||||
{
|
||||
ControlBox = e.Cancellable;
|
||||
}
|
||||
}
|
||||
appLoader.OperationFailed += new EventHandler<Core.LoaderEventArgs<Exception>>(appLoader_OperationFailed);
|
||||
appLoader.OperationFailed += (object sender, Core.LoaderEventArgs<Exception> e) => {
|
||||
if (callback != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
callback(e.EventData);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Just swallow the exception as we have no interest in it.
|
||||
}
|
||||
}
|
||||
};
|
||||
appLoader.ProgressChanged += new EventHandler<Core.LoaderEventArgs<Int32>>(appLoader_ProgressChanged);
|
||||
appLoader.StatusChanged += new EventHandler<Core.LoaderEventArgs<String>>(appLoader_StatusChanged);
|
||||
appLoader.OperationCompleted += new EventHandler<EventArgs>(appLoader_OperationCompleted);
|
||||
|
||||
void appLoader_OperationFailed(object sender, Core.LoaderEventArgs<Exception> e)
|
||||
{
|
||||
appContext.AppForm.ShowError(e.EventData);
|
||||
//
|
||||
DialogResult = DialogResult.Abort;
|
||||
Close();
|
||||
}
|
||||
appLoader.LoadAppDistributive();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Log.WriteInfo("Execution was canceled by user");
|
||||
Close();
|
||||
}
|
||||
void appLoader_OperationCompleted(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void OnLoaderFormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (this.DialogResult == DialogResult.Cancel)
|
||||
{
|
||||
appLoader.AbortOperation();
|
||||
}
|
||||
// Remove event handlers
|
||||
appLoader.OperationFailed -= new EventHandler<Core.LoaderEventArgs<Exception>>(appLoader_OperationFailed);
|
||||
appLoader.ProgressChanged -= new EventHandler<Core.LoaderEventArgs<Int32>>(appLoader_ProgressChanged);
|
||||
appLoader.StatusChanged -= new EventHandler<Core.LoaderEventArgs<String>>(appLoader_StatusChanged);
|
||||
appLoader.OperationCompleted -= new EventHandler<EventArgs>(appLoader_OperationCompleted);
|
||||
}
|
||||
}
|
||||
void appLoader_StatusChanged(object sender, Core.LoaderEventArgs<String> e)
|
||||
{
|
||||
lblProcess.Text = e.StatusMessage;
|
||||
lblValue.Text = e.EventData;
|
||||
// Adjust Cancel button availability for an operation being performed
|
||||
if (btnCancel.Enabled != e.Cancellable)
|
||||
{
|
||||
btnCancel.Enabled = e.Cancellable;
|
||||
}
|
||||
// This check allows to avoid extra form redrawing operations
|
||||
if (ControlBox != e.Cancellable)
|
||||
{
|
||||
ControlBox = e.Cancellable;
|
||||
}
|
||||
}
|
||||
|
||||
void appLoader_ProgressChanged(object sender, Core.LoaderEventArgs<Int32> e)
|
||||
{
|
||||
bool updateControl = (progressBar.Value != e.EventData);
|
||||
progressBar.Value = e.EventData;
|
||||
// Adjust Cancel button availability for an operation being performed
|
||||
if (btnCancel.Enabled != e.Cancellable)
|
||||
{
|
||||
btnCancel.Enabled = e.Cancellable;
|
||||
}
|
||||
// This check allows to avoid extra form redrawing operations
|
||||
if (ControlBox != e.Cancellable)
|
||||
{
|
||||
ControlBox = e.Cancellable;
|
||||
}
|
||||
//
|
||||
if (updateControl)
|
||||
{
|
||||
progressBar.Update();
|
||||
}
|
||||
}
|
||||
|
||||
void appLoader_OperationFailed(object sender, Core.LoaderEventArgs<Exception> e)
|
||||
{
|
||||
DialogResult = DialogResult.Abort;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DetachEventHandlers();
|
||||
Log.WriteInfo("Execution was canceled by user");
|
||||
Close();
|
||||
}
|
||||
|
||||
private void DetachEventHandlers()
|
||||
{
|
||||
// Detach event handlers
|
||||
if (appLoader != null)
|
||||
{
|
||||
appLoader.OperationFailed -= new EventHandler<Core.LoaderEventArgs<Exception>>(appLoader_OperationFailed);
|
||||
appLoader.ProgressChanged -= new EventHandler<Core.LoaderEventArgs<Int32>>(appLoader_ProgressChanged);
|
||||
appLoader.StatusChanged -= new EventHandler<Core.LoaderEventArgs<String>>(appLoader_StatusChanged);
|
||||
appLoader.OperationCompleted -= new EventHandler<EventArgs>(appLoader_OperationCompleted);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoaderFormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (this.DialogResult == DialogResult.Cancel)
|
||||
{
|
||||
if (appLoader != null)
|
||||
{
|
||||
appLoader.AbortOperation();
|
||||
appLoader = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue