/// <summary> /// Inserts the integration service method parameter. /// </summary> /// <param name="dto">The dto.</param> /// <exception cref="System.ArgumentNullException">dto</exception> /// <exception cref="System.Data.DBConcurrencyException"></exception> public void InsertIntegrationServiceMethodParameter(IntegrationServiceMethodParameterDto dto) { const string CommandText = @" INSERT INTO [dbo].[IntegrationServiceMethodParameters] ( [MethodId] ,[LastModifiedOn] ,[Guid] ,[Name] ,[Namespace] ,[TypeGuid] ,[AllowMultiple] ,[SerializeAsSequence] ,[IsNullable] ) VALUES ( @methodId ,GETDATE() ,@guid ,@name ,@namespace ,@typeGuid ,@allowMultiple ,@serializeAsSequence ,@isNullable ) SET @id = SCOPE_IDENTITY();"; if (dto == null) throw new ArgumentNullException("dto"); using (var cmd = new SqlCommand(CommandText)) { var idParam = cmd.Parameters.Add("@id", SqlDbType.Int); idParam.Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@methodId", dto.MethodId); cmd.Parameters.AddWithValue("@guid", dto.Guid); cmd.Parameters.AddWithValue("@name", dto.Name); cmd.Parameters.AddWithValue("@namespace", dto.Namespace); cmd.Parameters.AddWithValue("@typeGuid", AdoHelper.NullCheck(dto.TypeGuid)); cmd.Parameters.AddWithValue("@allowMultiple", dto.AllowMultiple); cmd.Parameters.AddWithValue("@serializeAsSequence", dto.SerializeAsSequence); cmd.Parameters.AddWithValue("@isNullable", dto.IsNullable); var rowsAffected = Database.Execute(cmd); if (rowsAffected == 0) throw new DBConcurrencyException(ConcurencyException); dto.Id = (int)idParam.Value; } }
/// <summary> /// Updates the integration service method parameter. /// </summary> /// <param name="dto">The dto.</param> /// <exception cref="System.ArgumentNullException">dto</exception> /// <exception cref="System.Data.DBConcurrencyException"></exception> public void UpdateIntegrationServiceMethodParameter(IntegrationServiceMethodParameterDto dto) { const string CommandText = @" UPDATE [dbo].[IntegrationServiceMethodParameters] SET [MethodId] = @methodId ,[LastModifiedOn] = GETDATE() ,[Guid] = @guid ,[Name] = @name ,[Namespace] = @namespace ,[TypeGuid] = @typeGuid ,[AllowMultiple] = @allowMultiple ,[SerializeAsSequence] = @serializeAsSequence ,[IsNullable] = @isNullable WHERE [Id] = @id;"; if (dto == null) throw new ArgumentNullException("dto"); using (var cmd = new SqlCommand(CommandText)) { cmd.Parameters.AddWithValue("@id", dto.Id); cmd.Parameters.AddWithValue("@methodId", dto.MethodId); cmd.Parameters.AddWithValue("@guid", dto.Guid); cmd.Parameters.AddWithValue("@name", dto.Name); cmd.Parameters.AddWithValue("@namespace", dto.Namespace); cmd.Parameters.AddWithValue("@typeGuid", AdoHelper.NullCheck(dto.TypeGuid)); cmd.Parameters.AddWithValue("@allowMultiple", dto.AllowMultiple); cmd.Parameters.AddWithValue("@serializeAsSequence", dto.SerializeAsSequence); cmd.Parameters.AddWithValue("@isNullable", dto.IsNullable); var rowsAffected = Database.Execute(cmd); if (rowsAffected == 0) throw new DBConcurrencyException(ConcurencyException); } }
/// <summary> /// Reads the integration service method parameters. /// </summary> /// <param name="settingsDto">The settings dto.</param> /// <param name="reader">The reader.</param> private static void ReadIntegrationServiceMethodParameters(IntegrationServiceCreationSettingsDto settingsDto, IDataReader reader) { reader.NextResult(); int? methodId = null; IntegrationServiceMethodDto method = null; while (reader.Read()) { var parameterDto = new IntegrationServiceMethodParameterDto { Id = reader.GetInt32(0), MethodId = reader.GetInt32(1), Guid = reader.GetGuid(2), Name = reader.GetString(3), Namespace = reader.GetString(4), TypeGuid = reader.GetGuid(5), AllowMultiple = reader.GetBoolean(6), SerializeAsSequence = reader.GetBoolean(7), IsNullable = reader.GetBoolean(8) }; if (parameterDto.MethodId != methodId) { method = settingsDto.Methods.First(m => m.Id == parameterDto.MethodId); methodId = parameterDto.MethodId; } method.InputParameters.Add(parameterDto); } }