private async Task CheckInternal()
        {
            AspNetZeroLicenseChecker zeroLicenseChecker = this;

            try
            {
                zeroLicenseChecker._uniqueComputerId     = AspNetZeroLicenseChecker.GetUniqueComputerId();
                zeroLicenseChecker._licenseCheckFilePath = Path.Combine(Path.GetTempPath(), zeroLicenseChecker.GetHashedValue(zeroLicenseChecker.GetLicenseCode()) + ".tmp");
                zeroLicenseChecker.Logger.Debug(zeroLicenseChecker._licenseCheckFilePath);
            }
            catch
            {
                return;
            }
            try
            {
                if (!zeroLicenseChecker.IsProjectNameValid())
                {
                    throw new AspNetZeroLicenseException("Failed to validate project name. Should not rename a project downloaded from aspnetzero.com. You can contact to [email protected] if you are using a licensed product.");
                }
                if (zeroLicenseChecker.CheckedBefore())
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                zeroLicenseChecker.Logger.Fatal("Failed to validate project name. Should not rename a project downloaded from aspnetzero.com. You can contact to [email protected] if you are using a licensed product." + Environment.NewLine + ex.Message, ex);
                Environment.Exit(-42);
            }
            await zeroLicenseChecker.ValidateLicenseOnServer();
        }
 private static string GetLicenseExpiredString()
 {
     return(AspNetZeroLicenseChecker.StringGeneratorFromInteger(new int[29]
     {
         1400382,
         1103131,
         973808,
         360813,
         1240081,
         1210727,
         1092451,
         1070315,
         1281862,
         1270461,
         400917,
         1310564,
         1760086,
         1220024,
         1471866,
         1142506,
         1020320,
         622427,
         1591867,
         630063,
         1160906,
         320602,
         1101332,
         1240054,
         1140016,
         480081,
         1160031,
         1260050,
         1540058
     }));
 }
 protected override string GetSalt()
 {
     return(AspNetZeroLicenseChecker.StringGeneratorFromInteger(new int[20]
     {
         1040716,
         800845,
         530130,
         1070016,
         1150778,
         561680,
         610543,
         1100661,
         850465,
         701962,
         720252,
         450500,
         1041016,
         580023,
         1060241,
         670061,
         1190528,
         580670,
         620222,
         1070077
     }));
 }
        private bool CheckedBefore()
        {
            if (!File.Exists(this._licenseCheckFilePath))
            {
                return(false);
            }
            string licenseCheckDate = this.GetLastLicenseCheckDate();

            if (this.GetHashedValue(AspNetZeroLicenseChecker.GetTodayAsString()) == licenseCheckDate || this.GetHashedValue(AspNetZeroLicenseChecker.GetLicenseExpiredString()) == licenseCheckDate)
            {
                return(true);
            }
            File.Delete(this._licenseCheckFilePath);
            return(false);
        }
        private async Task <LicenseValidationResult> ValidateLicense(
            string licenseCode)
        {
            AspNetZeroLicenseChecker zeroLicenseChecker = this;
            LicenseValidationResult  result;

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.BaseAddress = new Uri("https://www.aspnetzero.com/");
                httpClient.DefaultRequestHeaders.Accept.Clear();
                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                LicenseCheckInfo licenseInfo = new LicenseCheckInfo()
                {
                    LicenseCode         = licenseCode,
                    UniqueComputerId    = zeroLicenseChecker._uniqueComputerId,
                    ComputerName        = AspNetZeroLicenseChecker.GetComputerName(),
                    ControlCode         = Guid.NewGuid().ToString(),
                    DateOfClient        = DateTime.Now,
                    ProjectAssemblyName = zeroLicenseChecker.GetAssemblyName(),
                    LicenseController   = zeroLicenseChecker.GetLicenseController()
                };
                HttpResponseMessage httpResponseMessage = await httpClient.PostAsync("LicenseManagement/CheckLicense", (HttpContent) new StringContent(licenseInfo.ToJsonString(false, false), Encoding.UTF8, "application/json"));

                if (!httpResponseMessage.IsSuccessStatusCode)
                {
                    throw new AbpException("Failed on license check");
                }
                AjaxResponse <LicenseValidationResult> ajaxResponse = JsonConvert.DeserializeObject <AjaxResponse <LicenseValidationResult> >(await httpResponseMessage.Content.ReadAsStringAsync());
                if (ajaxResponse.Success && ajaxResponse.Result != null)
                {
                    if (zeroLicenseChecker.GetHashedValue(licenseInfo.ControlCode) != ajaxResponse.Result.ControlCode)
                    {
                        throw new AspNetZeroLicenseException("Failed on license check");
                    }
                    result      = ajaxResponse.Result;
                    licenseInfo = (LicenseCheckInfo)null;
                }
                else
                {
                    ErrorInfo error = ajaxResponse.Error;
                    throw new AbpException(error == null || error.Message == null ? "Failed on license check" : error.Message);
                }
            }
            return(result);
        }
 protected override string GetHashedValueWithoutUniqueComputerId(string str)
 {
     using (MD5CryptoServiceProvider cryptoServiceProvider = new MD5CryptoServiceProvider())
         return(AspNetZeroLicenseChecker.EncodeBase64(cryptoServiceProvider.ComputeHash(Encoding.UTF8.GetBytes(str + this.GetSalt()))));
 }
 private void MarkAsLastRequest()
 {
     File.WriteAllText(this._licenseCheckFilePath, this.GetHashedValue(AspNetZeroLicenseChecker.GetLicenseExpiredString()));
 }
 private void UpdateLastLicenseCheckDate()
 {
     File.WriteAllText(this._licenseCheckFilePath, this.GetHashedValue(AspNetZeroLicenseChecker.GetTodayAsString()));
 }