protected void cmdSave_Click(object sender, EventArgs e) { if (ddlRoles.SelectedIndex > 0) { PortalController.UpdatePortalSetting(ModuleContext.PortalId, "OpenContent_EditorsRoleId", ddlRoles.SelectedValue, true); } else { PortalController.DeletePortalSetting(ModuleContext.PortalId, "OpenContent_EditorsRoleId"); } PortalController.UpdatePortalSetting(ModuleContext.PortalId, "OpenContent_AutoAttach", cbMLContent.Checked.ToString(), true); int maxVersions; if (int.TryParse(ddlMaxVersions.SelectedValue, out maxVersions)) { OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController.SetMaxVersions(maxVersions); } PortalController.UpdatePortalSetting(ModuleContext.PortalId, "OpenContent_Logging", ddlLogging.SelectedValue, true); int editLayout; if (int.TryParse(ddlEditLayout.SelectedValue, out editLayout)) { OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController.SetEditLayout((AlpacaLayoutEnum)editLayout); } OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController.SetLoadBootstrap(cbLoadBootstrap.Checked); OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController.SetGoogleApiKey(tbGoogleApiKey.Text); OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController.SetFastHandlebars(cbFastHandlebars.Checked); Response.Redirect(Globals.NavigateURL(), true); }
/// <summary> /// Sets the ZoneID from PortalSettings /// </summary> /// <param name="ZoneID"></param> /// <param name="PortalID"></param> public static void SetZoneID(int?ZoneID, int PortalID) { if (ZoneID.HasValue) { PortalController.UpdatePortalSetting(PortalID, Settings.PortalSettingsPrefix + "ZoneID", ZoneID.Value.ToString()); } else { PortalController.DeletePortalSetting(PortalID, Settings.PortalSettingsPrefix + "ZoneID"); } }
public void SetGithubRepository(string value) { if (string.IsNullOrEmpty(value)) { PortalController.DeletePortalSetting(_portalId, SETTINGS_GITHUB_REPOSITORY); } else { PortalController.UpdatePortalSetting(_portalId, SETTINGS_GITHUB_REPOSITORY, value, true); } }
public void SetEditorRoleId(string value) { if (string.IsNullOrEmpty(value)) { PortalController.DeletePortalSetting(_portalId, SETTINGS_EDITOR_ROLE_ID); } else { PortalController.UpdatePortalSetting(_portalId, SETTINGS_EDITOR_ROLE_ID, value, true); } }
public static void UpdateConfig(OAuthConfigBase config) { if (config.HostConfig) { HostController.Instance.Update(config.Service + "_APIKey", config.APIKey, true); HostController.Instance.Update(config.Service + "_APISecret", config.APISecret, true); HostController.Instance.Update(config.Service + "_Enabled", config.Enabled.ToString(CultureInfo.InvariantCulture), true); PortalController.DeletePortalSetting(config.PortalID, config.Service + "_APIKey"); PortalController.DeletePortalSetting(config.PortalID, config.Service + "_APISecret"); PortalController.DeletePortalSetting(config.PortalID, config.Service + "_Enabled"); } else { PortalController.UpdatePortalSetting(config.PortalID, config.Service + "_APIKey", config.APIKey); PortalController.UpdatePortalSetting(config.PortalID, config.Service + "_APISecret", config.APISecret); PortalController.UpdatePortalSetting(config.PortalID, config.Service + "_Enabled", config.Enabled.ToString(CultureInfo.InvariantCulture)); } ClearConfig(config.Service, config.PortalID); }
private void RemoveProVersion() { foreach (PortalInfo portal in PortalController.Instance.GetPortals()) { //reset default devices created flag string defaultPreviewProfiles; var settings = PortalController.Instance.GetPortalSettings(portal.PortalID); if (settings.TryGetValue("DefPreviewProfiles_Created", out defaultPreviewProfiles) && defaultPreviewProfiles == "DNNCORP.CE") { PortalController.DeletePortalSetting(portal.PortalID, "DefPreviewProfiles_Created"); } } var package = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == "DotNetNuke.Professional.PreviewProfileManagement"); if (package != null) { var installer = new Installer(package, Globals.ApplicationMapPath); installer.UnInstall(true); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Searches for and indexes modified users for the given portal. /// </summary> /// <returns>Count of indexed records</returns> /// ----------------------------------------------------------------------------- public override int IndexSearchDocuments(int portalId, ScheduleHistoryItem schedule, DateTime startDateLocal, Action <IEnumerable <SearchDocument> > indexer) { Requires.NotNull("indexer", indexer); const int saveThreshold = BatchSize; var totalIndexed = 0; var checkpointModified = false; startDateLocal = GetLocalTimeOfLastIndexedItem(portalId, schedule.ScheduleID, startDateLocal); var searchDocuments = new Dictionary <string, SearchDocument>(); var needReindex = PortalController.GetPortalSettingAsBoolean(UserIndexResetFlag, portalId, false); if (needReindex) { startDateLocal = SqlDateTime.MinValue.Value.AddDays(1); } var controller = new ListController(); var textDataType = controller.GetListEntryInfo("DataType", "Text"); var richTextDataType = controller.GetListEntryInfo("DataType", "RichText"); var profileDefinitions = ProfileController.GetPropertyDefinitionsByPortal(portalId, false, false) .Cast <ProfilePropertyDefinition>() .Where(d => (textDataType != null && d.DataType == textDataType.EntryID) || (richTextDataType != null && d.DataType == richTextDataType.EntryID)) .ToList(); try { int startUserId; var checkpointData = GetLastCheckpointData(portalId, schedule.ScheduleID); if (string.IsNullOrEmpty(checkpointData) || !int.TryParse(checkpointData, out startUserId)) { startUserId = Null.NullInteger; } int rowsAffected; IList <int> indexedUsers; do { rowsAffected = FindModifiedUsers(portalId, startDateLocal, searchDocuments, profileDefinitions, out indexedUsers, ref startUserId); if (rowsAffected > 0 && searchDocuments.Count >= saveThreshold) { //remove existing indexes DeleteDocuments(portalId, indexedUsers); var values = searchDocuments.Values; totalIndexed += IndexCollectedDocs(indexer, values); SetLastCheckpointData(portalId, schedule.ScheduleID, startUserId.ToString()); SetLocalTimeOfLastIndexedItem(portalId, schedule.ScheduleID, values.Last().ModifiedTimeUtc.ToLocalTime()); searchDocuments.Clear(); checkpointModified = true; } } while (rowsAffected > 0); if (searchDocuments.Count > 0) { //remove existing indexes DeleteDocuments(portalId, indexedUsers); var values = searchDocuments.Values; totalIndexed += IndexCollectedDocs(indexer, values); checkpointModified = true; } if (needReindex) { PortalController.DeletePortalSetting(portalId, UserIndexResetFlag); } } catch (Exception ex) { checkpointModified = false; Exceptions.Exceptions.LogException(ex); } if (checkpointModified) { // at last reset start user pointer SetLastCheckpointData(portalId, schedule.ScheduleID, Null.NullInteger.ToString()); SetLocalTimeOfLastIndexedItem(portalId, schedule.ScheduleID, DateTime.Now); } return(totalIndexed); }
private void RemoveProVersion() { //update the tab module to use CE version var tabController = new TabController(); var moduleController = new ModuleController(); TabInfo newTab; var portalController = new PortalController(); foreach (PortalInfo portal in portalController.GetPortals()) { //Update Site Redirection management page var tabId = TabController.GetTabByTabPath(portal.PortalID, "//Admin//DevicePreviewManagement", Null.NullString); if (tabId == Null.NullInteger) { newTab = Upgrade.AddAdminPage(portal, "Device Preview Management", "Device Preview Management.", "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_16X16.png", "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_32X32.png", true); } else { newTab = tabController.GetTab(tabId, portal.PortalID, true); newTab.IconFile = "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_16X16.png"; newTab.IconFileLarge = "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_32X32.png"; tabController.UpdateTab(newTab); } //Remove Pro edition module int moduleID = Null.NullInteger; IDictionary <int, ModuleInfo> modules = moduleController.GetTabModules(newTab.TabID); if (modules != null) { foreach (ModuleInfo m in modules.Values) { if (m.DesktopModule.FriendlyName == "Device Preview Management") { moduleID = m.ModuleID; break; } } } if (moduleID != Null.NullInteger) { moduleController.DeleteTabModule(newTab.TabID, moduleID, false); } //Add community edition module ModuleDefinitionInfo mDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("DNN Device Preview Management"); if (mDef != null) { Upgrade.AddModuleToPage(newTab, mDef.ModuleDefID, "Device Preview Management", "~/desktopmodules/DevicePreviewManagement/images/DevicePreview_Standard_32X32.png", true); } //reset default devices created flag string defaultPreviewProfiles; var settings = PortalController.GetPortalSettingsDictionary(portal.PortalID); if (settings.TryGetValue("DefPreviewProfiles_Created", out defaultPreviewProfiles) && defaultPreviewProfiles == "DNNCORP.CE") { PortalController.DeletePortalSetting(portal.PortalID, "DefPreviewProfiles_Created"); } } var package = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == "DotNetNuke.Professional.PreviewProfileManagement"); if (package != null) { var installer = new Installer(package, Globals.ApplicationMapPath); installer.UnInstall(true); } }
/// ----------------------------------------------------------------------------- /// <summary> /// Returns the collection of SearchDocuments populated with Tab MetaData for the given portal. /// </summary> /// <param name="portalId"></param> /// <param name="startDateLocal"></param> /// <returns></returns> /// <history> /// [vnguyen] 04/16/2013 created /// </history> /// ----------------------------------------------------------------------------- public override IEnumerable <SearchDocument> GetSearchDocuments(int portalId, DateTime startDateLocal) { var searchDocuments = new Dictionary <string, SearchDocument>(); var needReindex = PortalController.GetPortalSettingAsBoolean(UserIndexResetFlag, portalId, false); if (needReindex) { startDateLocal = SqlDateTime.MinValue.Value.AddDays(1); } var controller = new ListController(); var textDataType = controller.GetListEntryInfo("DataType", "Text"); var richTextDataType = controller.GetListEntryInfo("DataType", "RichText"); var profileDefinitions = ProfileController.GetPropertyDefinitionsByPortal(portalId, false, false) .Cast <ProfilePropertyDefinition>() .Where(d => (textDataType != null && d.DataType == textDataType.EntryID) || (richTextDataType != null && d.DataType == richTextDataType.EntryID)).ToList(); try { var startUserId = Null.NullInteger; while (true) { var reader = DataProvider.Instance() .GetAvailableUsersForIndex(portalId, startDateLocal, startUserId, BatchSize); int rowsAffected = 0; var indexedUsers = new List <int>(); while (reader.Read()) { var userSearch = GetUserSearch(reader); AddBasicInformation(searchDocuments, indexedUsers, userSearch, portalId); //log the userid so that it can get the correct user collection next time. if (userSearch.UserId > startUserId) { startUserId = userSearch.UserId; } foreach (var definition in profileDefinitions) { var propertyName = definition.PropertyName; if (!ContainsColumn(propertyName, reader)) { continue; } var propertyValue = reader[propertyName].ToString(); if (string.IsNullOrEmpty(propertyValue) || !propertyValue.Contains(ValueSplitFlag)) { continue; } var splitValues = Regex.Split(propertyValue, Regex.Escape(ValueSplitFlag)); propertyValue = splitValues[0]; var visibilityMode = ((UserVisibilityMode)Convert.ToInt32(splitValues[1])); var extendedVisibility = splitValues[2]; var modifiedTime = Convert.ToDateTime(splitValues[3]).ToUniversalTime(); if (string.IsNullOrEmpty(propertyValue)) { continue; } var uniqueKey = string.Format("{0}_{1}", userSearch.UserId, visibilityMode).ToLowerInvariant(); if (visibilityMode == UserVisibilityMode.FriendsAndGroups) { uniqueKey = string.Format("{0}_{1}", uniqueKey, extendedVisibility); } if (searchDocuments.ContainsKey(uniqueKey)) { var document = searchDocuments[uniqueKey]; document.Keywords.Add(propertyName, propertyValue); if (modifiedTime > document.ModifiedTimeUtc) { document.ModifiedTimeUtc = modifiedTime; } } else { //Need remove use exists index for all visibilities. if (!indexedUsers.Contains(userSearch.UserId)) { indexedUsers.Add(userSearch.UserId); } if (!string.IsNullOrEmpty(propertyValue)) { var searchDoc = new SearchDocument { SearchTypeId = UserSearchTypeId, UniqueKey = uniqueKey, PortalId = portalId, ModifiedTimeUtc = modifiedTime, Description = userSearch.FirstName, Title = userSearch.DisplayName }; searchDoc.Keywords.Add(propertyName, propertyValue); searchDoc.NumericKeys.Add("superuser", Convert.ToInt32(userSearch.SuperUser)); searchDocuments.Add(uniqueKey, searchDoc); } } } rowsAffected++; } //close the data reader reader.Close(); //remov exists indexes DeleteDocuments(portalId, indexedUsers); if (rowsAffected == 0) { break; } } if (needReindex) { PortalController.DeletePortalSetting(portalId, UserIndexResetFlag); } } catch (Exception ex) { Exceptions.Exceptions.LogException(ex); } return(searchDocuments.Values); }
/// ----------------------------------------------------------------------------- /// <summary> /// Returns the collection of SearchDocuments populated with Tab MetaData for the given portal. /// </summary> /// <param name="portalId"></param> /// <param name="startDate"></param> /// <returns></returns> /// <history> /// [vnguyen] 04/16/2013 created /// </history> /// ----------------------------------------------------------------------------- public override IEnumerable <SearchDocument> GetSearchDocuments(int portalId, DateTime startDate) { var searchDocuments = new Dictionary <string, SearchDocument>(); var needReindex = PortalController.GetPortalSettingAsBoolean(UserIndexResetFlag, portalId, false); if (needReindex) { startDate = SqlDateTime.MinValue.Value; } try { var startUserId = Null.NullInteger; while (true) { var reader = DataProvider.Instance().GetAvailableUsersForIndex(portalId, startDate, startUserId, BatchSize); int rowsAffected = 0; var indexedUsers = new List <int>(); while (reader.Read()) { var userId = Convert.ToInt32(reader["UserId"]); var displayName = reader["DisplayName"].ToString(); var firstName = reader["FirstName"].ToString(); var propertyName = reader["PropertyName"].ToString(); var propertyValue = reader["PropertyValue"].ToString(); var visibilityMode = ((UserVisibilityMode)Convert.ToInt32(reader["Visibility"])); var modifiedTime = Convert.ToDateTime(reader["ModifiedTime"]).ToUniversalTime(); //log the userid so that it can get the correct user collection next time. if (userId > startUserId) { startUserId = userId; } var uniqueKey = string.Format("{0}_{1}", userId, visibilityMode).ToLowerInvariant(); if (visibilityMode == UserVisibilityMode.FriendsAndGroups) { uniqueKey = string.Format("{0}_{1}", uniqueKey, reader["ExtendedVisibility"]); } if (searchDocuments.ContainsKey(uniqueKey)) { var document = searchDocuments[uniqueKey]; document.Body += string.Format(" {0}", propertyValue); if (modifiedTime > document.ModifiedTimeUtc) { document.ModifiedTimeUtc = modifiedTime; } } else { //Need remove use exists index for all visibilities. if (!indexedUsers.Contains(userId)) { indexedUsers.Add(userId); } if (!string.IsNullOrEmpty(propertyValue)) { var searchDoc = new SearchDocument { SearchTypeId = UserSearchTypeId, UniqueKey = uniqueKey, PortalId = portalId, ModifiedTimeUtc = modifiedTime, Body = propertyValue, Description = firstName, Title = displayName }; searchDocuments.Add(uniqueKey, searchDoc); } else if (!searchDocuments.ContainsKey(string.Format("{0}_{1}", userId, UserVisibilityMode.AllUsers).ToLowerInvariant())) { if (!indexedUsers.Contains(userId)) { indexedUsers.Add(userId); } //if the user doesn't exist in search collection, we need add it with ALLUsers mode, //so that can make sure DisplayName will be indexed var searchDoc = new SearchDocument { SearchTypeId = UserSearchTypeId, UniqueKey = string.Format("{0}_{1}", userId, UserVisibilityMode.AllUsers).ToLowerInvariant(), PortalId = portalId, ModifiedTimeUtc = modifiedTime, Body = string.Empty, Description = firstName, Title = displayName }; searchDocuments.Add(searchDoc.UniqueKey, searchDoc); } } rowsAffected++; } //close the data reader reader.Close(); //remov exists indexes DeleteDocuments(portalId, indexedUsers); if (rowsAffected == 0) { break; } } if (needReindex) { PortalController.DeletePortalSetting(portalId, UserIndexResetFlag); } } catch (Exception ex) { Exceptions.Exceptions.LogException(ex); } return(searchDocuments.Values); }