public string Execute(OutboundVoucherFile outboundVoucherFile) //CoinFile doc, CoinFileInfo info)
        {
            var filename = string.Empty;

            switch (outboundVoucherFile.OperationType)
            {
                case "ImageExchange":
                    { filename = GetImageExchangeFileName(outboundVoucherFile); 
                      break; 
                    }
                case "Cuscal":
                    {
                        filename = GetCuscalFilename(outboundVoucherFile);
                        break;
                    }
                case "AgencyXML":
                    { filename = GetOtherAgencyFileName(outboundVoucherFile); 
                      break; 
                    }

                default: //IE
                    {
                        filename = GetImageExchangeFileName(outboundVoucherFile);
                        break; 
                    }
            }

            return filename;
        }
Exemplo n.º 2
0
        private string CreateImageExchangeFile(OutboundVoucherFile outboundVoucherFile, CuscalFile cuscalFile)
        {
            var xmlFullPath = String.Join("\\", outboundVoucherFile.FileLocation, outboundVoucherFile.FileName);
            var zipFullPath = String.Join("\\", outboundVoucherFile.FileLocation, outboundVoucherFile.ZipFileName);

            fileSystem.File.AppendAllLines(xmlFullPath, cuscalFile.VoucherItems);

            Log.Information("Cuscal file has been created: {@file}", xmlFullPath);

            Log.Information("Zipping file");
            using (ZipFile zip = new ZipFile())
            {
                zip.Password = outboundVoucherFile.ZipPassword;
                zip.AddFile(xmlFullPath, @"\");

                Log.Information("Job ID location is : {@JobIDLoc}", outboundVoucherFile.FileLocation);
                var allImages = fileSystem.Directory.EnumerateFiles(outboundVoucherFile.FileLocation)
                    .Where(t => t.EndsWith(".JPG", StringComparison.OrdinalIgnoreCase))
                    .Select(file => zip.AddFile(fileSystem.Path.Combine(outboundVoucherFile.FileLocation, file), @"\"));

                Log.Information("Job ID location is - after : {@JobIDLoc}", outboundVoucherFile.FileLocation);
                Log.Debug("Added {@numberOfImages} image JPG file(s)", allImages.Count().ToString());

                zip.Save(zipFullPath);
            }

            Log.Information("Deleting the original xml file");
            fileSystem.File.Delete(xmlFullPath);

            return xmlFullPath;
        }
Exemplo n.º 3
0
        public async Task ProcessAsync_ShouldCreateFile()
        {
            var fixture = new Fixture();
            coinFile = fixture.Create<CoinFile>();

            outboundVoucherFile = fixture.Create<OutboundVoucherFile>();

            outboundVoucherFile.FileLocation = @"c:\someDir";
            outboundVoucherFile.FileName = @"someFileName.xml";

            mapper
                .Setup(m => m.Map(It.IsAny<OutboundVoucherFile>()))
                .Returns(coinFile);

            coinFileWriter
                .Setup(w => w.SaveFile(coinFile, @"c:\someDir\someFileName.xml"))
                .Returns(() => Task.FromResult(string.Empty));

            coinFileCreator = GetCoinFileCreator();

            await coinFileCreator.ProcessAsync(outboundVoucherFile);

            mapper.VerifyAll();
            coinFileWriter.VerifyAll();
        }
        private string GetImageExchangeFileName(OutboundVoucherFile outboundVoucherFile) 
        {
            // Format CCYYMMDD (Date assigned by Image Archive capture date that is assigned to items)
            var dataProcessingDate = outboundVoucherFile.ProcessingDate.ToString(CoinValueConstants.CoinDateFormatString);

            var fileCreationDateTime = dateTimeProvider.CurrentTimeInAustralianEasternTimeZone();

            // Format CCYYMMDD (File creation date assigned by system procedure)
            var fileCreationDate = fileCreationDateTime.ToString(CoinValueConstants.CoinDateFormatString);

            // Format HHMMSS (File creation time assigned by system procedure)
            var fileCreationTime = fileCreationDateTime.ToString(CoinValueConstants.CoinTimeFormatString);

            // Numeric 16 (Exchange Partner derived number. Represents logical reference to source data to assist file resend etc)
            var batchNumber = outboundVoucherFile.BatchNumber.ToString("D16");

            // Alphanumeric	3 (Sending organisation)
            var sourceOrganisation = sendingOrganisation;

            // Alphanumeric 3 (Receiving organisation)
            var destinationOrganisation = outboundVoucherFile.EndpointShortName;

            // Numeric 6 (File sequence number for processing day)
            //     As part of COIN Industry Testing, it was highlighted that this number 
            //     needs to be unique for a day (previously we just used "000000").
            //     However, there is no requirement to guarantee order or starting value.
            //     So for now, just use the last 6 digits of the batch number

            var sequenceNumber = outboundVoucherFile.SequenceNumber.PadLeft(6, '0'); //batchNumber.Substring(10, 6);

            // Generate based on the the spec outlined in the document:
            // [APCA - Industry Test Strategy and Plan - 13 May 2014 Appendix 6.docx]

            var fileName = string.Join(".",
                CoinValueConstants.CoinFilePrefix,
                dataProcessingDate,
                fileCreationDate,
                fileCreationTime,
                batchNumber,
                sourceOrganisation,
                destinationOrganisation,
                sequenceNumber,
                CoinValueConstants.CoinFileExtension);

            return fileName;
        }
Exemplo n.º 5
0
        private async Task<string> CreateImageExchangeFile(OutboundVoucherFile outboundVoucherFile, CoinFile imageExchangeFile)
        {
            var fileFullPath = fileSystem.Path.Combine(outboundVoucherFile.FileLocation, outboundVoucherFile.FileName);

            await writer.SaveFile(imageExchangeFile, fileFullPath);

            Log.Debug("Image exchange file has been created: {file}", fileFullPath);

            if (outboundVoucherFile.OperationType == "ImageExchange")
            {
                var zipFileFullPath = fileFullPath.Replace(".xml", ".zip");
                using (ZipFile zip = new ZipFile())
                {
                    zip.AddFile(fileFullPath, @"\");
                    zip.Save(zipFileFullPath);
                }
            }
            return fileFullPath;
        }
Exemplo n.º 6
0
        public async Task ProcessAsync(OutboundVoucherFile outboundVoucherFile)
        {
            Guard.IsNotNull(outboundVoucherFile, "OutboundVoucherFile");
            Guard.IsNotNull(outboundVoucherFile.FileName, "OutboundVoucherFile.FileName");
            Guard.IsNotNull(outboundVoucherFile.FileLocation, "OutboundVoucherFile.FileLocation");

            CoinFile imageExchangeFile = null;
            CuscalFile cuscalFile = null;

            if (outboundVoucherFile.OperationType == ImageExchangeType.Cuscal.ToString())
            {
                cuscalFile = OutboundVoucherFileToCuscalFile.Map(outboundVoucherFile);
                CreateImageExchangeFile(outboundVoucherFile, cuscalFile);
            }
            else
            {
                imageExchangeFile = documentMapper.Map(outboundVoucherFile);
                await CreateImageExchangeFile(outboundVoucherFile, imageExchangeFile);
            }
        }
Exemplo n.º 7
0
        public OutboundVoucherFile Execute(Batch batch)
        {
            var outboundVoucherFile = new OutboundVoucherFile
            {
                EndpointShortName = batch.ShortTargetEndpoint,
                EndpointLongName = batch.LongTargetEndPoint,
                ProcessingDate = batch.ProcessingDate,
                BatchNumber = batch.BatchNumber,
                FileLocation = batch.FileLocation,
                SequenceNumber = batch.SequenceNumber,
                OperationType = batch.OperationType,
                 ZipPassword = batch.ZipPassword
                
            };

            var fileName = fileNameCreator.Execute(outboundVoucherFile);
            var zipFilename = string.Empty;
            if (outboundVoucherFile.OperationType == ImageExchangeType.Cuscal.ToString())
            {
                var filenameArray = fileName.Split(';');
                if (filenameArray.Length != 2)
                    Log.Warning("{BatchCreator:Execute} Filename may be incorrect. An error may be expected in the next execution.");
                else
                {
                    fileName = filenameArray[0];
                    zipFilename = filenameArray[1];
                }
                
            }
            else if (outboundVoucherFile.OperationType == ImageExchangeType.ImageExchange.ToString())
            {
                zipFilename = fileName.Replace(".xml", ".zip");
            }
         

            outboundVoucherFile.FileName = fileName;
            outboundVoucherFile.ZipFileName = zipFilename;
   
            return outboundVoucherFile;
        }
Exemplo n.º 8
0
        public string Execute(OutboundVoucherFile outboundVoucherFile) //CoinFile doc, CoinFileInfo info)
        {

            var fileCreationDateTime = dateTimeProvider.CurrentTimeInAustralianEasternTimeZone();
            var fileCreationDate = fileCreationDateTime.ToString(CoinValueConstants.CoinDateFormatString);
            var fileCreationTime = fileCreationDateTime.ToString(CoinValueConstants.CoinTimeFormatString);

            // Numeric 16 (Exchange Partner derived number. Represents logical reference to source data to assist file resend etc)
            var batchNumber = outboundVoucherFile.BatchNumber.ToString("D16");

            // Alphanumeric	3 (Sending organisation)
            var sourceOrganisation = sendingOrganisation;

            // Alphanumeric 3 (Receiving organisation)
            var destinationOrganisation = outboundVoucherFile.EndpointShortName;

            var fileTypePrefix = string.Join(sourceOrganisation, destinationOrganisation);
            // Numeric 6 (File sequence number for processing day)
            //     As part of COIN Industry Testing, it was highlighted that this number 
            //     needs to be unique for a day (previously we just used "000000").
            //     However, there is no requirement to guarantee order or starting value.
            //     So for now, just use the last 6 digits of the batch number

            var sequenceNumber = 001;

            // Generate based on the the spec outlined in the document:
            // [APCA - Industry Test Strategy and Plan - 13 May 2014 Appendix 6.docx]

            var fileName = string.Join(".",
                fileTypePrefix,
                fileCreationDate,
                fileCreationTime,
                sequenceNumber,
                CoinValueConstants.CoinFileExtension);

            return fileName;
        }
 public static CuscalFile Map(OutboundVoucherFile input)
 {
     var cuscalItems = input.Vouchers.Select(voucher => BuildValueDictionary(voucher, input.ProcessingDate));
     
     return new CuscalFile(cuscalItems);
 }
Exemplo n.º 10
0
        private string GetCuscalZipFilename(OutboundVoucherFile outboundVoucherFile)
        {
            var zipFilename = String.Join(".", environment, "NAB", "RPT", "CUSCAL",
                String.Join
                    (string.Empty, outboundVoucherFile.ProcessingDate.Year.ToString(),
                        outboundVoucherFile.ProcessingDate.ToString("MM", CultureInfo.InvariantCulture),
                        outboundVoucherFile.ProcessingDate.ToString("dd", CultureInfo.InvariantCulture)), "zip");

            return zipFilename;
        }
Exemplo n.º 11
0
        private string GetCuscalFilename(OutboundVoucherFile outboundVoucherFile)
        {
            var filenames = string.Empty;
            var cuscalFilename = String.Join(".",String.Join
                ("_", "Cuscal",
                 "Cheque",
                 String.Join
                    (string.Empty, outboundVoucherFile.ProcessingDate.ToString("dd", CultureInfo.InvariantCulture),
                     outboundVoucherFile.ProcessingDate.ToString("MM", CultureInfo.InvariantCulture),
                     outboundVoucherFile.ProcessingDate.Year.ToString())), "csv");

            var zipFilename = GetCuscalZipFilename(outboundVoucherFile);

            filenames = String.Join(";", cuscalFilename, zipFilename);
            return filenames;
        }