Exportfile for AOT version 1.0 or later Formatversion: 1 ***Element: CLS ; Microsoft Dynamics AX Class: Tutorial_ClassWithQueryRun nicht geladen ; -------------------------------------------------------------------------------- CLSVERSION 1 CLASS #Tutorial_ClassWithQueryRun Id 50003 PROPERTIES Name #Tutorial_ClassWithQueryRun Extends #RunBaseBatch RunOn #Called from ENDPROPERTIES METHODS Version: 3 SOURCE #allowSaveLast #public boolean allowSaveLast() #{ # boolean ret; # ; # # // true = Gets the last choice stored in the last value table # // false = call initParmDefault() # ret = super(); # # return ret; #} ENDSOURCE SOURCE #canGoBatch #public boolean canGoBatch() #{ # boolean ret; # ; # # // Enable/disable batch # ret = true; # # return ret; #} ENDSOURCE SOURCE #caption #// Here goes the caption of the class (used ex. for dialog-title) #public ClassDescription caption() #{ # ClassDescription ret; # ; # # ret = "Tutorial-Class"; # # return ret; #} ENDSOURCE SOURCE #classDeclaration #class Tutorial_ClassWithQueryRun extends RunBaseBatch #{ # FilenameSave filenameSave; # DialogField df_FileNameSave; # DialogField df_DialogDate; # date dialogDate; # SysQueryRun queryrun; # TextIo textIo; # # #file # # #define.CurrentVersion(2) # #define.Version1(1) # #localmacro.CurrentList # fileNameSave, # dialogDate, # queryRun # #endmacro #} ENDSOURCE SOURCE #closeFile #private void closeFile() #{ # ; # textIo = null; #} ENDSOURCE SOURCE #dialog #protected Object dialog(DialogRunbase dialog, boolean forceOnClient) #{ # DialogRunbase ret; # ; # # ret = super(dialog, forceOnClient); # # // Note: Don't use addFieldValue when using Default-Button # # df_FileNameSave = ret.addField(typeid(FilenameSave)); # df_DialogDate = ret.addField(typeid(TransDate)); # # // Add helptext # df_FileNameSave.helpText('Enter filename'); # df_DialogDate.helpText('Field is not used. Demonstration purpose only'); # # ret.filenameLookupFilter(this.filenameLookupFilter()); # ret.filenameLookupInitialPath(this.filenameLookupInitialPath()); # ret.filenameLookupTitle(this.filenameLookupTitle()); # # return ret; #} ENDSOURCE SOURCE #dialogClear #public void dialogClear() #{ # ; # super(); # # // Rebuild query/queryRun # this.initQuery(); # # // Clear parameters # filenameSave = ""; # dialogDate = dateNull(); #} ENDSOURCE SOURCE #filenameLookupFilter #FilenameFilter filenameLookupFilter() #{ # return ["Tab-Separated Files;Text-Files",'*.tsv;*.txt']; #} ENDSOURCE SOURCE #filenameLookupInitialPath #Filename filenameLookupInitialPath() #{ # #WinApi # ; # # return winApi::getFolderPath(#CSIDL_DESKTOP); #} ENDSOURCE SOURCE #filenameLookupTitle #str filenameLookupTitle() #{ # return "@SYS63229"; #} ENDSOURCE SOURCE #getFromDialog #public boolean getFromDialog() #{ # boolean ret; # ; # # ret = super(); # # this.parmFilename(df_FileNameSave.value()); # this.parmDialogDate(df_DialogDate.value()); # # return ret; #} ENDSOURCE SOURCE #initParmDefault #public void initParmDefault() #{ # #WINAPI # ; # super(); # # filenameSave = WinAPI::getFolderPath(#CSIDL_DESKTOP) + #FilePathDelimiter + "exportFile.tsv"; # dialogDate = systemdateget(); # # // Build query/queryrun # this.initQuery(); #} ENDSOURCE SOURCE #initQuery #public Query initQuery() #{ # Query query; # QueryBuildDataSource queryBuildDataSource; # QueryBuildRange queryBuildRangeInvoiceDate; # ; # # query = new Query(); # # queryBuildDataSource = query.addDataSource(tablenum(CustInvoiceJour)); # # // Build ranges for SELECT-Button # SysQuery::findOrCreateRange(queryBuildDataSource, fieldnum(CustInvoiceJour, OrderAccount)); # SysQuery::findOrCreateRange(queryBuildDataSource, fieldnum(CustInvoiceJour, InvoiceAccount)); # # // Add locked Range # queryBuildRangeInvoiceDate = query.dataSourceTable(tablenum(CustInvoiceJour)).addRange(fieldnum(CustInvoiceJour, InvoiceDate)); # queryBuildRangeInvoiceDate.value("01.01.2010.."); # queryBuildRangeInvoiceDate.status(RangeStatus::Locked); # # // Add sort fields # query.dataSourceTable(tablenum(CustInvoiceJour)).addSortField(fieldnum(CustInvoiceJour, InvoiceDate), SortOrder::Ascending); # # queryrun = new SysQueryRun(query); # # return query; #} ENDSOURCE SOURCE #pack #public container pack() #{ # ; # return [ #CurrentVersion, # filenameSave, # dialogDate, # queryrun.pack() ]; #} ENDSOURCE SOURCE #parmDialogDate #public TransDate parmDialogDate(TransDate _dialogDate = dialogDate) #{ # ; # dialogDate = _dialogDate; # # return dialogDate; #} # ENDSOURCE SOURCE #parmFilename #Filename parmFilename(FilenameSave _filename = filenameSave) #{ # ; # filenameSave = _filename; # # return filenameSave; #} ENDSOURCE SOURCE #putToDialog #protected void putToDialog() #{ # ; # df_FileNameSave.value(this.parmFilename()); # df_DialogDate.value(this.parmDialogDate()); # # super(); #} ENDSOURCE SOURCE #queryRun #public QueryRun queryRun() #{ # QueryRun ret; # ; # # ret = queryrun; # # return ret; #} ENDSOURCE SOURCE #run #public void run() #{ # CustInvoiceJour custInvoiceJour; # #AviFiles # ; # # super(); # # setprefix(Tutorial_ClassWithQueryRun::description()); # # // Check Parameters # if(!this.validate(this)) # { # return; # } # # // Create/Open File # textIo = Tutorial_ClassWithQueryRun::createFile(this.parmFilename()); # # // Lets go # try # { # // Init progress # this.progressInit(this.caption(),SysQuery::countTotal(this.queryRun()), #AviTransfer); # # while(this.queryRun().next()) # { # custInvoiceJour = queryrun.get(tablenum(CustInvoiceJour)); # # // Update progress # this.parmProgress().incCount(); # # // Write file # textIo.write(custInvoiceJour.InvoiceAccount + #delimiterTab); # textIo.write(custInvoiceJour.InvoiceId + #delimiterTab); # } # } # catch (Exception::Error) # { # this.closeFile(); # } # # this.closeFile(); # # info("@SYS92126"); #} ENDSOURCE SOURCE #runsImpersonated #public boolean runsImpersonated() #{ # boolean ret; # # ret = super(); # # // ret = TRUE: Runs on server (default) # // ret = FALSE: Runs only if started through Basic > Periodic > Batch > Processing # # return ret; #} ENDSOURCE SOURCE #showClearButton #protected boolean showClearButton() #{ # boolean ret; # ; # # // Enable/disable Clear-Button # ret = true; # # return ret; #} ENDSOURCE SOURCE #showDefaultButton #public boolean showDefaultButton() #{ # boolean ret; # ; # # // Enable/disable Default-Button # ret = true; # # return ret; #} ENDSOURCE SOURCE #showQuerySelectButton #boolean showQuerySelectButton() #{ # boolean ret; # ; # # // User can change query # ret = true; # # return ret; #} ENDSOURCE SOURCE #showQueryValues #public boolean showQueryValues() #{ # boolean ret; # ; # # // Determines whether a Select button is to be added to the dialog. If you change the return value to true, the button will be added. # ret = true; # # return ret; #} ENDSOURCE SOURCE #unpack #public boolean unpack(container packedClass) #{ # Integer version = conpeek(packedClass,1); # PackedQueryRun packedQueryRun; # ; # # switch (version) # { # case(#CurrentVersion) : # [version,filenameSave,dialogDate,packedQueryRun] = packedClass; # # if (queryIsPackedOk(packedQueryRun)) # { # queryrun = new QueryRun(packedQueryRun); # # if(!queryrun) # { # this.initQuery(); # } # } # break; # case(#Version1) : # // New dialog-field "date" was added in classversion 2 # [version,filenameSave,packedQueryRun] = packedClass; # # if (queryIsPackedOk(packedQueryRun)) # { # queryrun = new QueryRun(packedQueryRun); # # if(!queryrun) # { # this.initQuery(); # } # } # # dialogDate = systemdateget(); # # break; # default : # return false; # } # # return true; #} ENDSOURCE SOURCE #validate #public boolean validate(Object calledFrom) #{ # boolean ret; # ; # # // Method is called from dialog, and manually called in run-method # # ret = super(calledFrom); # # if(ret && !this.parmFilename()) # { # ret = checkFailed(strfmt("@SYS89866", "@SYS16423")); # } # # if(ret && !this.queryRun()) # { # ret = checkFailed(strfmt("@SYS89866", "@SYS25531")); # } # # return ret; #} ENDSOURCE SOURCE #construct #public static Tutorial_ClassWithQueryRun construct() #{ # ; # return new Tutorial_ClassWithQueryRun(); #} # ENDSOURCE SOURCE #createFile #public static server textio createFile(fileName _fileNameSave) #{ # fileIOPermission fileIOPermission; # textio textio; # #file # ; # # fileIOPermission = new fileIOPermission(_fileNameSave, #io_write); # fileIOPermission.assert(); # # textIo = new TextIo(_fileNameSave, #io_write); # if( !textIo) # { # throw error(strfmt("@SYS72245", _fileNameSave)); # } # # return textIo; #} ENDSOURCE SOURCE #description #static ClassDescription description() #{ # ; # // Here goes a description of the class # return "Tutorial for classes with queryRun and file-export"; #} ENDSOURCE SOURCE #howToUseClass #public static str howToUseClass() #{ # Tutorial_ClassWithQueryRun tutorial_ClassWithQueryRun; # ; # # tutorial_ClassWithQueryRun = Tutorial_ClassWithQueryRun::construct(); # tutorial_ClassWithQueryRun.parmFilename(@'c:\temp\temp_123.tsv'); # tutorial_ClassWithQueryRun.parmDialogDate(systemdateget()); # tutorial_ClassWithQueryRun.initQuery(); # tutorial_ClassWithQueryRun.run(); #} ENDSOURCE SOURCE #main #public static void main(Args args) #{ # Tutorial_ClassWithQueryRun tutorial_ClassWithQueryRun = Tutorial_ClassWithQueryRun::construct(); # ; # # if(tutorial_ClassWithQueryRun.prompt()) # { # tutorial_ClassWithQueryRun.run(); # } #} # ENDSOURCE ENDMETHODS ENDCLASS ***Element: END