Ejemplo n.º 1
0
        public void GetDeliveryReport(string requestId)
        {
            UniqueJob uniqueJob = null;

            try
            {
                uniqueJob = this.uniqueJobList.AddOrUpdate("GetDeliveryReport", requestId);
                if (uniqueJob == null)
                {
                    return;                    // Job 已經存在
                }
                using (var scope = this.unitOfWork.CreateTransactionScope())
                {
                    var deliveryReportQueueRepository = this.unitOfWork.Repository <DeliveryReportQueue>();

                    var deliveryReportQueue = deliveryReportQueueRepository.Get(p => p.RequestId == requestId);
                    if (deliveryReportQueue == null)
                    {
                        return;
                    }

                    ISmsProvider provider = GetProvider(deliveryReportQueue.ProviderName);

                    if (provider != null) // 取得DeliveryReport並沒有急迫性,等到簡訊供應商可供連線再取即可。
                    {
                        provider.GetDeliveryReport(requestId);
                    }

                    scope.Complete();
                }

                ////////////////////////////////////////
            }
            catch (Exception ex)
            {
                this.logService.Error("GetDeliveryReport({0})", requestId);
                this.logService.Error(ex);
                throw;
            }
            finally
            {
                if (uniqueJob != null)
                {
                    this.uniqueJobList.Remove(uniqueJob);
                }
            }
        }