/// <summary> /// Generate test messages in the inbound queue /// </summary> /// <param name="imagesFolderPath">The full path of the image folder</param> /// <returns></returns> private static RecogniseBatchCourtesyAmountRequest PopulateInboundQueue( string imagesFolderPath) { int j; var batchRequest = new RecogniseBatchCourtesyAmountRequest(); var list = new List <RecogniseCourtesyAmountRequest>(); batchRequest.jobIdentifier = Path.GetFileName(imagesFolderPath); //var fileCount = Directory.GetFiles(imagesFolderPath, "*.tif").GetLength(0); var fileEnum = Directory.GetFiles(imagesFolderPath, "*.tif"); foreach (var filePath in fileEnum) { var fileName = Path.GetFileName(filePath); if (fileName != null) { var pos1 = fileName.IndexOf('-'); //var pos2 = fileName.LastIndexOf('_'); var request = new RecogniseCourtesyAmountRequest() { documentReferenceNumber = fileName.Substring(pos1 + 1, 9), processingDate = new DateTime(2015, 3, 30) }; list.Add(request); } } //Console.WriteLine(string.Format("The {0}th message has {1} image files", i, j)); batchRequest.voucher = list.ToArray(); //rabbitService.PopulateInboundQueue(batchRequest, correlationId++.ToString()); return(batchRequest); }
public BatchInfo Map(RecogniseBatchCourtesyAmountRequest message) { //var body = Encoding.UTF8.GetString(message.Body); //Log.Debug("Message body was {0}", body); //var currentMessage = JsonConvert.DeserializeObject<RecogniseBatchCourtesyAmountRequest>(body); //Log.Information("The batch has correlationId {0}", message.BasicProperties.CorrelationId); BatchInfo batchInfo = new BatchInfo(); IList <ChequeImageInfo> imageList = new List <ChequeImageInfo>(); // TODO: get CorrelationId //batchInfo.CorrelationId = message.BasicProperties.CorrelationId; //RecogniseCourtesyAmountRequest; Parallel.ForEach(message.Voucher, item => { //Log.Debug("The batch contains image file {0} with ref {1}.", item.frontImageIdentifier, item.documentReferenceNumber); imageList.Add(new ChequeImageInfo() { //CorrelationId = message.BasicProperties.CorrelationId, DocumentReferenceNumber = item.DocumentReferenceNumber, Urn = Path.Combine(adapterConfiguration.ImageFileFolder, item.FrontImageIdentifier), //Type = (ImageFormat)Enum.Parse(typeof(ImageFormat), currentMessage.FileType, true), Status = 0, }); }); batchInfo.ChequeImageInfos = imageList.ToArray(); return(batchInfo); }
public void WhenAMessageWithJobIdentifierArrivesInQueueLombard_Service_Outclearings_Recognisecourtesyamount_Request_QueueForTheFollowingVouchers(string jobId, Table table) { var vouchers = table.CreateSet <RecogniseCourtesyAmountRequest>(); var message = new RecogniseBatchCourtesyAmountRequest { jobIdentifier = jobId, voucher = vouchers.ToArray() }; AutoReadCarBus.Publish(message); Thread.Sleep(3000); }
public static void Publish(RecogniseBatchCourtesyAmountRequest request) { Requests.Add(request); Task.WaitAll(InboundExchange.PublishAsync(request, null)); }