Esempio n. 1
0
        /// <summary>
        /// Updates field security config.
        /// </summary>
        /// <param name="securityConfigurationDto">The security DTO.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void UpdateFieldSecurityConfig(ProcessSecurityConfigFieldDto securityConfigurationDto)
        {
            if (securityConfigurationDto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "securityConfigurationDto"));

            const string Sql = @"
    UPDATE  [dbo].[ProcessSecurityConfigFields]
    SET     [SecurityConfigId] = @SecurityConfigId ,
            [FieldGuid] = @FieldGuid ,
            [CanView] = @CanView ,
            [CanEdit] = @CanEdit ,
            [Guid] = @Guid
    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("@SecurityConfigId", securityConfigurationDto.SecurityConfigId);
                    cmd.Parameters.AddWithValue("@FieldGuid", securityConfigurationDto.FieldGuid);
                    cmd.Parameters.AddWithValue("@CanView", securityConfigurationDto.CanView);
                    cmd.Parameters.AddWithValue("@CanEdit", securityConfigurationDto.CanEdit);
                    cmd.Parameters.AddWithValue("@Guid", securityConfigurationDto.Guid);

                    cmd.ExecuteNonQuery();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Inserts field security config.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void InsertFieldSecurityConfig(ProcessSecurityConfigFieldDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CmdText = @"
INSERT INTO [dbo].[ProcessSecurityConfigFields]
           ([SecurityConfigId]
           ,[FieldGuid]
           ,[CanView]
           ,[CanEdit]
           ,[Guid])
     VALUES
           (@SecurityConfigId
           ,@FieldGuid
           ,@CanView
           ,@CanEdit
           ,@Guid);
  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("@SecurityConfigId", dto.SecurityConfigId);
                    cmd.Parameters.AddWithValue("@FieldGuid", dto.FieldGuid);
                    cmd.Parameters.AddWithValue("@CanView", dto.CanView);
                    cmd.Parameters.AddWithValue("@CanEdit", dto.CanEdit);
                    cmd.Parameters.AddWithValue("@Guid", dto.Guid);

                    var id = cmd.ExecuteScalar();

                    dto.Id = Convert.ToInt32(id, CultureInfo.InvariantCulture);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// The read security config fields.
        /// </summary>
        /// <param name="sr">The reader.</param>
        /// <param name="process">The process.</param>
        private static void ReadSecurityConfigFields(SafeDataReader sr, ProcessEditDto process)
        {
            sr.NextResult();
            while (sr.Read())
            {
                var securityConfigFieldDto = new ProcessSecurityConfigFieldDto
                {
                    Id = sr.GetInt32(0),
                    SecurityConfigId = sr.GetInt32(1),
                    CanView = sr.GetBool(2),
                    CanEdit = sr.GetBool(3),
                    Guid = sr.GetGuid(4),
                    FieldGuid = sr.GetGuid(5)
                };
                var config = process.SecurityConfigs.FirstOrDefault(sc => sc.Id == securityConfigFieldDto.SecurityConfigId);

                if (config != null)
                {
                    config.SecurityConfigFields.Add(securityConfigFieldDto);
                }
            }
        }