/// <summary>
        /// Updates the integration service.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentNullException">dto</exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void UpdateIntegrationService(ProcessIntegrationServiceDto dto)
        {
            const string CommandText = @"
UPDATE [dbo].[IntegrationServices]
SET
     [ProcessId] = @processId
    ,[Guid] = @guid
    ,[LastModifiedOn] = GETDATE()
    ,[Name] = @name
    ,[Direction] = @direction
    ,[Documentation] = @documentation
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("@processId", dto.ProcessId);
                cmd.Parameters.AddWithValue("@guid", dto.Guid);
                cmd.Parameters.AddWithValue("@name", dto.Name);
                cmd.Parameters.AddWithValue("@direction", dto.Direction.ToString());
                cmd.Parameters.AddWithValue("@documentation", dto.Documentation);

                var rowsAffected = Database.Execute(cmd);

                if (rowsAffected == 0)
                    throw new DBConcurrencyException(ConcurencyException);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Reads the integration services.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="sr">The sr.</param>
        private static void ReadIntegrationServices(ProcessEditDto process, SafeDataReader sr)
        {
            sr.NextResult();

            while (sr.Read())
            {
                var dto = new ProcessIntegrationServiceDto
                              {
                                  Id = sr.GetInt32(0),
                                  Guid = sr.GetGuid(1),
                                  Name = sr.GetString(2),
                                  Direction =
                                      (IntegrationServiceDirection)
                                      Enum.Parse(typeof(IntegrationServiceDirection), sr.GetString(3), true),
                                  Documentation = sr.GetString(4)
                              };

                process.IntegrationServiceList.Add(dto);
            }
        }
        /// <summary>
        /// Inserts the integration service.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentNullException">dto</exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void InsertIntegrationService(ProcessIntegrationServiceDto dto)
        {
            const string CommandText = @"
INSERT INTO [dbo].[IntegrationServices]
(
     [ProcessId]
    ,[Guid]
    ,[LastModifiedOn]
    ,[Name]
    ,[Direction]
    ,[Documentation]
)
VALUES
(
     @processId
    ,@guid
    ,GETDATE()
    ,@name
    ,@direction
    ,@documentation
);

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("@processId", dto.ProcessId);
                cmd.Parameters.AddWithValue("@guid", dto.Guid);
                cmd.Parameters.AddWithValue("@name", dto.Name);
                cmd.Parameters.AddWithValue("@direction", dto.Direction.ToString());
                cmd.Parameters.AddWithValue("@documentation", dto.Documentation);

                var rowsAffected = Database.Execute(cmd);

                if (rowsAffected == 0)
                    throw new DBConcurrencyException(ConcurencyException);

                dto.Id = (int)idParam.Value;
            }
        }