public void StartSubscriberThreads() //need to resolve dependencies... { //UpdateQueue when fulfillment it updated StartThread("FulfillmentUpdate", (channel, msg) => { var updateRequest = msg.FromJson <UpdateFulfillment>(); var updateOrderInQueue = new UpdateOrderInQueue { OrderId = updateRequest.OrderId, Status = updateRequest.Status, Fulfiller = updateRequest.Fulfiller }; using (var service = Container.Resolve <OrderQueueService>()) { service.Put(updateOrderInQueue); } var hub = GlobalHost.ConnectionManager.GetHubContext("OrdersQueueGridHub"); if (hub != null) { hub.Clients.All.updateGrid(updateOrderInQueue); } }); }
public object Put(UpdateOrderInQueue request) { var result = RedisExec((redisCon) => { var orderToUpdateJson = redisCon.GetValueFromHash("urn:OrdersInQueue", request.OrderId.ToString()); if (!String.IsNullOrEmpty(orderToUpdateJson)) { var orderToUpdate = JsonSerializer.DeserializeFromString <OrderInQueue>(orderToUpdateJson); if (request.Status == "Completed") { redisCon.RemoveEntryFromHash("urn:OrdersInQueue", orderToUpdate.OrderId.ToString()); return("Entry Removed"); } orderToUpdate.Status = request.Status; orderToUpdate.Fulfiller = request.Fulfiller; redisCon.SetEntryInHash("urn:OrdersInQueue", orderToUpdate.OrderId.ToString(), orderToUpdate.ToJson()); return("Update Successful"); } return("Entry Not Found"); }); return(result); }