public void PublishToSubscriber(Common.Model.Message pMessage) { if (pMessage is Common.Model.DeliverProcessedMessage) { Common.Model.DeliverProcessedMessage lMessage = pMessage as Common.Model.DeliverProcessedMessage; string orderNumber = lMessage.orderNumber; Guid pDeliveryId = lMessage.pDeliveryId; DeliveryStatus status = (DeliveryStatus)lMessage.status; string errorMsg = lMessage.errorMsg; NotificationProvider.NotifyDeliveryProcessed(orderNumber, pDeliveryId, status, errorMsg); } else if (pMessage is Common.Model.DeliverCompleteMessage) { Common.Model.DeliverCompleteMessage lMessage = pMessage as Common.Model.DeliverCompleteMessage; Guid pDeliveryId = lMessage.pDeliveryId; DeliveryStatus status = (DeliveryStatus)lMessage.status; NotificationProvider.NotifyDeliveryCompletion(pDeliveryId, status); } else if (pMessage is Common.Model.TransferResultMessage) { Common.Model.TransferResultMessage lMessage = pMessage as Common.Model.TransferResultMessage; Boolean success = lMessage.Success; String Msg = lMessage.Message; Guid orderId = lMessage.OrderNumber; OrderProvider.AfterTransferResultReturns(success, orderId, Msg); } }
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(); } } }