Download() private static method

Downloads and updates the premium data file.
private static Download ( IList licenceKeys, FileInfo binaryFile ) : AutoUpdateStatus
licenceKeys IList /// The licence key to use for the update request. ///
binaryFile System.IO.FileInfo /// Location of the master data file. ///
return AutoUpdateStatus
        /// <summary>
        /// Activates the licence key provided.
        /// </summary>
        /// <param name="licenceKey">Licence key</param>
        public static LicenceKeyResults Activate(string licenceKey)
        {
            try
            {
                try
                {
                    CheckConfig();
                }
                catch (Exception ex)
                {
                    EventLog.Warn(ex);
                    return(LicenceKeyResults.Config);
                }

                // Download the new data file.
                var result = AutoUpdate.Download(new string[] { licenceKey });
                if (result != LicenceKeyResults.Success)
                {
                    return(result);
                }

                // Write the license key to the bin folder.
                try
                {
                    File.WriteAllText(Path.Combine(
                                          HostingEnvironment.ApplicationPhysicalPath,
                                          Path.Combine("bin", Constants.LicenceKeyFileName)), licenceKey);
                }
                catch (Exception ex)
                {
                    EventLog.Warn(ex);
                    return(LicenceKeyResults.WriteLicenceFile);
                }
            }
            catch (Exception ex)
            {
                EventLog.Warn(ex);
                return(LicenceKeyResults.GenericFailure);
            }

            return(LicenceKeyResults.Success);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Checks for a new version of the data file if licence keys are available.
 /// </summary>
 public static void Download()
 {
     AutoUpdate.Download(LicenceKey.Keys);
 }
 /// <summary>
 /// Checks for a new version of the data file if licence keys are available.
 /// </summary>
 /// <returns>
 /// Update status indicating whether or not the update was successful.
 /// </returns>
 public static LicenceKeyResults Download()
 {
     return(AutoUpdate.Download(LicenceKey.Keys));
 }