コード例 #1
0
        /// <summary>
        /// Inserts the integration service call rule.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentNullException">dto</exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void InsertIntegrationServiceCallRule(IntegrationServiceCallRuleDto dto)
        {
            const string CommandText = @"
INSERT INTO [dbo].[IntegrationServiceCallRules]
(
     [LastModifiedOn]
    ,[CallSettingsId]
    ,[RuleGuid]
)
VALUES
(
     GETDATE()
    ,@callSettingsId
    ,@ruleGuid
);

SET @id = SCOPE_IDENTITY();";

            if (dto == null)
                throw new ArgumentNullException("dto");

            using (var cmd = new SqlCommand(CommandText))
            {
                var idParam = cmd.Parameters.Add("@id", SqlDbType.Int);

                idParam.Direction = ParameterDirection.Output;

                cmd.Parameters.AddWithValue("@callSettingsId", dto.CallSettingsId);
                cmd.Parameters.AddWithValue("@ruleGuid", dto.RuleGuid);

                var rowsAffected = Database.Execute(cmd);

                if (rowsAffected == 0)
                    throw new DBConcurrencyException(ConcurencyException);

                dto.Id = (int)idParam.Value;
            }
        }
コード例 #2
0
        /// <summary>
        /// Updates the integration service call rule.
        /// </summary>
        /// <param name="dto">The dto.</param>
        /// <exception cref="System.ArgumentNullException">dto</exception>
        /// <exception cref="System.Data.DBConcurrencyException"></exception>
        public void UpdateIntegrationServiceCallRule(IntegrationServiceCallRuleDto dto)
        {
            const string CommandText = @"
UPDATE [dbo].[IntegrationServiceCallRules]
SET
     [LastModifiedOn] = GETDATE()
    ,[CallSettingsId] = @callSettingsId
    ,[RuleGuid] = @ruleGuid
WHERE [Id] = @id;";

            if (dto == null)
                throw new ArgumentNullException("dto");

            using (var cmd = new SqlCommand(CommandText))
            {
                cmd.Parameters.AddWithValue("@id", dto.Id);
                cmd.Parameters.AddWithValue("@callSettingsId", dto.CallSettingsId);
                cmd.Parameters.AddWithValue("@ruleGuid", dto.RuleGuid);

                var rowsAffected = Database.Execute(cmd);

                if (rowsAffected == 0)
                    throw new DBConcurrencyException(ConcurencyException);
            }
        }
コード例 #3
0
        /// <summary>
        /// Reads the integration service call rules.
        /// </summary>
        /// <param name="callSettingsDto">The call settings dto.</param>
        /// <param name="reader">The reader.</param>
        private static void ReadIntegrationServiceCallRules(IntegrationServiceCallSettingsDto callSettingsDto, IDataReader reader)
        {
            reader.NextResult();

            while (reader.Read())
            {
                var ruleDto = new IntegrationServiceCallRuleDto { Id = reader.GetInt32(0), RuleGuid = reader.GetGuid(1) };
                callSettingsDto.Rules.Add(ruleDto);
            }
        }