Example #1
0
        public ActionResult <IEnumerable <Order> > Get()
        {
            var file     = new File();
            var fileInfo = new FileInfo(FilePath);
            var engine   = new FileHelperEngine <Order>();
            var records  = engine.ReadFile(fileInfo.FullName);

            file.TotalRecords     = engine.TotalRecords;
            file.FilePath         = fileInfo.FullName;
            file.LastWriteTimeUtc = fileInfo.LastWriteTimeUtc;
            file.ProcessTimeUtc   = DateTime.UtcNow;

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: "files", durable: true, exclusive: false, autoDelete: false, arguments: null);

                    var fileMsg = new FileMessage(channel);
                    fileMsg.Push(file);
                    channel.QueueDeclare(queue: "orders", durable: false, exclusive: false, autoDelete: false, arguments: null);
                    var msg = new OrderMessage(channel);
                    foreach (var record in records)
                    {
                        msg.Push(record);
                    }
                }

            return(records);
        }