private static LicenseInfo _GetLicense(string userName, string password) { LicenseInfo license = null; if (_InnerLicenser.RequireAuthentication) { _ValidateCredentials(userName, password); license = _InnerLicenser.GetLicense(userName, password); } else { license = _InnerLicenser.GetLicense(); } return(license); }
/// <summary> /// Implements license retrieval. /// </summary> /// <param name="getLicense">The function to be used for license retrival.</param> /// <param name="userName">The user name to be used to authenticate within /// license service.</param> /// <param name="password">The password to be used to authenticate within /// license service.</param> /// <returns>License object for the free single vehicle role.</returns> /// <exception cref="T:ESRI.ArcLogistics.LicenseException"> /// <list type="bullet"> /// <item> /// <description>License service failed processing request.</description> /// </item> /// <item> /// <description>Specified credentials are invalid.</description> /// </item> /// <item> /// <description>There is no license for the user with the specified /// credentials or all licenses have expired.</description> /// </item> /// </list></exception> /// <exception cref="T:ESRI.ArcLogistics.CommunicationError">Failed to /// communicate with the License service.</exception> private LicenseInfo _GetLicense( Func <string, string, LicenseInfo> getLicense, string userName, string password) { var licenseCache = _licenseCacheStorage.Load(); LicenseCacheEntry cacheEntry = null; licenseCache.Entries.TryGetValue(userName, out cacheEntry); LicenseInfo licenseInfo = null; // get license try { licenseInfo = getLicense(userName, password); _license = licenseInfo.License; _licenseValidationDate = licenseInfo.LicenseValidationDate; } catch (LicenseException ex) { if (ex.ErrorCode == LicenseError.LicenseExpired && cacheEntry != null) { Licenser.ExpiredLicense = cacheEntry.License; } throw; } // set new account if (RequireAuthentication) { _licAccount = new NetworkCredential(userName, password); } // notify clients _NotifyLicenseActivated(); // We need to store license in cache in order to display it's routes // number (and probably other info) when it expires. However, if // the license is a free single vehicle one we should not store it // in the cache to not overwrite a "real" license info. if (_license.PermittedRouteNumber > 1) { var licenseExpirationWarningWasShown = false; if (cacheEntry != null && cacheEntry.License == _license) { licenseExpirationWarningWasShown = cacheEntry.LicenseExpirationWarningWasShown; } cacheEntry = new LicenseCacheEntry() { LicenseExpirationWarningWasShown = licenseExpirationWarningWasShown, License = _license, }; licenseCache.Entries[userName] = cacheEntry; _licenseCacheStorage.Save(licenseCache); } return(licenseInfo); }