public override void Remove(int tabModuleId) { var controller = new ModuleController(); ModuleInfo tabModule = controller.GetTabModule(tabModuleId); int portalId = tabModule.PortalID; if (portalId == Null.NullInteger) { portalId = PortalSettings.Current.PortalId; } string cacheFolder = GetCacheFolder(portalId); var filesNotDeleted = new StringBuilder(); int i = 0; foreach (string File in Directory.GetFiles(cacheFolder, tabModuleId + "_*.*")) { if (!FileSystemUtils.DeleteFileWithWait(File, 100, 200)) { filesNotDeleted.Append(File + ";"); } else { i += 1; } } if (filesNotDeleted.Length > 0) { throw new IOException("Deleted " + i + " files, however, some files are locked. Could not delete the following files: " + filesNotDeleted); } }
private int DoAddNewModule(string title, int desktopModuleId, string paneName, int position, int permissionType, string align) { var objModules = new ModuleController(); try { DesktopModuleInfo desktopModule; if (!DesktopModuleController.GetDesktopModules(PortalSettings.Current.PortalId).TryGetValue(desktopModuleId, out desktopModule)) { throw new ArgumentException("desktopModuleId"); } } catch (Exception ex) { Exceptions.LogException(ex); } var tabModuleId = Null.NullInteger; foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values) { var objModule = new ModuleInfo(); objModule.Initialize(PortalSettings.Current.ActiveTab.PortalID); objModule.PortalID = PortalSettings.Current.ActiveTab.PortalID; objModule.TabID = PortalSettings.Current.ActiveTab.TabID; objModule.ModuleOrder = position; objModule.ModuleTitle = string.IsNullOrEmpty(title) ? objModuleDefinition.FriendlyName : title; objModule.PaneName = paneName; objModule.ModuleDefID = objModuleDefinition.ModuleDefID; if (objModuleDefinition.DefaultCacheTime > 0) { objModule.CacheTime = objModuleDefinition.DefaultCacheTime; if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger) { ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true); if ((defaultModule != null)) { objModule.CacheTime = defaultModule.CacheTime; } } } objModules.InitialModulePermission(objModule, objModule.TabID, permissionType); if (PortalSettings.Current.ContentLocalizationEnabled) { Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.Current.PortalId); //set the culture of the module to that of the tab var tabInfo = new TabController().GetTab(objModule.TabID, PortalSettings.Current.PortalId, false); objModule.CultureCode = tabInfo != null ? tabInfo.CultureCode : defaultLocale.Code; } else { objModule.CultureCode = Null.NullString; } objModule.AllTabs = false; objModule.Alignment = align; objModules.AddModule(objModule); if (tabModuleId == Null.NullInteger) { tabModuleId = objModule.ModuleID; } //update the position to let later modules with add after previous one. position = objModules.GetTabModule(objModule.TabModuleID).ModuleOrder + 1; } return tabModuleId; }