예제 #1
0
        /// <summary>
        /// Inserts action.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void InsertAction(ProcessActionEditDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
                @"
INSERT INTO [dbo].[ActionDefinitions]
(
     [Guid]
    ,[ProcessId]
    ,[Name]
    ,[Documentation]
    ,[Subject]
    ,[Message]
    ,[ActionType]
    ,[GroupName]
)
VALUES
(
     @guid
    ,@processId
    ,@name
    ,@documentation
    ,@subject
    ,@message
    ,@actionType
    ,@groupName
);

SELECT [Id]
FROM   [dbo].[ActionDefinitions]
WHERE  [Id] = SCOPE_IDENTITY()";

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

                using (var cmd = new SqlCommand(CommandText, cn))
                {
                    cmd.Parameters.AddWithValue("@guid", dto.Guid);
                    cmd.Parameters.AddWithValue("@processId", dto.ProcessId);
                    cmd.Parameters.AddWithValue("@name", dto.Name);
                    cmd.Parameters.AddWithValue("@documentation", dto.Documentation);
                    cmd.Parameters.AddWithValue("@subject", dto.Subject);
                    cmd.Parameters.AddWithValue("@message", dto.Message);
                    cmd.Parameters.AddWithValue("@actionType", dto.ActionType.ToString());
                    cmd.Parameters.AddWithValue("@groupName", dto.GroupName);

                    dto.Id = (int)cmd.ExecuteScalar();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Updates action.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        /// <exception cref="System.Data.DBConcurrencyException">Indicates stale data.</exception>
        public void UpdateAction(ProcessActionEditDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
                @"
UPDATE [dbo].[ActionDefinitions]
SET  [Name]         = @name
    ,[Documentation]= @documentation
    ,[Subject]      = @subject
    ,[Message]      = @message
    ,[ActionType]   = @actionType
    ,[GroupName]    = @groupName
WHERE [Id] = @actionId";

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

                using (var cmd = new SqlCommand(CommandText, cn))
                {
                    cmd.Parameters.AddWithValue("@name", dto.Name);
                    cmd.Parameters.AddWithValue("@documentation", dto.Documentation);
                    cmd.Parameters.AddWithValue("@subject", dto.Subject);
                    cmd.Parameters.AddWithValue("@message", dto.Message);
                    cmd.Parameters.AddWithValue("@actionType", dto.ActionType.ToString());
                    cmd.Parameters.AddWithValue("@groupName", dto.GroupName);
                    cmd.Parameters.AddWithValue("@actionId", dto.Id);

                    var rowsAffected = cmd.ExecuteNonQuery();

                    if (rowsAffected == 0)
                    {
                        throw new DBConcurrencyException(Resources.StaleDataException);
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Updates action.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <param name="locDto">The localization DTO object.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        /// <exception cref="DBConcurrencyException">Indicates stale data.</exception>
        public void UpdateActionWithLocalization(ProcessActionEditDto dto, ProcessActionLocalizationDto locDto)
        {
            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
                @"
UPDATE [dbo].[ActionDefinitions]
SET  [ActionType]   = @actionType
WHERE [Id] = @actionId";

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

                using (var cmd = new SqlCommand(CommandText, cn))
                {
                    cmd.Parameters.AddWithValue("@actionType", dto.ActionType.ToString());
                    cmd.Parameters.AddWithValue("@actionId", dto.Id);

                    var rowsAffected = cmd.ExecuteNonQuery();

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

            UpdateProcessActionLocalization(locDto);
        }