static void Init() { // LexActivator.SetProductFile ("ABSOLUTE_PATH_OF_PRODUCT.DAT_FILE"); LexActivator.SetProductData("PASTE_CONTENT_OF_PRODUCT.DAT_FILE"); LexActivator.SetProductId("PASTE_PRODUCT_ID", LexActivator.PermissionFlags.LA_USER); LexActivator.SetAppVersion("PASTE_YOUR_APP_VERION"); }
private void Activate_Click(object sender, RoutedEventArgs e) { int status; status = LexActivator.SetProductKey(keyTb.Text.Trim()); if (status == LexActivator.LA_OK) { } else { MessageBox.Show("Incorrect key."); return; } status = LexActivator.ActivateProduct(); if (status == LexActivator.LA_OK) { MainWindow.legit = true; Close(); } else if (status == LexActivator.LA_EXPIRED) { MessageBox.Show("Incorrect key."); } else { MessageBox.Show("Incorrect key."); } }
public bool ActivateTrialLicense(out bool hasError, out int status, string firstName, string lastName, string eMail, string organization, Guid userId) { status = LexActivator.SetTrialActivationMetadata("FirstName", firstName); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata FirstName Code {status}"); hasError = true; return(false); } status = LexActivator.SetTrialActivationMetadata("LastName", lastName); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata LastName Code {status}"); hasError = true; return(false); } status = LexActivator.SetTrialActivationMetadata("eMail", eMail); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata eMail Code {status}"); hasError = true; return(false); } status = LexActivator.SetTrialActivationMetadata("Organization", organization); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata Organization Code {status}"); hasError = true; return(false); } status = LexActivator.SetTrialActivationMetadata("UserId", userId.ToString()); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata UserId Code {status}"); hasError = true; return(false); } status = LexActivator.ActivateTrial(); var statusEnum = (StatusCodesEnum)status; if (statusEnum == StatusCodesEnum.LA_OK) { hasError = false; Init(); return(true); } else if (status == LexActivator.StatusCodes.LA_TRIAL_EXPIRED) { hasError = false; return(false); } else { hasError = false; return(false); } }
private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { var sra = LexActivator.ActivateTrial(); e.Result = sra; return; }
private void Save(object sender, RoutedEventArgs e) { TxtFirstNameError.Visibility = string.IsNullOrWhiteSpace(TxtFirstName.Value) ? Visibility.Visible : Visibility.Collapsed; TxtLastNameError.Visibility = string.IsNullOrWhiteSpace(TxtLastName.Value) ? Visibility.Visible : Visibility.Collapsed; TxtEMailError.Visibility = string.IsNullOrWhiteSpace(TxtEMail.Value) ? Visibility.Visible : Visibility.Collapsed; TxtOrganizationError.Visibility = string.IsNullOrWhiteSpace(TxtOrganization.Value) ? Visibility.Visible : Visibility.Collapsed; RegexUtilities util = new RegexUtilities(); TxtEMailError.Visibility = util.IsValidEmail(TxtEMail.Value) == false ? Visibility.Visible : Visibility.Collapsed; if (TxtFirstNameError.Visibility == Visibility.Visible || TxtLastNameError.Visibility == Visibility.Visible || TxtEMailError.Visibility == Visibility.Visible || TxtOrganizationError.Visibility == Visibility.Visible ) { return; } var backgroundWorker = new BackgroundWorker { WorkerReportsProgress = false, WorkerSupportsCancellation = false }; backgroundWorker.DoWork += BackgroundWorker_DoWork; backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted; int lest; lest = LexActivator.SetTrialActivationMetadata("FirstName", TxtFirstName.Value); if (lest != LexActivator.StatusCodes.LA_OK) { return; } lest = LexActivator.SetTrialActivationMetadata("LastName", TxtLastName.Value); if (lest != LexActivator.StatusCodes.LA_OK) { return; } lest = LexActivator.SetTrialActivationMetadata("eMail", TxtEMail.Value); if (lest != LexActivator.StatusCodes.LA_OK) { return; } lest = LexActivator.SetTrialActivationMetadata("Organization", TxtOrganization.Value); if (lest != LexActivator.StatusCodes.LA_OK) { return; } RadBusyIndicator.IsBusy = true; backgroundWorker.RunWorkerAsync(); }
private bool CheckLicense() { var isLicenseGenuine = LexActivator.IsLicenseGenuine(); if (isLicenseGenuine == LexActivator.StatusCodes.LA_OK) { Status = LicenseHelperStatusEnum.HaveLicense; GetLicenseInfo(); return(true); } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_SUSPENDED) { Status = LicenseHelperStatusEnum.LicenseSuspended; return(false); } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_EXPIRED) { Status = LicenseHelperStatusEnum.LicenseExpired; return(false); } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_GRACE_PERIOD_OVER) { Status = LicenseHelperStatusEnum.LicenseGracePeriodOver; return(false); } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_FAIL) { Status = LicenseHelperStatusEnum.DontHaveLicense; return(false); } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_E_PRODUCT_ID) { Status = LicenseHelperStatusEnum.WrongProductId; return(false); } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_E_LICENSE_KEY) { Status = LicenseHelperStatusEnum.WrongProductKey; return(false); } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_E_TIME) { Status = LicenseHelperStatusEnum.ComputerClockError; return(false); } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_E_TIME_MODIFIED) { Status = LicenseHelperStatusEnum.ComputerClockCracked; return(false); } else { Status = LicenseHelperStatusEnum.DontHaveLicense; return(false); } }
public ActivationForm() { InitializeComponent(); int status; // status = LexActivator.SetProductFile ("ABSOLUTE_PATH_OF_PRODUCT.DAT_FILE"); status = LexActivator.SetProductData("PASTE_CONTENT_OF_PRODUCT.DAT_FILE"); if (status != LexActivator.StatusCodes.LA_OK) { this.statusLabel.Text = "Error setting product file: " + status.ToString(); return; } status = LexActivator.SetProductId("PASTE_PRODUCT_ID", LexActivator.PermissionFlags.LA_USER); if (status != LexActivator.StatusCodes.LA_OK) { this.statusLabel.Text = "Error setting product id: " + status.ToString(); return; } // Setting license callback is recommended for floating licenses // status = LexActivator.SetLicenseCallback(LicenseCallback); // if (status != LexActivator.StatusCodes.LA_OK) // { // this.statusLabel.Text = "Error setting callback function: " + status.ToString(); // return; // } status = LexActivator.IsLicenseGenuine(); if (status == LexActivator.StatusCodes.LA_OK || status == LexActivator.StatusCodes.LA_EXPIRED || status == LexActivator.StatusCodes.LA_SUSPENDED || status == LexActivator.StatusCodes.LA_GRACE_PERIOD_OVER) { // uint expiryDate = 0; // LexActivator.GetLicenseExpiryDate(ref expiryDate); // int daysLeft = (int)(expiryDate - unixTimestamp()) / 86500; this.statusLabel.Text = "License genuinely activated! Activation Status: " + status.ToString(); this.activateBtn.Text = "Deactivate"; this.activateTrialBtn.Enabled = false; return; } status = LexActivator.IsTrialGenuine(); if (status == LexActivator.StatusCodes.LA_OK) { uint trialExpiryDate = 0; LexActivator.GetTrialExpiryDate(ref trialExpiryDate); int daysLeft = (int)(trialExpiryDate - unixTimestamp()) / 86500; this.statusLabel.Text = "Trial period! Days left:" + daysLeft.ToString(); this.activateTrialBtn.Enabled = false; } else if (status == LexActivator.StatusCodes.LA_TRIAL_EXPIRED) { this.statusLabel.Text = "Trial has expired!"; } else { this.statusLabel.Text = "Trial has not started or has been tampered: " + status.ToString(); } }
public bool SetIndexer(string serverId) { var status = LexActivator.SetTrialActivationMetadata("Indexer01", serverId); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata Indexer01 Code {status}"); return(false); } return(true); }
static void Activate() { LexActivator.SetLicenseKey("PASTE_LICENSE_KEY"); LexActivator.SetActivationMetadata("key1", "value1"); int status = LexActivator.ActivateLicense(); if (LexStatusCodes.LA_OK == status || LexStatusCodes.LA_EXPIRED == status || LexStatusCodes.LA_SUSPENDED == status) { Console.WriteLine("License activated successfully: ", status); } else { Console.WriteLine("License activation failed: ", status); } }
public bool Reset(out int statusCode) { var reset = LexActivator.Reset(); if (reset == LexActivator.StatusCodes.LA_OK) { statusCode = reset; Init(); return(true); } else { statusCode = reset; Init(); return(false); } }
public ActivationForm() { InitializeComponent(); try { // LexActivator.SetProductFile ("ABSOLUTE_PATH_OF_PRODUCT.DAT_FILE"); LexActivator.SetProductData("PASTE_CONTENT_OF_PRODUCT.DAT_FILE"); LexActivator.SetProductId("PASTE_PRODUCT_ID", LexActivator.PermissionFlags.LA_USER); // LexActivator.SetLicenseCallback(LicenseCallback); int status = LexActivator.IsLicenseGenuine(); if (status == LexStatusCodes.LA_OK || status == LexStatusCodes.LA_EXPIRED || status == LexStatusCodes.LA_SUSPENDED || status == LexStatusCodes.LA_GRACE_PERIOD_OVER) { uint expiryDate = LexActivator.GetLicenseExpiryDate(); int daysLeft = (int)(expiryDate - unixTimestamp()) / 86400; this.statusLabel.Text = "License genuinely activated! Activation Status: " + status.ToString(); this.activateBtn.Text = "Deactivate"; this.activateTrialBtn.Enabled = false; // Checking for software release update // LexActivator.CheckForReleaseUpdate("windows", "1.0.0", "stable", SoftwareReleaseUpdateCallback); return; } status = LexActivator.IsTrialGenuine(); if (status == LexStatusCodes.LA_OK) { uint trialExpiryDate = LexActivator.GetTrialExpiryDate(); int daysLeft = (int)(trialExpiryDate - unixTimestamp()) / 86400; this.statusLabel.Text = "Trial period! Days left:" + daysLeft.ToString(); this.activateTrialBtn.Enabled = false; } else if (status == LexStatusCodes.LA_TRIAL_EXPIRED) { this.statusLabel.Text = "Trial has expired!"; } else { this.statusLabel.Text = "Trial has not started or has been tampered: " + status.ToString(); } } catch (LexActivatorException ex) { this.statusLabel.Text = "Error code: " + ex.Code.ToString() + " Error message: " + ex.Message; } }
private bool CheckTrialLicense() { var isTrialGenuine = LexActivator.IsTrialGenuine(); if (isTrialGenuine == LexActivator.StatusCodes.LA_OK) { Status = LicenseHelperStatusEnum.HaveTrialLicense; //var timeToExpire = expireDate.Subtract(DateTime.Now); GetTrialLicenseInfo(); return(true); } else if (isTrialGenuine == LexActivator.StatusCodes.LA_TRIAL_EXPIRED) { Status = LicenseHelperStatusEnum.TrialLicenseExpired; return(false); } else if (isTrialGenuine == LexActivator.StatusCodes.LA_FAIL) { Status = LicenseHelperStatusEnum.DontHaveLicense; return(false); } else if (isTrialGenuine == LexActivator.StatusCodes.LA_E_TIME) { Status = LicenseHelperStatusEnum.ComputerClockError; return(false); } else if (isTrialGenuine == LexActivator.StatusCodes.LA_E_TIME_MODIFIED) { Status = LicenseHelperStatusEnum.ComputerClockCracked; return(false); } else if (isTrialGenuine == LexActivator.StatusCodes.LA_E_PRODUCT_ID) { Status = LicenseHelperStatusEnum.WrongProductId; return(false); } else { Status = LicenseHelperStatusEnum.DontHaveLicense; return(false); } }
private void activateBtn_Click(object sender, EventArgs e) { int status; if (this.activateBtn.Text == "Deactivate") { status = LexActivator.DeactivateLicense(); if (status == LexActivator.StatusCodes.LA_OK) { this.statusLabel.Text = "License deactivated successfully"; this.activateBtn.Text = "Activate"; this.activateTrialBtn.Enabled = true; return; } this.statusLabel.Text = "Error deactivating license: " + status.ToString(); return; } status = LexActivator.SetLicenseKey(productKeyBox.Text); if (status != LexActivator.StatusCodes.LA_OK) { this.statusLabel.Text = "Error setting license key: " + status.ToString(); return; } status = LexActivator.SetActivationMetadata("key1", "value1"); if (status != LexActivator.StatusCodes.LA_OK) { this.statusLabel.Text = "Error setting activation metadata: " + status.ToString(); return; } status = LexActivator.ActivateLicense(); if (status == LexActivator.StatusCodes.LA_OK || status == LexActivator.StatusCodes.LA_EXPIRED || status == LexActivator.StatusCodes.LA_SUSPENDED) { this.statusLabel.Text = "Activation Successful :" + status.ToString(); this.activateBtn.Text = "Deactivate"; this.activateTrialBtn.Enabled = false; } else { this.statusLabel.Text = "Error activating the license: " + status.ToString(); return; } }
private void activateTrialBtn_Click(object sender, EventArgs e) { try { LexActivator.SetTrialActivationMetadata("key2", "value2"); int status = LexActivator.ActivateTrial(); if (status != LexStatusCodes.LA_OK) { this.statusLabel.Text = "Error activating the trial: " + status.ToString(); return; } else { this.statusLabel.Text = "Trial started Successful"; } } catch (LexActivatorException ex) { this.statusLabel.Text = "Error code: " + ex.Code.ToString() + " Error message: " + ex.Message; } }
private void activateTrialBtn_Click(object sender, EventArgs e) { int status; status = LexActivator.SetTrialActivationMetadata("key2", "value2"); if (status != LexActivator.StatusCodes.LA_OK) { this.statusLabel.Text = "Error setting activation metadata: " + status.ToString(); return; } status = LexActivator.ActivateTrial(); if (status != LexActivator.StatusCodes.LA_OK) { this.statusLabel.Text = "Error activating the trial: " + status.ToString(); return; } else { this.statusLabel.Text = "Trial started Successful"; } }
public MainWindow() { ExportedData.Init(); AutoScroll = true; Application.Current.DispatcherUnhandledException += (o, args) => { Exception ex = (Exception)args.Exception; log.Debug("UI exception: "); log.Debug(ex); //throw ex; }; int status; legit = false; try { LexActivator.SetGracePeriodForNetworkError(0); LexActivator.SetDayIntervalForServerCheck(1); } catch (Exception e) { log.Debug(e); } status = LexActivator.SetProductFile("Product.dat"); if (status != LexActivator.LA_OK) { MessageBox.Show("Corrupted files! Please redownload the software."); Environment.Exit(0); } status = LexActivator.SetVersionGUID("014FF53D-5C6C-5266-7A89-E9601F37F5B1", LexActivator.PermissionFlags.LA_USER); if (status != LexActivator.LA_OK) { MessageBox.Show("Corrupted data!"); Environment.Exit(0); } LexActivator.ActivateProduct(); status = LexActivator.IsProductGenuine(); if (status == LexActivator.LA_OK || status == LexActivator.LA_GP_OVER) { legit = true; } status = LexActivator.IsTrialGenuine(); if (status == LexActivator.LA_OK) { legit = true; uint daysLeft = 0; LexActivator.GetTrialDaysLeft(ref daysLeft, LexActivator.TrialType.LA_V_TRIAL); MessageBox.Show($"Trial days left: {daysLeft}"); } else if (status == LexActivator.LA_T_EXPIRED && !legit) { MessageBox.Show("Trial has expired!"); } if (!legit) { var _loginForm = new LoginForm(); _loginForm.ShowDialog(); } if (!legit) { MessageBox.Show("Failed atuh."); Environment.Exit(0); } pSelf = this; ViewModel = new ViewModel(); this.DataContext = ViewModel; //var bot = new L2Bot(new Injector(23, 123)); //bot.Engine.Init(bot.PlayerData, // new H5ActionsController(bot.PlayerData, // new Client(new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)))); //bot.PlayerData.Skills.Add(123, new Skill() {SkillId = 22}); InitializeComponent(); //LogHelper.GetLogger($"\\ RONIN .cs").Info($"L2 Ronin BETA {Assembly.GetEntryAssembly().GetName().Version}"); versionLabel.Text = $"L2 Ronin BETA Release v{Assembly.GetEntryAssembly().GetName().Version}"; this.Title = RandomString(10); //log.Debug(Title); CrackCheckThread = new Thread(delegate() { while (true) { Thread.Sleep(30 * 60 * 1000); LexActivator.ActivateProduct(); status = LexActivator.IsProductGenuine(); if (status != LexActivator.LA_OK && status != LexActivator.LA_GP_OVER) { Environment.Exit(0); } } }); CrackCheckThread.Start(); Style itemContainerStyle = new Style(typeof(ListBoxItem)); itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.MouseDoubleClickEvent, new MouseButtonEventHandler(ListBox_MouseDoubleClick))); BotsList.ItemContainerStyle = itemContainerStyle; log.Debug(Assembly.GetEntryAssembly().GetName().Version); log.Debug(getOSInfo()); string OStype = ""; if (Environment.Is64BitOperatingSystem) { OStype = "64-Bit, "; } else { OStype = "32-Bit, "; } OStype += Environment.ProcessorCount.ToString() + " Processor"; log.Debug(OStype); var l2rerouterThread = new Thread(Injectora.RerouteL2s); l2rerouterThread.SetApartmentState(ApartmentState.STA); l2rerouterThread.Start(); //Hierarchy h = (Hierarchy)LogManager.GetRepository(); //h.Root.Level = Level.All; //h.Root.AddAppender(new TextBoxAppender()); //h.Configured = true; }
private bool Init(string sourceFolder, out bool hasError, out int statusCode) { lock (balanceLock) { if (isInitted) { hasError = hasErrorInternal; statusCode = statusCodeInternal; return(true); } try { if (File.Exists("LexActivator.dll") == false) { try { File.Copy(Path.Combine(sourceFolder, "LexActivator_86.dll"), "LexActivator.dll", true); } catch (Exception ex) { logger.Error(ex, "LexActivator_86 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } var isDebug = false; isDebug = false; #if DEBUG isDebug = true; #endif #if LA_ANY_CPU try { if (File.Exists("LexActivator64.dll") == false) { File.Copy(Path.Combine(sourceFolder, "LexActivator_64.dll"), "LexActivator64.dll", true); } } catch (Exception ex) { logger.Error(ex, "LexActivator_64 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } if (isDebug == false) { try { File.Copy(Path.Combine(sourceFolder, "msvcp100_64.dll"), "msvcp100.dll", true); } catch (Exception ex) { logger.Error(ex, "msvcp100_64 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } if (isDebug == false) { try { File.Copy(Path.Combine(sourceFolder, "msvcr100_64.dll"), "msvcr100.dll", true); } catch (Exception ex) { logger.Error(ex, "msvcr100_64 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } #else if (isDebug == false) { try { File.Copy(Path.Combine(sourceFolder, "msvcp100_86.dll"), "msvcp100.dll", true); } catch (Exception ex) { logger.Error(ex, "msvcp100_86 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } if (isDebug == false) { try { File.Copy(Path.Combine(sourceFolder, "msvcr100_86.dll"), "msvcr100.dll", true); } catch (Exception ex) { logger.Error(ex, "msvcr100_86 copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } } #endif try { if (File.Exists("Product.dat") == false) { File.Copy(Path.Combine(sourceFolder, "Product.dat"), "Product.dat", true); } } catch (Exception ex) { logger.Error(ex, "Product.dat copy error"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } int setProductFile = 0; try { setProductFile = LexActivator.SetProductFile("Product.dat"); } catch (DllNotFoundException dllNotFoundException) { logger.Error(dllNotFoundException, $"SetProductFile error. Code: {setProductFile}"); logger.Error(dllNotFoundException.ToString()); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } catch (Exception ex) { logger.Error(ex, $"SetProductFile error. Code: {setProductFile}"); hasError = hasErrorInternal; statusCode = statusCodeInternal; return(false); } if (setProductFile != LexActivator.StatusCodes.LA_OK) { logger.Error($"SetProductFile error. Code: {setProductFile}"); hasError = true; statusCode = setProductFile; statusCodeInternal = statusCode; hasErrorInternal = hasError; isInitted = true; return(false); } var setProductId = LexActivator.SetProductId("f4a935cd-21ad-4bd2-8b5b-c929e0275340", LexActivator.PermissionFlags.LA_USER); if (setProductId != LexActivator.StatusCodes.LA_OK) { logger.Error($"SetProductId error. Code: {setProductFile}"); hasError = true; statusCode = setProductId; statusCodeInternal = statusCode; hasErrorInternal = hasError; isInitted = true; return(false); } else { hasError = false; statusCode = setProductId; } //var licenseHelperReset = Reset(out int statusCodeReset); statusCodeInternal = statusCode; hasErrorInternal = hasError; isInitted = true; return(true); } catch (Exception ex) { hasError = true; statusCode = 0; logger.Error(ex); } statusCodeInternal = statusCode; hasErrorInternal = hasError; isInitted = true; return(false); } }
static void Main(string[] args) { try { Init(); LexActivator.SetLicenseCallback(LicenseCallback); int status = LexActivator.IsLicenseGenuine(); if (LexStatusCodes.LA_OK == status) { Console.WriteLine("License is genuinely activated!"); uint expiryDate = LexActivator.GetLicenseExpiryDate(); int daysLeft = (int)(expiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400; Console.WriteLine("Days left:" + daysLeft); // Checking for software release update // LexActivator.CheckForReleaseUpdate("windows", "1.0.0", "stable", SoftwareReleaseUpdateCallback); } else if (LexStatusCodes.LA_EXPIRED == status) { Console.WriteLine("License is genuinely activated but has expired!"); } else if (LexStatusCodes.LA_GRACE_PERIOD_OVER == status) { Console.WriteLine("License is genuinely activated but grace period is over!"); } else if (LexStatusCodes.LA_SUSPENDED == status) { Console.WriteLine("License is genuinely activated but has been suspended!"); } else { int trialStatus; trialStatus = LexActivator.IsTrialGenuine(); if (LexStatusCodes.LA_OK == trialStatus) { uint trialExpiryDate = LexActivator.GetTrialExpiryDate(); int daysLeft = (int)(trialExpiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400; Console.WriteLine("Trial days left: " + daysLeft); } else if (LexStatusCodes.LA_TRIAL_EXPIRED == trialStatus) { Console.WriteLine("Trial has expired!"); // Time to buy the product key and activate the app Activate(); } else { Console.WriteLine("Either trial has not started or has been tampered!"); // Activating the trial trialStatus = LexActivator.ActivateTrial(); // Ideally on a button click inside a dialog if (LexStatusCodes.LA_OK == trialStatus) { uint trialExpiryDate = LexActivator.GetTrialExpiryDate(); int daysLeft = (int)(trialExpiryDate - DateTimeOffset.Now.ToUnixTimeSeconds()) / 86400; Console.WriteLine("Trial days left: " + daysLeft); } else { // Trial was tampered or has expired Console.WriteLine("Trial activation failed: " + trialStatus); } } } } catch (LexActivatorException ex) { Console.WriteLine("Error code: " + ex.Code.ToString() + " Error message: " + ex.Message); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
private TrialLicenseInfo GetTrialLicenseInfo() { lock (trialLicenseInfoLock) { var trialLicenseInfo = new TrialLicenseInfo(); int status = 0; try { var sbTrialId = new StringBuilder(256); status = LexActivator.GetTrialId(sbTrialId, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } trialLicenseInfo.TrialId = sbTrialId.ToString(); } catch { } try { var sbFirstName = new StringBuilder(256); status = LexActivator.GetTrialActivationMetadata("FirstName", sbFirstName, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } trialLicenseInfo.FirstName = sbFirstName.ToString(); } catch { } try { var sbLastName = new StringBuilder(256); status = LexActivator.GetTrialActivationMetadata("LastName", sbLastName, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } trialLicenseInfo.LastName = sbLastName.ToString(); } catch { } try { var sbEMail = new StringBuilder(256); status = LexActivator.GetTrialActivationMetadata("eMail", sbEMail, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } trialLicenseInfo.EMail = sbEMail.ToString(); } catch { } try { var sbOrganization = new StringBuilder(256); status = LexActivator.GetTrialActivationMetadata("Organization", sbOrganization, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } trialLicenseInfo.Organization = sbOrganization.ToString(); } catch { } try { var sbIndexer = new StringBuilder(256); status = LexActivator.GetTrialActivationMetadata("Indexer01", sbIndexer, 256); if (status == LexActivator.StatusCodes.LA_OK) { trialLicenseInfo.Indexer01 = sbIndexer.ToString(); } } catch { } try { uint trialExpiryDate = 0; status = LexActivator.GetTrialExpiryDate(ref trialExpiryDate); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } var expireDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); var TrialDueDate = expireDate.AddSeconds(trialExpiryDate).ToLocalTime(); trialLicenseInfo.TrialDueDate = TrialDueDate; } catch { } return(trialLicenseInfo); } }
private LicenseInfo GetLicenseInfo() { lock (licenseInfoLock) { var licenseInfo = new LicenseInfo(); int status = 0; try { var sbLicenseKey = new StringBuilder(256); status = LexActivator.GetLicenseKey(sbLicenseKey, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } licenseInfo.LicenseKey = sbLicenseKey.ToString(); } catch { } try { var sbLicenseUserEmail = new StringBuilder(256); status = LexActivator.GetLicenseUserEmail(sbLicenseUserEmail, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } licenseInfo.LicenseUserEmail = sbLicenseUserEmail.ToString(); } catch { } try { var sbLicenseUserName = new StringBuilder(256); status = LexActivator.GetLicenseUserName(sbLicenseUserName, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } licenseInfo.LicenseUserName = sbLicenseUserName.ToString(); } catch { } try { var sbMaxAllowedIndexerRoleCount = new StringBuilder(256); status = LexActivator.GetLicenseMetadata("MaxAllowedIndexerRoleCount", sbMaxAllowedIndexerRoleCount, 256); if (status == LexActivator.StatusCodes.LA_OK) { if (int.TryParse(sbMaxAllowedIndexerRoleCount.ToString(), out int dummyMaxAllowedIndexerRoleCount)) { licenseInfo.MaxAllowedIndexerRoleCount = dummyMaxAllowedIndexerRoleCount; } } } catch { } for (int i = 1; i < 33; i++) { try { var sbIndexer = new StringBuilder(256); status = LexActivator.GetLicenseMetadata("Indexer" + i.ToString().PadLeft(2, '0'), sbIndexer, 256); if (status == LexActivator.StatusCodes.LA_OK) { licenseInfo.AddIndexer(sbIndexer.ToString()); } } catch { } } try { var sbFirstName = new StringBuilder(256); status = LexActivator.GetActivationMetadata("FirstName", sbFirstName, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } licenseInfo.FirstName = sbFirstName.ToString(); } catch { } try { var sbLastName = new StringBuilder(256); status = LexActivator.GetActivationMetadata("LastName", sbLastName, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } licenseInfo.LastName = sbLastName.ToString(); } catch { } try { var sbEMail = new StringBuilder(256); status = LexActivator.GetActivationMetadata("eMail", sbEMail, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } licenseInfo.EMail = sbEMail.ToString(); } catch { } try { var sbOrganization = new StringBuilder(256); status = LexActivator.GetActivationMetadata("Organization", sbOrganization, 256); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } licenseInfo.Organization = sbOrganization.ToString(); } catch { } try { uint licenseExpiryDate = 0; status = LexActivator.GetLicenseExpiryDate(ref licenseExpiryDate); if (status != LexActivator.StatusCodes.LA_OK) { return(null); } var expireDate = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); var dueDate = expireDate.AddSeconds(licenseExpiryDate).ToLocalTime(); licenseInfo.LicenseExpiryDate = dueDate; } catch { } return(licenseInfo); } }
private void LexLicenseControl_Loaded(object sender, RoutedEventArgs e) { SpLicenseOk.Visibility = Visibility.Collapsed; SpLicenseNoLicense.Visibility = Visibility.Collapsed; SpLicenseError.Visibility = Visibility.Collapsed; SpLicenseIsSuspended.Visibility = Visibility.Collapsed; SpLicenseExpired.Visibility = Visibility.Collapsed; SpTrialLicenseOk.Visibility = Visibility.Collapsed; SpTrialLicenseIsSuspended.Visibility = Visibility.Collapsed; SpTrialLicenseExpired.Visibility = Visibility.Collapsed; var isLicenseGenuine = LexActivator.IsLicenseGenuine(); if (isLicenseGenuine == LexActivator.StatusCodes.LA_OK) { SpLicenseOk.Visibility = Visibility.Visible; } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_EXPIRED) { SpLicenseExpired.Visibility = Visibility.Visible; } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_SUSPENDED) { SpLicenseIsSuspended.Visibility = Visibility.Visible; } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_GRACE_PERIOD_OVER) { SpLicenseExpired.Visibility = Visibility.Visible; } else if (isLicenseGenuine == LexActivator.StatusCodes.LA_FAIL || isLicenseGenuine == LexActivator.StatusCodes.LA_E_PRODUCT_ID || isLicenseGenuine == LexActivator.StatusCodes.LA_E_LICENSE_KEY || isLicenseGenuine == LexActivator.StatusCodes.LA_E_TIME || isLicenseGenuine == LexActivator.StatusCodes.LA_E_TIME_MODIFIED) { SpLicenseError.Visibility = Visibility.Visible; ErrorCode.Text = ((StatusCodesEnum)isLicenseGenuine).ToString(); } else { var isTrialGenuine = LexActivator.IsTrialGenuine(); if (isTrialGenuine == LexActivator.StatusCodes.LA_OK) { uint trialExpiryDate = 0; var getTrialExpiryDate = LexActivator.GetTrialExpiryDate(ref trialExpiryDate); var dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); dtDateTime = dtDateTime.AddSeconds(trialExpiryDate).ToLocalTime(); //LexActivator.Reset(); SpTrialLicenseOk.Visibility = Visibility.Visible; } else if (isTrialGenuine == LexActivator.StatusCodes.LA_TRIAL_EXPIRED) { SpTrialLicenseExpired.Visibility = Visibility.Visible; } else if (isTrialGenuine == LexActivator.StatusCodes.LA_SUSPENDED) { SpTrialLicenseIsSuspended.Visibility = Visibility.Visible; } else { SpLicenseNoLicense.Visibility = Visibility.Visible; } //SpLicenseError.Visibility = Visibility.Visible; } }
private void ActivateTrialLicense(object obj) { IsBusy = true; int status; status = LexActivator.SetTrialActivationMetadata("FirstName", FirstName); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata FirstName Code {status}"); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { IsBusy = false; SendErrorLogVisibility = Visibility.Visible; Status = LocHelper.GetWord("Error setting activation data."); })); return; } status = LexActivator.SetTrialActivationMetadata("LastName", LastName); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata LastName Code {status}"); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { IsBusy = false; SendErrorLogVisibility = Visibility.Visible; Status = LocHelper.GetWord("Error setting activation data."); })); return; } status = LexActivator.SetTrialActivationMetadata("eMail", EMail); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata eMail Code {status}"); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { IsBusy = false; SendErrorLogVisibility = Visibility.Visible; Status = LocHelper.GetWord("Error setting activation data."); })); return; } status = LexActivator.SetTrialActivationMetadata("Organization", Organization); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetTrialActivationMetadata Organization Code {status}"); Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { IsBusy = false; SendErrorLogVisibility = Visibility.Visible; Status = LocHelper.GetWord("Error setting activation data."); })); return; } Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { var activateTrial = LexActivator.ActivateTrial(); var statusEnum = (StatusCodesEnum)activateTrial; IsBusy = false; if (statusEnum == StatusCodesEnum.LA_OK) { Status = LocHelper.GetWord("You have successfully started your trial license. You can close this window and start using Celsus."); CloseWindowVisibility = Visibility.Visible; } else if (status == LexActivator.StatusCodes.LA_TRIAL_EXPIRED) { Status = LocHelper.GetWord("Product trial has expired."); CloseWindowVisibility = Visibility.Visible; } else { Status = LocHelper.GetWord($"Error occured. Error code {statusEnum.ToString()}"); CloseWindowVisibility = Visibility.Visible; } })); return; }
public bool ActivateSerial(out bool hasError, out int status, string firstName, string lastName, string eMail, string organization, string serial) { status = LexActivator.SetActivationMetadata("FirstName", firstName); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetActivationMetadata FirstName Code {status}"); hasError = true; return(false); } status = LexActivator.SetActivationMetadata("LastName", lastName); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetActivationMetadata LastName Code {status}"); hasError = true; return(false); } status = LexActivator.SetActivationMetadata("eMail", eMail); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetActivationMetadata eMail Code {status}"); hasError = true; return(false); } status = LexActivator.SetActivationMetadata("Organization", organization); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetActivationMetadata Organization Code {status}"); hasError = true; return(false); } status = LexActivator.SetLicenseKey(serial); if (status != LexActivator.StatusCodes.LA_OK) { logger.Warn($"SetActivationMetadata Serial Code {status}"); hasError = true; return(false); } status = LexActivator.ActivateLicense(); var statusEnum = (StatusCodesEnum)status; if (statusEnum == StatusCodesEnum.LA_OK) { hasError = false; Init(); return(true); } else if (status == LexActivator.StatusCodes.LA_EXPIRED) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_SUSPENDED) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_REVOKED) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_FAIL) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_PRODUCT_ID) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_INET) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_VM) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_TIME) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_ACTIVATION_LIMIT) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_SERVER) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_CLIENT) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_LICENSE_KEY) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_LICENSE_TYPE) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_COUNTRY) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_IP) { hasError = false; return(false); } else if (status == LexActivator.StatusCodes.LA_E_RATE_LIMIT) { hasError = false; return(false); } else { hasError = false; return(false); } }