@@ -359,8 +359,8 @@ protected IEnumerable<OperationData> ImportTimeLog(ISOTask loggedTask, ISOTimeLo
359359 //Determine products
360360 Dictionary < string , List < ISOProductAllocation > > deviceProductAllocations = GetProductAllocationsByDeviceElement ( loggedTask , dvc ) ;
361361
362- //Create a separate operation for each product form (liquid, granular or solid) .
363- List < List < string > > deviceElementGroups = SplitElementsByProductForm ( deviceProductAllocations , loggedDeviceElementsByDevice [ dvc ] , dvc ) ;
362+ //Create a separate operation for each combination of specific product properties .
363+ List < List < string > > deviceElementGroups = SplitElementsByProductProperties ( deviceProductAllocations , loggedDeviceElementsByDevice [ dvc ] , dvc ) ;
364364
365365 foreach ( var deviceElementGroup in deviceElementGroups )
366366 {
@@ -404,18 +404,18 @@ protected IEnumerable<OperationData> ImportTimeLog(ISOTask loggedTask, ISOTimeLo
404404 return null ;
405405 }
406406
407- private List < List < string > > SplitElementsByProductForm ( Dictionary < string , List < ISOProductAllocation > > productAllocations , HashSet < string > loggedDeviceElementIds , ISODevice dvc )
407+ private List < List < string > > SplitElementsByProductProperties ( Dictionary < string , List < ISOProductAllocation > > productAllocations , HashSet < string > loggedDeviceElementIds , ISODevice dvc )
408408 {
409409 //This function splits device elements logged by single TimeLog into groups based
410- //on product form referenced by these elements. This is done using following logic:
410+ //on product form/type referenced by these elements. This is done using following logic:
411411 // - determine used products forms and list of device element ids for each form
412412 // - for each product form determine device elements from all other forms
413413 // - remove these device elements and their children from a copy of device hierarchy elements
414414 // - this gives a list of device elements to keep for a product form
415415 var deviceElementIdsByProductForm = productAllocations
416- . SelectMany ( x => x . Value . Select ( y => new { Form = GetProductFormByProductAllocation ( y ) , Id = x . Key } ) )
417- . Where ( x => x . Form . HasValue )
418- . GroupBy ( x => x . Form , x => x . Id )
416+ . SelectMany ( x => x . Value . Select ( y => new { Product = GetProductByProductAllocation ( y ) , Id = x . Key } ) )
417+ . Where ( x => x . Product != null )
418+ . GroupBy ( x => new { x . Product . Form , x . Product . ProductType } , x => x . Id )
419419 . Select ( x => x . Distinct ( ) . ToList ( ) )
420420 . ToList ( ) ;
421421
@@ -441,7 +441,7 @@ private List<List<string>> SplitElementsByProductForm(Dictionary<string, List<IS
441441 return deviceElementGroups ;
442442 }
443443
444- private ProductFormEnum ? GetProductFormByProductAllocation ( ISOProductAllocation pan )
444+ private Product GetProductByProductAllocation ( ISOProductAllocation pan )
445445 {
446446 var adaptProductId = TaskDataMapper . InstanceIDMap . GetADAPTID ( pan . ProductIdRef ) ;
447447 var adaptProduct = TaskDataMapper . AdaptDataModel . Catalog . Products . FirstOrDefault ( x => x . Id . ReferenceId == adaptProductId ) ;
@@ -451,7 +451,7 @@ private List<List<string>> SplitElementsByProductForm(Dictionary<string, List<IS
451451 {
452452 TaskDataMapper . AddError ( $ "ProductAllocation referencing Product={ pan . ProductIdRef } skipped since no matching product found") ;
453453 }
454- return adaptProduct ? . Form ;
454+ return adaptProduct ;
455455 }
456456
457457 private List < string > FilterDeviceElementIds ( DeviceHierarchyElement deviceHierarchyElement , List < string > idsToRemove )
0 commit comments