Esempio n. 1
0
        private RouteStop GetRouteStopFromLeg(int subscriberId, ImportedLeg leg, StopAction sa, Dictionary <string, Location> locationsByLegacyId,
                                              TimeSpan?windowStart = null, TimeSpan?windowEnd = null, int stopDelay = 60)
        {
            Location location;

            try
            {
                location = locationsByLegacyId[leg.CustomerNumber];
            }
            catch (Exception ex)
            {
                location = new Location()
                {
                    DisplayName = "Loc not found",
                };
            }

            if (location != null && (location.DisplayName.ToLower().Contains("publix") || location.DisplayName.ToLower().Contains("associated grocers")))
            {
                stopDelay = 240;
            }

            var result = new RouteStop()
            {
                SubscriberId = subscriberId,
                StopAction   = sa,
                LocationId   = location.Id,
                Location     = location,
                StopDelay    = stopDelay,
                WindowStart  = windowStart.HasValue ? windowStart.Value.Ticks : 0,
                WindowEnd    = windowEnd.HasValue ? windowEnd.Value.Ticks : new TimeSpan(23, 59, 0).Ticks,
            };

            return(result);
        }
Esempio n. 2
0
 public ManifestLegs(ImportedLeg leg) : this(new List <ImportedLeg>() { leg })
 {
 }
        private ImportedLeg ExtractJob(string[] values)
        {
            const string ErrorTemplate = @"Error retrieving field {0} for record {1} with error of:\n{2}";

            _dictionary = values.GetString(_shipperNameIndex);
            var result = new ImportedLeg();

            try
            {
                result.ManifestNumber = values.GetString(_manifestNumberIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ManifestNumber", "No Manifest Number Read", e.Message));
            }
            try
            {
                result.SealNumber = values.GetString(_sealNumberIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "SealNumber", result.ManifestNumber, e.Message));
            }
            try
            {
                result.BillOfLadingNumber = values.GetString(_billOfLadingNumberIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "BillOfLadingNumber", result.ManifestNumber, e.Message));
            }
            try
            {
                result.Trailer = values.GetString(_trailerIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "Trailer", result.ManifestNumber, e.Message));
            }
            try
            {
                result.ManifestType = values.GetString(_manifestTypeIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ManifestType", result.ManifestNumber, e.Message));
            }
            try
            {
                result.ServiceType = values.GetString(_serviceTypeIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ServiceType", result.ManifestNumber, e.Message));
            }
            try
            {
                result.RecordType = values.GetString(_recordTypeIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "RecordType", result.ManifestNumber, e.Message));
            }
            try
            {
                result.SequenceNumber = values.GetInt(_sequenceNumberIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "SequenceNumber", result.ManifestNumber, e.Message));
            }
            try
            {
                result.ScheduledStop = values.GetBool(_scheduledStopIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ScheduledStop", result.ManifestNumber, e.Message));
            }
            try
            {
                result.IsHazmat = values.GetBool(_isHazmatIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "IsHazmat", result.ManifestNumber, e.Message));
            }

            // leg details
            try
            {
                result.NumberOfLegs = values.GetInt(_numberOfLegsIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "NumberOfLegs", result.ManifestNumber, e.Message));
            }
            try
            {
                result.LegNumber = values.GetString(_legNumberIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegNumber", result.ManifestNumber, e.Message));
            }
            try
            {
                result.LegNumberCredited = values.GetString(_legNumberCreditedIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegNumberCredited", result.ManifestNumber, e.Message));
            }
            try
            {
                result.LegType = values.GetString(_legTypeIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegType", result.ManifestNumber, e.Message));
            }

            try
            {
                result.LegOriginCity = values.GetString(_legOriginCityIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegOriginCity", result.ManifestNumber, e.Message));
            }
            try
            {
                result.LegOriginState = values.GetString(_legOriginStateIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegOriginState", result.ManifestNumber, e.Message));
            }
            try
            {
                result.LegOriginZip = TryGetSubstring(values.GetString(_legOriginZipIndex), 0, 5);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegOriginZip", result.ManifestNumber, e.Message));
            }

            try
            {
                result.LegDestinationCity = values.GetString(_legDestinationCityIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegDestinationCity", result.ManifestNumber, e.Message));
            }
            try
            {
                result.LegDestinationState = values.GetString(_legDestinationStateIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegDestinationState", result.ManifestNumber, e.Message));
            }
            try
            {
                result.LegDestinationZip = TryGetSubstring(values.GetString(_legDestinationZipIndex), 0, 5);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LegDestinationZip", result.ManifestNumber, e.Message));
            }

            try
            {
                // times
                result.LoadTime = values.GetInt(_scheduledLoadTimeIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LoadTime", result.ManifestNumber, e.Message));
            }
            try
            {
                result.LoadDateTime = values.GetCustomDateTime(_loadDateStringIndex, _loadTimeStringIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "LoadDateTime", result.ManifestNumber, e.Message));
            }
            try
            {
                result.DeliveryDateTime = values.GetCustomDateTime(_deliveryDateStringIndex, _deliveryTimeStringIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "DeliveryDateTime", result.ManifestNumber, e.Message));
            }
            try
            {
                result.ScheduledDateTime = values.GetCustomDateTime(_scheduledDateStringIndex, _scheduledTimeStringIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ScheduledDateTime", result.ManifestNumber, e.Message));
            }

            try
            {
                // company
                result.CustomerNumber = values.GetString(_customerNumberIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "CustomerNumber", result.ManifestNumber, e.Message));
            }
            try
            {
                result.CompanyName = values.GetString(_companyNameIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "CompanyName", result.ManifestNumber, e.Message));
            }
            try
            {
                result.CompanyAddress1 = SanitizeAddress(values.GetString(_companyAddress1Index));
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "CompanyAddress1", result.ManifestNumber, e.Message));
            }
            try
            {
                result.CompanyAddress2 = values.GetString(_companyAddress2Index);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "CompanyAddress2", result.ManifestNumber, e.Message));
            }
            try
            {
                result.CompanyCity = values.GetString(_companyCityIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "CompanyCity", result.ManifestNumber, e.Message));
            }
            try
            {
                result.CompanyState = values.GetString(_companyStateIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "CompanyState", result.ManifestNumber, e.Message));
            }
            try
            {
                result.CompanyZip = TryGetSubstring(values.GetString(_companyZipIndex), 0, 5);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "CompanyZip", result.ManifestNumber, e.Message));
            }

            try
            {
                // consignee
                result.ConsigneeNumber = values.GetInt(_consigneeNumberIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ConsigneeNumber", result.ManifestNumber, e.Message));
            }
            try
            {
                result.ConsigneeName = values.GetString(_consigneeNameIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ConsigneeName", result.ManifestNumber, e.Message));
            }
            try
            {
                result.ShipperNumber = values.GetInt(_shipperNumberIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ShipperNumber", result.ManifestNumber, e.Message));
            }
            try
            {
                result.ShipperName = values.GetString(_shipperNameIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "ShipperName", result.ManifestNumber, e.Message));
            }

            try
            {
                // order origin
                result.OriginZone = values.GetString(_originZoneIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "OriginZone", result.ManifestNumber, e.Message));
            }
            try
            {
                result.OrderOriginCity = values.GetString(_orderOriginCityIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "OrderOriginCity", result.ManifestNumber, e.Message));
            }
            try
            {
                result.OrderOriginState = values.GetString(_orderOriginStateIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "OrderOriginState", result.ManifestNumber, e.Message));
            }
            try
            {
                result.OrderOriginZip = TryGetSubstring(values.GetString(_orderOriginZipIndex), 0, 5);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "OrderOriginZip", result.ManifestNumber, e.Message));
            }

            try
            {
                // order destination
                result.DestinationZone = values.GetString(_destinationZoneIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "DestinationZone", result.ManifestNumber, e.Message));
            }
            try
            {
                result.OrderDestinationCity = values.GetString(_orderDestinationCityIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "OrderDestinationCity", result.ManifestNumber, e.Message));
            }
            try
            {
                result.OrderDestinationState = values.GetString(_orderDestinationStateIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "OrderDestinationState", result.ManifestNumber, e.Message));
            }
            try
            {
                result.OrderDestinationZip = TryGetSubstring(values.GetString(_orderDestinationZipIndex), 0, 5);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "OrderDestinationZip", result.ManifestNumber, e.Message));
            }

            try
            {
                result.StopOffCity = values.GetString(_stopOffCityIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "StopOffCity", result.ManifestNumber, e.Message));
            }
            try
            {
                result.StopOffState = values.GetString(_stopOffStateIndex);
            }
            catch (Exception e)
            {
                ReportErrors.AddError(string.Format(ErrorTemplate, "StopOffState", result.ManifestNumber, e.Message));
            }
            return(result);
        }