private static string identifier = "LM"; // LeanMail /// <summary> /// /// </summary> public static async void Prueba2() { manager = new LicenseManager(serverUri, identifier) { // the length of time that is allowed to pass without having contact to the server can be customized MaximumTimeElapsedWithoutServerContact = TimeSpan.FromDays(14) }; var licenciaGuardada = manager.TryGetSavedDataLicense(email); //si está guardada, validar que se haya actualizado hoy if (licenciaGuardada != null) { var x = licenciaGuardada.CachedTimestamp.AddDays(1).Date <= DateTime.Now.Date; if (x) { await ConsultarLicencia(); } } else { await ConsultarLicencia(); } }
public static async Task <LicenseResponse> Prueba3(string myEmail, string nombre, string apellido, string telefono) { email = string.IsNullOrEmpty(myEmail) ? email : myEmail.Trim(); manager = new LicenseManager(serverUri, identifier) { // the length of time that is allowed to pass without having contact to the server can be customized MaximumTimeElapsedWithoutServerContact = TimeSpan.FromDays(14) }; //recupero la licencia guardada var licenciaGuardada = manager.TryGetSavedDataLicense(email); if (licenciaGuardada != null) { if (string.IsNullOrEmpty(licenciaGuardada.Email) || licenciaGuardada.License.State == LicenseResponseState.Failure_NoLicense) { // the user/company does not have a license for the product // in this case you should prompt the user for if they want to create a trial account try { license = await manager.CreateTrialAsync(email, nombre, apellido, telefono); return(license); } catch (Exception ex) { //consulto y actualizo caché license = await ConsultarLicencia(); return(license); } } else { if (email != licenciaGuardada.Email) { //consulto y actualizo caché license = await ConsultarLicencia(); } else { //si está guardada, validar que se haya actualizado hoy var actualizadaRecientemente = licenciaGuardada.CachedTimestamp.AddDays(1).Date > DateTime.Now.Date; if (!actualizadaRecientemente) { //consulto y actualizo caché license = await ConsultarLicencia(); } else { license = licenciaGuardada.License; } } return(license); } } else { //no está cacheada, entonces la consulto, guardo y devuelvo los módulos license = await ConsultarLicencia(); return(license); } }