コード例 #1
0
        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();
                }
            }
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        /// <summary>
        /// Create a new DeliveryInfo object.
        /// </summary>
        /// <param name="id">Initial value of the Id property.</param>
        /// <param name="sourceAddress">Initial value of the SourceAddress property.</param>
        /// <param name="destinationAddress">Initial value of the DestinationAddress property.</param>
        /// <param name="orderNumber">Initial value of the OrderNumber property.</param>
        /// <param name="deliveryIdentifier">Initial value of the DeliveryIdentifier property.</param>
        /// <param name="deliveryNotificationAddress">Initial value of the DeliveryNotificationAddress property.</param>
        /// <param name="status">Initial value of the Status property.</param>
        public static DeliveryInfo CreateDeliveryInfo(global::System.Int32 id, global::System.String sourceAddress, global::System.String destinationAddress, global::System.String orderNumber, global::System.Guid deliveryIdentifier, global::System.String deliveryNotificationAddress, global::System.Int32 status)
        {
            DeliveryInfo deliveryInfo = new DeliveryInfo();

            deliveryInfo.Id                          = id;
            deliveryInfo.SourceAddress               = sourceAddress;
            deliveryInfo.DestinationAddress          = destinationAddress;
            deliveryInfo.OrderNumber                 = orderNumber;
            deliveryInfo.DeliveryIdentifier          = deliveryIdentifier;
            deliveryInfo.DeliveryNotificationAddress = deliveryNotificationAddress;
            deliveryInfo.Status                      = status;
            return(deliveryInfo);
        }
コード例 #4
0
 public Guid SubmitDelivery(DeliveryCo.Business.Entities.DeliveryInfo pDeliveryInfo, int[][] confirmedOrders)
 {
     using (TransactionScope lScope = new TransactionScope())
         using (DeliveryCoEntityModelContainer lContainer = new DeliveryCoEntityModelContainer())
         {
             pDeliveryInfo.DeliveryIdentifier = Guid.NewGuid();
             pDeliveryInfo.Status             = 0;
             lContainer.DeliveryInfo.Add(pDeliveryInfo);
             lContainer.SaveChanges();
             ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo, confirmedOrders)));
             lScope.Complete();
         }
     return(pDeliveryInfo.DeliveryIdentifier);
 }
コード例 #5
0
        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();
                }
            }
        }
コード例 #6
0
ファイル: DeliveryProvider.cs プロジェクト: agaw/aurora
        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();
            }
        }
コード例 #7
0
        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();
                }
        }
コード例 #8
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;
 }
コード例 #9
0
        public Guid SubmitDelivery(DeliveryCo.Business.Entities.DeliveryInfo pDeliveryInfo, List <Tuple <String, List <String> > > pOrderItems)
        {
            using (TransactionScope lScope = new TransactionScope())
                using (DeliveryCoEntityModelContainer lContainer = new DeliveryCoEntityModelContainer())
                {
                    pDeliveryInfo.DeliveryIdentifier = Guid.NewGuid();
                    pDeliveryInfo.Status             = 0;
                    lContainer.DeliveryInfo.Add(pDeliveryInfo);
                    lContainer.SaveChanges();
                    ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo, pOrderItems)));
                    lScope.Complete();
                }

            Console.WriteLine("===========Delivery Submitted===========");
            Console.WriteLine("Order items:");
            foreach (Tuple <String, List <String> > x in pOrderItems)
            {
                Console.WriteLine("          " + x.Item1);
            }
            Console.WriteLine("Time: " + DateTime.Now);
            Console.WriteLine("========================================");
            Console.WriteLine(" ");
            return(pDeliveryInfo.DeliveryIdentifier);
        }
コード例 #10
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DeliveryInfoes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDeliveryInfoes(DeliveryInfo deliveryInfo)
 {
     base.AddObject("DeliveryInfoes", deliveryInfo);
 }
コード例 #11
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DeliveryInfoes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDeliveryInfoes(DeliveryInfo deliveryInfo)
 {
     base.AddObject("DeliveryInfoes", deliveryInfo);
 }
コード例 #12
0
 /// <summary>
 /// Create a new DeliveryInfo object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="sourceAddress">Initial value of the SourceAddress property.</param>
 /// <param name="destinationAddress">Initial value of the DestinationAddress property.</param>
 /// <param name="orderNumber">Initial value of the OrderNumber property.</param>
 /// <param name="deliveryIdentifier">Initial value of the DeliveryIdentifier property.</param>
 /// <param name="deliveryNotificationAddress">Initial value of the DeliveryNotificationAddress property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 public static DeliveryInfo CreateDeliveryInfo(global::System.Int32 id, global::System.String sourceAddress, global::System.String destinationAddress, global::System.String orderNumber, global::System.Guid deliveryIdentifier, global::System.String deliveryNotificationAddress, global::System.Int32 status)
 {
     DeliveryInfo deliveryInfo = new DeliveryInfo();
     deliveryInfo.Id = id;
     deliveryInfo.SourceAddress = sourceAddress;
     deliveryInfo.DestinationAddress = destinationAddress;
     deliveryInfo.OrderNumber = orderNumber;
     deliveryInfo.DeliveryIdentifier = deliveryIdentifier;
     deliveryInfo.DeliveryNotificationAddress = deliveryNotificationAddress;
     deliveryInfo.Status = status;
     return deliveryInfo;
 }