Exemplo n.º 1
0
        /// <summary>
        /// Inserts security config.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void InsertSecurityConfig(ProcessSecurityConfigDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CmdText = @"
  INSERT    dbo.ProcessSecurityConfigs
            ( ProcessId ,
              RoleId ,
              BusinessUnitId ,
              StateGuid ,
              PersonFieldName
            )
  VALUES    ( @processId , -- ProcessId - int
              @roleId , -- RoleId - int
              @buId , -- BusinessUnitId - int
              @stateGuid , -- StateGuid - uniqueidentifier
              @personFieldName   -- PersonFieldName - nvarchar(100)
            );
  SELECT    @@IDENTITY  
";

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

                using (var cmd = new SqlCommand(CmdText, cn))
                {
                    cmd.Parameters.AddWithValue("@processId", dto.ProcessId);
                    cmd.Parameters.AddWithValue("@roleId", dto.RoleId);
                    cmd.Parameters.AddWithValue("@buId", dto.BusinessUnitId);
                    cmd.Parameters.AddWithValue("@stateGuid", dto.StateGuid);
                    cmd.Parameters.AddWithValue("@personFieldName", dto.PersonFieldName);
                    dto.Id = Convert.ToInt32(cmd.ExecuteScalar(), CultureInfo.InvariantCulture);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates security config.
        /// </summary>
        /// <param name="securityConfigurationDto">The security DTO.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        /// <exception cref="System.ArgumentException">The input DTO is null.</exception>
        public void UpdateSecurityConfig(ProcessSecurityConfigDto securityConfigurationDto)
        {
            if (securityConfigurationDto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "securityConfigurationDto"));

            const string Sql =
    @"
   UPDATE   [dbo].[ProcessSecurityConfigs]
   SET      [ProcessId] = @ProcessId ,
            [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", securityConfigurationDto.Id);
                    cmd.Parameters.AddWithValue("@ProcessId", securityConfigurationDto.ProcessId);
                    cmd.Parameters.AddWithValue("@BusinessUnitId", securityConfigurationDto.BusinessUnitId);
                    cmd.Parameters.AddWithValue("@RoleId", securityConfigurationDto.RoleId);
                    cmd.Parameters.AddWithValue("@StateGuid", securityConfigurationDto.StateGuid);
                    cmd.Parameters.AddWithValue("@PersonFieldName", securityConfigurationDto.PersonFieldName);

                    cmd.ExecuteNonQuery();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reads process security configurations.
        /// </summary>
        /// <param name="process">The process.</param>
        /// <param name="sr">The reader.</param>
        private static void ReadProcessSecurityConfigs(ProcessEditDto process, SafeDataReader sr)
        {
            sr.NextResult();

            while (sr.Read())
            {
                var securityConfigurationDto = new ProcessSecurityConfigDto
                {
                    Id = sr.GetInt32(0),
                    ProcessId = sr.GetInt32(1),
                    RoleId = sr.GetInt32(2),
                    BusinessUnitId = sr.GetInt32(3),
                    StateGuid = sr.GetGuid(4),
                    PersonFieldName = sr.GetString(5)
                };

                process.SecurityConfigs.Add(securityConfigurationDto);
            }

            ReadSecurityConfigFields(sr, process);
            ReadSecurityConfigSystemFields(sr, process);
        }