public ScutexLicense Validate(ScutexLicense scutexLicense) { try { if (!EventLog.SourceExists("Scutex")) EventLog.CreateEventSource("Scutex", "Application"); if (scutexLicense.IsTrialValid) { EventLog.WriteEntry("Scutex", "SCUTEX: Your trial is invalid, this can be due to tampering or system changes/corruption.", EventLogEntryType.Warning, 500); Environment.Exit(1001); } if (scutexLicense.WasTrialFristRun) EventLog.WriteEntry("Scutex", "SCUTEX: This is your first time running the product, your trail starts now.", EventLogEntryType.Warning, 500); if (scutexLicense.IsTrialExpired) { EventLog.WriteEntry("Scutex", "SCUTEX: Your trial has expired, please buy the product if you wish to continue using it.", EventLogEntryType.Warning, 500); Environment.Exit(1001); } } catch { } return scutexLicense; }
public RegisterResult Register(string licenseKey, LicenseBase scutexLicense, ScutexLicense license) { RegisterResult registerResult = new RegisterResult(); registerResult.ScutexLicense = license; bool result = _licenseKeyService.ValidateLicenseKey(licenseKey, scutexLicense, true); ClientLicense cl = null; if (result) { KeyData keyData = _licenseKeyService.GetLicenseKeyData(licenseKey, scutexLicense, false); if (keyData.LicenseKeyType != LicenseKeyTypes.Enterprise && keyData.LicenseKeyType != LicenseKeyTypes.HardwareLockLocal) { try { if (keyData.LicenseKeyType == LicenseKeyTypes.HardwareLock) cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, false, (ClientLicense)scutexLicense, _hardwareFingerprintService.GetHardwareFingerprint(FingerprintTypes.Default)); else cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, false, (ClientLicense)scutexLicense, null); if (cl.IsLicensed && cl.IsActivated) { registerResult.Result = ProcessCodes.ActivationSuccess; registerResult.ClientLicense = cl; } else { registerResult.Result = ProcessCodes.ActivationFailed; } } catch { registerResult.Result = ProcessCodes.ActivationFailed; } } else { cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, true, (ClientLicense)scutexLicense, null); registerResult.Result = ProcessCodes.LicenseKeyNotActivated; } } else { registerResult.Result = ProcessCodes.KeyInvalid; } if (cl != null) { license.IsLicensed = cl.IsLicensed; license.IsActivated = cl.IsActivated; license.ActivatedOn = cl.ActivatedOn; } return registerResult; }
public LicenseWindow(object licensingManager, ScutexLicense scutexLicense, ClientLicense clientLicense) { InitializeComponent(); _clientLicense = clientLicense; _licensingManager = licensingManager as LicensingManager; _scutexLicense = scutexLicense; SetIcon(); SetWindowIcon(); SetFormData(); SetFormDisplay(); SetTrialDelayTimer(); }
public RegisterContent(ClientLicense clientLicense, ScutexLicense scutexLicense) : this() { _clientLicense = clientLicense; _scutexLicense = scutexLicense; switch (_clientLicense.KeyGeneratorType) { case KeyGeneratorTypes.StaticSmall: txtLicenseKey.InputMask = @"www-wwwwww-wwww"; break; case KeyGeneratorTypes.StaticLarge: txtLicenseKey.InputMask = @"wwwww-wwwww-wwwww-wwwww-wwwww"; break; } }
public ScutexLicense Validate(ScutexLicense scutexLicense) { if (scutexLicense.IsTrialValid) { Debug.WriteLine(Resources.ConsoleInteractionService_Validate_TrialInvalid); } if (scutexLicense.WasTrialFristRun) Debug.WriteLine(Resources.ConsoleInteractionService_Validate_TrialFirstRun); if (scutexLicense.IsTrialExpired) { Debug.WriteLine(Resources.ConsoleInteractionService_Validate_TrialExpired); } return scutexLicense; }
public ScutexLicense Validate(ScutexLicense scutexLicense) { WriteScutexHeader(); if (scutexLicense.IsTrialValid) { Console.WriteLine(Resources.ConsoleInteractionService_Validate_TrialInvalid); Thread.Sleep(2000); Environment.Exit(1001); } if (scutexLicense.WasTrialFristRun) Console.WriteLine(Resources.ConsoleInteractionService_Validate_TrialFirstRun); if (scutexLicense.IsTrialExpired) { Console.WriteLine(Resources.ConsoleInteractionService_Validate_TrialExpired); Thread.Sleep(2000); Environment.Exit(1001); } return scutexLicense; }
private void ShowLicensingWindow(ScutexLicense scutexLicense) { ThreadRunner runner = new ThreadRunner(); runner.RunInSTA( delegate { LicenseWindow window = new LicenseWindow(this, scutexLicense, _clientLicenseService.GetClientLicense()); window.Show(); System.Windows.Threading.Dispatcher.Run(); }); }
public ScutexComponentLicense(ScutexLicense license) { License = license; }
public ScutexLicense GetScutexLicense(ClientLicense clientLicense) { ScutexLicense scutexLicense = new ScutexLicense(); scutexLicense.TrialFaultReason = TrialFaultReasons.None; scutexLicense.IsTrialValid = true; scutexLicense.LastRun = clientLicense.LastRun; scutexLicense.TrialSettings = clientLicense.TrialSettings; scutexLicense.TrailNotificationSettings = clientLicense.TrailNotificationSettings; scutexLicense.IsCommunityEdition = ApplicationConstants.IsCommunityEdition; if (!clientLicense.FirstRun.HasValue) { Logging.LogDebug(string.Format("Is First Run!")); clientLicense.FirstRun = _networkTimeProvider.GetNetworkTime(); scutexLicense.WasTrialFristRun = true; Logging.LogDebug(string.Format("FirstRun SetTo: {0}", clientLicense.FirstRun.Value)); } else { Logging.LogDebug(string.Format("Is Existing Run!")); Logging.LogDebug(string.Format("FirstRun Date: {0}", clientLicense.FirstRun.Value)); Logging.LogDebug(string.Format("NetTime Date: {0}", _networkTimeProvider.GetNetworkTime())); } if (clientLicense.LastRun.HasValue && _networkTimeProvider.GetNetworkTime() < clientLicense.LastRun) { Logging.LogDebug(string.Format("TIME FAULT")); Logging.LogDebug(string.Format("LastRun Date: {0}", clientLicense.LastRun.Value)); Logging.LogDebug(string.Format("NetRun Date: {0}", _networkTimeProvider.GetNetworkTime())); Logging.LogDebug(string.Format("Delta: {0}", (_networkTimeProvider.GetNetworkTime() - clientLicense.LastRun.Value))); scutexLicense.IsTrialValid = false; scutexLicense.TrialFaultReason = TrialFaultReasons.TimeFault; } clientLicense.LastRun = _networkTimeProvider.GetNetworkTime(); Logging.LogDebug(string.Format("Old Run Count: {0}", clientLicense.RunCount)); clientLicense.RunCount++; Logging.LogDebug(string.Format("New Run Count: {0}", clientLicense.RunCount)); scutexLicense.FirstRun = clientLicense.FirstRun; switch (clientLicense.TrialSettings.ExpirationOptions) { case TrialExpirationOptions.Days: TimeSpan ts = clientLicense.FirstRun.Value - _networkTimeProvider.GetNetworkTime().AddDays(-int.Parse(clientLicense.TrialSettings.ExpirationData)); scutexLicense.TrialRemaining = ts.Days; if (ts.Days <= 0) { scutexLicense.IsTrialExpired = true; Logging.LogDebug(string.Format("Trial Expired")); } else { scutexLicense.IsTrialExpired = false; Logging.LogDebug(string.Format("Trial Not Expired")); } break; } // TODO: Need to set a fair amount of data here, like licensed edition, level, etc if (clientLicense.IsLicensed) { scutexLicense.IsLicensed = clientLicense.IsLicensed; Logging.LogDebug(string.Format("Product is licensed")); } else { Logging.LogDebug(string.Format("Product is not licensed")); } Logging.LogDebug(string.Format("Saving client license")); _clientLicenseService.SaveClientLicense(clientLicense); return scutexLicense; }
public ScutexLicense Validate(string licenseKey, ScutexLicense scutexLicense, ClientLicense clientLicense) { return scutexLicense; }