示例#1
0
        ///<summary>
        ///Commits the list of work items by using the specified <see cref="T:System.Transactions.Transaction"></see> object.
        ///</summary>
        ///
        ///<param name="workItems">The work items to be committed.</param>
        ///<param name="transaction">The <see cref="T:System.Transactions.Transaction"></see> associated with the pending work.</param>
        public void Commit(Transaction transaction, ICollection workItems)
        {
            TraceHelper.Trace();

            try
            {
                using (IResourceAccessor resourceAccessor = CreateAccessor(this.resourceProvider, transaction))
                {
                    foreach (PendingWorkItem workItem in workItems)
                    {
                        switch (workItem.Type)
                        {
                        case PendingWorkItem.ItemType.Instance:
                            resourceAccessor.InsertInstanceState(workItem,
                                                                 serviceId, this.OwnershipTimeout);

                            continue;

                        case PendingWorkItem.ItemType.CompletedScope:
                            resourceAccessor.InsertCompletedScope(
                                workItem.InstanceId, workItem.StateId,
                                workItem.SerialisedActivity);

                            continue;

                        case PendingWorkItem.ItemType.ActivationComplete:
                            resourceAccessor.UnlockInstanceState(
                                workItem.InstanceId, this.serviceId);

                            continue;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                TraceHelper.Trace(unexpectedExceptionText, e);

                base.RaiseServicesExceptionNotHandledEvent(e, Guid.Empty);
            }
        }