admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Quintiq file version 2.0
#parent: #root
StaticMethod CreateUpdateFromUI (
  LibCal_Calendar owner_i,
  LibCal_LeadingParticipation participation_i,
  String subject_i,
  String description_i,
  String type_i,
  LibCal_EventType eventtype_i,
  Real capacity_i,
  LibCal_EventCategory category_i,
  Boolean isDefault_i,
  Date startDate_i,
  Duration startTimeOfDay_i,
  Date endDate_i,
  Duration endTimeOfDay_i,
  Boolean isAllDay_i,
  Boolean isRecurring_i,
  Number recurrenceInterval_i,
  String patternType_i,
  Boolean patternDaily_IsEveryWeekday_i,
  String patternWeekly_Weekdays_i,
  Boolean patternMonthly_IsDay_i,
  Number patternMonthly_Day_i,
  String patternMonthly_WeekOfMonth_i,
  String patternMonthly_DayOfWeek_i,
  Boolean patternYearly_IsDate_i,
  Number patternYearly_Month_i,
  Number patternYearly_Day_i,
  String patternYearly_WeekOfMonth_i,
  String patternYearly_DayOfWeek_i,
  String periodType_i,
  Date periodStartDate_i,
  Number nrOfOccurrences_i,
  Date periodEndDate_i,
  LibCal_Calendars subscribers_i,
  Boolean ismultiple
) as LibCal_Event
{
  Description: 'Create and/or update an Event and its LeadingParticipation, based on information from the UI.'
  TextBody:
  [*
    //事件创建二开方法
    //查询是否已有同名在批量界面创建的事件s
    event := selectobject( owner_i, Event, event, event.Subject() = subject_i 
                           and event.EventType() = eventtype_i );
    
    //只有通过批量创建界面且已有同名事件进入下面操作
    if( ismultiple and not isnull( event ) ){
      event.IsMultiple( true );
      lp        := event.LeadingParticipation();
      timezone  := lp.Calendar().GetTimeZone();
      starttime := startDate_i.DateTime( timezone ).AddAsPeriod( timezone, startTimeOfDay_i );
      endtime   := endDate_i.DateTime( timezone ).AddAsPeriod( timezone, endTimeOfDay_i );
      etis      := selectset( lp, Subscription.ExplicitTimeInterval, eti, true );
    //  startDate := starttime.Date( timezone );
    //  endDate   := endtime.Date( timezone ) - ifexpr( endtime = endtime.StartOfDay( timezone ), 1, 0 );
      leadingETI := selectobject( lp, ExplicitTimeInterval, eti, eti.Start() = starttime and eti.End() = endtime );
    
      if( isnull( leadingETI ) ){
        leadingETI := lp.CreateTimeInterval( starttime, endtime, event.Capacity() );
      }
      lp.AddSubscribers( subscribers_i, true );
    
      if( not isnull( leadingETI ) ){
        traverse( lp, Subscription, subscription, subscribers_i.Find( subscription.Calendar() ) >= 0 ){
    
          traverse( subscription, ExplicitTimeInterval, eti, etis.Find( eti ) < 0 ){
            eti.Delete();
          }
          subscribingETI := subscription.CreateTimeInterval( starttime, endtime, event.Capacity() );
          if( not isnull( subscribingETI ) ){
            subscribingETI.LeadingETI( relset, leadingETI );
          }
        }
      }
    } else {
      event := LibCal_Event::CreateUpdateFromUI( owner_i, participation_i, subject_i, description_i, type_i, capacity_i, category_i, isDefault_i, 
                                      startDate_i, startTimeOfDay_i, endDate_i, endTimeOfDay_i, isAllDay_i, 
                                      isRecurring_i, recurrenceInterval_i,
                                      patternType_i, patternDaily_IsEveryWeekday_i, patternWeekly_Weekdays_i, 
                                      patternMonthly_IsDay_i, patternMonthly_Day_i, patternMonthly_WeekOfMonth_i, patternMonthly_DayOfWeek_i,
                                      patternYearly_IsDate_i, patternYearly_Month_i, patternYearly_Day_i, patternYearly_WeekOfMonth_i, patternYearly_DayOfWeek_i,
                                      periodType_i, periodStartDate_i, nrOfOccurrences_i, periodEndDate_i, subscribers_i, ismultiple );
    }
    
    if( not isnull( event ) ){
      event.EventType( relset, eventtype_i );
    }
    
    return event;
  *]
}