예제 #1
0
 /// <summary>
 /// Downloads provider update info
 /// </summary>
 public static ProviderUpdateInfo DownloadProviderUpdateInfo(ProviderInfo provider)
 {
     if (provider != null)
     {
         ProviderUpdateInfo info = (ProviderUpdateInfo)Updaters.DownloadUpdateInfo(typeof(ProviderUpdateInfo), provider.UpdateInfoUrl);
         return(info);
     }
     return(null);
 }
예제 #2
0
        /// <summary>
        /// Download and install the provider
        /// </summary>
        public static bool Install(string providerName)
        {
            // Download the provider
            ProviderInfo       provider   = Providers.FindProvider(Providers.InstalledProviders, providerName);
            ProviderUpdateInfo updateInfo = DownloadProviderUpdateInfo(provider);

            // Check if update is required
            if (Common.CompareASProxyVersions(updateInfo.Version, provider.Version) == 1)
            {
                // Download the package and install it
                return(Install(updateInfo));
            }
            return(false);
        }
예제 #3
0
        /// <summary>
        /// Will automatically install all loaded providers
        /// </summary>
        public static void InstallLoadedProviders()
        {
            // Only loaded providers
            foreach (ProviderInfo provider in Providers.LoadedProviders)
            {
                ProviderUpdateInfo updateInfo = DownloadProviderUpdateInfo(provider);

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

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

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

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

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

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

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

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

				// If installing provider files was successful, we install assembly files
				Updaters.InstallAssemblyPackage(updateInfo.AssemblyFiles, package);
			}
			finally
			{
				package.Close();
			}
		}
예제 #8
0
	void DisplayProviderUpdate(ProviderUpdateInfo updateInfo, ProviderInfo installedInfo, bool installed, string message)
	{
		pgUpdateProvider.Visible = true;
		lblUpProviderName.Text = installedInfo.Name;
		lblUpProviderVersion.Text = installedInfo.Version;

		if (installed)
		{
			lblUpProviderStatus.Text = "Update was successful.";
			lblUpProviderStatus.ForeColor = Color.Green;
			btnUpProviderUpdate.Enabled = false;
		}
		else if (updateInfo == null)
		{
			lblUpProviderStatus.Text = "Unable to check for update.";
			lblUpProviderStatus.ForeColor = Color.Red;
			btnUpProviderUpdate.Enabled = false;
		}
		else
		{
			lblUpProviderName.Text = updateInfo.ProviderName;
			lblUpProviderVersion.Text = updateInfo.Version;
			if (Common.CompareASProxyVersions(updateInfo.Version, installedInfo.Version) == 1)
			{
				lblUpProviderStatus.Text = "Update is available.";
				lblUpProviderStatus.ForeColor = Color.Green;
				btnUpProviderUpdate.Enabled = true;
			}
			else
			{
				lblUpProviderStatus.Text = "Update is not available.";
				lblUpProviderStatus.ForeColor = Color.Red;
				btnUpProviderUpdate.Enabled = false;
			}
		}

		if (!string.IsNullOrEmpty(message))
			lblUpProviderStatus.Text = message;

	}