示例#1
0
 public void SaveTransferControl(string controlNumber, IList <string> files, int jobId)
 {
     _transferControlRepository.InsertTransferControl(new Models.TransferControl
     {
         BatchControlNumber = controlNumber.ToString(CultureInfo.InvariantCulture),
         Files = files.Select(file => new TransferControlFile {
             FileLocation = file
         }).ToList(),
         ReceivedDate = DateTime.Now,
         JobId        = jobId
     });
 }
示例#2
0
        public bool Process()
        {
            bool success = true;

            string controlFile = GetControlFilePath();

            if (!File.Exists(controlFile))
            {
                _log.Info("Outbound: No control file to process at " + controlFile);
                return(true);
            }

            _log.Debug("Outbound: reading " + controlFile);

            var manhattanMasterControl = MapTransforControlFromManhattanFile(controlFile);

            using (var transactionScope = Scope.CreateTransactionScope())
            {
                // process each unique batch by grouping batch control number
                foreach (var batch in manhattanMasterControl.Select(e => e.BatchControlNumber).Distinct().ToList())
                {
                    try
                    {
                        var transferControl   = CreateTransferControl(batch, manhattanMasterControl);
                        var transferControlId = _transferControlRepository.InsertTransferControl(transferControl);

                        _log.Debug("Outbound:Created transfer id " + transferControlId + " for batch " + batch);
                    }
                    catch (Exception exception)
                    {
                        _log.Exception("Outbound:Fatal exception processing batch " + batch, exception);
                        success = false;
                    }
                }

                if (!success)
                {
                    return(false);
                }

                MoveToProcessedFolder(controlFile);

                transactionScope.Complete();
            }

            return(true);
        }