/// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="serializerRepresentationId">The identifier.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    int serializerRepresentationId)
                {
                    var sprocName  = FormattableString.Invariant($"[{streamName}].{nameof(GetSerializerRepresentationFromId)}");
                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <int>(
                            nameof(InputParamName.Id),
                            Tables.SerializerRepresentation.Id.SqlDataType,
                            serializerRepresentationId),
                        new OutputParameterDefinition <SerializationKind>(
                            nameof(OutputParamName.SerializationKind),
                            Tables.SerializerRepresentation.SerializationKind.SqlDataType),
                        new OutputParameterDefinition <int>(
                            nameof(OutputParamName.ConfigTypeWithVersionId),
                            Tables.SerializerRepresentation.SerializationConfigurationTypeWithVersionId.SqlDataType),
                        new OutputParameterDefinition <CompressionKind>(
                            nameof(OutputParamName.CompressionKind),
                            Tables.SerializerRepresentation.CompressionKind.SqlDataType),
                        new OutputParameterDefinition <SerializationFormat>(
                            nameof(OutputParamName.SerializationFormat),
                            Tables.SerializerRepresentation.SerializationFormat.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
示例#2
0
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="configType">The serialization configuration type identifiers.</param>
                /// <param name="serializationKind">The <see cref="SerializationKind"/>.</param>
                /// <param name="serializationFormat">The <see cref="SerializationFormat"/>.</param>
                /// <param name="compressionKind">The <see cref="CompressionKind"/>.</param>
                /// <param name="unregisteredTypeEncounteredStrategy">The <see cref="UnregisteredTypeEncounteredStrategy"/>.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    IdentifiedType configType,
                    SerializationKind serializationKind,
                    SerializationFormat serializationFormat,
                    CompressionKind compressionKind,
                    UnregisteredTypeEncounteredStrategy unregisteredTypeEncounteredStrategy)
                {
                    var sprocName = Invariant($"[{streamName}].[{nameof(GetIdAddIfNecessarySerializerRepresentation)}]");

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <int>(nameof(InputParamName.ConfigTypeWithoutVersionId), Tables.TypeWithoutVersion.Id.SqlDataType, configType.IdWithoutVersion),
                        new InputParameterDefinition <int>(nameof(InputParamName.ConfigTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType, configType.IdWithVersion),
                        new InputParameterDefinition <string>(nameof(InputParamName.SerializationKind), Tables.SerializerRepresentation.SerializationKind.SqlDataType, serializationKind.ToString()),
                        new InputParameterDefinition <string>(nameof(InputParamName.SerializationFormat), Tables.SerializerRepresentation.SerializationFormat.SqlDataType, serializationFormat.ToString()),
                        new InputParameterDefinition <string>(nameof(InputParamName.CompressionKind), Tables.SerializerRepresentation.CompressionKind.SqlDataType, compressionKind.ToString()),
                        new InputParameterDefinition <string>(nameof(InputParamName.UnregisteredTypeEncounteredStrategy), Tables.SerializerRepresentation.SerializationKind.SqlDataType, unregisteredTypeEncounteredStrategy.ToString()),
                        new OutputParameterDefinition <int>(nameof(OutputParamName.Id), Tables.SerializerRepresentation.Id.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="concern">The concern.</param>
                /// <param name="details">The details.</param>
                /// <param name="recordId">The record identifier.</param>
                /// <param name="newStatus">The new status.</param>
                /// <param name="acceptableCurrentStatuses">The acceptable current statuses.</param>
                /// <param name="tagIdsForEntryCsv">The tag identifiers as CSV.</param>
                /// <param name="inheritRecordTags">The tags on the record should also be on the handling entry.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    string concern,
                    string details,
                    long recordId,
                    HandlingStatus newStatus,
                    IReadOnlyCollection <HandlingStatus> acceptableCurrentStatuses,
                    string tagIdsForEntryCsv,
                    bool inheritRecordTags)
                {
                    var sprocName = Invariant($"[{streamName}].{nameof(PutHandling)}");

                    var acceptableCurrentStatusesCsv = acceptableCurrentStatuses.Select(_ => _.ToString()).ToCsv();

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <string>(nameof(InputParamName.Concern), Tables.Handling.Concern.SqlDataType, concern),
                        new InputParameterDefinition <string>(nameof(InputParamName.Details), Tables.Handling.Details.SqlDataType, details),
                        new InputParameterDefinition <long>(nameof(InputParamName.RecordId), Tables.Handling.RecordId.SqlDataType, recordId),
                        new InputParameterDefinition <string>(nameof(InputParamName.NewStatus), Tables.Handling.Status.SqlDataType, newStatus.ToString()),
                        new InputParameterDefinition <string>(nameof(InputParamName.AcceptableCurrentStatusesCsv), new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant), acceptableCurrentStatusesCsv),
                        new InputParameterDefinition <string>(nameof(InputParamName.TagIdsForEntryCsv), Tables.Record.TagIdsCsv.SqlDataType, tagIdsForEntryCsv),
                        new InputParameterDefinition <int>(nameof(InputParamName.InheritRecordTags), new IntSqlDataTypeRepresentation(), inheritRecordTags ? 1 : 0),
                        new InputParameterDefinition <int>(nameof(InputParamName.IsUnHandledRecord), new IntSqlDataTypeRepresentation(), 0),
                        new InputParameterDefinition <int>(nameof(InputParamName.IsClaimingRecordId), new IntSqlDataTypeRepresentation(), 0),
                        new OutputParameterDefinition <long>(nameof(OutputParamName.Id), Tables.Handling.Id.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
        public StoredProcedureExecutionResult DeepCloneWithOperation(ExecuteStoredProcedureOp operation)
        {
            var result = new StoredProcedureExecutionResult(
                operation,
                this.OutputParameters?.DeepClone());

            return(result);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StoredProcedureExecutionResult"/> class.
        /// </summary>
        /// <param name="operation">The operation.</param>
        /// <param name="outputParameters">The output parameters.</param>
        public StoredProcedureExecutionResult(
            ExecuteStoredProcedureOp operation,
            IReadOnlyDictionary <string, ISqlOutputParameterResult> outputParameters)
        {
            operation.MustForArg(nameof(operation)).NotBeNull();
            outputParameters.MustForArg(nameof(outputParameters)).NotBeNull().And().NotContainAnyKeyValuePairsWithNullValue();

            this.Operation        = operation;
            this.OutputParameters = outputParameters;
        }
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="concern">Handling concern.</param>
                /// <param name="convertedRecordFilter">Converted form of <see cref="RecordFilter"/>.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    string concern,
                    RecordFilterConvertedForStoredProcedure convertedRecordFilter)
                {
                    var sprocName  = Invariant($"[{streamName}].[{nameof(GetHandlingStatuses)}]");
                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.Concern),
                            Tables.Handling.Concern.SqlDataType,
                            concern),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.InternalRecordIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.InternalRecordIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.IdentifierTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.IdentifierTypeIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.ObjectTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.ObjectTypeIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.StringIdentifiersXml),
                            new XmlSqlDataTypeRepresentation(),
                            convertedRecordFilter.StringIdsToMatchXml),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagIdsToMatchCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.TagIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagMatchStrategy),
                            new StringSqlDataTypeRepresentation(false, 40),
                            convertedRecordFilter.TagMatchStrategy.ToString()),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.VersionMatchStrategy),
                            new StringSqlDataTypeRepresentation(false, 20),
                            convertedRecordFilter.VersionMatchStrategy.ToString()),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.DeprecatedIdEventTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.DeprecatedIdEventTypeIdsCsv),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.RecordIdHandlingStatusXml),
                            new XmlSqlDataTypeRepresentation()),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName)
                {
                    var sprocName = Invariant($"[{streamName}].[{nameof(GetStreamDetails)}]");

                    var parameters = new List <ParameterDefinitionBase>
                    {
                        new OutputParameterDefinition <string>(nameof(OutputParamName.DetailsXml), new XmlSqlDataTypeRepresentation()),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
示例#8
0
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="operation">The operation to use as inputs.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    StandardGetNextUniqueLongOp operation)
                {
                    var sprocName = Invariant($"[{streamName}].[{nameof(GetNextUniqueLong)}]");

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <string>(nameof(InputParamName.Details), Tables.NextUniqueLong.Details.SqlDataType, operation.Details),
                        new OutputParameterDefinition <long>(nameof(OutputParamName.Value), Tables.NextUniqueLong.Id.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="assemblyQualifiedNameWithoutVersion">The assembly qualified name.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    string assemblyQualifiedNameWithoutVersion)
                {
                    var sprocName = Invariant($"[{streamName}].[{nameof(GetIdAddIfNecessaryTypeWithoutVersion)}]");

                    var parameters =
                        new List <ParameterDefinitionBase>
                    {
                        new InputParameterDefinition <string>(nameof(InputParamName.AssemblyQualifiedNameWithoutVersion), Tables.TypeWithoutVersion.AssemblyQualifiedName.SqlDataType, assemblyQualifiedNameWithoutVersion),
                        new OutputParameterDefinition <int>(nameof(OutputParamName.Id), Tables.TypeWithoutVersion.Id.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
示例#10
0
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="typeId">The identifier.</param>
                /// <param name="versioned">Including version.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    int typeId,
                    bool versioned)
                {
                    var sprocName = Invariant($"[{streamName}].{nameof(GetTypeFromId)}");

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <int>(nameof(InputParamName.Id), versioned ? Tables.TypeWithVersion.Id.SqlDataType : Tables.TypeWithoutVersion.Id.SqlDataType, typeId),
                        new InputParameterDefinition <int>(nameof(InputParamName.Versioned), new IntSqlDataTypeRepresentation(), versioned ? 1 : 0),
                        new OutputParameterDefinition <string>(nameof(OutputParamName.AssemblyQualifiedName), versioned ? Tables.TypeWithVersion.AssemblyQualifiedName.SqlDataType : Tables.TypeWithoutVersion.AssemblyQualifiedName.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
示例#11
0
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="serializerRepresentation">The serializer representation.</param>
                /// <param name="identifierType">The identifier type.</param>
                /// <param name="objectType">The object type.</param>
                /// <param name="internalRecordId">The optional internal record identifier (for stream re-play).</param>
                /// <param name="serializedObjectId">The serialized object identifier.</param>
                /// <param name="serializedObjectString">The serialized object as a string (should have data IFF the serializer is set to SerializationFormat.String, otherwise null).</param>
                /// <param name="serializedObjectBytes">The serialized object as a byte array (should have data IFF the serializer is set to SerializationFormat.Binary, otherwise null).</param>
                /// <param name="objectDateTimeUtc">The date time of the object if exists.</param>
                /// <param name="tagIdsCsv">The tag identifiers as CSV.</param>
                /// <param name="existingRecordStrategy">Existing record encountered strategy.</param>
                /// <param name="recordRetentionCount">Number of records to keep if using a pruning <paramref name="existingRecordStrategy"/>.</param>
                /// <param name="versionMatchStrategy">Type version match strategy.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    IdentifiedSerializerRepresentation serializerRepresentation,
                    IdentifiedType identifierType,
                    IdentifiedType objectType,
                    long?internalRecordId,
                    string serializedObjectId,
                    string serializedObjectString,
                    byte[] serializedObjectBytes,
                    DateTime?objectDateTimeUtc,
                    string tagIdsCsv,
                    ExistingRecordStrategy existingRecordStrategy,
                    int?recordRetentionCount,
                    VersionMatchStrategy versionMatchStrategy)
                {
                    var sprocName = Invariant($"[{streamName}].{nameof(PutRecord)}");

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <int>(nameof(InputParamName.SerializerRepresentationId), Tables.SerializerRepresentation.Id.SqlDataType, serializerRepresentation.Id),
                        new InputParameterDefinition <int?>(nameof(InputParamName.IdentifierTypeWithoutVersionId), Tables.TypeWithoutVersion.Id.SqlDataType, identifierType?.IdWithoutVersion),
                        new InputParameterDefinition <int?>(nameof(InputParamName.IdentifierTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType, identifierType?.IdWithVersion),
                        new InputParameterDefinition <int?>(nameof(InputParamName.ObjectTypeWithoutVersionId), Tables.TypeWithoutVersion.Id.SqlDataType, objectType?.IdWithoutVersion),
                        new InputParameterDefinition <int?>(nameof(InputParamName.ObjectTypeWithVersionId), Tables.TypeWithVersion.Id.SqlDataType, objectType?.IdWithVersion),
                        new InputParameterDefinition <long?>(nameof(InputParamName.InternalRecordId), Tables.Record.Id.SqlDataType, internalRecordId),
                        new InputParameterDefinition <string>(nameof(InputParamName.StringSerializedId), Tables.Record.StringSerializedId.SqlDataType, serializedObjectId),
                        new InputParameterDefinition <string>(nameof(InputParamName.StringSerializedObject), Tables.Record.StringSerializedObject.SqlDataType, serializedObjectString),
                        new InputParameterDefinition <byte[]>(nameof(InputParamName.BinarySerializedObject), Tables.Record.BinarySerializedObject.SqlDataType, serializedObjectBytes),
                        new InputParameterDefinition <DateTime?>(nameof(InputParamName.ObjectDateTimeUtc), Tables.Record.ObjectDateTimeUtc.SqlDataType, objectDateTimeUtc),
                        new InputParameterDefinition <string>(nameof(InputParamName.TagIdsCsv), Tables.Record.TagIdsCsv.SqlDataType, tagIdsCsv),
                        new InputParameterDefinition <ExistingRecordStrategy>(nameof(InputParamName.ExistingRecordStrategy), new StringSqlDataTypeRepresentation(false, 50), existingRecordStrategy),
                        new InputParameterDefinition <int?>(nameof(InputParamName.RecordRetentionCount), new IntSqlDataTypeRepresentation(), recordRetentionCount),
                        new InputParameterDefinition <VersionMatchStrategy>(nameof(InputParamName.VersionMatchStrategy), new StringSqlDataTypeRepresentation(false, 50), versionMatchStrategy),
                        new OutputParameterDefinition <long?>(nameof(OutputParamName.Id), Tables.Record.Id.SqlDataType),
                        new OutputParameterDefinition <string>(nameof(OutputParamName.ExistingRecordIdsCsv), Tables.Record.TagIdsCsv.SqlDataType),
                        new OutputParameterDefinition <string>(nameof(OutputParamName.PrunedRecordIdsCsv), Tables.Record.TagIdsCsv.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
示例#12
0
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="tags">The tag set.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    IReadOnlyCollection <NamedValue <string> > tags)
                {
                    var sprocName  = Invariant($"[{streamName}].[{nameof(GetIdsAddIfNecessaryTagSet)}]");
                    var tagsXml    = TagConversionTool.GetTagsXmlString(tags);
                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagsXml),
                            new XmlSqlDataTypeRepresentation(),
                            tagsXml),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.TagIdsXml),
                            new XmlSqlDataTypeRepresentation()),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="tagIds">The tag identifier set.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    IReadOnlyList <long> tagIds)
                {
                    var sprocName  = Invariant($"[{streamName}].{Name}");
                    var tagIdsCsv  = tagIds?.Select(_ => _.ToStringInvariantPreferred()).ToCsv();
                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagIdsCsv),
                            Tables.Record.TagIdsCsv.SqlDataType,
                            tagIdsCsv),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.TagsXml),
                            new XmlSqlDataTypeRepresentation()),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
示例#14
0
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="loginName">The login name.</param>
                /// <param name="username">The username.</param>
                /// <param name="clearTextPassword">The password.</param>
                /// <param name="roles">The roles as CSV.</param>
                /// <param name="shouldCreateLogin">Indicates whether or not to create the login or look it up (must specify <paramref name="loginName"/> if this is TRUE).</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    string loginName,
                    string username,
                    string clearTextPassword,
                    string roles,
                    bool shouldCreateLogin)
                {
                    var sprocName = Invariant($"[{streamName}].{nameof(CreateStreamUser)}");

                    var parameters = new List<ParameterDefinitionBase>()
                                     {
                                         new InputParameterDefinition<string>(nameof(InputParamName.LoginName), new StringSqlDataTypeRepresentation(true, 128), loginName ?? username),
                                         new InputParameterDefinition<string>(nameof(InputParamName.Username), new StringSqlDataTypeRepresentation(true, 128), username),
                                         new InputParameterDefinition<string>(nameof(InputParamName.ClearTextPassword), new StringSqlDataTypeRepresentation(true, 128), clearTextPassword),
                                         new InputParameterDefinition<string>(nameof(InputParamName.RoleCsv), new StringSqlDataTypeRepresentation(true, StringSqlDataTypeRepresentation.MaxUnicodeLengthConstant), roles),
                                         new InputParameterDefinition<int>(nameof(InputParamName.ShouldCreateLogin), new IntSqlDataTypeRepresentation(), shouldCreateLogin ? 1 : 0),
                                     };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return result;
                }
示例#15
0
                /// <summary>
                /// Builds the execute stored procedure op.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="concern">The concern.</param>
                /// <param name="details">The details.</param>
                /// <param name="convertedRecordFilter">Converted form of <see cref="RecordFilter"/>.</param>
                /// <param name="tagIdsForEntryCsv">The tag identifiers of tags to add to new entries.</param>
                /// <param name="orderRecordsBy">The order records strategy.</param>
                /// <param name="minimumInternalRecordId">The optional minimum internal record identifier, null for default.</param>
                /// <param name="inheritRecordTags">The tags on the record should also be on the handling entry.</param>
                /// <param name="streamRecordItemsToInclude">The items to include.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    string concern,
                    string details,
                    RecordFilterConvertedForStoredProcedure convertedRecordFilter,
                    string tagIdsForEntryCsv,
                    OrderRecordsBy orderRecordsBy,
                    long?minimumInternalRecordId,
                    bool inheritRecordTags,
                    StreamRecordItemsToInclude streamRecordItemsToInclude)
                {
                    streamRecordItemsToInclude
                    .MustForArg(nameof(streamRecordItemsToInclude))
                    .BeElementIn(
                        new[]
                    {
                        StreamRecordItemsToInclude.MetadataAndPayload,
                        StreamRecordItemsToInclude.MetadataOnly,
                    });

                    var sprocName = Invariant($"[{streamName}].{nameof(TryHandleRecord)}");

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.Concern),
                            Tables.Handling.Concern.SqlDataType,
                            concern),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.Details),
                            Tables.Handling.Details.SqlDataType,
                            details),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.InternalRecordIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.InternalRecordIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.IdentifierTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.IdentifierTypeIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.ObjectTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.ObjectTypeIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.StringIdentifiersXml),
                            new XmlSqlDataTypeRepresentation(),
                            convertedRecordFilter.StringIdsToMatchXml),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagIdsToMatchCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.TagIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagMatchStrategy),
                            new StringSqlDataTypeRepresentation(false, 40),
                            convertedRecordFilter.TagMatchStrategy.ToString()),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.VersionMatchStrategy),
                            new StringSqlDataTypeRepresentation(false, 20),
                            convertedRecordFilter.VersionMatchStrategy.ToString()),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.DeprecatedIdEventTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.DeprecatedIdEventTypeIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagIdsForEntryCsv),
                            Tables.Record.TagIdsCsv.SqlDataType,
                            tagIdsForEntryCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.OrderRecordsBy),
                            new StringSqlDataTypeRepresentation(false, 50),
                            orderRecordsBy.ToString()),
                        new InputParameterDefinition <int>(
                            nameof(InputParamName.InheritRecordTags),
                            new IntSqlDataTypeRepresentation(),
                            inheritRecordTags ? 1 : 0),
                        new InputParameterDefinition <long?>(
                            nameof(InputParamName.MinimumInternalRecordId),
                            Tables.Record.Id.SqlDataType,
                            minimumInternalRecordId),
                        new InputParameterDefinition <int>(
                            nameof(InputParamName.IncludePayload),
                            new IntSqlDataTypeRepresentation(),
                            streamRecordItemsToInclude == StreamRecordItemsToInclude.MetadataAndPayload ? 1 : 0),
                        new OutputParameterDefinition <int>(nameof(OutputParamName.ShouldHandle), new IntSqlDataTypeRepresentation()),
                        new OutputParameterDefinition <int>(nameof(OutputParamName.IsBlocked), new IntSqlDataTypeRepresentation()),
                        new OutputParameterDefinition <long>(nameof(OutputParamName.Id), Tables.Handling.Id.SqlDataType),
                        new OutputParameterDefinition <long>(nameof(OutputParamName.InternalRecordId), Tables.Record.Id.SqlDataType),
                        new OutputParameterDefinition <int>(
                            nameof(OutputParamName.SerializerRepresentationId),
                            Tables.SerializerRepresentation.Id.SqlDataType),
                        new OutputParameterDefinition <int>(
                            nameof(OutputParamName.IdentifierTypeWithVersionId),
                            Tables.TypeWithVersion.Id.SqlDataType),
                        new OutputParameterDefinition <int>(
                            nameof(OutputParamName.ObjectTypeWithVersionId),
                            Tables.TypeWithVersion.Id.SqlDataType),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.StringSerializedId),
                            Tables.Record.StringSerializedId.SqlDataType),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.StringSerializedObject),
                            Tables.Record.StringSerializedObject.SqlDataType),
                        new OutputParameterDefinition <byte[]>(
                            nameof(OutputParamName.BinarySerializedObject),
                            Tables.Record.BinarySerializedObject.SqlDataType),
                        new OutputParameterDefinition <DateTime>(
                            nameof(OutputParamName.RecordDateTime),
                            Tables.Record.RecordCreatedUtc.SqlDataType),
                        new OutputParameterDefinition <DateTime?>(
                            nameof(OutputParamName.ObjectDateTime),
                            Tables.Record.ObjectDateTimeUtc.SqlDataType),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.TagIdsCsv),
                            Tables.Record.TagIdsCsv.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }
                /// <summary>
                /// Builds the execute stored procedure operation.
                /// </summary>
                /// <param name="streamName">Name of the stream.</param>
                /// <param name="convertedRecordFilter">Converted form of <see cref="RecordFilter"/>.</param>
                /// <param name="streamRecordItemsToInclude">The items to include.</param>
                /// <returns>Operation to execute stored procedure.</returns>
                public static ExecuteStoredProcedureOp BuildExecuteStoredProcedureOp(
                    string streamName,
                    RecordFilterConvertedForStoredProcedure convertedRecordFilter,
                    StreamRecordItemsToInclude streamRecordItemsToInclude)
                {
                    streamRecordItemsToInclude
                    .MustForArg(nameof(streamRecordItemsToInclude))
                    .BeElementIn(
                        new[]
                    {
                        StreamRecordItemsToInclude.MetadataAndPayload,
                        StreamRecordItemsToInclude.MetadataOnly,
                    });

                    var sprocName = Invariant($"[{streamName}].[{nameof(GetLatestRecord)}]");

                    var parameters = new List <ParameterDefinitionBase>()
                    {
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.InternalRecordIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.InternalRecordIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.IdentifierTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.IdentifierTypeIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.ObjectTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.ObjectTypeIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.StringIdentifiersXml),
                            new XmlSqlDataTypeRepresentation(),
                            convertedRecordFilter.StringIdsToMatchXml),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagIdsToMatchCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.TagIdsCsv),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.TagMatchStrategy),
                            new StringSqlDataTypeRepresentation(false, 40),
                            convertedRecordFilter.TagMatchStrategy.ToString()),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.VersionMatchStrategy),
                            new StringSqlDataTypeRepresentation(false, 20),
                            convertedRecordFilter.VersionMatchStrategy.ToString()),
                        new InputParameterDefinition <string>(
                            nameof(InputParamName.DeprecatedIdEventTypeIdsCsv),
                            new StringSqlDataTypeRepresentation(false, StringSqlDataTypeRepresentation.MaxNonUnicodeLengthConstant),
                            convertedRecordFilter.DeprecatedIdEventTypeIdsCsv),
                        new InputParameterDefinition <int>(
                            nameof(InputParamName.IncludePayload),
                            new IntSqlDataTypeRepresentation(),
                            streamRecordItemsToInclude == StreamRecordItemsToInclude.MetadataAndPayload ? 1 : 0),
                        new OutputParameterDefinition <long>(nameof(OutputParamName.InternalRecordId), Tables.Record.Id.SqlDataType),
                        new OutputParameterDefinition <int>(
                            nameof(OutputParamName.SerializerRepresentationId),
                            Tables.SerializerRepresentation.Id.SqlDataType),
                        new OutputParameterDefinition <int>(
                            nameof(OutputParamName.IdentifierTypeWithVersionId),
                            Tables.TypeWithVersion.Id.SqlDataType),
                        new OutputParameterDefinition <int>(
                            nameof(OutputParamName.ObjectTypeWithVersionId),
                            Tables.TypeWithVersion.Id.SqlDataType),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.StringSerializedId),
                            Tables.Record.StringSerializedId.SqlDataType),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.StringSerializedObject),
                            Tables.Record.StringSerializedObject.SqlDataType),
                        new OutputParameterDefinition <byte[]>(
                            nameof(OutputParamName.BinarySerializedObject),
                            Tables.Record.BinarySerializedObject.SqlDataType),
                        new OutputParameterDefinition <DateTime>(
                            nameof(OutputParamName.RecordDateTime),
                            Tables.Record.RecordCreatedUtc.SqlDataType),
                        new OutputParameterDefinition <DateTime?>(
                            nameof(OutputParamName.ObjectDateTime),
                            Tables.Record.ObjectDateTimeUtc.SqlDataType),
                        new OutputParameterDefinition <string>(
                            nameof(OutputParamName.TagIdsCsv),
                            Tables.Record.TagIdsCsv.SqlDataType),
                    };

                    var result = new ExecuteStoredProcedureOp(sprocName, parameters);

                    return(result);
                }