示例#1
0
        public DateTime SaveLicenseTemp(Stream licenseStream)
        {
            try
            {
                using var reader = new StreamReader(licenseStream);
                var licenseJsonString = reader.ReadToEnd();
                var license           = License.Parse(licenseJsonString);

                var dueDate = Validate(license);

                SaveLicense(licenseStream, LicensePathTemp);

                return(dueDate);
            }
            catch (Exception ex)
            {
                LogError(ex);
                throw;
            }
        }
        public static void SaveLicenseTemp(Stream licenseStream)
        {
            try
            {
                using (var reader = new StreamReader(licenseStream))
                {
                    var licenseJsonString = reader.ReadToEnd();
                    var license           = License.Parse(licenseJsonString);

                    Validate(license);

                    SaveLicense(licenseStream, LicensePathTemp);
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                throw;
            }
        }
示例#3
0
        public void RefreshLicense()
        {
            try
            {
                var temp = true;
                if (!File.Exists(LicensePathTemp))
                {
                    Log.Debug("Temp license not found");

                    if (!File.Exists(LicensePath))
                    {
                        throw new BillingNotFoundException("License not found");
                    }
                    temp = false;
                }

                using (var licenseStream = GetLicenseStream(temp))
                    using (var reader = new StreamReader(licenseStream))
                    {
                        var licenseJsonString = reader.ReadToEnd();
                        var license           = License.Parse(licenseJsonString);

                        LicenseToDB(license);

                        if (temp)
                        {
                            SaveLicense(licenseStream, LicensePath);
                        }
                    }

                if (temp)
                {
                    File.Delete(LicensePathTemp);
                }
            }
            catch (Exception ex)
            {
                LogError(ex);
                throw;
            }
        }