Exemple #1
0
        public void SubmitReport(HandlingReport handlingReport)
        {
            IList <string> errors = new List <string>();

            DateTime?    completionTime = HandlingReportParser.ParseCompletionTime(handlingReport, errors);
            VoyageNumber voyageNumber   = HandlingReportParser.ParseVoyageNumber(handlingReport.VoyageNumber, errors);
            HandlingType type           = HandlingReportParser.ParseEventType(handlingReport.Type, errors);
            UnLocode     unLocode       = HandlingReportParser.ParseUnLocode(handlingReport.UnLocode, errors);

            foreach (string trackingIdStr in handlingReport.TrackingIds)
            {
                TrackingId trackingId = HandlingReportParser.ParseTrackingId(trackingIdStr, errors);

                if (errors.IsEmpty())
                {
                    DateTime registrationTime = DateTime.Now;
                    var      attempt          = new HandlingEventRegistrationAttempt(
                        registrationTime, completionTime.Value, trackingId, voyageNumber, type, unLocode);
                    applicationEvents.ReceivedHandlingEventRegistrationAttempt(attempt);
                }
                else
                {
                    string errorString = String.Join("\r\n", errors.ToArray());
                    logger.Error("Parse error in handling report: " + errorString);

                    throw new FaultException <HandlingReportException>(new HandlingReportException(errorString), new FaultReason(errorString));
                }
            }
        }
        private void QueueAttempt(string completionTimeStr, string trackingIdStr, string voyageNumberStr,
                                  string unLocodeStr, string eventTypeStr)
        {
            var errors = new List <string>();

            DateTime     date         = HandlingReportParser.ParseDate(completionTimeStr, errors);
            TrackingId   trackingId   = HandlingReportParser.ParseTrackingId(trackingIdStr, errors);
            VoyageNumber voyageNumber = HandlingReportParser.ParseVoyageNumber(voyageNumberStr, errors);
            HandlingType eventType    = HandlingReportParser.ParseEventType(eventTypeStr, errors);
            UnLocode     unLocode     = HandlingReportParser.ParseUnLocode(unLocodeStr, errors);

            if (errors.IsEmpty())
            {
                var attempt = new HandlingEventRegistrationAttempt(DateTime.Now, date,
                                                                   trackingId, voyageNumber,
                                                                   eventType, unLocode);
                AppEvents.ReceivedHandlingEventRegistrationAttempt(attempt);
            }
            else
            {
                throw new Exception(ToStringBuilder.ReflectionToString(errors));
            }
        }