| Quintiq file version 2.0 | 
| #parent: #root | 
| Method MPSyncUnitShiftPattern ( | 
|   Boolean isoverwritemanualconfig, | 
|   IOUnitShiftPatterns iounitshiftpatterns | 
| ) | 
| { | 
|   Description: 'Synchronization of UnitShiftPattern for MPSync' | 
|   TextBody: | 
|   [* | 
|     existing := selectset( this, Unit.UnitShiftPattern, item, true ); | 
|     updates := construct( UnitShiftPatterns ); | 
|      | 
|     traverse( iounitshiftpatterns , Elements, io, io.IsValid() ) | 
|     { | 
|       unit := Unit::FindUnitTypeIndex( io.UnitID() ); | 
|       shiftpattern := ShiftPattern::FindShiftPatternTypeIndex( io.ShiftPatternName() ); | 
|        | 
|       if( not ( isnull( unit ) or isnull( shiftpattern ) ) ) | 
|        { | 
|         objectinstance := UnitShiftPattern::FindUnitShiftPatternTypeIndex( io.UnitID(),io.ShiftPatternName() ); | 
|          | 
|         if( isnull( objectinstance ) ) | 
|         { | 
|           objectinstance := UnitShiftPattern::Create( unit, shiftpattern ); | 
|         } | 
|          | 
|         else if( not isnull( objectinstance ) and ( not objectinstance.IsManuallyConfigured() or isoverwritemanualconfig ) )  | 
|         { | 
|           objectinstance.Update( io.IsAllowed(), true ); // set to true indicate value from external ( db, excel ) | 
|           updates.Add( objectinstance ); | 
|         } | 
|          | 
|         if( not isnull( objectinstance ) ) | 
|         { | 
|           objectinstance.CustomUpdate( io, isoverwritemanualconfig ); | 
|         } | 
|       } | 
|     } | 
|     tobedeleteset := existing.Difference( updates ); | 
|      | 
|     traverse( tobedeleteset, Elements, ele, not ele.IsManuallyConfigured() or isoverwritemanualconfig) | 
|     { | 
|       ele.Delete(); | 
|     } | 
|   *] | 
| } |