public void CompleteOrder(int Id) { Order tmp = DeliveryOrders.Find(x => x.Id == Id); DeliveryOrders.RemoveAll(x => x.Id == Id); tmp.CompleteOrderDate = DateTime.Now; DeliveryCompleted.Add(tmp); }
public async Task <bool> HandleMessageAsync(string messageType, string message, IDictionary <string, object> userproperties) { try { var id = Encoding.UTF8.GetString((byte[])userproperties["Id"]); var ordertype = Encoding.UTF8.GetString((byte[])userproperties["OrderType"]); var sendingdate = Encoding.UTF8.GetString((byte[])userproperties["SendingDate"]); List <ValueDTO> values = new List <ValueDTO>(); values.Add(new ValueDTO() { Key = "Id", Value = id }); values.Add(new ValueDTO() { Key = "OrderType", Value = ordertype }); values.Add(new ValueDTO() { Key = "SendingDate", Value = sendingdate }); var valresponse = await _service.Validate("CardCompos", ".json", message); var streamid = Guid.NewGuid(); var filename = string.Format("{0}_{1}.json", id, messageType); if (await _service.AddToStorage(streamid, message, filename, "json", valresponse.Valid)) { Guid headerid = Guid.NewGuid(); var xx = await _service.AddHeader(headerid, "CardCompos"); var yy = await _service.AddFileExtension(headerid, streamid, filename, valresponse.Valid, string.Join("\n", valresponse.Messages), values); DeliveryCompleted e = await _service.CreateFowardingCommand(headerid); await _messagePublisher.PublishMessageAsync(messageType, e, "DataService", null); //await _messagePublisher.PublishMessageAsync(messageType, e, "", null); await _messagePublisher.PublishMessageAsync(messageType, e, "notification", null); } //scaler aanroepen //status terugkoppelen. } catch (Exception ex) { return(false); } return(true); }
private async Task HandleAsync(DeliveryCompleted dr) { await _azurequeuenotifier.SendMessageAsync("status", new StatusCommand()); //Customer customer = new Customer //{ // CustomerId = cr.CustomerId, // Name = cr.Name, // TelephoneNumber = cr.TelephoneNumber, // EmailAddress = cr.EmailAddress //}; //Log.Information("Register customer: {Id}, {Name}, {TelephoneNumber}, {Email}", // customer.CustomerId, customer.Name, customer.TelephoneNumber, customer.EmailAddress); //await _repo.RegisterCustomerAsync(customer); //await Task.Delay(1000); }
private async Task HandleAsync(FileDelivered fileDelivered) { DeliveryCompleted e = await _service.ProcessSingleFile(fileDelivered); //await _messagePublisher.PublishMessageAsync(e.MessageType, e, "DataService", null); //await _messagePublisher.PublishMessageAsync(e.MessageType, e, "notification", null); //var jobs = await _repo.GetMaintenanceJobsToBeInvoicedAsync(); //foreach (var jobsPerCustomer in jobs.GroupBy(job => job.CustomerId)) //{ // DateTime invoiceDate = DateTime.Now; // string customerId = jobsPerCustomer.Key; // Customer customer = await _repo.GetCustomerAsync(customerId); // Invoice invoice = new Invoice // { // InvoiceId = $"{invoiceDate.ToString("yyyyMMddhhmmss")}-{customerId.Substring(0, 4)}", // InvoiceDate = invoiceDate.Date, // CustomerId = customer.CustomerId, // JobIds = string.Join('|', jobsPerCustomer.Select(j => j.JobId)) // }; // StringBuilder specification = new StringBuilder(); // decimal totalAmount = 0; // foreach (var job in jobsPerCustomer) // { // TimeSpan duration = job.EndTime.Value.Subtract(job.StartTime.Value); // decimal amount = Math.Round((decimal)duration.TotalHours * HOURLY_RATE, 2); // totalAmount += amount; // specification.AppendLine($"{job.EndTime.Value.ToString("dd-MM-yyyy")} : {job.Description} on vehicle with license {job.LicenseNumber} - Duration: {duration.TotalHours} hour - Amount: € {amount}"); // } // invoice.Specification = specification.ToString(); // invoice.Amount = totalAmount; // await SendInvoice(customer, invoice); // await _repo.RegisterInvoiceAsync(invoice); // Log.Information("Invoice {Id} sent to {Customer}", invoice.InvoiceId, customer.Name); //} }
private void Apply(DeliveryCompleted @event) { Status = OrderStatus.Delivered; DeliveredTimestamp = @event.Timestamp; }