Exemple #1
0
 /// <summary>
 /// Downloads plugin update info
 /// </summary>
 public static PluginUpdateInfo DownloadPluginUpdateInfo(PluginInfo plugin)
 {
     if (plugin != null)
     {
         PluginUpdateInfo info = (PluginUpdateInfo)Updaters.DownloadUpdateInfo(typeof(PluginUpdateInfo), plugin.UpdateInfoUrl);
         return(info);
     }
     return(null);
 }
Exemple #2
0
        /// <summary>
        /// Download and install the plugin
        /// </summary>
        public static bool Install(string pluginName)
        {
            // Download the plugin
            PluginInfo       plugin     = Plugins.FindPlugin(Plugins.InstalledPlugins, pluginName);
            PluginUpdateInfo updateInfo = DownloadPluginUpdateInfo(plugin);

            // Check if update is required
            if (Common.CompareASProxyVersions(updateInfo.Version, plugin.Version) == 1)
            {
                // Download the package and install it
                return(Install(updateInfo));
            }
            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Will automatically install all loaded plugins
        /// </summary>
        public static void InstallLoadedPlugins()
        {
            // Only loaded plugins
            foreach (PluginInfo plugin in Plugins.LoadedPlugins)
            {
                PluginUpdateInfo updateInfo = DownloadPluginUpdateInfo(plugin);

                // Check if update is required
                if (Common.CompareASProxyVersions(updateInfo.Version, plugin.Version) == 1)
                {
                    // Download and install the plugin
                    Install(updateInfo);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Saves the package file to ASProxy location
        /// </summary>
        static void ApplyPackage(PluginUpdateInfo updateInfo, string zipFile)
        {
            ZipFile package = new ZipFile(zipFile);

            try
            {
                // First we install plugin files
                Updaters.InstallExtenderPackage(updateInfo.PluginFiles, package);

                // If installing plugin files was successful, we install assembly files
                Updaters.InstallAssemblyPackage(updateInfo.AssemblyFiles, package);
            }
            finally
            {
                package.Close();
            }
        }
Exemple #5
0
        /// <summary>
        /// Download the plugin update package and install it
        /// </summary>
        public static bool Install(PluginUpdateInfo pluginInfo)
        {
            string tempFile = Path.GetTempFileName();
            try
            {
                // download the package
                Updaters.GetDataFile(pluginInfo.UpdatePackageUrl, tempFile);

                // apply the downloaded package
                ApplyPackage(pluginInfo, tempFile);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                // delete downloaded package
                File.Delete(tempFile);
            }
        }
Exemple #6
0
        /// <summary>
        /// Download the plugin update package and install it
        /// </summary>
        public static bool Install(PluginUpdateInfo pluginInfo)
        {
            string tempFile = Path.GetTempFileName();

            try
            {
                // download the package
                Updaters.GetDataFile(pluginInfo.UpdatePackageUrl, tempFile);

                // apply the downloaded package
                ApplyPackage(pluginInfo, tempFile);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
            finally
            {
                // delete downloaded package
                File.Delete(tempFile);
            }
        }
		/// <summary>
		/// Saves the package file to ASProxy location
		/// </summary>
		static void ApplyPackage(PluginUpdateInfo updateInfo, string zipFile)
		{
			ZipFile package = new ZipFile(zipFile);
			try
			{
				// First we install plugin files
				Updaters.InstallExtenderPackage(updateInfo.PluginFiles, package);

				// If installing plugin files was successful, we install assembly files
				Updaters.InstallAssemblyPackage(updateInfo.AssemblyFiles, package);
			}
			finally
			{
				package.Close();
			}
		}
	void DisplayPluginUpdate(PluginUpdateInfo updateInfo, PluginInfo installedInfo, bool installed, string message)
	{
		pgUpdatePlugin.Visible = true;
		lblUpPluginName.Text = installedInfo.Name;
		lblUpPluginVersion.Text = installedInfo.Version;

		if (installed)
		{
			lblUpPluginStatus.Text = "Update was successful";
			lblUpPluginStatus.ForeColor = Color.Green;
			btnUpPluginUpdate.Enabled = false;
		}
		else if (updateInfo == null)
		{
			lblUpPluginStatus.Text = "Unable to check for update.";
			lblUpPluginStatus.ForeColor = Color.Red;
			btnUpPluginUpdate.Enabled = false;
		}
		else
		{
			lblUpPluginName.Text = updateInfo.PluginName;
			lblUpPluginVersion.Text = updateInfo.Version;
			if (Common.CompareASProxyVersions(updateInfo.Version, installedInfo.Version) == 1)
			{
				lblUpPluginStatus.Text = "Update is available.";
				lblUpPluginStatus.ForeColor = Color.Green;
				btnUpPluginUpdate.Enabled = true;
			}
			else
			{
				lblUpPluginStatus.Text = "Update is not available.";
				lblUpPluginStatus.ForeColor = Color.Red;
				btnUpPluginUpdate.Enabled = false;
			}
		}
		if (!string.IsNullOrEmpty(message))
			lblUpPluginStatus.Text = message;

	}