//public Guid SubmitDelivery(DeliveryCo.Business.Entities.DeliveryInfo pDeliveryInfo) //{ // using(TransactionScope lScope = new TransactionScope()) // using(DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) // { // pDeliveryInfo.DeliveryIdentifier = Guid.NewGuid(); // pDeliveryInfo.Status = 0; // lContainer.DeliveryInfoes.AddObject(pDeliveryInfo); // lContainer.SaveChanges(); // ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo))); // lScope.Complete(); // } // return pDeliveryInfo.DeliveryIdentifier; //} public void SubmitDelivery(Message message) { //Specify the binding to be used for the client. NetMsmqBinding binding = new NetMsmqBinding(NetMsmqSecurityMode.None); //Specify the address to be used for the client. EndpointAddress address = new EndpointAddress("net.msmq://localhost/private/PublisherMessageQueue"); PublisherServiceClient lClient = new PublisherServiceClient(binding, address); using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { DeliveryMessage mDeliveryMessage = message as DeliveryMessage; mDeliveryMessage.DeliveryIdentifier = Guid.NewGuid(); mDeliveryMessage.Status = 0; mDeliveryMessage.Topic = "delivery"; DeliveryInfo pDeliveryInfo = new DeliveryInfo() { OrderNumber = mDeliveryMessage.OrderNumber, SourceAddress = mDeliveryMessage.SourceAddress, DestinationAddress = mDeliveryMessage.DestinationAddress, DeliveryNotificationAddress = "net.msmq://localhost/private/DeliveryNotificationQueue" }; lContainer.DeliveryInfoes.AddObject(pDeliveryInfo); lContainer.SaveChanges(); //lClient.Publish(mDeliveryMessage); //Console.WriteLine("Delivery submitted and planing deliver to " + pDeliveryInfo.DestinationAddress); ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo, mDeliveryMessage.DeliveryIdentifier, lClient))); lScope.Complete(); } }
public void SubmitDelivery(DeliveryCo.Business.Entities.DeliveryInfo pDeliveryInfo) { try { using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.DeliveryIdentifier = Guid.NewGuid(); pDeliveryInfo.Status = 0; lContainer.DeliveryInfoes.AddObject(pDeliveryInfo); lContainer.SaveChanges(); ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo))); IDeliveryNotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); lService.NotifyDeliverySubmitted(pDeliveryInfo.OrderNumber, pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Submitted, ""); lScope.Complete(); } } catch (Exception ex) { using (TransactionScope lScope = new TransactionScope(TransactionScopeOption.Suppress)) { IDeliveryNotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); lService.NotifyDeliverySubmitted(pDeliveryInfo.OrderNumber, pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Failed, ex.ToString()); lScope.Complete(); } } }
public void SubmitDelivery(DeliveryInfo pDeliveryInfo) { SystemWideLogging.LogServiceClient.LogEvent("DeliveryCo :: DeliveryCo.Business\\DeliveryCo.Business.Components\\DeliveryProvider.cs :: public void SubmitDelivery(DeliveryInfo pDeliveryInfo)", "Received Delivery Request from MessageBus - via Pub/Sub"); using (var lScope = new TransactionScope()) using (var lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.DeliveryIdentifier = pDeliveryInfo.DeliveryIdentifier; pDeliveryInfo.Status = 0; lContainer.DeliveryInfoes.AddObject(pDeliveryInfo); lContainer.SaveChanges(); ThreadPool.QueueUserWorkItem(pObj => ScheduleDelivery(pDeliveryInfo)); lScope.Complete(); } SystemWideLogging.LogServiceClient.LogEvent("DeliveryCo :: DeliveryCo.Business\\DeliveryCo.Business.Components\\DeliveryProvider.cs :: public void SubmitDelivery(DeliveryInfo pDeliveryInfo)", "Sending Delivery Confirmation Receipt to VideoStore - via MSMQ"); // Send notification back to VideoStore App var notificationService = ServiceFactory.GetService <IDeliveryNotificationService>(DeliveryNotificationServiceEndpointAddress); notificationService.NotifyDeliverySubmission(Guid.Parse(pDeliveryInfo.OrderNumber), pDeliveryInfo.DeliveryIdentifier); Console.WriteLine("Delivery request for order '{0}' has submitted", pDeliveryInfo.OrderNumber); }
public Guid SubmitDelivery(DeliveryCo.Business.Entities.DeliveryInfo pDeliveryInfo) { using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.Status = 0; lContainer.DeliveryInfoes.AddObject(pDeliveryInfo); lContainer.SaveChanges(); ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo))); lScope.Complete(); } return(pDeliveryInfo.DeliveryIdentifier); }
private void ScheduleDelivery(DeliveryInfo pDeliveryInfo) { Console.WriteLine("Delivering to" + pDeliveryInfo.DestinationAddress); Thread.Sleep(3000); //notifying of delivery completion using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.Status = 1; IDeliveryNotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); lService.NotifyDeliveryCompletion(pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Delivered); } }
private void ScheduleDelivery(DeliveryInfo pDeliveryInfo) { IDeliveryNotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); Console.WriteLine("Delivering to" + pDeliveryInfo.DestinationAddress + pDeliveryInfo.OrderNumber); Thread.Sleep(1000); //notifying of delivery completion using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.Status = 1; lService.NotifyDeliveryCompletion(pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Delivered); Console.WriteLine("Just notified Video Store the order: " + pDeliveryInfo.OrderNumber + " has been delivered"); } }
public void SubmitDelivery(DeliveryCo.Business.Entities.DeliveryInfo pDeliveryInfo) { try { using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.DeliveryIdentifier = Guid.NewGuid(); pDeliveryInfo.Status = 0; lContainer.DeliveryInfoes.AddObject(pDeliveryInfo); lContainer.SaveChanges(); ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo))); //IDeliveryNotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); //lService.NotifyDeliveryProcessed(pDeliveryInfo.OrderNumber, pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Submitted, ""); Common.Model.DeliverProcessedMessage deliverProcessedMessage = new Common.Model.DeliverProcessedMessage() { Topic = "VideoStore", orderNumber = pDeliveryInfo.OrderNumber, pDeliveryId = pDeliveryInfo.DeliveryIdentifier, status = (int)DeliveryInfoStatus.Submitted, errorMsg = "" }; PublisherServiceClient lClient = new PublisherServiceClient(); lClient.Publish(deliverProcessedMessage); lScope.Complete(); } // return pDeliveryInfo.DeliveryIdentifier; } catch (Exception ex) { using (TransactionScope lScope = new TransactionScope(TransactionScopeOption.Suppress)) { //IDeliveryNotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); //lService.NotifyDeliveryProcessed(pDeliveryInfo.OrderNumber, pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Failed, ex.ToString()); //lScope.Complete(); Common.Model.DeliverProcessedMessage deliverProcessedMessage = new Common.Model.DeliverProcessedMessage() { Topic = "VideoStore", orderNumber = pDeliveryInfo.OrderNumber, pDeliveryId = pDeliveryInfo.DeliveryIdentifier, status = (int)DeliveryInfoStatus.Failed, errorMsg = ex.ToString() }; PublisherServiceClient lClient = new PublisherServiceClient(); lClient.Publish(deliverProcessedMessage); lScope.Complete(); } } }
private void ScheduleDelivery(DeliveryInfo pDeliveryInfo, Guid pDeliveryIdentifier, PublisherServiceClient lClient) { Thread.Sleep(10000); Console.WriteLine("Order: " + pDeliveryInfo.DestinationAddress + " Delivered at " + DateTime.Now.ToString()); //notifying of delivery completion using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.Status = 1; //IDeliveryNotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); //lService.NotifyDeliveryCompletion(pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Delivered); DeliveryMessage mDeliveryMessage = new DeliveryMessage() { OrderNumber = pDeliveryInfo.OrderNumber, DeliveryIdentifier = pDeliveryIdentifier, Status = 1, Topic = "delivery" }; lClient.Publish(mDeliveryMessage); lScope.Complete(); } }
private void ScheduleDelivery(DeliveryInfo pDeliveryInfo) { Console.WriteLine("Delivering to" + pDeliveryInfo.DestinationAddress); Thread.Sleep(3000); //notifying of delivery completion using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.Status = 1; //IDeliveryNotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); //lService.NotifyDeliveryCompletion(pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Delivered); Common.Model.DeliverCompleteMessage deliverCompleteMessage = new Common.Model.DeliverCompleteMessage() { Topic = "VideoStore", pDeliveryId = pDeliveryInfo.DeliveryIdentifier, status = (int)DeliveryInfoStatus.Delivered }; PublisherServiceClient lClient = new PublisherServiceClient(); lClient.Publish(deliverCompleteMessage); lScope.Complete(); } }
public void SubmitDelivery(DeliveryCo.Business.Entities.DeliveryInfo pDeliveryInfo) { using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.DeliveryIdentifier = Guid.NewGuid(); pDeliveryInfo.Status = 0; lContainer.DeliveryInfoes.AddObject(pDeliveryInfo); lContainer.SaveChanges(); DeliverySubmittedInfo lItem = new DeliverySubmittedInfo { OrderNumber = new Guid(pDeliveryInfo.OrderNumber) }; DeliverySubmittedInfoToDeliverySubmittedNotification lVisitor = new DeliverySubmittedInfoToDeliverySubmittedNotification(pDeliveryInfo.DeliveryIdentifier); lVisitor.Visit(lItem); PublisherServiceClient lClient = new PublisherServiceClient(); lClient.Publish(lVisitor.Result); ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo))); lScope.Complete(); } }
public void SubmitDelivery(DeliveryCo.Business.Entities.DeliveryInfo pDeliveryInfo) { using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { try { //pDeliveryInfo.DeliveryIdentifier = Guid.NewGuid(); pDeliveryInfo.Status = 0; lContainer.DeliveryInfoes.AddObject(pDeliveryInfo); lContainer.SaveChanges(); ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo))); lScope.Complete(); } catch (Exception lException) { Console.WriteLine("Error occured while delivering: " + lException.Message); DeliveryNotificationService.DeliveryNotificationServiceClient lClient = new DeliveryNotificationService.DeliveryNotificationServiceClient(); lClient.NotifyDeliveryCompletion(pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Failed); throw; } } //return pDeliveryInfo.DeliveryIdentifier; }
private void ScheduleDelivery(DeliveryInfo pDeliveryInfo) { Console.WriteLine("Delivering to" + pDeliveryInfo.DestinationAddress); Thread.Sleep(3000); //notifying of delivery completion using (TransactionScope lScope = new TransactionScope()) { using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.Status = 1; lContainer.SaveChanges(); DeliveryCompletedInfo lItem = new DeliveryCompletedInfo { DeliveryInfo = pDeliveryInfo }; DeliveryCompletedInfoToDeliveryCompletedNotification lVisitor = new DeliveryCompletedInfoToDeliveryCompletedNotification(); lVisitor.Visit(lItem); PublisherServiceClient lClient = new PublisherServiceClient(); lClient.Publish(lVisitor.Result); lScope.Complete(); } } }