Example #1
0
        private void ScheduleDelivery(DeliveryInfo pDeliveryInfo)
        {
            // Thread.Sleep(TimeSpan.FromSeconds(3));

            Console.WriteLine("Delivering to" + pDeliveryInfo.DestinationAddress);
            //   Console.WriteLine("DeliverID: " + pDeliveryInfo.DeliveryIdentifier);
            Thread.Sleep(3000);
            DeliveryNotificationService.DeliveryNotificationServiceClient lClient = new DeliveryNotificationService.DeliveryNotificationServiceClient();
            lClient.NotifyDeliveryCompletion(pDeliveryInfo.DeliveryIdentifier, DeliveryInfoStatus.Delivered);
        }
Example #2
0
 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;
 }