/// <summary> /// Retrieve a completed scope from the persistence store. /// </summary> /// <param name="scopeId"></param> /// <returns></returns> public Byte[] RetrieveCompletedScope(Guid scopeId) { Byte[] completedScope = null; using (DbCommand dbCommand = CreateCommand(_nameResolver.ResolveCommandName(PersistenceCommandName.RetrieveCompletedScope), CommandType.StoredProcedure)) { AddParameter(dbCommand, _nameResolver.ResolveParameterName( PersistenceCommandName.RetrieveCompletedScope, PersistenceParameterName.ScopeId), scopeId, AdoDbType.Guid); AddParameter(dbCommand, _nameResolver.ResolveParameterName( PersistenceCommandName.RetrieveCompletedScope, PersistenceParameterName.Result), AdoDbType.Int32, ParameterDirection.Output); AddParameter(dbCommand, _nameResolver.ResolveParameterName( PersistenceCommandName.RetrieveCompletedScope, PersistenceParameterName.State), AdoDbType.Cursor, ParameterDirection.Output); Int32?result; using (IDataReader dataReader = dbCommand.ExecuteReader()) { if (dataReader.Read()) { completedScope = (Byte[])_valueReader.GetValue(dataReader, 0); } result = _valueReader.GetNullableInt32(dbCommand, _nameResolver.ResolveParameterName( PersistenceCommandName.RetrieveInstanceState, PersistenceParameterName.Result)); } if (completedScope == null && result > 0) { // scope could not be found throw new PersistenceException(RM.Get_Error_ScopeCouldNotBeLoaded(scopeId)); } } return(completedScope); }
/// <summary> /// Retrieve a completed scope from the persistence store. /// </summary> /// <param name="scopeId"></param> /// <returns></returns> public byte[] RetrieveCompletedScope(Guid scopeId) { byte[] completedScope = null; using (DbCommand dbCommand = resourceProvider.CreateCommand(this.dbConnection, nameResolver.ResolveCommandName(CommandNames.RetrieveCompletedScope), CommandType.StoredProcedure)) { resourceProvider.AddParameter(dbCommand, nameResolver.ResolveParameterName(CommandNames.RetrieveCompletedScope, ParameterNames.ScopeId), scopeId, AdoDbType.Guid); resourceProvider.AddParameter(dbCommand, nameResolver.ResolveParameterName(CommandNames.RetrieveCompletedScope, ParameterNames.Result), AdoDbType.Int32, ParameterDirection.Output); resourceProvider.AddParameter(dbCommand, nameResolver.ResolveParameterName(CommandNames.RetrieveCompletedScope, ParameterNames.State), AdoDbType.Cursor, ParameterDirection.Output); int?result; using (IDataReader dataReader = dbCommand.ExecuteReader()) { if (dataReader.Read()) { completedScope = (byte[])dataReader.GetValue(0); } result = valueReader.GetNullableInt32(dbCommand, nameResolver.ResolveParameterName( CommandNames.RetrieveInstanceState, ParameterNames.Result)); } if (completedScope == null && result > 0) { // scope could not be found throw new WorkflowPersistenceException(string.Format( "Scope with identifier {0} could not be loaded.", scopeId)); } } return(completedScope); }