Disconnecting or Closing Noah 2/3 Modules



The Business API can close or disconnect Noah 4 module in one of two ways: by asking if it is alright to close or disconnect and awaiting an OK before closing, or by simply closing or disconnecting directly.

When asking whether it is alright to close, the Business API uses the method SafeToCloseEx with the arguments ModuleID and RunningModuleID. This method closes the module if an OK is received. The sample code below outlines this method. For a detailed description of the sequence please refer to More Information_N4 Business System API

IMPORTANT: It’s NOT possible to close Noah 4 modules.

void Ctrl_StopModule(object obj, ModuleEventArg arg)

        {

            Module module = arg.Module;

            RunningModule runningModule = arg.RunningModule;

            foreach (Module mod in businessApiObj.Modules)

            {

                if (mod.CompareTo(module) == 0)

                    mod.SafeToCloseEx(runningModule.ModuleID, runningModule.RunningModuleHandle);

     }    

   }



If Noah Client returns with ModuleCloseAccepted then the module is closed and the business system developer does not need to do anything.



If the Module declines the close request then the business system can force a close and/or disconnect. This is done by calling the method CloseModule on the module. The same method can be used if the business system needs to force the module to close. Refer to the sample code below:

void Ctrl_StopModule(object obj, ModuleEventArg arg)

        {

            Module module = arg.Module;

            RunningModule runningModule = arg.RunningModule;

            foreach (Module mod in businessApiObj.Modules)

            {

                if (mod.CompareTo(module) == 0)

                    mod.CloseModule(runningModule.ModuleID, runningModule.RunningModuleHandle);

     }    

  }           



NOTE: All objects in the Business API, which are defined as ‘information holders’ will implement a method called CompareTo. This is due to the base class IComparable which the information holder inherits from the Noah 4 implementation.