lazhen
2024-06-14 42e52dd7a48775cd83be92cc46ea42aa124cb15c
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
Quintiq file version 2.0
#parent: #root
Method InitializeTable (
  LibCal_Calendars subscribers
)
{
  TextBody:
  [*
    // 甄兰鸽 May-28-2024 (created)
    rownr                 := this.LibCal_SubscriberEventRow( relsize );
    subscribercolumn      := selectobject( this, LibCal_SubscriberEventColumn, column, column.RowName() = 'Line' );
    if( isnull( subscribercolumn ) ){
      subscribercolumn := this.LibCal_SubscriberEventColumn( relnew, RowName := 'Line' );
    }
    eventcolumn := selectobject( this, LibCal_SubscriberEventColumn, column, column.RowName() = 'Event' );
    if( isnull( eventcolumn ) ){
      eventcolumn := this.LibCal_SubscriberEventColumn( relnew, RowName := 'Event' );
    }
    
    traverse( subscribers, Elements, subscriber ){
    //  info( '------------------------', subscriber.CalendarID(), subscriber.CalendarType() );
    //  traverse( subscriber,Participation.astype( LibCal_Subscription ).LeadingParticipation, participation ){
      traverse( subscriber,Participation.astype( LibCal_Subscription ).LeadingParticipation, participation, participation.Event().EventCategory().Name() = 'Unavailable' and participation.Event().Subject() = '测试' ){
    //    info( '------------------------', participation.Event().Subject(), '------', participation.Event().EventCategory().Name() );
        event := participation.Event();
        
        row := selectobject( this, LibCal_SubscriberEventRow, row, row.Subscriber() = subscriber.CalendarID() 
                             and row.Event() = event.Subject() 
                             and row.EventType() = event.EventType().Name() 
                             );
        
        if( isnull( row ) ){
          row := this.LibCal_SubscriberEventRow( relnew, RowNr := rownr, Subscriber := subscriber.CalendarID(), 
                                                 Event := event.Subject(), 
                                                 EventType := event.EventType().Name() );
          
          subscribercell := subscribercolumn.LibCal_SubscriberEventCell( relnew, Value := row.Subscriber() );
          if( counter( this, LibCal_SubscriberEventRow, linerow, linerow.Subscriber() = row.Subscriber() ) <> 1 ){
            subscribercell.Value( '' );
          }
          row.LibCal_SubscriberEventCell( relinsert, subscribercell );
          
          eventcell := eventcolumn.LibCal_SubscriberEventCell( relnew, Value := row.Event() );
          row.LibCal_SubscriberEventCell( relinsert, eventcell );
          rownr := rownr + 1;
        }
        
        traverse( participation, ExplicitTimeInterval, eti ){
          info( eti.Start(), eti.End(), eti.DefinitionName() );
          if( this.ID() = 'Day' ){
            this.InitializeDay( this, row, eti.Start(), eti.End(), event.Description() );
          }else if( this.ID() = 'Week' ){
            this.InitializeWeek( this, row, eti.Start(), eti.End(), event.Description() );
          }else{
            this.InitializeMonth( this, row, eti.Start(), eti.End(), event.Description() );
          }
        }
        
        
    //
    //    endTime     := participation.EndDate().DateTime( timezone ).AddAsPeriod( timezone, event.EndTimeOfDay() );
    //    startTime   := participation.StartDate().DateTime( timezone ).AddAsPeriod( timezone, event.StartTimeOfDay() );
    
      }
    }
    
    //traverse( this, LibCal_SubscriberEventColumn, column ){
    //  traverse( this, LibCal_SubscriberEventRow, row ){
    //    if( not exists( column, LibCal_SubscriberEventCell, cell, cell.LibCal_SubscriberEventRow() = row ) ) {
    //      cell := column.LibCal_SubscriberEventCell( relnew, Value := '' );
    //      row.LibCal_SubscriberEventCell( relinsert, cell );
    //    }
    //  }
    //}
  *]
}