From 23f7cd51d607dead573dfa5b251d402d502111a2 Mon Sep 17 00:00:00 2001
From: lihongji <3117313295@qq.com>
Date: 星期五, 26 七月 2024 16:44:14 +0800
Subject: [PATCH] Merge branch 'dev' of http://47.101.211.7:10101/r/VWED into dev

---
 _Main/BL/Type_LibCal_Event/StaticMethod_CreateUpdateFromUI.qbl |   75 +++++++++++++++----------------------
 1 files changed, 30 insertions(+), 45 deletions(-)

diff --git a/_Main/BL/Type_LibCal_Event/StaticMethod_CreateUpdateFromUI.qbl b/_Main/BL/Type_LibCal_Event/StaticMethod_CreateUpdateFromUI.qbl
index 76e31f8..df18866 100644
--- a/_Main/BL/Type_LibCal_Event/StaticMethod_CreateUpdateFromUI.qbl
+++ b/_Main/BL/Type_LibCal_Event/StaticMethod_CreateUpdateFromUI.qbl
@@ -41,55 +41,39 @@
   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 );
-    //鏌ヨ鏄惁宸叉湁鍚屽悕浜嬩欢
+    //鏌ヨ鏄惁宸叉湁鍚屽悕鍦ㄦ壒閲忕晫闈㈠垱寤虹殑浜嬩欢s
     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 );
+                           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() );
+      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 );
+          }
         }
       }
-      //淇敼鏃т簨浠剁殑闂撮殧
-      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, 
@@ -97,8 +81,9 @@
                                       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 );
+                                      periodType_i, periodStartDate_i, nrOfOccurrences_i, periodEndDate_i, subscribers_i, ismultiple );
     }
+    
     if( not isnull( event ) ){
       event.EventType( relset, eventtype_i );
     }

--
Gitblit v1.9.3