Exemplo n.º 1
0
        /// <summary>
        /// Inserts default layout into the unpublished copy to convert to version 2.2.
        /// </summary>
        /// <param name="processGuid">The process unique identifier.</param>
        /// <param name="dto">layout dto.</param>
        /// <exception cref="System.ArgumentException"></exception>
        public void InsertDefaultLayout(Guid processGuid, ProcessLayoutDto dto)
        {
            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var connection = ctx.Connection;

                const string commandText = @"
DECLARE @processId INT
SET @processId = (SELECT Id FROM Processes p WHERE p.Guid = @processGuid AND p.IsPublishedCopy = 0 AND p.IsRemoved = 0)
IF NOT EXISTS (SELECT 1 FROM Layouts l WHERE l.ProcessId = @processId AND l.Guid = @layoutGuid)	
    INSERT	INTO [dbo].[Layouts]
            ( [Name] ,
              [Guid] ,
              [ProcessId] ,
              [LayoutDefinition] ,
              [IsDefault]
            )
    VALUES	( @name ,
              @layoutGuid ,
              @processId ,
              @layoutDefiniton ,
              @isDefault
            )";
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddWithValue("@processGuid", processGuid);
                    command.Parameters.AddWithValue("@name", dto.Name);
                    command.Parameters.AddWithValue("@layoutGuid", dto.GuidId);
                    command.Parameters.AddWithValue("@isDefault", dto.IsDefault);
                    command.Parameters.AddWithValue("@layoutDefiniton", dto.LayoutDefinition);
                    
                    command.ExecuteNonQuery();
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Updates the process layout with localization.
 /// </summary>
 /// <param name="dto">The dto.</param>
 /// <param name="buildLocalizationDto">The build localization dto.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 /// <exception cref="NotImplementedException"></exception>
 public void UpdateProcessLayoutWithLocalization(ProcessLayoutDto dto, ProcessLayoutLocalizationDto buildLocalizationDto)
 {
     //TODO do we need to localize layouts?
     UpdateProcessLayout(dto);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Updates the process layout.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void UpdateProcessLayout(ProcessLayoutDto dto)
        {

            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var connection = ctx.Connection;

                const string commandText = @"
 UPDATE [dbo].[Layouts]
   SET [Name] = @name
      ,[Guid] = @guid
      ,[ProcessId] = @processId
      ,[IsDefault] = @isDefault
      ,[LayoutDefinition] = @layoutDefiniton
 WHERE id = @id";
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddWithValue("@name", dto.Name);
                    command.Parameters.AddWithValue("@guid", dto.GuidId);
                    command.Parameters.AddWithValue("@processId", dto.ProcessId);
                    command.Parameters.AddWithValue("@layoutDefiniton", dto.LayoutDefinition);
                    command.Parameters.AddWithValue("@isDefault", dto.IsDefault);
                    command.Parameters.AddWithValue("@id", dto.Id);

                    var rowsAffetcted = command.ExecuteNonQuery();

                    if (rowsAffetcted == 0)
                    {
                        throw new DBConcurrencyException(Resources.StaleDataException);
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Inserts the layout.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void InsertLayout(ProcessLayoutDto dto)
        {
            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var connection = ctx.Connection;

                const string commandText = @"
INSERT	INTO [dbo].[Layouts]
        ( [Name] ,
          [Guid] ,
          [ProcessId] ,
          [LayoutDefinition] ,
          [IsDefault]
        )
VALUES	( @name ,
          @guid ,
          @processId ,
          @layoutDefiniton ,
          @isDefault
        )
SET @p_id = SCOPE_IDENTITY()";
                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.AddWithValue("@name", dto.Name);
                    command.Parameters.AddWithValue("@guid", dto.GuidId);
                    command.Parameters.AddWithValue("@processId", dto.ProcessId);
                    command.Parameters.AddWithValue("@isDefault", dto.IsDefault);
                    command.Parameters.AddWithValue("@layoutDefiniton", dto.LayoutDefinition);
                    var idParam = new SqlParameter("@p_id", SqlDbType.Int, 0, "Id") { Direction = ParameterDirection.Output };
                    command.Parameters.Add(idParam);
                    
                    var rowsAffetcted = command.ExecuteNonQuery();

                    if (rowsAffetcted == 0)
                    {
                        throw new DBConcurrencyException(Resources.StaleDataException);
                    }

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