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);
            }
        }