Exporting files from MDriven Server
Line 31: Line 31:
''NO101087,Cosmica Tygg 90 ST…''
''NO101087,Cosmica Tygg 90 ST…''


==== SQLExport serverside action ====
==== New Addition 2019-March ====
The SQLExport action is an action used to write data from your model into another external SQLdatabase. It is an alternative way to export data – way to needs no other external components or maintenance than what MDriven Server provides.
Adding a viewModel column named "filedata" - and this results in a Image,Blob or other byte array type - this data is saved rather than the ViewModel-data-as-XML. If the "filedata"-column is of type string - the string content is written to the file.


SQLExport requires 'connectionstring' on root, 'data' as a Nesting that contains the datarow(s) to insert or update and on data - 'queryforinsert','queryforupdate' and 'queryforselectcount' as attributes (if queryforselectcount returns 0 the queryforinsert is used, else update).
See also [[SQLExport from MDriven Server|SQLExport]]


''Update 2018-10-18: you can now use 'connectionstringodbc' and the logic will use ODBC connection instead.''
The very common case of “replicating” some model driven data to another database is implemented and scheduled in minutes.
[[File:Exporting files from MDriven Server 06.png|frameless|510x510px]]
[[Category:Advanced]]
[[Category:Advanced]]
[[Category:MDriven Server]]
[[Category:MDriven Server]]

Revision as of 09:15, 28 February 2019

Producing export files from MDriven Server

You can also write files by adding an action column called “savefile”; when the periodic action supervisor in MDrivenServer sees this action column it looks for two additonal columns; path and filename (case insensitive). If these are found the complete result of the ViewModel is streamed out as xml by using the ViewModelXMLUtils.GetDataAsXml method. The xml is then saved to path/filename.

Like this:

Exporting files from MDriven Server.png

In a real world application it looked like this:

Exporting files from MDriven Server 02.png

Notice that both path and filename are evaluated expressions, furthermore the Action UpdateExportTime is executed last – and it changes some data. Since the whole execution is wrapped in a memory transaction we make sure that we do not update the export time unless the file was written and everything is ok.

The resulting file looked like this:

Exporting files from MDriven Server 03.png

Shaping and transforming export files

This SaveFile action has been updated to look for a column named xslt, if it is found the contents of the field is assumed to be a valid xslt transformation. The xml from the viewmodel is transformed with the xslt and the result is saved as above.

So if your xslt is…

<?xml version='1.0'?>
 <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
 version='1.0'> <xsl:output method='text' omit-xml-declaration='yes'/> 
            <xsl:value-of select='ArticleNumber'/>,<xsl:value-of
 select='SalesArticleName'/>
        </xsl:template>
 </xsl:stylesheet>

… then your output would be…

NO101087,Cosmica Tygg 90 ST…

New Addition 2019-March

Adding a viewModel column named "filedata" - and this results in a Image,Blob or other byte array type - this data is saved rather than the ViewModel-data-as-XML. If the "filedata"-column is of type string - the string content is written to the file.

See also SQLExport

This page was edited 123 days ago on 01/11/2024. What links here