Exemplo n.º 1
0
 public static void Log(IPopTransaction transaction, string format, params object[] args)
 {
     Verbose("CID:{0} {1}: {2}",
       transaction.Connection.Id,
       transaction.GetType().Name.Replace("Transaction", string.Empty),
       args == null ? format : string.Format(format, args));
 }
        private PopCommandResult PostProcessTransaction(IPopTransaction t)
        {
            switch (t.Result.Code) {
            /*
             * disconnect without processing responses
             */
            case PopCommandResultCode.InternalError:
              CloseConnection();
              throw new PopException(t.Result.Description, t.Result.Exception);

            case PopCommandResultCode.SocketTimeout:
              CloseConnection();
              throw new TimeoutException(string.Format("socket timeout in {0}", t.GetType().FullName), t.Result.Exception);

            case PopCommandResultCode.ConnectionError:
            case PopCommandResultCode.UpgradeError:
              CloseConnection();
              throw t.Result.Exception;
              }

              return t.Result;
        }
        private PopCommandResult ProcessTransaction(IPopTransaction t)
        {
            if (transactionTimeout == Timeout.Infinite) {
            // no timeout
            PreProcessTransaction(t, handlesIncapableAsException);

            ProcessTransactionInternal(t);

            return PostProcessTransaction(t);
              }
              else {
            var async = BeginProcessTransaction(t, handlesIncapableAsException);

            if (async.AsyncWaitHandle.WaitOne(transactionTimeout, false)) {
              return EndProcessTransaction(async);
            }
            else {
              CloseConnection();
              throw new TimeoutException(string.Format("transaction timeout ({0})", t.GetType().FullName));
            }
              }
        }