陈清红
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
73
74
75
76
77
Quintiq file version 2.0
#parent: #root
Method RequestReceiveGetSet (NamedValueTree nvt_i)
{
  Description: 'Handle the request for GetSet in the Data Manager.'
  TextBody:
  [*
    // Jacky C Sep-4-2015 (created)
    sourceKind := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCEKIND() );
    sourceName := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_SOURCENAME() );
    
    // Extract requesting dataset kind and name - Used when requestor does not match source
    requestingKind := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_REQUESTINGDATASETKIND() );
    requestingName := LibInt_MessageAccessor::GetHeaderPropertyAsString( nvt_i, LibDMF_CommunicationChannel::HEADER_REQUESTINGDATASETNAME() );
    
    root := this.CommunicationChannelRoot();
    
    // Retrieve IntegrationEvent
    event := root.EventGetLast( sourceKind, sourceName );
    
    // only DM can respond to this request type
    // if this is not allowed in Hierarchy channel, additional condition will be required
    if( this.CommunicationChannelRoot().IsDataManager() )
    {
      systemOnChannel := this.GetSystemOnChannel( sourceKind, sourceName );
    
      feedback := '';
      set := this.GetSetOfInterest( nvt_i, false, feedback );
      gp  := this.CommunicationChannelRoot().GlobalParameters();
    
      // 1. checks for interest
      if( not isnull( set ) )
      {
        if( systemOnChannel.CanSend() )
        {
          // Save requesting kind and name into SOC for the sending process. This MUST be cleared later.
          systemOnChannel.SetRequestingDataset( requestingKind, requestingName );
    
          // 2. checks for last updated
          lastUpdated := LibInt_MessageAccessor::GetHeaderPropertyAsDateTime( nvt_i, LibDMF_CommunicationChannel::HEADER_LAST_UPDATED() );
          if( not lastUpdated < set.TimestampLastUpdated() )
          {
            // do not return set objects
            // RFC: instead of returning empty set, should create a header to flag it.
          }
    
          data := this.DataCollect( set );
    
          // Set isNotification to false, regardless of the setting of the interest.
          // A request should return the requested data.
          isNotification := false;
          this.MessageSendSetUpdatedToSystem( set.SetType().Name(), set.Name(), isNotification, data, systemOnChannel, gp.DM_DatasetKind(), gp.DM_DatasetName(), set.TimestampLastUpdated() );
        }
        else
        {
          root.EventLogActivityError( event,
                                      "SystemOnChannel is not fully configured",
                                      "SystemOnChannel is not fully configured; "
                                      + "Host = '" + systemOnChannel.HostName()
                                      + "', Port = " + [String]systemOnChannel.PortNr()
                                      + "', IsSoftDeleted = " + [String]systemOnChannel.IsSoftDeleted() );
        }
      }
      else
      {
        // Signal error: interest not found
        this.MessageSendErrorToSystem( LibDMF_CommunicationChannel::REQUEST_GETSET(), feedback, systemOnChannel, gp.DM_DatasetKind(), gp.DM_DatasetName() );
      }
    }
    else
    {
      root.EventLogActivityError( event,
                                  "Request cannot be fulfilled.",
                                  "Request cannot be fulfilled. System " + this.CommunicationChannelRoot().SystemShortName() + " is not a Data Manager." );
    }
  *]
}