Used to fetch new device data from 51Degrees.mobi if a premium licence has been installed.
        /// <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);
        }
Пример #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));
 }
 /// <summary>
 /// Validates the download for success and checks the data set can
 /// be loaded. Uses the memory factory as this validates more elements
 /// of the data file.
 /// </summary>
 /// <param name="result">Result of the download process.</param>
 private void ValidateDownload(AutoUpdate.AutoUpdateStatus result)
 {
     if (result != AutoUpdate.AutoUpdateStatus.AUTO_UPDATE_SUCCESS)
     {
         Assert.Fail(
             "Data file update process failed with status '{0}'.",
             result.ToString());
     }
     using (var dataSet = MemoryFactory.Create(TestDataFile.FullName))
     {
         if (dataSet.Name.Equals("Lite"))
         {
             Console.WriteLine("Data set name was: " + dataSet.Name);
             Assert.Fail("Data set name was 'Lite'.");
         }
     }
 }