public ConsoleResultModel Run() { if (PageId.HasValue) { // getting a specific module instance List <ModuleInstanceModel> lst = new List <ModuleInstanceModel>(); var mi = ModuleController.Instance.GetModule((int)ModuleId, (int)PageId, true); if (mi != null) { lst.Add(ModuleInstanceModel.FromDnnModuleInfo(mi)); } return(new ConsoleResultModel(string.Empty) { data = lst }); } else { List <ModuleInfoModel> lst = new List <ModuleInfoModel>(); ArrayList results = ModuleController.Instance.GetAllTabsModulesByModuleID((int)ModuleId); if (results != null && results.Count > 0) { lst.Add(ModuleInfoModel.FromDnnModuleInfo((ModuleInfo)results[0])); } else { return(new ConsoleResultModel($"No module found with ID '{ModuleId}'")); } return(new ConsoleResultModel(string.Empty) { data = lst }); } }
public override ConsoleResultModel Run() { var modules = new List <ModuleInfoModel>(); KeyValuePair <HttpStatusCode, string> message; var movedModule = ModulesControllerLibrary.Instance.CopyModule( PortalSettings, ModuleId, PageId, TargetPageId, Pane, true, out message, true ); if (movedModule == null && !string.IsNullOrEmpty(message.Value)) { return(new ConsoleErrorResultModel(message.Value)); } modules.Add(ModuleInfoModel.FromDnnModuleInfo(movedModule)); return(new ConsoleResultModel(LocalizeString("Prompt_ModuleMoved")) { Data = modules, Records = modules.Count }); }
private List <ModuleInfoModel> GetModulesInPortal(string nameFilter = null) { ArrayList lst = ModuleController.Instance.GetModules(PortalId); List <ModuleInfoModel> lstOut = new List <ModuleInfoModel>(); if (string.IsNullOrEmpty(nameFilter)) { foreach (ModuleInfo mi in lst) { lstOut.Add(ModuleInfoModel.FromDnnModuleInfo(mi)); } } else { var lstQuery = from ModuleInfo o in lst where o.DesktopModule.ModuleName.ToLowerInvariant().Contains(nameFilter.Trim().ToLowerInvariant()) select o; foreach (ModuleInfo mi in lstQuery) { lstOut.Add(ModuleInfoModel.FromDnnModuleInfo(mi)); } } return(lstOut); }
private List <ModuleInfoModel> ListFromDictionary(Dictionary <int, ModuleInfo> dict) { List <ModuleInfoModel> lst = new List <ModuleInfoModel>(); foreach (KeyValuePair <int, ModuleInfo> kvp in dict) { lst.Add(ModuleInfoModel.FromDnnModuleInfo(kvp.Value)); } return(lst); }
private List <ModuleInfoModel> GetModuleById() { var mc = new ModuleController(); var mi = mc.GetModule((int)ModuleId, (int)PageId, false); var lst = new List <ModuleInfoModel>(); if (mi != null) { lst.Add(ModuleInfoModel.FromDnnModuleInfo(mi)); } return(lst); }
public override ConsoleResultModel Run() { var lst = new List <ModuleInfoModel>(); KeyValuePair <HttpStatusCode, string> message; var moduleInfo = ModulesControllerLibrary.Instance.GetModule( this.PortalSettings, this.ModuleId, this.PageId, out message); if (moduleInfo == null && !string.IsNullOrEmpty(message.Value)) { return(new ConsoleErrorResultModel(message.Value)); } lst.Add(ModuleInfoModel.FromDnnModuleInfo(moduleInfo)); return(new ConsoleResultModel { Data = lst, Records = lst.Count, Output = string.Format(this.LocalizeString("Prompt_GetModule_Result"), this.ModuleId, this.PageId) }); }
public ConsoleResultModel Run() { List <ModuleInfoModel> lst = new List <ModuleInfoModel>(); var moduleToBeCopied = ModuleController.Instance.GetModule((int)ModuleId, (int)PageId, true); var targetTab = TabController.Instance.GetTab((int)TargetPageId, PortalId); if (targetTab == null) { return(new ConsoleErrorResultModel(string.Format("Could not load Target Page. No page found in the portal with ID '{0}'", TargetPageId))); } if (moduleToBeCopied != null) { try { ModuleController.Instance.CopyModule(moduleToBeCopied, targetTab, Pane, (bool)IncludeSettings); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); return(new ConsoleErrorResultModel("An error occurred while copying the module. See the DNN Event Viewer for Details.")); } // get the new module var copiedModule = ModuleController.Instance.GetModule(moduleToBeCopied.ModuleID, (int)TargetPageId, true); lst.Add(ModuleInfoModel.FromDnnModuleInfo(copiedModule)); } else { return(new ConsoleResultModel(string.Format("No module found with ID '{0}'", ModuleId))); } return(new ConsoleResultModel("Successfully copied the module") { data = lst }); }
public override ConsoleResultModel Run() { var max = Max <= 0 ? 10 : (Max > 500 ? 500 : Max); int total; var portalDesktopModules = DesktopModuleController.GetPortalDesktopModules(PortalId); var modules = ModulesControllerLibrary.Instance .GetModules( PortalSettings, Deleted, out total, ModuleName, ModuleTitle, PageId, (Page > 0 ? Page - 1 : 0), max) .Select(x => ModuleInfoModel.FromDnnModuleInfo(x, Deleted)) .Where(m => { var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(m.ModuleDefId); return(portalDesktopModules.Any(kvp => kvp.Value.DesktopModuleID == moduleDefinition?.DesktopModuleID)); }) .ToList(); var totalPages = total / max + (total % max == 0 ? 0 : 1); var pageNo = Page > 0 ? Page : 1; return(new ConsoleResultModel { Data = modules, PagingInfo = new PagingInfo { PageNo = pageNo, TotalPages = totalPages, PageSize = max }, Records = modules.Count, Output = modules.Count == 0 ? LocalizeString("Prompt_NoModules") : "" }); }
public ConsoleResultModel Run() { List <ModuleInfoModel> lst = new List <ModuleInfoModel>(); var moduleToRestore = ModuleController.Instance.GetModule((int)ModuleId, (int)PageId, true); if (moduleToRestore != null) { if (moduleToRestore.IsDeleted) { try { ModuleController.Instance.RestoreModule(moduleToRestore); // get the new module info object var restoredModule = ModuleController.Instance.GetModule(moduleToRestore.ModuleID, moduleToRestore.TabID, true); lst.Add(ModuleInfoModel.FromDnnModuleInfo(restoredModule)); } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.LogException(ex); return(new ConsoleErrorResultModel("An error occurred while attempting to restore the module. See the DNN Event Viewer for Details")); } } else { return(new ConsoleResultModel("Cannot restore module. It is not deleted.")); } } else { return(new ConsoleResultModel(string.Format("No module found with ID '{0}'", ModuleId))); } return(new ConsoleResultModel("Successfully restored the module.") { data = lst }); }
public override ConsoleResultModel Run() { var lst = new List <ModuleInfoModel>(); KeyValuePair <HttpStatusCode, string> message; var copiedModule = ModulesControllerLibrary.Instance.CopyModule( this.PortalSettings, this.ModuleId, this.PageId, this.TargetPageId, this.Pane, this.IncludeSettings ?? true, out message); if (copiedModule == null && !string.IsNullOrEmpty(message.Value)) { return(new ConsoleErrorResultModel(message.Value)); } lst.Add(ModuleInfoModel.FromDnnModuleInfo(copiedModule)); return(new ConsoleResultModel(this.LocalizeString("Prompt_ModuleCopied")) { Data = lst, Records = lst.Count }); }