protected override void OnInit(EventArgs e) { base.OnInit(e); this.cmdUpdate.Click += this.cmdUpdate_Click; this.cmdCancel.Click += this.cmdCancel_Click; this._providerId = Convert.ToInt32(this.Request.Params["ProviderId"]); var provider = ExtensionUrlProviderController.GetModuleProviders(this.ModuleContext.PortalId) .SingleOrDefault(p => p.ProviderConfig.ExtensionUrlProviderId == this._providerId); if (provider != null) { var settingsControlSrc = provider.ProviderConfig.SettingsControlSrc; var settingsControl = this.Page.LoadControl(settingsControlSrc); this.providerSettingsPlaceHolder.Controls.Add(settingsControl); // ReSharper disable SuspiciousTypeConversion.Global this._providerSettingsControl = settingsControl as IExtensionUrlProviderSettingsControl; // ReSharper restore SuspiciousTypeConversion.Global if (this._providerSettingsControl != null) { this._providerSettingsControl.Provider = provider.ProviderConfig; } } }
/// ----------------------------------------------------------------------------- /// <summary> /// The Install method installs the UrlProvider component. /// </summary> /// ----------------------------------------------------------------------------- public override void Install() { try { // Ensure DesktopModule Cache is cleared DataCache.RemoveCache(string.Format(DataCache.DesktopModuleCacheKey, Null.NullInteger)); var desktopModule = DesktopModuleController.GetDesktopModuleByModuleName(this._desktopModuleName, Null.NullInteger); if (desktopModule != null) { this._extensionUrlProvider.DesktopModuleId = desktopModule.DesktopModuleID; } // Attempt to get the Desktop Module this._installedExtensionUrlProvider = ExtensionUrlProviderController.GetProviders(Null.NullInteger) .SingleOrDefault(p => p.ProviderType == this._extensionUrlProvider.ProviderType); if (this._installedExtensionUrlProvider != null) { this._extensionUrlProvider.ExtensionUrlProviderId = this._installedExtensionUrlProvider.ExtensionUrlProviderId; } ExtensionUrlProviderController.SaveProvider(this._extensionUrlProvider); this.Completed = true; this.Log.AddInfo(string.Format(Util.URLPROVIDER_Registered, this._extensionUrlProvider.ProviderName)); } catch (Exception ex) { this.Log.AddFailure(ex); } }
public HttpResponseMessage GetExtensionUrlProviders() { try { var providers = ExtensionUrlProviderController.GetProviders(this.PortalId).Select(p => new { p.ExtensionUrlProviderId, p.ProviderName, p.IsActive, SettingUrl = this.NavigationManager.NavigateURL(this.PortalSettings.AdminTabId, "UrlProviderSettings", "Display=settings&popUp=true&ProviderId=" + p.ExtensionUrlProviderId) }).ToList(); var response = new { Success = true, Providers = providers }; return(this.Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception exc) { Logger.Error(exc); return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public void BindAction(int portalId, int tabId, int moduleId) { var providers = ExtensionUrlProviderController.GetProviders(portalId); Localization.LocalizeDataGrid(ref providersGrid, LocalResourceFile); providersGrid.DataSource = providers; providersGrid.DataBind(); UrlSettingsExtensionControl.BindAction(portalId, tabId, moduleId); var settings = new DotNetNuke.Entities.Urls.FriendlyUrlSettings(portalId); if (settings.EnableCustomProviders == false) { providersGrid.Visible = false; providersWarningLabel.Visible = true; providersWarningLabel.Text = LocalizeString("ExtensionProvidersDisabled.Text"); } else { if (providersGrid.Items.Count == 0) { providersGrid.Visible = false; providersWarningLabel.Visible = true; providersWarningLabel.Text = LocalizeString("NoProvidersInstalled.Text"); } } }
public void BindAction(int portalId, int tabId, int moduleId) { var providers = ExtensionUrlProviderController.GetProviders(portalId); Localization.LocalizeDataGrid(ref providersGrid, LocalResourceFile); providersGrid.DataSource = providers; providersGrid.DataBind(); UrlSettingsExtensionControl.BindAction(portalId, tabId, moduleId); }
public void GetModuleProviders_ExcludeSingleProviderWithTypeThatDoesNotExist() { var getExtensionUrlProvidersDataSet = GetDataSetForExtensionUrlProvidersCall(); var providersTable = getExtensionUrlProvidersDataSet.Tables[0]; AddProviderRow(providersTable, providerType: "This.Is.Not.A.Real.Type"); SetupGetModuleProvidersCall(getExtensionUrlProvidersDataSet.CreateDataReader()); var providers = ExtensionUrlProviderController.GetModuleProviders(Constants.PORTAL_ValidPortalId); Assert.IsNotNull(providers, "Providers list should be empty, not null"); Assert.IsEmpty(providers, "Providers list should be empty, since there is only an invalid entry"); }
void cmdUpdate_Click(object sender, EventArgs e) { if (_providerSettingsControl != null) { var settings = _providerSettingsControl.SaveSettings(); foreach (var setting in settings) { ExtensionUrlProviderController.SaveSetting(_providerId, ModuleContext.PortalId, setting.Key, setting.Value); } } Response.Redirect(Globals.NavigateURL(ModuleContext.PortalSettings.ActiveTab.TabID)); }
/// ----------------------------------------------------------------------------- /// <summary> /// The Rollback method undoes the installation of the component in the event /// that one of the other components fails. /// </summary> /// ----------------------------------------------------------------------------- public override void Rollback() { // If Temp Provider exists then we need to update the DataStore with this if (this._installedExtensionUrlProvider == null) { // No Temp Provider - Delete newly added module this.DeleteProvider(); } else { // Temp Provider - Rollback to Temp ExtensionUrlProviderController.SaveProvider(this._installedExtensionUrlProvider); } }
protected void OnChangeProviderStatus(object sender, EventArgs e) { var checkbox = (sender as CheckBox); var providerId = Convert.ToInt32((checkbox.Parent.FindControl("urlProviderId") as HiddenField).Value); if (checkbox.Checked) { ExtensionUrlProviderController.EnableProvider(providerId, ModuleContext.PortalId); } else { ExtensionUrlProviderController.DisableProvider(providerId, ModuleContext.PortalId); } }
public void GetModuleProviders_OnlyExcludeProviderWithTypeThatDoesNotExistButIncludeOther() { var getExtensionUrlProvidersDataSet = GetDataSetForExtensionUrlProvidersCall(); var providersTable = getExtensionUrlProvidersDataSet.Tables[0]; AddProviderRow(providersTable, providerName: "Broken Provider", providerType: "This.Is.Not.A.Real.Type"); AddProviderRow(providersTable, providerName: "Working Provider", providerType: typeof(FakeExtensionUrlProvider).AssemblyQualifiedName); SetupGetModuleProvidersCall(getExtensionUrlProvidersDataSet.CreateDataReader()); var providers = ExtensionUrlProviderController.GetModuleProviders(Constants.PORTAL_ValidPortalId); Assert.IsNotNull(providers, "Providers list should be empty, not null"); Assert.AreEqual(1, providers.Count, "Providers list should have the one valid entry, but not the invalid entry"); Assert.AreEqual("Working Provider", providers[0].ProviderConfig.ProviderName, "Providers list should have the valid entry"); }
private static void SerializeExtensionUrlProviders(XmlWriter writer, int portalId) { var providers = ExtensionUrlProviderController.GetModuleProviders(portalId); if (!providers.Any()) { return; } writer.WriteStartElement("extensionUrlProviders"); foreach (var provider in providers) { writer.WriteStartElement("extensionUrlProvider"); writer.WriteElementString("name", provider.ProviderConfig.ProviderName); writer.WriteElementString("active", provider.ProviderConfig.IsActive.ToString()); var settings = provider.ProviderConfig.Settings; if (settings.Any()) { writer.WriteStartElement("settings"); foreach (var setting in settings) { writer.WriteStartElement("setting"); writer.WriteAttributeString("name", setting.Key); writer.WriteAttributeString("value", setting.Value); writer.WriteEndElement(); } writer.WriteEndElement(); } ////if (provider.ProviderConfig.TabIds.Any()) ////{ //// writer.WriteStartElement("tabIds"); //// foreach (var tabId in provider.ProviderConfig.TabIds) //// { //// // TODO: translate to tab path? //// writer.WriteElementString("tabId", tabId.ToString(CultureInfo.InvariantCulture)); //// } //// writer.WriteEndElement(); ////} writer.WriteEndElement(); } writer.WriteEndElement(); }
private void DeleteProvider() { try { ExtensionUrlProviderInfo tempUrlProvider = ExtensionUrlProviderController.GetProviders(Null.NullInteger).Where(p => p.ProviderName == this._extensionUrlProvider.ProviderName && p.ProviderType == this._extensionUrlProvider.ProviderType).FirstOrDefault(); if (tempUrlProvider != null) { ExtensionUrlProviderController.DeleteProvider(tempUrlProvider); this.Log.AddInfo(string.Format(Util.URLPROVIDER_UnRegistered, tempUrlProvider.ProviderName)); } } catch (Exception ex) { this.Log.AddFailure(ex); } }
public HttpResponseMessage UpdateExtensionUrlProviderStatus(UpdateExtensionUrlProviderStatusRequest request) { try { if (request.IsActive) { ExtensionUrlProviderController.EnableProvider(request.ProviderId, this.PortalId); } else { ExtensionUrlProviderController.DisableProvider(request.ProviderId, this.PortalId); } return(this.Request.CreateResponse(HttpStatusCode.OK, new { Success = true })); } catch (Exception exc) { Logger.Error(exc); return(this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
private void cmdUpdate_Click(object sender, EventArgs e) { if (!this.Page.IsValid) { return; } if (this._providerSettingsControl != null) { var settings = this._providerSettingsControl.SaveSettings(); foreach (var setting in settings) { ExtensionUrlProviderController.SaveSetting(this._providerId, this.ModuleContext.PortalId, setting.Key, setting.Value); } } if (this.DisplayMode != "editor" && this.DisplayMode != "settings") { this.Response.Redirect(this._navigationManager.NavigateURL(this.ModuleContext.PortalSettings.ActiveTab.TabID)); } }
private void DeleteProvider() { try { //Attempt to get the Desktop Module //Attempt to get the Desktop Module DesktopModuleInfo desktopModule = DesktopModuleController.GetDesktopModuleByPackageID(Package.PackageID); ExtensionUrlProviderInfo tempUrlProvider = ExtensionUrlProviderController.GetProviders(Null.NullInteger) .SingleOrDefault(p => p.DesktopModuleId == desktopModule.DesktopModuleID); if (tempUrlProvider != null) { ExtensionUrlProviderController.DeleteProvider(tempUrlProvider); Log.AddInfo(string.Format(Util.URLPROVIDER_UnRegistered, tempUrlProvider.ProviderName)); } } catch (Exception ex) { Log.AddFailure(ex); } }