private void licenseStatus_ItemUpdated(object sender, EventArgs e) { if (pdSectionLicense == null || licenseStatus == null) return; GeneralTabLicenseStatusStringifier ss = new GeneralTabLicenseStatusStringifier(licenseStatus); Program.Invoke(Program.MainWindow, () => { pdSectionLicense.UpdateEntryValueWithKey( FriendlyName("host.license_params-expiry"), ss.ExpiryDate, ss.ShowExpiryDate); }); Program.Invoke(Program.MainWindow, () => { pdSectionLicense.UpdateEntryValueWithKey( Messages.LICENSE_STATUS, ss.ExpiryStatus, true); }); }
private void generateLicenseBox() { Host host = xenObject as Host; if (host == null) return; PDSection s = pdSectionLicense; if (host.license_params == null || host.IsXCP) return; Dictionary<string, string> info = new Dictionary<string, string>(host.license_params); // This field is now supressed as it has no meaning under the current license scheme, and was never // enforced anyway. info.Remove("sockets"); // Remove "expiry" field for "basic" license if (!string.IsNullOrEmpty(host.edition) && host.edition == "basic") info.Remove("expiry"); if (info.ContainsKey("expiry")) { ToolStripMenuItem editItem = new ToolStripMenuItem(Messages.LAUNCH_LICENSE_MANAGER); editItem.Click += delegate { if (LicenseLauncher != null) { LicenseLauncher.Parent = Program.MainWindow; LicenseLauncher.LaunchIfRequired(false, ConnectionsManager.XenConnections); } }; GeneralTabLicenseStatusStringifier ss = new GeneralTabLicenseStatusStringifier(licenseStatus); s.AddEntry(Messages.LICENSE_STATUS, ss.ExpiryStatus, editItem); s.AddEntry(FriendlyName("host.license_params-expiry"), ss.ExpiryDate, editItem, ss.ShowExpiryDate); info.Remove("expiry"); } if (!string.IsNullOrEmpty(host.edition)) { s.AddEntry(FriendlyName("host.edition"), Helpers.GetFriendlyLicenseName(host)); if (info.ContainsKey("sku_type")) { info.Remove("sku_type"); } } else if (info.ContainsKey("sku_type")) { s.AddEntry(FriendlyName("host.license_params-sku_type"), Helpers.GetFriendlyLicenseName(host)); info.Remove("sku_type"); } if(Helpers.ClearwaterOrGreater(host)) s.AddEntry(Messages.NUMBER_OF_SOCKETS, host.CpuSockets.ToString()); if (host.license_server.ContainsKey("address")) { var licenseServerAddress = host.license_server["address"].Trim(); if (licenseServerAddress == "" || licenseServerAddress.ToLower() == "localhost") s.AddEntry(FriendlyName(String.Format("host.license_server-address")), host.license_server["address"]); else { var openUrl = new ToolStripMenuItem(Messages.LICENSE_SERVER_WEB_CONSOLE_GOTO); openUrl.Click += (sender, args) => Program.OpenURL(string.Format(Messages.LICENSE_SERVER_WEB_CONSOLE_FORMAT, licenseServerAddress, Host.LicenseServerWebConsolePort)); s.AddEntryLink(FriendlyName(String.Format("host.license_server-address")), host.license_server["address"], new[] {openUrl}, openUrl.PerformClick); } } if (host.license_server.ContainsKey("port")) { s.AddEntry(FriendlyName(String.Format("host.license_server-port")), host.license_server["port"]); } foreach (string key in new string[] { "productcode", "serialnumber" }) { if (info.ContainsKey(key)) { string row_name = string.Format("host.license_params-{0}", key); string k = key; if (host.license_params[k] != string.Empty) s.AddEntry(FriendlyName(row_name), host.license_params[k]); info.Remove(key); } } string restrictions = Helpers.GetHostRestrictions(host); if (restrictions != "") { s.AddEntry(Messages.RESTRICTIONS, restrictions); } }
private void generateLicenseBox() { Host host = xenObject as Host; if (host == null) return; PDSection s = pdSectionLicense; if (host.license_params == null || host.IsXCP) return; Dictionary<string, string> info = new Dictionary<string, string>(host.license_params); // This field is now supressed as it has no meaning under the current license scheme, and was never // enforced anyway. info.Remove("sockets"); if (info.ContainsKey("expiry")) { ToolStripMenuItem editItem = MainWindow.NewToolStripMenuItem(Messages.LAUNCH_LICENSE_MANAGER, delegate { if(LicenseLauncher != null) { LicenseLauncher.Parent = Program.MainWindow; LicenseLauncher.LaunchIfRequired(false, ConnectionsManager.XenConnections); } }); GeneralTabLicenseStatusStringifier ss = new GeneralTabLicenseStatusStringifier(licenseStatus); s.AddEntry(Messages.LICENSE_STATUS, ss.ExpiryStatus, new List<ToolStripMenuItem>(new [] { editItem })); s.AddEntry(FriendlyName("host.license_params-expiry"), ss.ExpiryDate, new List<ToolStripMenuItem>(new ToolStripMenuItem[] { editItem })); info.Remove("expiry"); } if (!string.IsNullOrEmpty(host.edition)) { s.AddEntry(FriendlyName("host.edition"), FriendlyName(String.Format("host.edition-{0}", host.edition)) ?? String.Empty); if (info.ContainsKey("sku_type")) { info.Remove("sku_type"); } } else if (info.ContainsKey("sku_type")) { s.AddEntry(FriendlyName("host.license_params-sku_type"), Helpers.GetFriendlyLicenseName(host)); info.Remove("sku_type"); } if(Helpers.ClearwaterOrGreater(host)) s.AddEntry(Messages.NUMBER_OF_SOCKETS, host.CpuSockets.ToString()); if (host.license_server.ContainsKey("address")) { s.AddEntry(FriendlyName(String.Format("host.license_server-address")), host.license_server["address"]); } if (host.license_server.ContainsKey("port")) { s.AddEntry(FriendlyName(String.Format("host.license_server-port")), host.license_server["port"]); } if (host.software_version.ContainsKey("dbv")) { s.AddEntry("DBV", host.software_version["dbv"]); } foreach (string key in new string[] { "productcode", "serialnumber" }) { if (info.ContainsKey(key)) { string row_name = string.Format("host.license_params-{0}", key); string k = key; if (host.license_params[k] != string.Empty) s.AddEntry(FriendlyName(row_name), host.license_params[k]); info.Remove(key); } } string restrictions = Helpers.GetHostRestrictions(host); if (restrictions != "") { s.AddEntry(Messages.RESTRICTIONS, restrictions); } }
public void StatusNotUpdatedProvided() { Mock<ILicenseStatus> mockStatus = new Mock<ILicenseStatus>(); mockStatus.Setup(s => s.Updated).Returns(false); GeneralTabLicenseStatusStringifier fs = new GeneralTabLicenseStatusStringifier(mockStatus.Object); Assert.That(fs.ExpiryStatus, Is.EqualTo(Messages.GENERAL_UNKNOWN)); }
public void NullStatusProvided() { GeneralTabLicenseStatusStringifier fs = new GeneralTabLicenseStatusStringifier(null); Assert.That(fs.ExpiryStatus, Is.EqualTo(Messages.GENERAL_UNKNOWN)); }
public void StatusToNonTimeStringConversion(TestData data) { Mock<ILicenseStatus> mockStatus = new Mock<ILicenseStatus>(); Mock<Host> host = ObjectManager.NewXenObject<Host>(id); host.Setup(h => h.IsFreeLicense()).Returns(data.IsFree); mockStatus.Setup(s => s.LicencedHost).Returns(host.Object); mockStatus.Setup(l => l.ExpiryDate).Returns(data.Expiry); mockStatus.Setup(s => s.Updated).Returns(true); mockStatus.Setup(s => s.LicenseExpiresExactlyIn).Returns(data.Expiry.Value.Subtract(data.Ref)); mockStatus.Setup(s => s.CurrentState).Returns(data.State); GeneralTabLicenseStatusStringifier fs = new GeneralTabLicenseStatusStringifier(mockStatus.Object); Assert.That(fs.ExpiryStatus, Is.EqualTo(data.Expected)); }