陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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() );
    }
  *]
}