/// <summary>
/// Activates the data array containing the premium data.
/// </summary>
/// <param name="data">Data to activate</param>
public static LicenceKeyResults Activate(byte[] data)
{
try
{
DataSet dataSet = null;
// Validate the data provided is correct.
try
{
dataSet = StreamFactory.Create(data);
}
catch (MobileException ex)
{
EventLog.Warn(ex);
return(LicenceKeyResults.DataInvalid);
}
// Check the configuration.
try
{
CheckConfig();
}
catch (Exception ex)
{
EventLog.Warn(ex);
return(LicenceKeyResults.Config);
}
// Write the file to the binary data path.
try
{
File.WriteAllBytes(Detection.Configuration.Manager.BinaryFilePath, data);
File.SetLastAccessTimeUtc(Detection.Configuration.Manager.BinaryFilePath, dataSet.Published);
}
catch (IOException ex)
{
EventLog.Warn(ex);
return(LicenceKeyResults.WriteDataFile);
}
// Switch in the new data to complete activation.
WebProvider.Refresh();
EventLog.Info(String.Format(
"Activated binary data file '{0}' with new version " +
"dated the '{1:d}'.",
AutoUpdate.MasterBinaryDataFile.FullName,
dataSet.Published));
}
catch (Exception ex)
{
EventLog.Warn(ex);
return(LicenceKeyResults.GenericFailure);
}
return(LicenceKeyResults.Success);
}