public bool ModuleHasPrereq(CswEnumNbtModuleName Module)
        {
            int            moduleId  = _CswNbtResources.Modules.GetModuleId(Module);
            CswTableSelect modulesTS = _CswNbtResources.makeCswTableSelect("modulehasparent", "modules");
            DataTable      modulesDT = modulesTS.getTable("where prereq is not null and moduleid = " + moduleId);

            return(modulesDT.Rows.Count > 0);
        }
        }     // initModules()

        /// <summary>
        /// Returns whether a module is enabled
        /// </summary>
        public bool IsModuleEnabled(CswEnumNbtModuleName Module)
        {
            if (false == _RulesAreInitialized)
            {
                initModules();
            }
            return(_ModuleRules[Module].Enabled);
        } // IsModuleEnabled()
 /// <summary>
 /// Trigger the event appropriate to whether the module is currently enabled or disabled
 /// Use this to sync new or edited events with existing schemata
 /// </summary>
 public void triggerEvent(CswEnumNbtModuleName ModuleName)
 {
     if (IsModuleEnabled(ModuleName))
     {
         _ModuleRules[ModuleName].Enable();
     }
     else
     {
         _ModuleRules[ModuleName].Disable();
     }
 }
Example #4
0
 public void Enable()
 {
     if (_CswNbtResources.Modules.ModuleHasPrereq(this.ModuleName))
     {
         CswEnumNbtModuleName modulePrereq = _CswNbtResources.Modules.GetModulePrereq(this.ModuleName);
         if (false == _CswNbtResources.Modules.IsModuleEnabled(modulePrereq))
         {
             _CswNbtResources.Modules.EnableModule(modulePrereq);
         }
     }
     OnEnable();
 }
        /// <summary>
        /// Enable/disable a module in an ORNy safe fashion
        /// </summary>
        private void _updateModule(CswEnumNbtModuleName Module, bool Enable)
        {
            int moduleid = GetModuleId(Module);

            if (false == _RulesAreInitialized)
            {
                initModules();
            }

            bool ModuleEnabled = false;

            if (Enable)
            {
                string ErrorMsg = _ModuleRules[Module].CanModuleBeEnabled();
                if (false == String.IsNullOrEmpty(ErrorMsg))
                {
                    throw new CswDniException(CswEnumErrorType.Warning, "The " + Module.Value + " module cannot be enabled because: " + ErrorMsg,
                                              "The Module was not able to be enabled because an error message was returned from the CanModuleBeEnabled functuon");
                }
            }

            CswTableUpdate ModuleUpdate = _CswNbtResources.makeCswTableUpdate("ModuleManager.UpdateModule", "modules");
            DataTable      ModulesTbl   = ModuleUpdate.getTable("moduleid", moduleid);

            foreach (DataRow row in ModulesTbl.Rows)  //should only ever get one row
            {
                ModuleEnabled  = CswConvert.ToBoolean(row["enabled"]);
                row["enabled"] = CswConvert.ToDbVal(Enable);
                _ModuleRules[Module].Enabled = Enable;
            }

            //Case 31546 - if we're DISABLING a module, we have to call Disable() BEFORE reseting available metadata or metadata objects hidden by the module will not be fetchable in the toggle events
            if (false == Enable && ModuleEnabled)
            {
                _ModuleRules[Module].Disable();
            }

            ModuleUpdate.update(ModulesTbl);

            _CswNbtResources.MetaData.ResetEnabledNodeTypes();
            _CswNbtResources.finalize();
            _CswNbtResources.MetaData.refreshAll();

            //Case 31546 - if we ENABLING a module, we have to call Enable() AFTER reseting available metadata or modules won't be able to find their child metadata objects
            if (Enable && false == ModuleEnabled)
            {
                _ModuleRules[Module].Enable();
            }

            //We have to clear Session data or the view selects recent views will have non-accesible views and break
            _CswNbtResources.SessionDataMgr.removeAllSessionData(_CswNbtResources.Session.SessionId);
        }
        public void CreateModuleDependency(CswEnumNbtModuleName ParentModule, CswEnumNbtModuleName ChildModule)
        {
            int parentId = GetModuleId(ParentModule);
            int childId  = GetModuleId(ChildModule);

            CswTableUpdate modulesTU = _CswNbtResources.makeCswTableUpdate("createChildModule", "modules");
            DataTable      modulesDT = modulesTU.getTable("where moduleid = " + childId);

            foreach (DataRow row in modulesDT.Rows)
            {
                row["prereq"] = parentId;
            }
            modulesTU.update(modulesDT);
        }
        public void TogglePrintLabels(bool Hidden, CswEnumNbtModuleName Module)
        {
            CswNbtMetaDataObjectClass     printLabelOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.PrintLabelClass);
            CswNbtMetaDataObjectClassProp nodetypesOCP = printLabelOC.getObjectClassProp(CswNbtObjClassPrintLabel.PropertyName.NodeTypes);

            CswNbtView             printLabelsView = new CswNbtView(_CswNbtResources);
            CswNbtViewRelationship parent          = printLabelsView.AddViewRelationship(printLabelOC, false);

            CswTableSelect childObjectClasses_TS = _CswNbtResources.makeCswTableSelect("getModuleChildren", "jct_modules_objectclass");

            int       moduleId           = _CswNbtResources.Modules.GetModuleId(Module);
            DataTable childObjClasses_DT = childObjectClasses_TS.getTable("where moduleid = " + moduleId);
            bool      first = true;

            foreach (DataRow Row in childObjClasses_DT.Rows)
            {
                int ObjClassId = CswConvert.ToInt32(Row["objectclassid"]);
                foreach (CswNbtMetaDataNodeType NodeType in _CswNbtResources.MetaData.getNodeTypes(ObjClassId))
                {
                    if (first)
                    {
                        printLabelsView.AddViewPropertyAndFilter(parent, nodetypesOCP,
                                                                 Value: NodeType.NodeTypeName,
                                                                 FilterMode: CswEnumNbtFilterMode.Contains);

                        first = false;
                    }
                    else
                    {
                        printLabelsView.AddViewPropertyAndFilter(parent, nodetypesOCP,
                                                                 Value: NodeType.NodeTypeName,
                                                                 FilterMode: CswEnumNbtFilterMode.Contains,
                                                                 Conjunction: CswEnumNbtFilterConjunction.Or);
                    }
                }
            }


            ICswNbtTree printLabelsTree = _CswNbtResources.Trees.getTreeFromView(printLabelsView, false, true, true);
            int         childCount      = printLabelsTree.getChildNodeCount();

            for (int i = 0; i < childCount; i++)
            {
                printLabelsTree.goToNthChild(i);
                CswNbtNode printLabelNode = printLabelsTree.getNodeForCurrentPosition();
                printLabelNode.Hidden = Hidden;
                printLabelNode.postChanges(false);
                printLabelsTree.goToParentNode();
            }
        }
        /// <summary>
        /// NOTE: In this case, 'hidden' means hidden from the Modules page on the UI. This does
        ///       not restrict you from accessing the module on the server.
        /// </summary>
        /// <param name="Module"></param>
        /// <returns></returns>
        public bool ModuleIsHidden(CswEnumNbtModuleName Module)
        {
            bool Ret = false;

            int            ModuleId         = _CswNbtResources.Modules.GetModuleId(Module);
            CswTableSelect ModulesTblSelect = _CswNbtResources.makeCswTableSelect("isModuleHidden", "modules");
            DataTable      ModulesDt        = ModulesTblSelect.getTable("where moduleid = " + ModuleId);

            if (ModulesDt.Rows.Count > 0)
            {
                if (CswConvert.ToBoolean(ModulesDt.Rows[0]["hidden"]))
                {
                    Ret = true;
                }
            }

            return(Ret);
        }
        public CswEnumNbtModuleName GetModulePrereq(CswEnumNbtModuleName Module)
        {
            int    moduleId = _CswNbtResources.Modules.GetModuleId(Module);
            string sql      = @"select m2.name from modules m1
                                join modules m2 on m2.moduleid = m1.prereq
                           where m1.moduleid = :moduleid ";

            CswArbitrarySelect modulesAS = _CswNbtResources.makeCswArbitrarySelect("getPrereq", sql);

            modulesAS.addParameter("moduleid", moduleId.ToString());
            DataTable modulesDT = modulesAS.getTable();

            string PrereqName = "";

            foreach (DataRow row in modulesDT.Rows)
            {
                PrereqName = row["name"].ToString();
            }

            return(PrereqName);
        }
Example #10
0
        public Collection <CswEnumNbtModuleName> GetChildModules(CswEnumNbtModuleName Module)
        {
            Collection <CswEnumNbtModuleName> ret = new Collection <CswEnumNbtModuleName>();

            int    moduleId = _CswNbtResources.Modules.GetModuleId(Module);
            string sql      = @"select m1.name from modules m1
                               join modules m2 on m2.moduleid = m1.prereq
                           where m1.prereq = :moduleid ";

            CswArbitrarySelect arbSelect = _CswNbtResources.makeCswArbitrarySelect("ModuleManage.GetChildModules", sql);

            arbSelect.addParameter("moduleid", moduleId.ToString());

            DataTable tbl = arbSelect.getTable();

            foreach (DataRow row in tbl.Rows)
            {
                ret.Add(row["name"].ToString());
            }

            return(ret);
        }
Example #11
0
        private void initModules()
        {
            _ModuleIdToNameMapping = new Dictionary <int, CswEnumNbtModuleName>();

            // Fetch modules from database
            if (_CswNbtResources.IsInitializedForDbAccess)
            {
                CswTableSelect ModulesTableSelect = _CswNbtResources.makeCswTableSelect("modules_select", "modules");
                DataTable      ModulesTable       = ModulesTableSelect.getTable();
                foreach (DataRow ModuleRow in ModulesTable.Rows)
                {
                    CswEnumNbtModuleName ModuleName = CswConvert.ToString(ModuleRow["name"]);
                    if (ModuleName != CswEnumNbtModuleName.Unknown)
                    {
                        CswNbtModuleRule ModuleRule = _ModuleRules[ModuleName];
                        ModuleRule.Enabled = CswConvert.ToBoolean(ModuleRow["enabled"]);

                        int ModuleID = CswConvert.ToInt32(ModuleRow["moduleid"]);
                        _ModuleIdToNameMapping.Add(ModuleID, ModuleName.ToString());
                    }
                }
                _RulesAreInitialized = true;
            } // if( _CswResources.IsInitializedForDbAccess )
        }     // initModules()
Example #12
0
 public Int32 GetModuleId(CswEnumNbtModuleName Module)
 {
     return(GetModuleId(Module.ToString()));
 }
Example #13
0
 /// <summary>
 /// Disable a Module and trigger its disable event
 /// </summary>
 public void DisableModule(CswEnumNbtModuleName ModuleToDisable)
 {
     _updateModule(ModuleToDisable, false);
 }
Example #14
0
 /// <summary>
 /// Enable a Module and trigger its enable event
 /// </summary>
 public void EnableModule(CswEnumNbtModuleName ModuleToEnable)
 {
     _updateModule(ModuleToEnable, true);
 }
        public static CswNbtModuleRule makeModuleRule(CswNbtResources CswNbtResources, CswEnumNbtModuleName ModuleName)
        {
            CswNbtModuleRule ret = null;

            if (CswEnumNbtModuleName.CISPro == ModuleName)
            {
                ret = new CswNbtModuleRuleCISPro(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.Dev == ModuleName)
            {
                ret = new CswNbtModuleRuleDev(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.DirectStructureSearch == ModuleName)
            {
                ret = new CswNbtModuleRuleDirectStructureSearch(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.IMCS == ModuleName)
            {
                ret = new CswNbtModuleRuleIMCS(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.MLM == ModuleName)
            {
                ret = new CswNbtModuleRuleMLM(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.NBTManager == ModuleName)
            {
                ret = new CswNbtModuleRuleNBTManager(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.SI == ModuleName)
            {
                ret = new CswNbtModuleRuleSI(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.C3 == ModuleName)
            {
                ret = new CswNbtModuleRuleC3(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.Containers == ModuleName)
            {
                ret = new CswNbtModuleRuleContainers(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.FireCode == ModuleName)
            {
                ret = new CswNbtModuleRuleFireCode(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.SDS == ModuleName)
            {
                ret = new CswNbtModuleRuleSDS(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.RegulatoryLists == ModuleName)
            {
                ret = new CswNbtModuleRuleRegulatoryLists(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.Requesting == ModuleName)
            {
                ret = new CswNbtModuleRuleRequesting(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.MultiSite == ModuleName)
            {
                ret = new CswNbtModuleRuleMultiSite(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.MultiInventoryGroup == ModuleName)
            {
                ret = new CswNbtModuleRuleMultiInventoryGroup(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.FireDbSync == ModuleName)
            {
                ret = new CswNbtModuleRuleFireDbSync(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.PCIDSync == ModuleName)
            {
                ret = new CswNbtModuleRulePCIDSync(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.ManufacturerLotInfo == ModuleName)
            {
                ret = new CswNbtModuleRuleManufacturerLotInfo(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.LOLISync == ModuleName)
            {
                ret = new CswNbtModuleRuleLOLISync(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.DSD == ModuleName)
            {
                ret = new CswNbtModuleRuleDSD(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.ChemWatch == ModuleName)
            {
                ret = new CswNbtModuleRuleChemWatch(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.ArielSync == ModuleName)
            {
                ret = new CswNbtModuleRuleArielSync(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.C3ACD == ModuleName)
            {
                ret = new CswNbtModuleRuleC3ACD(CswNbtResources);
            }
            else if (CswEnumNbtModuleName.C3Products == ModuleName)
            {
                ret = new CswNbtModuleRuleC3Products(CswNbtResources);
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Error,
                                          "Unhandled ModuleName: " + ModuleName.ToString(),
                                          "CswNbtModuleRuleFactory did not recognize module name: " + ModuleName.ToString());
            }
            return(ret);
        }