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(fileName, (e) => AppContext.AppForm.ShowError(e));
                DialogResult result = form.ShowDialog(this);

                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));

                    //prepare installer args
                    Hashtable args = new Hashtable();

                    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;
            }

        }
Esempio n. 2
0
		private void StartInstaller(DataRowView row)
		{
			string applicationName = Utils.GetDbString(row["ApplicationName"]);
			string componentName = Utils.GetDbString(row["ComponentName"]);
			string componentCode = Utils.GetDbString(row["ComponentCode"]);
			string componentDescription = Utils.GetDbString(row["ComponentDescription"]);
			string component = Utils.GetDbString(row["Component"]);
			string version = Utils.GetDbString(row["Version"]);
			string fileName = row["FullFilePath"].ToString();
			string installerPath = Utils.GetDbString(row["InstallerPath"]);
			string installerType = Utils.GetDbString(row["InstallerType"]);
			//if ( installerType.StartsWith("WebsitePanel.Setup.Portal")) installerType = "WebsitePanel.Setup.StandaloneSetup285";
					
			
			if (CheckForInstalledComponent(componentCode))
			{
				AppContext.AppForm.ShowWarning("Component or its part is already installed.");
				return;
			}
			try
			{
				// download installer
				Loader form = new Loader(this.AppContext, fileName);
				DialogResult result = form.ShowDialog(this);

				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));

					//prepare installer args
					Hashtable args = new Hashtable();

					args["ComponentName"] = componentName;
					args["ApplicationName"] = applicationName;
					args["ComponentCode"] = componentCode;
					args["ComponentDescription"] = componentDescription;
					args["Version"] = version;
					args["InstallerFolder"] = tmpFolder;
					args["InstallerPath"] = installerPath;
					args["InstallerType"] = installerType;
					args["Installer"] = Path.GetFileName(fileName);
					args["ShellVersion"] = AppContext.AppForm.Version;
					args["BaseDirectory"] = FileUtils.GetCurrentDirectory();
					args["IISVersion"] = Global.IISVersion;
					args["SetupXml"] = this.componentSettingsXml;
					args["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;
			}
			
		}
Esempio n. 3
0
		/// <summary>
		/// Uninstalls component
		/// </summary>
		private void UninstallComponent()
		{
			Log.WriteStart("Uninstalling component");
			
			ComponentConfigElement element = AppContext.ScopeNode.Tag as ComponentConfigElement;
			string installer = element.GetStringSetting(Global.Parameters.Installer);
			string path = element.GetStringSetting(Global.Parameters.InstallerPath);
			string type = element.GetStringSetting(Global.Parameters.InstallerType);
			string componentId = element.ID;
			string componentCode = element.GetStringSetting(Global.Parameters.ComponentCode);
			string componentName = element.GetStringSetting(Global.Parameters.ComponentName);
			string release = element.GetStringSetting(Global.Parameters.Release);

			try
			{
				Log.WriteInfo(string.Format("Uninstalling {0}", componentName));
				//download installer
				Loader form = new Loader(this.AppContext, installer, componentCode, release);
				DialogResult result = form.ShowDialog(this);
				if (result == DialogResult.OK)
				{
					//run installer
					string tmpFolder = FileUtils.GetTempDirectory();
					path = Path.Combine(tmpFolder, path);
					Update();
					string method = "Uninstall";
					//
					Log.WriteStart(string.Format("Running installer {0}.{1} from {2}", type, method, path));
					//
					var args = new Hashtable
					{
						{ Global.Parameters.ComponentId, componentId },
						{ Global.Parameters.ComponentCode, componentCode },
						{ Global.Parameters.ShellVersion, AppContext.AppForm.Version },
						{ Global.Parameters.BaseDirectory, FileUtils.GetCurrentDirectory() },
						{ Global.Parameters.IISVersion, Global.IISVersion },
						{ Global.Parameters.ParentForm,  FindForm() },
					};
					//
					result = (DialogResult)AssemblyLoader.Execute(path, type, method, new object[] { args });
					//
					Log.WriteInfo(string.Format("Installer returned {0}", result));
					Log.WriteEnd("Installer finished");
					Update();
					ReloadApplication();
					FileUtils.DeleteTempDirectory();
					
				}
				Log.WriteEnd("Uninstall completed");
			}
			catch (Exception ex)
			{
				Log.WriteError("Installer error", ex);
				AppContext.AppForm.ShowError(ex);
			}
		}
Esempio n. 4
0
		/// <summary>
		/// Setup component
		/// </summary>
		private void SetupComponent()
		{
			Log.WriteStart("Starting component setup");

			var element = AppContext.ScopeNode.Tag as ComponentConfigElement;

			string installer = element.GetStringSetting("Installer");
			string path = element.GetStringSetting("InstallerPath");
			string type = element.GetStringSetting("InstallerType");
			string componentId = element.ID;
			string componentCode = element.GetStringSetting("ComponentCode");
			string componentName = element.GetStringSetting("ComponentName");
			string release = element.GetStringSetting("Release");

			try
			{
				Log.WriteInfo(string.Format("Setup {0} {1}", componentName, release));
				//download installer
				Loader form = new Loader(this.AppContext, installer, componentCode, release);
				DialogResult result = form.ShowDialog(this);
				if (result == DialogResult.OK)
				{
					string tmpFolder = Path.Combine(AppContext.CurrentPath, "Tmp");
					path = Path.Combine(tmpFolder, path);
					Update();
					string method = "Setup";
					Log.WriteStart(string.Format("Running installer {0}.{1} from {2}", type, method, path));
					Hashtable args = new Hashtable();
					args["ComponentId"] = componentId;
					args["ShellVersion"] = AppContext.AppForm.Version;
					args["BaseDirectory"] = FileUtils.GetCurrentDirectory();
                    args["IISVersion"] = Global.IISVersion;
					args["ParentForm"] = FindForm();
					args[Global.Parameters.ShellMode] = Global.VisualInstallerShell;
					//
					result = (DialogResult)AssemblyLoader.Execute(path, type, method, new object[] { args });
					//
					Log.WriteInfo(string.Format("Installer returned {0}", result));
					Log.WriteEnd("Installer finished");

					if (result == DialogResult.OK)
					{
						ReloadApplication();
					}
					FileUtils.DeleteTempDirectory();
				}
				Log.WriteEnd("Component setup completed");
			}
			catch (Exception ex)
			{
				Log.WriteError("Installer error", ex);
				this.AppContext.AppForm.ShowError(ex);
			}
		}
Esempio n. 5
0
		/// <summary>
		/// Runs component update
		/// </summary>
		/// <param name="fileName"></param>
		/// <param name="path"></param>
		/// <param name="type"></param>
		private void UpdateComponent(string fileName, string path, string type, string version)
		{
			// 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.InvokeRequired)
			{
				UpdateComponentCallback callBack = new UpdateComponentCallback(UpdateComponent);
				Invoke(callBack, new object[] { fileName, path, type, version });
			}
			else
			{
				Log.WriteStart("Updating component");

				ComponentConfigElement element = AppContext.ScopeNode.Tag as ComponentConfigElement;
				string componentId = element.ID;
				string componentName = element.GetStringSetting("ComponentName");

				try
				{
					Log.WriteInfo(string.Format("Updating {0}", componentName));
					//download installer
					Loader form = new Loader(this.AppContext, fileName);
					DialogResult result = form.ShowDialog(this);
					if (result == DialogResult.OK)
					{
						//run installer
						string tmpFolder = FileUtils.GetTempDirectory();
						string installerPath = Path.Combine(tmpFolder, path);
						Update();
						string method = "Update";
						Log.WriteStart(string.Format("Running installer {0}.{1} from {2}", type, method, path));
						Hashtable args = new Hashtable();
						args["ComponentId"] = componentId;
						args["ShellVersion"] = AppContext.AppForm.Version;
						args["BaseDirectory"] = FileUtils.GetCurrentDirectory();
						args["UpdateVersion"] = version;
						args["Installer"] = Path.GetFileName(fileName);
						args["InstallerType"] = type;
						args["InstallerPath"] = path;
						args["InstallerFolder"] = tmpFolder;
						args["IISVersion"] = Global.IISVersion;
						args["ParentForm"] = FindForm();

						result = (DialogResult)AssemblyLoader.Execute(installerPath, type, method, new object[] { args });
						Log.WriteInfo(string.Format("Installer returned {0}", result));
						Log.WriteEnd("Installer finished");
						Update();
						if (result == DialogResult.OK)
						{
							ReloadApplication();
						}
						FileUtils.DeleteTempDirectory();
					}
					Log.WriteEnd("Update completed");
				}
				catch (Exception ex)
				{
					Log.WriteError("Installer error", ex);
					AppContext.AppForm.ShowError(ex);
				}
			}
		}