Exemple #1
0
        /// <summary>
        /// Builds the command object for GetObraSocial method.
        /// </summary>
        /// <param name="cnn">The connection that will execute the procedure.</param>
        /// <param name="input">GetObraSocialInput instance for loading parameter values.</param>
        /// <returns>SqlCommand ready for execution.</returns>
        private SqlCommand GetGetObraSocialCommand(SqlConnection cnn, IGetObraSocialInput input)
        {
            SqlCommand result = new SqlCommand()
            {
                CommandType = CommandType.StoredProcedure,
                CommandText = "dbo.GetObraSocial",
                Connection  = cnn
            };

            result.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@IdPaciente",
                Direction     = ParameterDirection.Input,
                SqlDbType     = SqlDbType.Int,
                Scale         = 0,
                Precision     = 10,
                Value         = input.IdPaciente
            });

            result.Parameters.Add(new SqlParameter()
            {
                ParameterName = "@ReturnValue",
                Direction     = ParameterDirection.ReturnValue,
                SqlDbType     = SqlDbType.Int,
                Scale         = 0,
                Precision     = 10,
                Value         = DBNull.Value
            });

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Get pacient's Obras sociales.
        /// SQL+ Routine: dbo.GetObraSocial - Authored by IStrficek
        /// </summary>
        public GetObraSocialOutput GetObraSocial(IGetObraSocialInput input)
        {
            if (!input.IsValid())
            {
                throw new ArgumentException("GetObraSocialInput fails validation - use the GetObraSocialInput.IsValid() method prior to passing the input argument to the GetObraSocial method.", "input");
            }

            GetObraSocialOutput output = new GetObraSocialOutput();

            if (sqlConnection != null)
            {
                using (SqlCommand cmd = GetGetObraSocialCommand(sqlConnection, input))
                {
                    cmd.Transaction = sqlTransaction;
                    GetObraSocialCommand(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 = GetGetObraSocialCommand(cnn, input))
                        {
                            cnn.Open();
                            GetObraSocialCommand(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);
        }