Quintiq file version 2.0
|
#parent: #root
|
Method MPSyncShiftDay (
|
Boolean isoverwitemanualconfig,
|
IOShiftPattern ioshiftpattern,
|
ShiftPattern mpshiftpattern
|
)
|
{
|
Description: 'Synchronization of ShiftDay for MPSync'
|
TextBody:
|
[*
|
// Select a set of existing ShiftDay
|
existing := selectset( mpshiftpattern, ShiftDay, item, true );
|
updates := construct( ShiftDays );
|
|
// Traverse the new set of valid ShiftDay
|
traverse( ioshiftpattern , IOShiftDay, io, io.IsValid() )
|
{
|
id := io.ID();
|
shiftpattername := io.ShiftPatternName();
|
|
// Find existing ShiftDay
|
objectinstance := ShiftDay::FindShiftDayTypeIndex( id, shiftpattername );
|
|
// If no existing ShiftDay is found, create one
|
if( isnull( objectinstance ) )
|
{
|
objectinstance := ShiftDay::Create( mpshiftpattern,
|
io.ID(),
|
io.Capacity(),
|
io.Day(),
|
true );
|
|
}
|
// Else if the ShiftDay is not manually configured or the imported instance should overwrite manual configuration,
|
// update the existing ShiftDay
|
else if( not objectinstance.IsManuallyConfigured() or isoverwitemanualconfig )
|
{
|
// Update ShiftDay
|
objectinstance.Update( io.Capacity() ,true );
|
updates.Add( objectinstance );
|
}
|
|
if( not isnull( objectinstance ) )
|
{
|
objectinstance.CustomUpdate( ioshiftpattern, isoverwitemanualconfig );
|
}
|
}
|
|
// Get the set of old ShiftDay to be deleted
|
tobedeleteset := existing.Difference( updates );
|
|
// Traverse the set of ShiftDay to be deleted
|
// Only delete ShiftDay that is not manually configured or the imported instance should overwrite manual configuration
|
traverse( tobedeleteset, Elements, ele, not ele.IsManuallyConfigured() or isoverwitemanualconfig)
|
{
|
ele.Delete();
|
}
|
*]
|
}
|