Discover Esam's code

001private int CalculateStopTimeDuration(002   Product product,003   int carrierGroupId,004   List<ProductTypeStopTime> productTypeStopTimes)005{006   var deliveryServices = new List<string>();007   var stopTimes = new List<ProductTypeStopTime>();008 009   if (product.InstallationServices is null ||010       product.InstallationServices.Length < 1)011   {012       var deliveryService =013           product.DeliveryService ?? "Drempel";014 015       deliveryServices.Add(deliveryService);016 017       var stopTime = GetProductTypeStopTime(018           productTypeStopTimes,019           product,020           deliveryService);021 022       if (stopTime is object)023       {024           stopTimes.Add(stopTime);025       }026   }027   else028   {029       var installationServices = GetInstallationServices(030           product,031           carrierGroupId);032 033       deliveryServices.AddRange(034           installationServices.Select(035               srv => srv.InstallationServiceName));036 037       foreach (var service in installationServices)038       {039           var stopTime = GetProductTypeStopTime(040               productTypeStopTimes,041               product,042               service);043 044           if (stopTime is object)045           {046               stopTimes.Add(stopTime);047           }048       }049   }050 051   var totalStopTime = stopTimes.Sum(stopTime =>052       CalculateStopTimeDuration(053           stopTime,054           product.Quantity));055 056   if (totalStopTime == 0)057   {058       _monitoringEvents.DidNotFindStopTimes(059           product.ProductId,060           deliveryServices,061           product.ProductType,062           product.SubProductType);063   }064   else065   {066       _monitoringEvents.FoundStopTimes(067           product.ProductId,068           deliveryServices,069           product.ProductType,070           product.SubProductType,071           totalStopTime);072   }073 074   return totalStopTime;075}
Route optimization
This is actual code from the route optimization. Feel free to scroll through it.
Vorige
Volgende