| Quintiq file version 2.0 | 
| #parent: #root | 
| Method MessageSend (LibDMF_SystemOnChannel soc_i, String messageType_i, NamedValueTree nvt_i,  | 
|   String sourceKind_i, String sourceName_i, DateTime lastUpdate_i) | 
| { | 
|   TextBody: | 
|   [* | 
|     event := null( Object ); | 
|      | 
|     datasetKind := ""; | 
|     datasetName := ""; | 
|      | 
|     root := this.CommunicationChannelRoot(); | 
|      | 
|     // Retrieve the last event of the requester | 
|     if( not isnull( soc_i ) ) | 
|     { | 
|       datasetKind := soc_i.DatasetKind(); | 
|       datasetName := soc_i.DatasetName(); | 
|       event       := root.EventGetLast( datasetKind, datasetName ); | 
|     } | 
|      | 
|     // Use a QuintiqKey as the unique ID of a message. | 
|     messageID := [String]Key::NextPersistentKey(); | 
|      | 
|     // Get some characteristics of the Message out of the header. | 
|     isRequest := LibInt_MessageAccessor::HasHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_IS_REQUEST() ) and | 
|                  LibInt_MessageAccessor::GetHeaderPropertyAsBoolean( nvt_i, LibDMF_CommunicationChannel::HEADER_IS_REQUEST() ); | 
|      | 
|     isError := LibInt_MessageAccessor::HasHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_IS_ERROR() ) and | 
|                LibInt_MessageAccessor::GetHeaderPropertyAsBoolean( nvt_i, LibDMF_CommunicationChannel::HEADER_IS_ERROR() ); | 
|      | 
|     // Add additional information to the header of the NTV. | 
|     LibInt_MessageAccessor::SetHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_COMMUNICATIONCHANNEL(), this.Name()   ); | 
|     LibInt_MessageAccessor::SetHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_MESSAGETYPE(),          messageType_i ); | 
|     LibInt_MessageAccessor::SetHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_MESSAGEID(),            messageID     ); | 
|     LibInt_MessageAccessor::SetHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCEKIND(),           sourceKind_i  ); | 
|     LibInt_MessageAccessor::SetHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCENAME(),           sourceName_i  ); | 
|      | 
|     if( not isRequest and not isError ) | 
|     { | 
|       LibInt_MessageAccessor::SetHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_LAST_UPDATED(), lastUpdate_i ); | 
|     } | 
|      | 
|     // Update the IntegrationEvent | 
|     root.EventUpdateTraceInfo( event, messageID, this.RequestID(), messageType_i, this.IntegrationTechnology() ); | 
|      | 
|     // Add the RequestID if it has been registered. | 
|     // Mind: when a RequestID registered this indicates that a *Response* to a Request is being send, the Request itself has already been processed. | 
|     if( this.RequestID() <> LibDMF_CommunicationChannel::REQUEST_NO_ID() ) | 
|     { | 
|       LibInt_MessageAccessor::SetHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_REQUESTID(), this.RequestID() ); | 
|     } | 
|      | 
|     // Send the message based on the selected Integration Technology | 
|     if( this.IntegrationTechnology() = LibDMF_CommunicationChannel::INTEGRATION_TECHNOLOGY_SOAP() ) | 
|     { | 
|       this.MessageSendViaSOAP( soc_i, nvt_i ); | 
|     } | 
|     // LibMF disable temporarily | 
|     //else if( this.IntegrationTechnology() = LibDMF_CommunicationChannel::INTEGRATION_TECHNOLOGY_MESSAGE_FRAMEWORK() ) | 
|     //{ | 
|     //  this.MessageSendViaMF( soc_i, nvt_i ); | 
|     //} | 
|     else | 
|     { | 
|       root.EventLogActivityError( event, | 
|                                   "Unexpected Integration Technology '" + this.IntegrationTechnology() + "' encountered", | 
|                                   "Unexpected Integration Technology '" + this.IntegrationTechnology() + "' encountered; CommunicationChannel = " + this.Name() ); | 
|     } | 
|   *] | 
| } |