Пример #1
0
        public void Cancel(int publicationTaskID)
        {
            HelperClasses.Output.WriteMessage(string.Format("Cancel {0} ", publicationTaskID.ToString()));

            try
            {
                Entities.PublicationEntities.PublicationTask publicationTask = DAL.PublicationDAL.PublicationTask.GetPublicationTask(publicationTaskID);
                publicationTask.Status = -1;
                HelperClasses.Output.ThrowIfFailed(Proxy.SaveTask(publicationTask), "Could not cancel task publication.");
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #2
0
        private void PublishItems(Entities.PublicationEntities.PublicationTask publicationTask)
        {
            bool saved = false;

            try
            {
                foreach (Entities.PublicationEntities.PublicationItem publicationItem in publicationTask.PublicationItems)
                {
                    if (publicationItem.Status == 0)
                    {
                        //Put each item in the MSMQ and let MSMQ handle it.
                        //The distributor updates the publication item status, at some point in the future.
                        //The MSMQ is still transactional and automatically creates its own new transaction.
                        //But we don't want it to effect the ambient transaction, **so suppress it**.

                        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress))
                        {
                            Proxies.DistributionHubClient distributionHubService = new Proxies.DistributionHubClient();
                            distributionHubService.Distribute(publicationItem.PublicationItemID);

                            publicationItem.Status = 1;
                            saved = Proxy.SaveItem(publicationItem); //

                            if (saved)
                            {
                                HelperClasses.Output.WriteMessage(string.Format("Item {0} queued for publication.", publicationItem.PublicationItemID.ToString()));
                                scope.Complete();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                HelperClasses.Output.ThrowIfFailed(false, ex.Message);
            }
        }