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(); 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(1000); //notifying of delivery completion using (TransactionScope lScope = new TransactionScope()) using (DeliveryDataModelContainer lContainer = new DeliveryDataModelContainer()) { pDeliveryInfo.Status = 1; /** INotificationService lService = DeliveryNotificationServiceFactory.GetDeliveryNotificationService(pDeliveryInfo.DeliveryNotificationAddress); lService.NotifyDeliveryCompletion(pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Delivered); **/ NotificationService.NotificationServiceClient IClient = new NotificationService.NotificationServiceClient(); IClient.NotifyDeliveryCompletion(pDeliveryInfo.DeliveryIdentifier, DeliveryStatus.Delivered); lScope.Complete(); } }