Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Excerpt

PreInit should be performed by business systems that do not want to be connected at all time, but only upon request by NoahClient or itself when needed.

The Business system needs to call PreInit with a delegate to a method that can call connect on the BusinessAPI.


bool PreInit(RequestBSConnectNC r);

If the UserManager or PatientManager do not connect to NoahClient when the application starts, NoahClient must have a way to request the application to connect if it is running (to avoid that another instance of the same application is started). In order to make this possible the application must call PreInit. The PreInit call creates a named event based on where the application is installed and the name of the application. This information is also available in NoahClient, as it is one of the registration parameters. Whenever NoahClient needs the application to connect, the event is signaled.

Returns false if the function already has been called, and true otherwise.


bool PreUninit()

When an application shuts down it should call the PreUnint, which releases all resources allocated by the call of PreInit.

The function returns false if called without a call to PreInit and true otherwise.


delegate bool RequestBSConnectNC();

The delegate that the User/Patient manager must implement. RequestBSConnectNC() is called by NoahClient when it needs to launch a UserManager or PatientManager, to request the manager to Connect to Noah.

Info

public class NoahPreInitSample: IBSCallBack {

              public void Uninitialize() {

                     Himsa.Noah.BusinessAPI.NoahPreInit.PreUninit();

              }

              public void Initialize() {

                     try {

                           Himsa.Noah.BusinessAPI.NoahPreInit.PreInit(new

RequestBSConnectNC(ConnectRequestCallback));

                     }

                     catch (Exception ex) {

                           l.log.Error("PreInit()", ex);

                           throw;

                     }

              }

              private BusinessAPI _businessServer;

              private bool ConnectRequestCallback() {

                     if (_businessServer == null) {

                           _businessServer = new BusinessAPI();

                           try {

                                  _businessServer.Initialize(“MyServer”, null, this,

NoahAppType.PatientManger);

                           }

                            catch (Exception ex) {

                                  l.log.Error("Initialize() ", ex);

                           }

                     }

                     return true;

              }


              #region IBSCallBack Members


              public bool GetPatientIDsByInfo(object PatientInfo, out int[]

PatientID) {

                     throw new NotImplementedException();

              }

              public bool Login(out int UserID) {

                     // Simulate selecting user with id 8

                     UserID = 8;

                     return true;

              }

              public bool SetPatientIDByInfo(int[] PatientIDs, out int PatientID) {

                     // Simulating we selects patient with id 1

                     PatientID = 1;

                     return true;

              }

              #endregion

       }


TODO:

  • Can IBSCallBack.Login() / SetPatientIDByInfo() be called before BusinessAPI.Initialize() returns?