示例#1
0
        /// <summary>
        /// Selects page results from dbo.Feedback table.
        /// SQL+ Routine: dbo.FeedbackPaged - Authored by Alan Hyneman
        /// </summary>
        public FeedbackPagedOutput FeedbackPaged(IFeedbackPagedInput input, bool bypassValidation = false)
        {
            if (!bypassValidation)
            {
                if (!input.IsValid())
                {
                    throw new ArgumentException("FeedbackPagedInput fails validation - use the FeedbackPagedInput.IsValid() method prior to passing the input argument to the FeedbackPaged method.", "input");
                }
            }
            FeedbackPagedOutput output = new FeedbackPagedOutput();

            if (sqlConnection != null)
            {
                using (SqlCommand cmd = GetFeedbackPagedCommand(sqlConnection, input))
                {
                    cmd.Transaction = sqlTransaction;
                    FeedbackPagedCommand(cmd, output);
                }
                return(output);
            }
            for (int idx = 0; idx <= retryOptions.RetryIntervals.Count; idx++)
            {
                if (idx > 0)
                {
                    System.Threading.Thread.Sleep(retryOptions.RetryIntervals[idx - 1]);
                }
                try
                {
                    using (SqlConnection cnn = new SqlConnection(connectionString))
                        using (SqlCommand cmd = GetFeedbackPagedCommand(cnn, input))
                        {
                            cnn.Open();
                            FeedbackPagedCommand(cmd, output);
                            cnn.Close();
                        }
                    break;
                }
                catch (SqlException sqlException)
                {
                    bool throwException = true;

                    if (retryOptions.TransientErrorNumbers.Contains(sqlException.Number))
                    {
                        throwException = (idx == retryOptions.RetryIntervals.Count);

                        if (retryOptions.Logger != null)
                        {
                            retryOptions.Logger.Log(sqlException);
                        }
                    }
                    if (throwException)
                    {
                        throw;
                    }
                }
            }
            return(output);
        }
示例#2
0
 private void SetFeedbackPagedCommandOutputs(SqlCommand cmd, FeedbackPagedOutput output)
 {
     if (cmd.Parameters[2].Value != DBNull.Value)
     {
         output.PageCount = (int?)cmd.Parameters[2].Value;
     }
     if (cmd.Parameters[3].Value != DBNull.Value)
     {
         output.ReturnValue = (FeedbackPagedOutput.Returns)cmd.Parameters[3].Value;
     }
 }
示例#3
0
 private void FeedbackPagedCommand(SqlCommand cmd, FeedbackPagedOutput output)
 {
     using (SqlDataReader rdr = cmd.ExecuteReader())
     {
         output.ResultData = new List <FeedbackPagedResult>();
         while (rdr.Read())
         {
             output.ResultData.Add(GetFeedbackPagedResultFromReader(rdr));
         }
         rdr.Close();
     }
     SetFeedbackPagedCommandOutputs(cmd, output);
 }