private void ComputeUsage()
 {
     if (this.usage == -1)
     {
         this.usage = db.GetActiveLeads(license.LicenseId, time);
     }
 }
        protected override void OnLoad( EventArgs e )
        {
            Database db = new Database();
            License[] licenses = (from l in db.Licenses orderby l.Priority, l.LicenseId descending select l).ToArray();
            List<LicenseInfo> licenseInfos = new List<LicenseInfo>();

            for ( int i = 0; i < licenses.Length; i++ )
            {
                License license = licenses[i];
                LicenseInfo licenseInfo = new LicenseInfo {LicenseId = license.LicenseId};
                ParsedLicense parsedLicense = ParsedLicenseManager.GetParsedLicense( license.LicenseKey );
                if ( parsedLicense == null )
                {
                    licenseInfo.LicenseType = "INVALID";
                }
                else
                {
                    licenseInfo.LicenseType = parsedLicense.LicenseType.ToString();
                    licenseInfo.MaxUsers = parsedLicense.UserNumber;
                    licenseInfo.CurrentUsers = db.GetActiveLeads( license.LicenseId, VirtualDateTime.UtcNow );
                    licenseInfo.ProductCode = parsedLicense.Product.ToString();
                    licenseInfo.GraceStartTime = license.GraceStartTime;
                    licenseInfo.Status = license.Priority >= 0 ? "Active" : "Disabled";
                    licenseInfo.MaintenanceEndDate = parsedLicense.SubscriptionEndDate;
                }

                licenseInfos.Add( licenseInfo );
            }

            this.noLicensePanel.Visible = licenseInfos.Count == 0;
            this.GridView1.DataSource = licenseInfos;
            this.GridView1.DataBind();
        }
        protected override void OnLoad(EventArgs e)
        {
            Database db = new Database();

            License[]          licenses     = (from l in db.Licenses orderby l.Priority, l.LicenseId descending select l).ToArray();
            List <LicenseInfo> licenseInfos = new List <LicenseInfo>();

            for (int i = 0; i < licenses.Length; i++)
            {
                License     license     = licenses[i];
                LicenseInfo licenseInfo = new LicenseInfo {
                    LicenseId = license.LicenseId
                };
                ParsedLicense parsedLicense = ParsedLicenseManager.GetParsedLicense(license.LicenseKey);
                if (parsedLicense == null)
                {
                    licenseInfo.LicenseType = "INVALID";
                }
                else
                {
                    licenseInfo.LicenseType        = parsedLicense.LicenseType.ToString();
                    licenseInfo.MaxUsers           = parsedLicense.UserNumber;
                    licenseInfo.CurrentUsers       = db.GetActiveLeads(license.LicenseId, VirtualDateTime.UtcNow);
                    licenseInfo.ProductCode        = parsedLicense.Product.ToString();
                    licenseInfo.GraceStartTime     = license.GraceStartTime;
                    licenseInfo.Status             = license.Priority >= 0 ? "Active" : "Disabled";
                    licenseInfo.MaintenanceEndDate = parsedLicense.SubscriptionEndDate;
                }

                licenseInfos.Add(licenseInfo);
            }

            this.noLicensePanel.Visible = licenseInfos.Count == 0;
            this.GridView1.DataSource   = licenseInfos;
            this.GridView1.DataBind();
        }