陈清红
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
Quintiq file version 2.0
#parent: #root
Method MessageReceive (NamedValueTree nvt_i)
{
  TextBody:
  [*
    sourceKind  := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCEKIND()  );
    sourceName  := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCENAME()  );
    messageType := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_MESSAGETYPE() );
    messageID   := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_MESSAGEID()   );
    sourceName  := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCENAME()  );
    
    // See if it is an error message.
    isError := LibInt_MessageAccessor::HasHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_IS_ERROR() ) and
               LibInt_MessageAccessor::GetHeaderPropertyAsBoolean( nvt_i, LibDMF_CommunicationChannel::HEADER_IS_ERROR() );
    
    // The message might have been sent in response to a Request; in that case the header contains a RequestID.
    requestID   := ifexpr( LibInt_MessageAccessor::HasHeaderProperty( nvt_i, LibDMF_CommunicationChannel::HEADER_REQUESTID() ),
                           LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_REQUESTID() ),
                           LibDMF_CommunicationChannel::REQUEST_NO_ID() );
    
    requestInfo := ifexpr( requestID <> LibDMF_CommunicationChannel::REQUEST_NO_ID(), ", RequestID = " + requestID, "" );
    
    root := this.CommunicationChannelRoot();
    
    // Retrieve IntegrationEvent
    event := root.EventGetLast( sourceKind, sourceName );
    
    // Log this action for tracing and update the IntegrationEvent
    LibDMF_Util::Trace( sourceName, messageID, messageType, "", false, true );
    root.EventUpdateTraceInfo( event, messageID, requestID, messageType, "" );
    
    errorText := ifexpr( isError, "error ", "" );
    
    root.EventLogActivity( event,
                           "Received " + errorText + "message '" + messageType + "' for CommunicationChannel = '" + this.Name() + "'; MessageID = " + messageID + requestInfo );
    
    if( isError )
    {
      this.MessageReceiveError( nvt_i );
    }
    else
    {
      // SetUpdate and HierarchyUpdated are treated in the same way.
      if( messageType = LibDMF_CommunicationChannel::MESSAGETYPE_SETUPDATED() or
          messageType = LibDMF_CommunicationChannel::MESSAGETYPE_HIERARCHYUPDATED() )
      {
        this.MessageReceiveSetUpdated( messageType, nvt_i );
      }
      else if( messageType = LibDMF_CommunicationChannel::MESSAGETYPE_SETCREATED() )
      {
        this.MessageReceiveSetCreated( nvt_i );
      }
      else if( messageType = LibDMF_CommunicationChannel::MESSAGETYPE_SETREMOVED() )
      {
        this.MessageReceiveSetRemoved( nvt_i );
      }
      else if( messageType = LibDMF_CommunicationChannel::MESSAGETYPE_SETLISTUPDATED() )
      {
        this.MessageReceiveSetListUpdated( nvt_i );
      }
      else
      {
        root.EventLogActivityError( event,
                                    "Received unknown message '" + messageType + "' for CommunicationChannel = '" + this.Name() + "'",
                                    "Received unknown message '" + messageType + "' for CommunicationChannel = '" + this.Name() + "'; MessageID = " + messageID + requestInfo );
      }
    }
  *]
}