///<summary> ///Commits the list of work items by using the specified <see cref="T:System.Transactions.Transaction"></see> object. ///</summary> /// ///<param name="items">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 items) { TraceHelper.Trace(); if (transaction == null) { throw new ArgumentNullException("transaction"); } if (items == null) { throw new ArgumentNullException("items"); } try { using (IPersistenceResourceAccessor resourceAccessor = CreateAccessor(_resourceProvider, transaction)) { foreach (PendingWorkItem item in items) { switch (item.Type) { case PendingWorkItem.ItemType.Instance: resourceAccessor.InsertInstanceState(item, _serviceId, ownershipTimeout); continue; case PendingWorkItem.ItemType.CompletedScope: resourceAccessor.InsertCompletedScope( item.InstanceId, item.StateId, item.SerialisedActivity); continue; case PendingWorkItem.ItemType.UnlockWorkflow: resourceAccessor.UnlockInstanceState( item.InstanceId, _serviceId); continue; } } } } catch (Exception e) { String errorMessage = RM.Get_Error_PersistenceServiceException(e.ToString()); TraceHelper.Trace(errorMessage); PersistenceException persistenceException = new PersistenceException(errorMessage, e); RaiseServicesExceptionNotHandledEvent( persistenceException, Guid.Empty); throw persistenceException; } }
///<summary> /// Load the specified workflow instance into memory from the /// persistence store. ///</summary> ///<param name="instanceId"> /// The <see cref="T:System.Guid"></see> of the root activity of the workflow instance. /// </param> protected override Activity LoadWorkflowInstanceState(Guid instanceId) { TraceHelper.Trace(); Activity rootActivity; try { using (IPersistenceResourceAccessor resourceAccessor = CreateAccessor(_resourceProvider)) { byte[] instanceState = resourceAccessor.RetrieveInstanceState( instanceId, _serviceId, ownershipTimeout); rootActivity = RestoreFromDefaultSerializedForm(instanceState, null); } } catch (Exception e) { String errorMessage = RM.Get_Error_PersistenceServiceException(e.ToString()); TraceHelper.Trace(errorMessage); PersistenceException persistenceException = new PersistenceException(errorMessage, e); RaiseServicesExceptionNotHandledEvent( persistenceException, instanceId); throw persistenceException; } return(rootActivity); }
/// <summary> /// Load a completed scope from the persistence store. /// </summary> /// <param name="scopeId"> /// <see cref="Guid" /> representing the unique identifier of the completed scope. /// </param> /// <param name="outerActivity"> /// The activity in which to load the completed scope into. /// </param> protected override Activity LoadCompletedContextActivity(Guid scopeId, Activity outerActivity) { TraceHelper.Trace(); Activity contextActivity; try { using (IPersistenceResourceAccessor resourceAccessor = CreateAccessor(_resourceProvider)) { byte[] instanceState = resourceAccessor.RetrieveCompletedScope(scopeId); contextActivity = RestoreFromDefaultSerializedForm(instanceState, outerActivity); } } catch (Exception e) { String errorMessage = RM.Get_Error_PersistenceServiceException(e.ToString()); TraceHelper.Trace(errorMessage); PersistenceException persistenceException = new PersistenceException(errorMessage, e); RaiseServicesExceptionNotHandledEvent( persistenceException, WorkflowEnvironment.WorkflowInstanceId); throw persistenceException; } return(contextActivity); }
protected virtual IList <Guid> LoadExpiredWorkflowIds() { TraceHelper.Trace(); IList <Guid> instanceIds; try { using (IPersistenceResourceAccessor resourceAccessor = CreateAccessor(_resourceProvider)) { instanceIds = resourceAccessor.RetrieveExpiredTimerIds(_serviceId, ownershipTimeout); } } catch (Exception e) { String errorMessage = RM.Get_Error_PersistenceServiceException(e.ToString()); TraceHelper.Trace(errorMessage); RaiseServicesExceptionNotHandledEvent( new PersistenceException(errorMessage, e), Guid.Empty); instanceIds = new List <Guid>(); } return(instanceIds); }