// Create a nicely formatted string from AppOutputLines private string GetResultMessagesString(AppOutputLines oAppoutputLines) { var s1 = "Transformation result messages:\n"; foreach (AppOutputLine oAppoutputLine in oAppoutputLines) { s1 += GetAppoutputLineFullText(oAppoutputLine); s1 += "\n"; } return(s1); }
// Create a nicely formatted string from AppOutputLines private string GetResultMessagesString(AppOutputLines oAppoutputLines) { var s1 = "Transformation result messages:\n"; foreach (AppOutputLine oAppoutputLine in oAppoutputLines) { s1 += GetAppoutputLineFullText(oAppoutputLine); s1 += "\n"; } return s1; }
// ---- MAIN ------------------------------------- public void ExecuteMap(string mapForceDataMappingFile, string inputFile, string outputFile) { try { // Open an existing mapping. Document doc = null; #if DEBUG_TRANSFORMATION doc = mapforce.OpenDocument(mapForceDataMappingFile); #else ThreadStart threadStart = () => { try { doc = mapforce.OpenDocument(mapForceDataMappingFile); } catch (Exception ex) { Error(ex.Message, ex); } }; RunCommandAndShutDownPopups(threadStart); #endif if (null == doc) { return; } // Find existing components by name in the main mapping. // The names of components may not be unique as a schema component's name is derived from its schema file name. //var sourceComponent = FindComponent(doc.MainMapping, "Employees"); //var targetComponent = FindComponent(doc.MainMapping, "PersonList"); // If you do not know the names of the components for some reason, you could // use the following functions instead of FindComponent. var sourceComponent = GetFirstSourceComponent(doc.MainMapping); var targetComponent = GetFirstTargetComponent(doc.MainMapping); // Specify the desired input and output files. if (!string.IsNullOrEmpty(inputFile)) { sourceComponent.InputInstanceFile = inputFile; } if (!string.IsNullOrEmpty(outputFile)) { targetComponent.OutputInstanceFile = outputFile; } // Perform the transformation. // You can use doc.GenerateOutput() if you do not need result messages. // If you have a mapping with more than one target component and you want // to execute the transformation only for one specific target component, // call targetComponent.GenerateOutput() instead. AppOutputLines resultMessages = null; #if DEBUG_TRANSFORMATION resultMessages = doc.GenerateOutputEx(); #else threadStart = () => { resultMessages = doc.GenerateOutputEx(); }; RunCommandAndShutDownPopups(threadStart); #endif string summaryInfo = string.Format("Transformation result: {0}", GetResultMessagesString(resultMessages)); Console.WriteLine(summaryInfo); } catch (System.Runtime.InteropServices.COMException ex) { Error("Failure", ex); } catch (Exception err) { Error("Failure", err); } }