private TransferControlMaster UploadFile(TransferControlFile file,
                                                 Models.TransferControl transferControl)
        {
            var fileInfo = new FileInfo(file.FileLocation);

            var master = new TransferControlMaster
            {
                BatchControlNumber = transferControl.BatchControlNumber,
                TransferType       = ManhattanTransferType,
                Library            = _configuration.GetInboundFtpLocation(),
                Filename           = fileInfo.Name,
                Member             = fileInfo.Name,
                StatusFlag         = StatusFlag,
                DateCreated        = DateTime.Now.ToMainframeDate(),
                TimeCreated        = DateTime.Now.ToMainframeTime(),
                UserId             = _configuration.GetInboundFtpUsername(),
            };

            if (_configuration.GetInboundJobType() == JobType.AuroraInbound)
            {
                ProcessAuroraTransferControl(transferControl, master);
            }

            _log.Debug("Inbound : processing batch " +
                       transferControl.BatchControlNumber +
                       " file " +
                       fileInfo.FullName);

            FtpUploadFile(fileInfo);

            return(master);
        }
 private static void ProcessAuroraTransferControl(Models.TransferControl transferControl, TransferControlMaster master)
 {
     master.TransferType = AuroraTransferType;
     master.Priority     = AuroraPriority;
     master.CustomRecordExpansionField = AuoraProcessCodeForWarehouse;
     master.DateLastModified           = DateTime.Now.ToMainframeDate();
     master.TimeLastModified           = DateTime.Now.ToMainframeTime();
     if (transferControl.ReceivedDate != null)
     {
         master.BeginDate = transferControl.ReceivedDate.Value.ToMainframeDate();
         master.BeginTime = transferControl.ReceivedDate.Value.ToMainframeTime();
     }
     master.EndDate = DateTime.Now.ToMainframeDate();
     master.EndTime = DateTime.Now.ToMainframeTime();
 }
        public void UpdateTransferControl(Models.TransferControl transferControl)
        {
            const string updateTransferControl = @"UPDATE TransferControl
                                                   SET [JobId] = @JobId
                                                        ,[BatchControlNumber] = @BatchControlNumber
                                                        ,[ReceivedDate] = @ReceivedDate
                                                        ,[ProcessedDate] =@ProcessedDate
                                                   WHERE TransferControlid = @TransferControlId";

            using (var connection = DatabaseConnectionFactory.GetWarehouseManagementConnection())
            {
                connection.Open();

                connection.Execute(updateTransferControl, transferControl);
            }
        }
        private void AppendMasterControl(IEnumerable <TransferControlMaster> files,
                                         Models.TransferControl transferControl)
        {
            try
            {
                var transferControlWriter = new DataFileRepository <TransferControlMaster>();

                WriteFile(transferControlWriter, files);

                FtpAppendTransferControl();

                transferControl.ProcessedDate = DateTime.Now;
                _transferControlRepository.UpdateTransferControl(transferControl);

                MoveTransferControlMasterToProcessedFolder();
            }
            catch (Exception exception)
            {
                _log.Exception("Inbound : Failure transmitting outbound master control file ", exception);
                throw;
            }
        }
        public int InsertTransferControl(Models.TransferControl transferControl)
        {
            int transferControlId;

            const string insertTransferControlSql = @"INSERT INTO TransferControl
                                                    ([JobId]
                                                    ,[BatchControlNumber]
                                                    ,[ReceivedDate]
                                                    ,[ProcessedDate]) 
                                                    VALUES
                                                    (@JobId
                                                    ,@BatchControlNumber
                                                    ,@ReceivedDate
                                                    ,@ProcessedDate)
                                                    SELECT CAST(SCOPE_IDENTITY() as int)";

            const string insertTransferControlFileSql = @"INSERT INTO TransferControlFile
                                                       ( [TransferControlId]
                                                        ,[FileLocation] )
                                                       VALUES 
                                                       (@TransferControlId,
                                                        @FileLocation)";

            using (var connection = DatabaseConnectionFactory.GetWarehouseManagementConnection())
            {
                connection.Open();

                transferControlId = connection.Query <int>(insertTransferControlSql, transferControl).Single();

                foreach (var controlFile in transferControl.Files)
                {
                    controlFile.TransferControlId = transferControlId;
                    connection.Execute(insertTransferControlFileSql, controlFile);
                }
            }

            return(transferControlId);
        }
Example #6
0
        private Models.TransferControl CreateTransferControl(string batch, List <TransferControlMaster> masterControlMapping)
        {
            var outboundFileDirectory = _configuration.GetOutboundFileDirectory();

            var transferControl = new Models.TransferControl
            {
                BatchControlNumber = batch,
                Files        = new List <TransferControlFile>(),
                ReceivedDate = DateTime.Now,
                JobId        = DetermineJobId(batch, masterControlMapping)
            };

            foreach (var mapping in masterControlMapping)
            {
                if (mapping.BatchControlNumber == batch)
                {
                    transferControl.Files.Add(new TransferControlFile
                    {
                        FileLocation = Path.Combine(outboundFileDirectory, mapping.Filename)
                    });
                }
            }
            return(transferControl);
        }