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

            const string Sql =
                @"
INSERT  INTO [dbo].[ProcessCommandSecurityConfigurations]
        ( [ProcessCommandId] ,
          [RoleId] ,
          [BusinessUnitId] ,
          [StateGuid] ,
          [PersonFieldName]
        )
VALUES  ( @ProcessCommandId ,
          @RoleId ,
          @BusinessUnitId ,
          @stateGuid ,
          @personFieldName
        );
SELECT  SCOPE_IDENTITY()";

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

                using (var cmd = new SqlCommand(Sql, connection))
                {
                    cmd.Parameters.AddWithValue("@ProcessCommandId", dto.ProcessCommandId);
                    cmd.Parameters.AddWithValue("@RoleId", dto.RoleId);
                    cmd.Parameters.AddWithValue("@BusinessUnitId", dto.BusinessUnitId);
                    cmd.Parameters.AddWithValue("@stateGuid", dto.StateGuid);
                    cmd.Parameters.AddWithValue("@personFieldName", dto.PersonFieldName);

                    var r = cmd.ExecuteScalar();
                    var newId = int.Parse(r.ToString(), CultureInfo.InvariantCulture);

                    return newId;
                }
            }
        }
コード例 #2
0
ファイル: ProcessDAL.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Updates command security configuration.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void UpdateCommandSecurityConfiguration(ProcessCommandSecurityConfigurationDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string Sql =
                @"
UPDATE [dbo].[ProcessCommandSecurityConfigurations]
SET
    [ProcessCommandId] = @ProcessCommandId,
    [RoleId] = @RoleId,
    [BusinessUnitId] = @BusinessUnitId,
    [StateGuid] = @stateGuid,
    [PersonFieldName] = @personFieldName
WHERE [Id] = @Id";

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

                using (var cmd = new SqlCommand(Sql, connection))
                {
                    cmd.Parameters.AddWithValue("@Id", dto.Id);
                    cmd.Parameters.AddWithValue("@ProcessCommandId", dto.ProcessCommandId);
                    cmd.Parameters.AddWithValue("@RoleId", dto.RoleId);
                    cmd.Parameters.AddWithValue("@BusinessUnitId", dto.BusinessUnitId);
                    cmd.Parameters.AddWithValue("@stateGuid", dto.StateGuid);
                    cmd.Parameters.AddWithValue("@personFieldName", dto.PersonFieldName);

                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #3
0
ファイル: ProcessDAL2.cs プロジェクト: mparsin/Elements
        /// <summary>
        /// Reads command security configuration.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="sr">The reader.</param>
        private static void ReadCommandSecurityConfiguration(ProcessEditDto process, SafeDataReader sr)
        {
            int? commandId = null;
            ProcessCommandEditDto commandDto = null;
            sr.NextResult();
            while (sr.Read())
            {
                var securityConfiguration = new ProcessCommandSecurityConfigurationDto
                {
                    Id = sr.GetInt32(0),
                    ProcessCommandId = sr.GetInt32(1),
                    CommandId = sr.GetInt32(1),
                    RoleId = sr.GetInt32(2),
                    BusinessUnitId = sr.GetInt32(3),
                    StateGuid = sr.GetString(4),
                    PersonFieldName = sr.GetString(5)
                };

                if (commandId != securityConfiguration.CommandId)
                {
                    commandId = securityConfiguration.CommandId;
                    commandDto = process.Commands.First(c => c.Id == commandId);
                }

                commandDto.SecurityConfigurationList.Add(securityConfiguration);
            }
        }