Quantcast
Channel: AX Developer Forum
Viewing all articles
Browse latest Browse all 9880

AX 2012: Client and Server for Methods and Classes

$
0
0

I'm a new AX developer (coming from C#).  

I created a project, with 2 main classes, where X++ code imports Fixed Asset Journal entries. 

The class that does the Excel processing has its RunOn property set to Client.
The class that does the database inserts has its RunOn property set to Server.

The Client class instantiates the Server class once at the beginning, and then for each Excel row the Client class processes, the Client passes that Excel row's values to the Server class for inserting.


During compile, Best Practice is advising that I make the Server method static (apparently so that I don't have to instantiate a Server-bound class on the Client).

Here are the problems. 

1) The Server class maintains some state.  It keeps track of the journal name (if it changes in the Excel file, a new LedgerJournalTable row is inserted and related to the other tables' rows to be inserted), the journal line number (which is incremented for each call, and reset if the journal name changes or the max lines per journal limit is reached), and the max lines per journal.

2) The Server class instantiates LedgerJournalEngine in the constructor and uses that one instance throughout. 

If I make the Server method static, then it cannot access the state or class-level variables/objects.

As for the state part, I thought about using an ASP.NET-like, reverse-ViewState-like method of maintaining state.  The Client would pass the state to the Server, and the Server would pass it back to the Client, with any changes made to the values.  But wouldn't the overhead for the additional values being passed back and forth each time eat up any time saved by making the Server method static?

And then there's the matter of - best I can tell - having to new-up a LedgerJournalEngine object each time a new Excel row is processed. Seems to me that that would eat up a lot of the time that might be saved by making the Server method static.


Any suggestions?


Viewing all articles
Browse latest Browse all 9880

Trending Articles