NAV Timer

Kc_NirvanaKc_Nirvana Member Posts: 146
edited 2014-07-16 in NAV Three Tier
Hello,
Is it possible to use NavTimer.DLL from Navision 2009R2 in Nav2013R2 with NAS?
Thank you
Junior Consultant & Developer in Dynamics NAV

"I'm worse at what I do best
And for this gift I feel blessed
Our little group has always been
And always will until the end"

Nirvana - Nevermind - Smells Like Teen Spirit

Answers

  • daborgdaborg Member Posts: 54
    Not sure about using the old 2009 version, but there's a new timer DLL in the "RoleTailored Client\Add-ins\Timer" folder named "Microsoft.Dynamics.Nav.Timer.dll".

    We've done some recent work with this DLL and NAS and it seems to work just fine.
  • thegunzothegunzo Member Posts: 274
    You should really try to use WHILE Loops and SLEEP instead of the timer.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • Rob_HansenRob_Hansen Member Posts: 296
    That doesn't make any sense. The timer is used to implement completely different functionality than WHILE loops and SLEEP calls in code.
  • majormarcell1988majormarcell1988 Member Posts: 20
    Hi,

    NAV 2013 has a new addin called PingPong which does the same as timer would (in my understanding).

    http://www.dynamics.is/?p=1311

    Marcell
  • daborgdaborg Member Posts: 54
    Hi,

    NAV 2013 has a new addin called PingPong which does the same as timer would (in my understanding).

    http://www.dynamics.is/?p=1311

    Marcell

    The issue we found with this is that the PingPong control works great as a client side control, but it will not run server side, which is required for running with the NAS.
  • Kc_NirvanaKc_Nirvana Member Posts: 146
    daborg wrote:
    Hi,

    NAV 2013 has a new addin called PingPong which does the same as timer would (in my understanding).

    http://www.dynamics.is/?p=1311

    Marcell

    The issue we found with this is that the PingPong control works great as a client side control, but it will not run server side, which is required for running with the NAS.

    And that's my problem...
    I am migrating a NAV5 to a NAV7 and I used the NAV Timer 1.0 on NAS.
    The timer problem on NAS, it was solved by JobQueue but I still have one problem with the error handling.
    On NAV5 with Timer, when it gave an error they go to TimerError and rollback transaction even codeunits with Commit...
    Right now IF I try to Post a GenJnlLine and gives error, the line stay on the journal.....
    :(
    Junior Consultant & Developer in Dynamics NAV

    "I'm worse at what I do best
    And for this gift I feel blessed
    Our little group has always been
    And always will until the end"

    Nirvana - Nevermind - Smells Like Teen Spirit
  • thegunzothegunzo Member Posts: 274
    I would solve this with three codeunits and a parameter table

    1. Timer Codeunit
    2. Execution Codeunit
    3. Loggin Codeunit

    You need a parameter table like "Job Queue Entry"

    The Timer Codeunit would be something like this
    WHILE TRUE DO BEGIN 
      SuccessfulExecution := CODEUNIT.RUN(Codeunit::"Execution Codeunit",ParameterTable);
      IF NOT SuccessfulExecution THEN BEGIN
        ParameterTable.WasError := TRUE;
        ParameterTable.SetErrorMessage(GETLASTERRORTEXT);
      END;
      SuccessfulExecution := CODEUNIT.RUN(Codeunit::"Logging Codeunit",ParameterTable);  
      SLEEP(2000);  // Wait 2 seconds for next loop
    END;
    

    You start the timer codeunit using STARTSESSION command.

    In the execution codeunit you select what to do and returns all that needs to be logged via the parameter table.

    But

    What I do in real life is create a report and add that report to the Job Queue.
    In the report I execute a codeunit with error handling and logging.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • ara3nara3n Member Posts: 9,255
    I suggest to use Jobqueue. You can schedule to trigger a codeunit based on a time.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Kc_NirvanaKc_Nirvana Member Posts: 146
    thegunzo wrote:
    I would solve this with three codeunits and a parameter table

    1. Timer Codeunit
    2. Execution Codeunit
    3. Loggin Codeunit

    You need a parameter table like "Job Queue Entry"

    The Timer Codeunit would be something like this
    WHILE TRUE DO BEGIN 
      SuccessfulExecution := CODEUNIT.RUN(Codeunit::"Execution Codeunit",ParameterTable);
      IF NOT SuccessfulExecution THEN BEGIN
        ParameterTable.WasError := TRUE;
        ParameterTable.SetErrorMessage(GETLASTERRORTEXT);
      END;
      SuccessfulExecution := CODEUNIT.RUN(Codeunit::"Logging Codeunit",ParameterTable);  
      SLEEP(2000);  // Wait 2 seconds for next loop
    END;
    

    You start the timer codeunit using STARTSESSION command.

    In the execution codeunit you select what to do and returns all that needs to be logged via the parameter table.

    But

    What I do in real life is create a report and add that report to the Job Queue.
    In the report I execute a codeunit with error handling and logging.

    I had this code in NAV 5 that I can't seem to be running in NAV 2013
    Codeunit single instance
    gautTimer::Timer(Milliseconds : Integer)
    
    gcunInterfaceADO.StartConnection;
    
    //#########################            Copy Transactions to Navision Tables
    gcunInterfaceADO.CopySQLNAV('SP_NAVReadTransaction');
    
    //#########################            Process Entities
    IF grecInterfaceSetup."Entities Interface" THEN
      gcunInterfaceGeneral.ProcessEntitiesNAV;
    
    //#########################            Process Dossiers
    IF grecInterfaceSetup."Dossiers Interface" THEN
      gcunInterfaceGeneral.ProcessDossiersNAV;
    
    //#########################            Process Expenses
    IF grecInterfaceSetup."Expenses Interface" THEN BEGIN
      gcunInterfaceGeneral.ProcessExpensesSQL;
      gcunInterfaceGeneral.ProcessExpensesNAV;
    END;
    
    //#########################            Process Mov.
    IF grecInterfaceSetup."Mov. Interface" THEN BEGIN
      gcunInterfaceGeneral.ProcessMovNAV;
      gcunInterfaceGeneral.ProcessImp;
    END;
    
    gcunInterfaceADO.CloseConnection;
    
    
    //#########################            Process Expenses
    IF grecInterfaceSetup."Expense Interface" THEN BEGIN
      goptOrigin := goptOrigin::Expense;
      gcunInterfaceADO.StartConnectionExpense;
    
      gcunInterfaceADO.CopySQLNAVExpense('SELECT * FROM PortalVdA_View_NAV_Despesa');
    
      gcunInterfaceADO.CloseConnection;
    END;
    
    gautTimer::TimerError(ErrorString : Text[1024])
    
    IF goptOrigin = goptOrigin::Juris THEN
      gcunInterfaceADO.ProcessTransactionSQLNAV2(gintTransactionNo,'SP_SQLNAVTransactionModify',ErrorString)
    ELSE IF goptOrigin = goptOrigin::Nav THEN
      gcunInterfaceADO.ProcessTransactionSQLNAV2(gintTransactionNo,'SP_SQLNAVTransactionModify_NAV',ErrorString)
    ELSE IF goptOrigin = goptOrigin::Expense THEN
      gcunInterfaceADO.ProcessExpenseSQL(gcodExpense,2,ErrorString);
    //ERROR(ErrorString);
    

    I had ADODB automation which I replaced with DOTNET variables SQL...
    But it seems that if I put the one codeunit on single instance and run your code it only runs 1 time....
    :(
    Junior Consultant & Developer in Dynamics NAV

    "I'm worse at what I do best
    And for this gift I feel blessed
    Our little group has always been
    And always will until the end"

    Nirvana - Nevermind - Smells Like Teen Spirit
  • thegunzothegunzo Member Posts: 274
    You can study how the Job Queue works in standard NAV.
    In Codeunit 448 you will find the code
    WHILE JobQueue.Started DO BEGIN
      HandleRequest;
      COMMIT;
      JobQueue.LOCKTABLE;
      IF NOT JobQueue.GET(JobQueue.Code) THEN
        EXIT;
      IF NOT JobQueue.Started THEN
        EXIT;
      IF NOT (JobQueue."Session ID" = SESSIONID) THEN
        EXIT;
      JobQueue.UpdateHeartbeat;
      COMMIT;
      SLEEP(10000);
    END;
    

    Again I suggest that you use report to do the error checking for you codeunit and add the report to the standard job queue.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • Kc_NirvanaKc_Nirvana Member Posts: 146
    thegunzo wrote:
    You can study how the Job Queue works in standard NAV.
    In Codeunit 448 you will find the code
    WHILE JobQueue.Started DO BEGIN
      HandleRequest;
      COMMIT;
      JobQueue.LOCKTABLE;
      IF NOT JobQueue.GET(JobQueue.Code) THEN
        EXIT;
      IF NOT JobQueue.Started THEN
        EXIT;
      IF NOT (JobQueue."Session ID" = SESSIONID) THEN
        EXIT;
      JobQueue.UpdateHeartbeat;
      COMMIT;
      SLEEP(10000);
    END;
    

    Again I suggest that you use report to do the error checking for you codeunit and add the report to the standard job queue.

    Why report and not codeunit?
    Junior Consultant & Developer in Dynamics NAV

    "I'm worse at what I do best
    And for this gift I feel blessed
    Our little group has always been
    And always will until the end"

    Nirvana - Nevermind - Smells Like Teen Spirit
Sign In or Register to comment.