Skip to main content

I have a c# application that runs fme translation but how can I know if the translation was successfully or not?

How does your code run the FME translation? Using the .NET IFMEOWorkspaceRunner interface, or by any other method?


How does your code run the FME translation? Using the .NET IFMEOWorkspaceRunner interface, or by any other method?

No I don't use IFMEOWorkspaceRunner, the simplest way I found was to open a process and run it with arguments; but I need to know if the translation was successfully or not in order to save the result in a table.

 

In case is needed this is the code I use for open a process, pass the arguments and run fme.

 

 

ProcessStartInfo info = new ProcessStartInfo;

 

info.Arguments = "/C fme.exe " + workspace + " --BName " + BNameFix + " --BType " + BType + " --DB " + DB + " --Schema " + Schema + " --DName " + DName + " --DestDataset_ACAD " + "\\"";

 

info.FileName = "fme.exe";

 

Process.Start (info);

 

 


The simplest solution is probably to use the Process.ExitCode property:

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.exitcode?redirectedfrom=MSDN&view;=netframework-4.7.2#System_Diagnostics_Process_ExitCode

There may be some cases where this won't work, however, and if so you'll probably have to scan the FME log file and look for either string (I recommend case sensitive):

Translation was SUCCESSFUL

or

Translation FAILED

The simplest solution is probably to use the Process.ExitCode property:

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.exitcode?redirectedfrom=MSDN&view;=netframework-4.7.2#System_Diagnostics_Process_ExitCode

There may be some cases where this won't work, however, and if so you'll probably have to scan the FME log file and look for either string (I recommend case sensitive):

Translation was SUCCESSFUL

or

Translation FAILED
Thank you @david_r; but as you said this won't wok in some cases and I was thinking what if I can use python? there's any way that I can use python to know or to log into a file if the translation was successful or not? thanks

 


You can also use the workspace shutdown script to write out the translation status.

Sample Python shutdown script that will write either "SUCCESS" or "FAILURE" to the text file named <workspace filename>_status.log

import fme

message = 'SUCCESS' if fme.status else 'FAILURE'

log_filename = fme.macroValues>'FME_MF_DIR'] + '/' + 
               fme.macroValues/'WORKSPACE_NAME'] + '_status.log'

with open(log_filename, 'w') as statuslog:
    statuslog.write(message)

There's a lot if interesting stuff in the 'fme' module that you may want to in include in this file:

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Workbench/Configuration/FME_END_PYTHON.htm


Reply