コード例 #1
0
        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
            });
        }
コード例 #2
0
        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
                });
            }
        }
コード例 #3
0
        private void GetModuleInfo(ushort dev, ushort usCardType)
        {
            int    nNumMaxModules = 4;
            ushort modType;
            string moduleName, firmware, hardware;

            for (ushort mod = 0; mod < nNumMaxModules; mod++)
            {
                if (stfuncs.Get_4000Module_Type(dev, mod, out modType) == 0)
                {
                    if (GetModuleType(dev, mod, modType, out moduleName, out firmware, out hardware))
                    {
                        _scannedModule = new ModuleInfoModel();
                        regDevices[dev].mods[mod].mod        = mod;
                        _scannedModule.mod                   = mod;
                        regDevices[dev].mods[mod].ModuleType = modType;
                        _scannedModule.ModuleType            = modType;
                        regDevices[dev].mods[mod].ModuleName = moduleName;
                        _scannedModule.ModuleName            = moduleName;
                        regDevices[dev].mods[mod].modStatus  = true;
                        _scannedModule.modStatus             = true;

                        regDevices[dev].mods[mod].FirmwareVer = firmware;
                        _scannedModule.FirmwareVer            = firmware;

                        regDevices[dev].mods[mod].HardwareVer = hardware;
                        _scannedModule.HardwareVer            = hardware;

                        _scannedDevice.Modules.Add(_scannedModule);

                        GetModuleStatus("", dev, mod, modType);
                    }
                }
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
		public ModuleInfoControl()
		{
			this.InitializeComponent();

			moduleInfo = new ModuleInfoModel();

			DataContext = moduleInfo;
		}
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        public static IList <ModuleInfoModel> GetModules()
        {
            var result = new List <ModuleInfoModel>();

            foreach (var module in Modules)
            {
                var modProps = AllFields.Where(x => x.Name.StartsWith(module, System.StringComparison.OrdinalIgnoreCase));

                var modName = modProps.Where(x => x.Name.EndsWith("module", System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                var modId   = modProps.Where(x => x.Name.EndsWith("_id", System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                var mod = new ModuleInfoModel()
                {
                    Name     = GetText(modName?.GetValue("").ToString()) ?? "",
                    Id       = (ModuleEnum)modId?.GetValue(ModuleEnum.Help),
                    Commands = new List <CommandInfoModel>()
                };

                foreach (var command in modProps.Where(x => x.Name.EndsWith("command", System.StringComparison.OrdinalIgnoreCase)).ToList())
                {
                    var propName = command.Name.Split('_')[1];
                    var aliases  = new List <string>();

                    foreach (var alias in modProps.Where(x => x.Name.ToLowerInvariant().Contains(propName.ToLowerInvariant()) && x.Name.ToLowerInvariant().Contains("alias")).ToList())
                    {
                        aliases.Add(alias.GetValue("").ToString());
                    }

                    var commandName    = modProps.Where(x => x.Name.EndsWith($"{propName}_Name", System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault()?.GetValue("").ToString() ?? "";
                    var commandSummary = modProps.Where(x => x.Name.EndsWith($"{propName}_Summary", System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault()?.GetValue("").ToString() ?? "";
                    var examples       = modProps.Where(x => x.Name.ToLowerInvariant().Contains($"{propName.ToLowerInvariant()}_example")).Select(x => GetText(x.GetValue("").ToString())).ToList() ?? new List <string>();

                    var commandInfoModel = new CommandInfoModel
                    {
                        Name        = GetText(commandName),
                        Command     = propName,
                        Description = "",
                        Alias       = aliases,
                        Fields      = new List <FieldInfoModel>(),
                        Examples    = new List <string>()
                    };

                    commandInfoModel = ProcessDescription(commandInfoModel, GetText(commandSummary));

                    mod.Commands.Add(commandInfoModel);
                }

                result.Add(mod);
            }

            return(result);
        }
コード例 #9
0
        public ModuleDataGridViewModel(IDeviceScannerService servPxy)
        {
            _serviceProxy   = servPxy;//data service
            Devices         = new ObservableCollection <DeviceInfoModel>();
            DevicesInfo     = new ObservableCollection <DeviceInfoModel>();
            SelectedModules = new ModuleInformationModel();
            GetDevices();

            ModulesOnly           = new ObservableCollection <ModuleInfoModel>();
            singleModuleInfoModel = new ModuleInfoModel();

            _message = "Testing";

            RelayCommandSample = new RelayCommand(RelayCommandSampleExcFunc, RelayCommandSampleCanExcFlag);

            ReadAllCommand    = new RelayCommand(GetDevices);
            SaveCommand       = new RelayCommand <DeviceInfoModel>(SaveDevice);
            SearchCommand     = new RelayCommand(SearchDevice);
            SendDeviceCommand = new RelayCommand <DeviceInfoModel>(SendDeviceInfo);
            ReceiveDeviceInfo();

            logger.Log(LogLevel.Info, "--- ModuleDataGridViewModel:loaded ---");

            // Get lists of settings objects
            try
            {
                //Devices = ModuleDataModel.Instance.getDeviceLists();
                logger.Log(LogLevel.Debug, "All lists of settings objects are loaded.");
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, "EXCEPTION raised: " + ex.ToString());
            }

            // Set default values
            EnableDisableSettings = true;


            // We expect a message with some lists with changes.
            Messenger.Default.Register <MessageCommunicator>(this, MakingNewDeviceChanges);

            Messenger.Default.Register <DeviceSelectedMessage>(this, DeviceSelectedMessageHandler);


            logger.Log(LogLevel.Debug, "All default values are set. End of SerialCommViewModel() constructor!");

            Init();
        }
コード例 #10
0
        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)
            });
        }
コード例 #11
0
ファイル: HomeBus.cs プロジェクト: TuanCruise/Code
        public ModuleInfoModel ConvertFromViewModel(ModuleInfoViewModel viewModel)
        {
            if (viewModel == null)
            {
                return(new ModuleInfoModel());
            }
            var module = new ModuleInfoModel();
            var check  = viewModel.ModulesInfo.Where(x => x.SubModule == "MMN");

            if (check.Any())
            {
                module.ModulesInfo = check.First();
            }
            else
            {
                if (viewModel.ModulesInfo != null && viewModel.ModulesInfo.Any())
                {
                    module.ModulesInfo = viewModel.ModulesInfo.First();
                }
            }
            module.FieldsInfo       = viewModel.FieldsInfo.Where(x => x.ModuleID == module.ModulesInfo.ModuleID).ToList();
            module.ButtonsInfo      = viewModel.ButtonsInfo;
            module.ButtonParamsInfo = viewModel.ButtonParamsInfo;
            var lstLanguage = Task.Run(() => LoadAllBtnLanguage()).Result;

            if (lstLanguage != null)
            {
                viewModel.LanguageInfo.AddRange(lstLanguage);
            }
            module.LanguageInfo = viewModel.LanguageInfo;
            var btnLang = Task.Run(() => LoadAllBtnLanguage()).Result;

            if (btnLang != null)
            {
                module.LanguageInfo.AddRange(btnLang);
            }

            return(module);
        }
コード例 #12
0
        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
            });
        }
コード例 #13
0
        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") : ""
            });
        }
コード例 #14
0
        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
            });
        }
コード例 #15
0
ファイル: CopyModule.cs プロジェクト: Mariusz11711/DNN
        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
            });
        }
コード例 #16
0
ファイル: Edit.razor.cs プロジェクト: TuanCruise/Code
        protected override void OnInitialized()
        {
            try
            {
                editContext = new EditContext(moduleFieldInfoValidate);
                HomeBus homeBus = new HomeBus(moduleService, iConfiguration, distributedCache);
                edit = pEdit == "1" ? true : false;
                var data = Task.Run(() => homeBus.LoadViewBagEdit(modId, modSearchId, "", fieldNameEdit, parram, true, success)).Result;
                if (data != null)
                {
                    moduleInfoModel = data.ModuleInfo == null ? new ModuleInfoModel() : data.ModuleInfo;
                    moduleInfo      = data.ModuleInfo == null ? new ModuleInfo() : data.ModuleInfo.ModulesInfo;
                }
                else
                {
                    moduleInfoModel = new ModuleInfoModel();
                    moduleInfo      = new ModuleInfo();
                }
                //ViewBag.Title = moduleInfoModel.ModulesInfo == null ? "" : moduleInfoModel.ModulesInfo.ModuleName.GetLanguageTitle(moduleInfoModel.LanguageInfo);
                moduleFieldInfo = moduleInfoModel.FieldsInfo.Where(x => x.FieldGroup == FLDGROUP.COMMON.ToString()).Where(x => x.HideWeb != "Y").OrderBy(x => x.Order).ToList();
                if (moduleFieldInfo == null)
                {
                    moduleFieldInfo = new List <ModuleFieldInfo>();
                }
                codeInfos   = data.DataCombobox;
                dataControl = data.DataControl;
                //Set title
                var arr = new string[1];
                arr[0] = moduleInfoModel.ModulesInfo.ModuleName.GetLanguageTitle(moduleInfoModel.LanguageInfo);;
                Task.Run(() => JSRuntime.InvokeVoidAsync("SetTitle", arr));
                //Hết SetTitle
                foreach (var field in moduleFieldInfo)
                {
                    if (dataControl != null)
                    {
                        foreach (var item in dataControl)
                        {
                            var dataRows = ((Newtonsoft.Json.Linq.JContainer)item);

                            foreach (var column in dataRows)
                            {
                                var columnName = ((Newtonsoft.Json.Linq.JProperty)column).Name;
                                if (columnName.ToUpper() == field.FieldName.ToUpper())
                                {
                                    if (((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)column).Value).Value != null)
                                    {
                                        field.Value += (((Newtonsoft.Json.Linq.JValue)((Newtonsoft.Json.Linq.JProperty)column).Value).Value).ToString().Trim() + ",";
                                    }
                                }
                            }
                        }
                    }
                    if (field.Value != null)
                    {
                        field.Value = field.Value.Trim(',');
                    }
                }

                var lstSources = moduleFieldInfo.Where(x => !String.IsNullOrEmpty(x.ListSource) && x.ListSource.IndexOf("(") > 0 && x.ListSource.IndexOf("()") < 0).ToList();//Lấy các list source dạng store có truyền vào tên field
                var fieldChild = moduleFieldInfo.Where(x => x.FieldChilds != null).Select(x => x.FieldChilds);
                if (fieldChild.Any())
                {
                    foreach (var child in fieldChild)
                    {
                        var sourceChild = child.Where(x => !String.IsNullOrEmpty(x.ListSource) && x.ListSource.IndexOf("(") > 0 && x.ListSource.IndexOf("()") < 0);
                        if (sourceChild.Any())
                        {
                            lstSources.AddRange(sourceChild.ToList());
                        }
                    }
                }
                foreach (var item in lstSources)
                {
                    var sourceParr = item.ListSource.Substring(item.ListSource.IndexOf("(") + 1, item.ListSource.IndexOf(")") - item.ListSource.IndexOf("(") - 1).Split(",");
                    foreach (var source in sourceParr)
                    {
                        var checkItems = moduleFieldInfo.Where(x => ":" + x.FieldID.ToUpper() == source.ToUpper());
                        if (checkItems.Any())
                        {
                            item.ListSource = item.ListSource.Replace(source, checkItems.First().Value);
                        }
                    }
                }
                keyEdit = data.KeyEdit;
                //if (string.IsNullOrEmpty(HttpContext.Session.GetString("UserName")))
                //{
                //    return RedirectToAction("Login", "Home");
                //}
                //await LoadViewBagEdit(modId, modSearchId, subModId, fieldNameEdit, parram, edit, success);
                //codeInfos = DataCombobox;
            }
            catch (Exception e)
            {
            }
        }