コード例 #1
0
ファイル: ProcessDALActions.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Updates process view.
        /// </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 UpdateProcessViewWithLocalization(ProcessViewEditDto dto, ProcessViewLocalizationDto locDto)
        {
            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
    @"
UPDATE [dbo].[ProcessViews]
SET [LastModifiedOn]                = @p_LastModifiedOn
    ,[Guid]                         = @p_Guid
    ,[ViewType]                     = @p_ViewType
    ,[ViewConfiguration]            = @p_ViewConfiguration
WHERE [Id] = @p_Id;
";
            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var connection = ctx.Connection;

                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_Id", dto.Id);
                    command.Parameters.AddWithValue("@p_LastModifiedOn", dto.LastModifiedOn);
                    command.Parameters.AddWithValue("@p_Guid", dto.Guid);
                    command.Parameters.AddWithValue("@p_ViewType", dto.ViewType);
                    command.Parameters.AddWithValue("@p_ViewConfiguration", dto.ViewConfiguration);

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

            UpdateProcessViewLocalization(locDto);
        }
コード例 #2
0
ファイル: ProcessDALActions.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Inserts process view.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <exception cref="System.ArgumentException">The input DTO is null.</exception>
        public void InsertProcessView(ProcessViewEditDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
    @"
INSERT INTO [dbo].[ProcessViews]
(
     [ProcessId]
    ,[LastModifiedOn]
    ,[Guid]
    ,[Name]
    ,[Documentation]
    ,[ViewType]
    ,[ViewConfiguration]
)
VALUES
(
     @p_ProcessId
    ,@p_LastModifiedOn
    ,@p_Guid
    ,@p_Name
    ,@p_Documentation
    ,@p_ViewType
    ,@p_ViewConfiguration
);
SELECT [Id]
FROM [dbo].[ProcessViews]
WHERE [Id] = SCOPE_IDENTITY()";

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

                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_ProcessId", dto.ProcessId);
                    command.Parameters.AddWithValue("@p_LastModifiedOn", dto.LastModifiedOn);
                    command.Parameters.AddWithValue("@p_Guid", dto.Guid);
                    command.Parameters.AddWithValue("@p_Name", dto.Name);
                    command.Parameters.AddWithValue("@p_Documentation", dto.Documentation);
                    command.Parameters.AddWithValue("@p_ViewType", dto.ViewType);
                    command.Parameters.AddWithValue("@p_ViewConfiguration", dto.ViewConfiguration);

                    dto.Id = (int)command.ExecuteScalar();
                }
            }
        }