Example #1
0
 private void SetGetSQLDateTimeCommandOutputs(SqlCommand cmd, GetSQLDateTimeOutput output)
 {
     if (cmd.Parameters[0].Value != DBNull.Value)
     {
         output.ReturnValue = (DateTime?)cmd.Parameters[0].Value;
     }
 }
Example #2
0
        /// <summary>
        /// Get the date from SQL
        /// SQL+ Routine: dbo.GetSQLDateTime - Authored by Alan Hyneman
        /// </summary>
        public GetSQLDateTimeOutput GetSQLDateTime()
        {
            GetSQLDateTimeOutput output = new GetSQLDateTimeOutput();

            if (sqlConnection != null)
            {
                using (SqlCommand cmd = GetGetSQLDateTimeCommand(sqlConnection))
                {
                    cmd.Transaction = sqlTransaction;
                    GetSQLDateTimeCommand(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 = GetGetSQLDateTimeCommand(cnn))
                        {
                            cnn.Open();
                            GetSQLDateTimeCommand(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);
        }
Example #3
0
 private void GetSQLDateTimeCommand(SqlCommand cmd, GetSQLDateTimeOutput output)
 {
     cmd.ExecuteNonQuery();
     SetGetSQLDateTimeCommandOutputs(cmd, output);
 }