private ExecFactory() { #if LICENSING_ENABLED #if TIME_BOUNDED DateTime expiry = new DateTime(2016, 12, 31); #else DateTime expiry = DateTime.MaxValue; #endif // TIME_BOUNDED if (!_licenseChecked || DateTime.Now > expiry) { if (Debugger.IsAttached) { if (!LicenseManager.Check()) { MessageBox.Show("SageĀ® Simulation and Modeling Library license is invalid.", "Licensing Error"); } } try { LicenseManager.ReportUsage( ); } catch (WebException) { Console.WriteLine("Failure to report usage."); } catch (Exception) { Console.WriteLine("Failure to report usage."); } _licenseChecked = true; } #if TIME_BOUNDED Console.WriteLine("Trial license expiration, {0}.", expiry); #endif // TIME_BOUNDED #endif // LICENSING_ENABLED }
static void CheckLicense(string licenseItem) { LicenseError error = LicenseManager.Check(licenseItem); if (error == null) { Console.WriteLine(string.Format(string.Format("{0} licensed successfully.", licenseItem))); } else { OutputError(licenseItem, error); } }
private static void OutputLicenseItemValidation(string licenseItemName) { LicenseError licenseError = LicenseManager.Check(licenseItemName); Console.Write(licenseItemName + ": "); if (licenseError == null) { Console.WriteLine("A valid license granted"); } else { Console.WriteLine(string.Format("Cannot grant a valid license, reason=\"{0}\", message=\"{1}\"", licenseError.Reason, licenseError.Message)); } }