Beispiel #1
0
        private void queueAttempt(string completionTimeStr, string trackingIdStr, string voyageNumberStr, string unLocodeStr, string eventTypeStr)
        {
            var errors = new List <string>();

            var date         = HandlingReportParser.parseDate(completionTimeStr, errors);
            var trackingId   = HandlingReportParser.parseTrackingId(trackingIdStr, errors);
            var voyageNumber = HandlingReportParser.parseVoyageNumber(voyageNumberStr, errors);
            var eventType    = HandlingReportParser.parseEventType(eventTypeStr, errors);
            var unLocode     = HandlingReportParser.parseUnLocode(unLocodeStr, errors);
            var operatorCode = HandlingReportParser.parseOperatorCode();

            if (!errors.Any())
            {
                handlingEventService.registerHandlingEvent(date, trackingId, voyageNumber, unLocode, eventType, operatorCode);
            }
            else
            {
                throw new FormatException(String.Join(", ", errors));
            }
        }
Beispiel #2
0
        public void submitReport(HandlingReport handlingReport)
        {
            var validationErrors = new List <string>();

            var completionTime = handlingReport.completionTime;
            var voyageNumber   = HandlingReportParser.parseVoyageNumber(handlingReport.voyageNumber, validationErrors);
            var type           = HandlingReportParser.parseEventType(handlingReport.type, validationErrors);
            var unLocode       = HandlingReportParser.parseUnLocode(handlingReport.unLocode, validationErrors);
            var operatorCode   = HandlingReportParser.parseOperatorCode();

            var allErrors = new Dictionary <string, string>();

            foreach (string trackingIdStr in handlingReport.trackingIds)
            {
                var trackingId = HandlingReportParser.parseTrackingId(trackingIdStr, validationErrors);

                if (!validationErrors.Any())
                {
                    try
                    {
                        handlingEventService.registerHandlingEvent(completionTime, trackingId, voyageNumber, unLocode, type, operatorCode);
                    }
                    catch (CannotCreateHandlingEventException e)
                    {
                        logger.Error(e, e);
                        allErrors.Add(trackingIdStr, e.Message);
                    }
                }
                else
                {
                    logger.Error("Parse error in handling report: " + validationErrors);
                    allErrors.Add(trackingIdStr, String.Join(", ", validationErrors));
                }
            }

            if (allErrors.Any())
            {
                var faultInfo = new HandlingReportErrors();
                throw new FaultException <HandlingReportErrors>(faultInfo, createErrorMessage(allErrors));
            }
        }