Exemple #1
0
        public void SubmitDelivery(Entities.DeliveryInfo pDeliveryInfo)
        {
            using (DeliveryCoEntityModelContainer lContainer = new DeliveryCoEntityModelContainer())
            {
                pDeliveryInfo.DeliveryIdentifier = Guid.NewGuid();
                pDeliveryInfo.Status             = 0;
                lContainer.DeliveryInfo.Add(pDeliveryInfo);
                lContainer.SaveChanges();

                DeliverySubmittedInfo lItem = new DeliverySubmittedInfo {
                    OrderNumber = Guid.Parse(pDeliveryInfo.OrderNumber), DeliveryId = pDeliveryInfo.DeliveryIdentifier
                };
                DeliverySubmittedInfoMessageToDeliveryNotification lVisitor =
                    new DeliverySubmittedInfoMessageToDeliveryNotification(pDeliveryInfo.DeliveryIdentifier);
                lVisitor.Visit(lItem);
                PublisherServiceClient lClient = new PublisherServiceClient();
                lClient.Publish(lVisitor.Result);

                ThreadPool.QueueUserWorkItem(new WaitCallback((pObj) => ScheduleDelivery(pDeliveryInfo)));
            }
        }
Exemple #2
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();
                }
        }