Exemplo n.º 1
0
        public object Execute(
            TransactionChoice connType
            , CommandType commandType
            , string procedure
            , ExecuteType executeType
            , IList<SqlParameter> parameters
            , out ExecuteOutcome executeOutcome, out string executeOutcomeMessage)
        {
            object result = null;

            SqlCommand cmd = NewSqlCommand(connType, commandType, procedure, parameters);

            try
            {
                result = CommandExecute(executeType, cmd);
                executeOutcome = ExecuteOutcome.Success;
                executeOutcomeMessage = "";
            }
            catch (Exception ex)
            {
                if (ex.GetBaseException().Message.Contains("timeout") || ex.GetBaseException().Message.Contains("deadlock"))
                {
                    //return message that it timed out
                    executeOutcome = ExecuteOutcome.Timeout;
                    executeOutcomeMessage = "Server timed out or thread deadlock victim.  "
                           + ex.Message;
                }
                else
                {
                    executeOutcome = ExecuteOutcome.Failure;
                    throw ex;
                }
            }

            return result;
        }
Exemplo n.º 2
0
 private static void EvaluateOutcome(ExecuteOutcome outcome
     , string outcomeMessage, string methodName)
 {
     StringBuilder stringBuilder = new StringBuilder();
     if (outcome == ExecuteOutcome.Failure)
     {
         stringBuilder.AppendFormat("DataAccess:{0}:{1}", methodName, outcomeMessage);
         throw new Exception(stringBuilder.ToString());
     }
 }
Exemplo n.º 3
0
        public object GetData(TransactionChoice connType
            , CommandType commandType 
            , string procedureName
            , IList<SqlParameter> parameters
            , int retries
            , ExecuteType executeType, out ExecuteOutcome outcome
            , out string outcomeMsg)
        {
            object result = new object();
            IDataManager manager = SqlDataManager.UniqueInstance;
            ExecuteOutcome outcome1 = new ExecuteOutcome();
            outcome1 = ExecuteOutcome.Timeout;
            string outcomeMsg1 = "";
            //make database call
            for (int i = 0; i < retries && outcome1 == ExecuteOutcome.Timeout; i++)
            {
                result = manager.Execute(connType, commandType , procedureName
                                                       , executeType
                                                       , parameters
                                                       , out outcome1, out outcomeMsg1);
            }

            outcome = outcome1;
            outcomeMsg = outcomeMsg1;
            return result;
        }