Esempio n. 1
0
        private IEnumerable <IEdiMessage> processPartner(DocumentAssignments assignment)
        {
            var fileParser = assignment.Partner.Parser();
            var documents  = new List <IEdiMessage>();
            var segList    = assignment.Documents;

            foreach (var doc in segList)
            {
                var segments = doc.Segments;
                var file     = doc.File;
                try
                {
                    var docs = fileParser.Parse(segments);
                    if (docs.Count() > 0)
                    {
                        documents.AddRange(docs.Where(d => d != null));
                        moveFileToArchive(file);
                    }
                }
                catch (Exception e)
                {
                    Logger.Error(this, "Error processing file ", e);
                    _notificationSender.SendNotification("Failure processing incoming file", getRecipientList(),
                                                         string.Format("The file {0} could not be processed.  The file is being moved to the Error folder.  Error message: {1}", doc.File, e));
                    moveFileToErrorFolder(file);
                }
            }
            return(documents);
        }
Esempio n. 2
0
        public IEnumerable <DocumentAssignments> MakeAssignments(IList <FileEntity> files)
        {
            var assignments = new List <DocumentAssignments>();

            files.ForEach(f =>
            {
                var doc        = get_segments(f);
                var partner    = get_partner(doc);
                var assignment = assignments.Find(a => a.Partner == partner);
                if (assignment == null)
                {
                    assignment = new DocumentAssignments(partner);
                    assignments.Add(assignment);
                }
                assignment.Documents.Add(new DocumentFile(f, doc));
            });
            return(assignments);
        }
 private IEnumerable<IEdiMessage> processPartner(DocumentAssignments assignment)
 {
     var fileParser = assignment.Partner.Parser();
     var documents = new List<IEdiMessage>();
     var segList = assignment.Documents;
     foreach (var doc in segList)
     {
         var segments = doc.Segments;
         var file = doc.File;
         try
         {
             var docs = fileParser.Parse(segments);
             if (docs.Count() > 0)
             {
                 documents.AddRange(docs.Where(d => d != null));
                 moveFileToArchive(file);
             }
         }
         catch (Exception e)
         {
             Logger.Error(this, "Error processing file ", e);
             _notificationSender.SendNotification("Failure processing incoming file", getRecipientList(),
                                                  string.Format("The file {0} could not be processed.  The file is being moved to the Error folder.  Error message: {1}", doc.File, e));
             moveFileToErrorFolder(file);
         }
     }
     return documents;
 }
        public IEnumerable<DocumentAssignments> MakeAssignments(IList<FileEntity> files)
        {
            var assignments = new List<DocumentAssignments>();

            files.ForEach(f =>
                              {
                                  var doc = get_segments(f);
                                  var partner = get_partner(doc);
                                  var assignment = assignments.Find(a => a.Partner == partner);
                                  if (assignment == null)
                                  {
                                      assignment = new DocumentAssignments(partner);
                                      assignments.Add(assignment);
                                  }
                                  assignment.Documents.Add(new DocumentFile(f,doc));
                              });
            return assignments;
        }