| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod BatchSetUnitShiftPattern ( | 
|   Unit unit, | 
|   ShiftPattern shiftPattern, | 
|   Date startDate, | 
|   Date endDate, | 
|   Number skipDay | 
| ) | 
| { | 
|   TextBody: | 
|   [* | 
|     // Akari Oct-10-2024 (created) | 
|     owner := unit.MacroPlan(); | 
|      | 
|     saveDays := construct( Dates ); | 
|     for( i := startDate; i < endDate; i := i + skipDay ){ | 
|       saveDays.Add( i );  | 
|     } | 
|      | 
|      | 
|     dayPeriod_MPs := selectsortedset( owner,Period_MP,period_MP,  | 
|                                       period_MP.TimeUnit() = 'Day' and  | 
|                                       period_MP.StartDate() >= startDate and  | 
|                                       period_MP.EndDate() <= endDate and exists( saveDays, Elements,day,day = period_MP.StartDate()) ,period_MP.StartDate()); | 
|     weekPeriod_MPs := selectsortedset( owner,Period_MP,period_MP,  | 
|                                        period_MP.TimeUnit() = 'Week' and  | 
|                                        period_MP.StartDate() >= startDate and  | 
|                                        period_MP.EndDate() <= endDate and exists( saveDays, Elements,day,day = period_MP.StartDate()) ,period_MP.StartDate()); | 
|      | 
|      | 
|     if( dayPeriod_MPs.Size() > 0 ){ | 
|       unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,exists( dayPeriod_MPs,Elements,period_MP,period_MP = unitPeriodTime.Period_MP())); | 
|       if( unitPeriodTimes.Size() > 0 ){ | 
|         info( unitPeriodTimes.Size() ); | 
|         LocalTool::SetUnitShiftPattern( owner,unitPeriodTimes,shiftPattern ); | 
|       } | 
|     } | 
|     if( weekPeriod_MPs.Size() <> 0 ){ | 
|       unitPeriodTimes := selectset( unit,UnitPeriod.astype( UnitPeriodTime ),unitPeriodTime,exists( weekPeriod_MPs,Elements,period_MP,period_MP = unitPeriodTime.Period_MP())); | 
|       if( unitPeriodTimes.Size() > 0 ){ | 
|         LocalTool::SetUnitShiftPattern( owner,unitPeriodTimes,shiftPattern ); | 
|       } | 
|     } | 
|   *] | 
| } |