コード例 #1
0
ファイル: ProcessDAL.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Inserts picture step.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void InsertPictureStep(PictureStepDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText = @"
INSERT INTO [dbo].[stepPicture]
(
     [FieldId]
    ,[SearchWidth]
    ,[SearchHeight]
    ,[DetailsWidth]
    ,[DetailsHeight]
    ,[UseOriginalSize]
)
VALUES
(
     @FieldId
    ,@SearchWidth
    ,@SearchHeight
    ,@DetailsWidth
    ,@DetailsHeight
    ,@UseOriginalSize
)";

            using (var cmd = new SqlCommand(CommandText))
            {
                cmd.Parameters.AddWithValue("@fieldId", dto.FieldId);
                cmd.Parameters.AddWithValue("@SearchWidth", dto.SearchWidth);
                cmd.Parameters.AddWithValue("@SearchHeight", dto.SearchHeight);
                cmd.Parameters.AddWithValue("@DetailsWidth", dto.DetailsWidth);
                cmd.Parameters.AddWithValue("@DetailsHeight", dto.DetailsHeight);
                cmd.Parameters.AddWithValue("@UseOriginalSize", dto.UseOriginalSize);

                Database.Execute(cmd);
            }
        }
コード例 #2
0
ファイル: ProcessDAL.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Updates picture step.
        /// </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 UpdatePictureStep(PictureStepDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText = @"
UPDATE  [dbo].[stepPicture]
SET     [SearchWidth] = @SearchWidth ,
        [SearchHeight] = @SearchHeight ,
        [DetailsWidth] = @DetailsWidth ,
        [DetailsHeight] = @DetailsHeight ,
        [UseOriginalSize] = @UseOriginalSize
WHERE   FieldId = @fieldId";

            using (var cmd = new SqlCommand(CommandText))
            {
                cmd.Parameters.AddWithValue("@fieldId", dto.FieldId);
                cmd.Parameters.AddWithValue("@SearchWidth", dto.SearchWidth);
                cmd.Parameters.AddWithValue("@SearchHeight", dto.SearchHeight);
                cmd.Parameters.AddWithValue("@DetailsWidth", dto.DetailsWidth);
                cmd.Parameters.AddWithValue("@DetailsHeight", dto.DetailsHeight);
                cmd.Parameters.AddWithValue("@UseOriginalSize", dto.UseOriginalSize);

                Database.Execute(cmd);
            }
        }
コード例 #3
0
ファイル: ProcessDAL.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Retrieves the picture step.
        /// </summary>
        /// <param name="processName">
        /// The process name.
        /// </param>
        /// <param name="fieldName">
        /// The field name.
        /// </param>
        /// <param name="isPublishedCopy">
        /// Specifies whether to retrieve the published copy.
        /// </param>
        /// <returns>
        /// The picture step.
        /// </returns>
        public PictureStepDto FetchPictureStep(string processName, string fieldName, bool isPublishedCopy = false)
        {
            const string CommandText = @"
DECLARE @fieldId AS INT

SELECT @fieldId = f.Id
FROM
    [dbo].[Processes] p
    INNER JOIN [dbo].[Sections] s ON s.ProcessId = p.Id
    INNER JOIN [dbo].[Fields] f ON f.SectionId = s.Id
WHERE p.[SystemName] = @processName AND p.IsRemoved = 0 AND p.IsPublishedCopy = @isPublishedCopy AND f.SystemName = @fieldName;

EXEC [dbo].[GetPictureStep] @FieldId = @fieldId;";

            using (var connectionManager = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                using (var cmd = new SqlCommand(CommandText, connectionManager.Connection))
                {
                    cmd.Parameters.AddWithValue("@processName", processName);
                    cmd.Parameters.AddWithValue("@fieldName", fieldName);
                    cmd.Parameters.AddWithValue("@isPublishedCopy", isPublishedCopy);

                    using (var reader = cmd.ExecuteReader())
                    {
                        using (var safeReader = new SafeDataReader(reader))
                        {
                            if (safeReader.Read())
                            {
                                var dto = new PictureStepDto
                                              {
                                                  Id = safeReader.GetInt32(0),
                                                  SearchWidth = safeReader.GetInt32(1),
                                                  SearchHeight = safeReader.GetInt32(2),
                                                  DetailsWidth = safeReader.GetInt32(3),
                                                  DetailsHeight = safeReader.GetInt32(4),
                                                  UseOriginalSize = safeReader.GetBoolean(5)
                                              };

                                return dto;
                            }
                        }
                    }
                }
            }

            return null;
        }