Options

Execute code on NAS shutdown

GoMaDGoMaD Member Posts: 313
Is it possible to execute code when the nas gets a shutdown request?

If so, where can i enter this code?

(As far as I know it's not possible, but I'm asking anyway. I can always be wrong) :?
Now, let's see what we can see.
...
Everybody on-line.
...
Looking good!

Comments

  • Options
    DenSterDenSter Member Posts: 8,304
    No I don't think so, at least not in Navision. The only event that is exposed is the messagereceived one.
  • Options
    GoMaDGoMaD Member Posts: 313
    can you give more info on this event?

    Would be most helpfull
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • Options
    DenSterDenSter Member Posts: 8,304
    The communication component (i.e. an automation type variable of suntype 'Navision Communication Component version 2'.CommunicationComponent, usually called "CC2" in code samples) should be declared withevents (see properties page), and when you close the globals, you will see an added trigger called CC2::MessageReceived.

    Depending which adapter is hooked into CC2, it will execute the code in the trigger every time a message is received into the adapter/communication component.

    In case of a message queue, it will fire this even each time a message is received into the queue. When there are messages already in the queue when the MSMQ connection is made, this event will process all of them.

    This is a nutshell, read the w1w1atas.pdf document for NAS information in the Doc folder of the product CD, and take a look at a file called "devguide.chm", which is a windows help file with all you need to know about the communication component, including some code samples. Just search the product cd for that file name, it's on there a number of times.
  • Options
    DenSterDenSter Member Posts: 8,304
    doh.... #-o

    I'm sorry, I misread your question. NAS does not fire any events in Navision. The only thing it does is log into Navision, everything else you have to program yourself. When it closes down, the session is lost just like when you close Navision manually.

    Maybe you could do something in codeunit 1 in the LogInEnd function to process some custom code. You'd have to find a way for the session to know that it is a NAS session though.

    Interesting question :-k
  • Options
    GoMaDGoMaD Member Posts: 313
    FOUND IT!!!

    Just adjust the CompanyClose function in CodeUnit 1:
    CompanyClose()
    IF GUIALLOWED THEN
      LogInEnd
    // *** INS1.0 Start
    ELSE
      fctShutdownINS;
    // *** INS1.0 Stop
    

    This new function fctShutdownINS updates the NAS information.

    One remarkt though, you can only use functions from the Codeunit 1, you cannot use functions from other codeunits . If you do this the shutdown will result in an "internal error 2 in module 5" error.

    You can modify, insert or delete records in the tables BUT do not use the validate method. Causes the same problem as the Codeunit thingy.

    Regards,
    Now, let's see what we can see.
    ...
    Everybody on-line.
    ...
    Looking good!
  • Options
    DenSterDenSter Member Posts: 8,304
Sign In or Register to comment.