| 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: | 
|   [* | 
|     //事件创建二开方法 | 
|     //info( startDate_i, startTimeOfDay_i, endDate_i, endTimeOfDay_i, isAllDay_i, recurrenceInterval_i, patternType_i | 
|     //      , patternDaily_IsEveryWeekday_i, periodType_i, periodStartDate_i, nrOfOccurrences_i, periodEndDate_i ); | 
|     //查询是否已有同名事件 | 
|     event := selectobject( owner_i, Event, event, event.Subject() = subject_i  | 
|                      and event.StartTimeOfDay() = startTimeOfDay_i  | 
|                      and event.EndTimeOfDay() = endTimeOfDay_i  | 
|                      and event.EventType() = eventtype_i ); | 
|     //只有通过批量创建界面且已有同名事件进入下面操作 | 
|     if( ismultiple and not isnull( event ) ){ | 
|       startdate := startDate_i; | 
|       enddate   := startDate_i; | 
|       dates := construct( Dates ); | 
|       dates.Add( startDate_i ); | 
|       //获取旧事件的开始事件和结束事件,以及所有时间点 | 
|       traverse( event, Participation.ExplicitTimeInterval, eti ){ | 
|         if( startdate > eti.Start().Date() ){ | 
|           startdate := eti.Start().Date(); | 
|         } | 
|         if( enddate < eti.Start().Date() ) { | 
|           enddate := eti.Start().Date(); | 
|         } | 
|         if( not exists( dates, Elements, e, e = eti.Start().Date() ) ){ | 
|           dates.Add( eti.Start().Date() ); | 
|         } | 
|       } | 
|       //修改旧事件的间隔 | 
|       nrOfOccurrences_i := enddate - startdate + 1; | 
|       startDate_i := startdate; | 
|       endDate_i   := startdate; | 
|       periodStartDate_i := startdate; | 
|       periodEndDate_i := enddate; | 
|     //  info( startDate_i, startTimeOfDay_i, endDate_i, endTimeOfDay_i, isAllDay_i, recurrenceInterval_i, patternType_i | 
|     //      , patternDaily_IsEveryWeekday_i, periodType_i, periodStartDate_i, nrOfOccurrences_i, periodEndDate_i ); | 
|       event := LibCal_Event::CreateUpdateFromUI( owner_i, event.LeadingParticipation(), 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 ); | 
|       //删掉不需要的时间点 | 
|       timeIntervals := construct( LibCal_ExplicitTimeIntervals ); | 
|       traverse( event, Participation.ExplicitTimeInterval, eti ){ | 
|     //    info( '------------------------------', eti.Start(), eti.End(), exists( dates, Elements, e, e = eti.Start().Date() ), '------------------', dates.Find( eti.Start().Date() ) ); | 
|         if( dates.Find( eti.Start().Date() ) < 0 ){ | 
|           timeIntervals.Add( eti ); | 
|         } | 
|       } | 
|       LibCal_ExplicitTimeInterval::Delete( timeIntervals, true ); | 
|     } 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 ); | 
|     } | 
|     if( not isnull( event ) ){ | 
|       event.EventType( relset, eventtype_i ); | 
|     } | 
|      | 
|     return event; | 
|   *] | 
| } |