using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Text; using CMS.GlobalHelper; using CMS.LicenseProvider; using CMS.SettingsProvider; using CMS.UIControls; public partial class CMSModules_Licenses_Pages_License_List : SiteManagerPage { /// /// Client portal URL /// private const string CLIENT_PORTAL = "http://client.kentico.com/"; /// /// Support e-mail address /// private const string SUPPORT_MAIL = "support@kentico.com"; protected void Page_Load(object sender, EventArgs e) { // Setup page title text and image CurrentMaster.Title.TitleText = GetString("Licenses_License_List.Title"); CurrentMaster.Title.TitleImage = GetImageUrl("Objects/CMS_LicenseKey/object.png"); CurrentMaster.Title.HelpTopicName = "licenses_list"; CurrentMaster.Title.HelpName = "helpTopic"; // Prepare the new class header element string[,] actions = new string[3,8]; actions[0, 0] = "HyperLink"; actions[0, 1] = GetString("Licenses_License_List.New"); actions[0, 3] = "~/CMSModules/Licenses/Pages/License_New.aspx"; actions[0, 5] = GetImageUrl("Objects/CMS_LicenseKey/add.png"); actions[1, 0] = "HyperLink"; actions[1, 1] = GetString("license.list.export"); actions[1, 3] = "~/CMSModules/Licenses/Pages/License_Export_Domains.aspx"; actions[1, 5] = GetImageUrl("Objects/CMS_LicenseKey/export.png"); // Not supported in 5.0 final //actions[2, 1] = GetString("license.list.import"); //actions[2, 3] = "~/CMSModules/Licenses/Pages/License_Import_Licenses.aspx"; //actions[2, 5] = GetImageUrl("Objects/CMS_LicenseKey/import.png"); CurrentMaster.HeaderActions.Actions = actions; UniGridLicenses.GridView.PageSize = 20; UniGridLicenses.OnAction += new OnActionEventHandler(UniGridLicenses_OnAction); UniGridLicenses.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGridLicenses_OnExternalDataBound); UniGridLicenses.ZeroRowsText = GetString("general.nodatafound"); // Check if valid license for current domain exists LicenseValidationEnum validationResult = LicenseHelper.ValidateLicenseForDomain(URLHelper.GetCurrentDomain()); if (validationResult != LicenseValidationEnum.Valid) { // Build invalid license string StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} {1}

", GetString("InvalidLicense.Result"), LicenseHelper.GetValidationResultString(validationResult)) .AppendFormat("{0}
", GetString("invalidlicense.howto.option3.secondpart")); ShowWarning(GetString("invalidlicense.currentdomain"), sb.ToString(), null); } } /// /// External data binding handler. /// private object UniGridLicenses_OnExternalDataBound(object sender, string sourceName, object parameter) { switch (sourceName.ToLowerCSafe()) { case "editionname": string edition = ValidationHelper.GetString(parameter, "").ToLowerCSafe(); try { return LicenseHelper.GetEditionName(LicenseKeyInfoProvider.CharToEdition(edition)); } catch { return "#UNKNOWN#"; } case "expiration": return GetString(Convert.ToString(parameter)); case "licenseservers": int count = ValidationHelper.GetInteger(parameter, -1); if (count == LicenseKeyInfo.SERVERS_UNLIMITED) { return GetString("general.unlimited"); } else if (count > 0) { return count.ToString(); } return String.Empty; } return parameter; } /// /// Handles the UniGrid's OnAction event. /// /// Name of item (button) that threw event /// ID (value of Primary key) of corresponding data row protected void UniGridLicenses_OnAction(string actionName, object actionArgument) { if (actionName == "delete") { LicenseKeyInfoProvider.DeleteLicenseKeyInfo(Convert.ToInt32(actionArgument)); } else if (actionName == "view") { URLHelper.Redirect("License_View.aspx?licenseid=" + actionArgument.ToString()); } } }