Esempio n. 1
0
        public override CommandResponse BeginExecute(ICommand command, CommandRequest request)
        {
            var transaction = new CommandTransaction(command, request);

            _commands.TryAdd(request.Session, transaction);
            return(base.BeginExecute(command, request));
        }
        public override CommandResponse BeginExecute(ICommand command, CommandRequest request)
        {
            CommandTransaction existsTransaction;

            if (_commands.TryGetValue(request.Session, out existsTransaction))
            {
                var session = request.Session;
                var report  = existsTransaction.Command.GetLog();
                var result  = (string)null;
                if (existsTransaction.Command.State == ECommandState.Completed)
                {
                    Je.log.UnregisterTracer(command as TraceListener);
                    _commands.TryRemove(session, out existsTransaction);
                    result = (existsTransaction.Command.Result != null ? Je.xml.Of(existsTransaction.Command.Result) : string.Empty) ?? string.Empty;
                }
                return(new CommandResponse {
                    Session = session, Result = result, Report = report
                });
            }
            if (string.IsNullOrWhiteSpace(request.Command))
            {
                var session = request.Session;
                var result  = string.Empty;
                var report  = Je.cmd.MessagesOf(Je.err.ErrToMsg(new CommandNotDefinedException(session)));
                return(new CommandResponse {
                    Session = session, Result = result, Report = report
                });
            }
            var transaction = new CommandTransaction(command, request);

            if (_commands.TryAdd(request.Session, transaction))
            {
                Je.log.RegisterTracer(command as TraceListener);
                base.BeginExecute(command, request);
                Thread.Sleep(1111);
                return(BeginExecute(command, request));
            }
            return(base.BeginExecute(command, request));
        }
Esempio n. 3
0
 private void ExecuteCommand(CommandTransaction transaction)
 {
     try
     {
         if (transaction.Command.State == ECommandState.Completed)
         {
             _deleteds.Add(transaction.Request.Session);
             return;
         }
         if (transaction.Command.State == ECommandState.None)
         {
             transaction.Command.Value = transaction.Request.DeserializeParameter();
             transaction.Command.Execute();
             return;
         }
     }
     catch (Exception e)
     {
         _deleteds.Add(transaction.Request.Session);
         Je.log.To(e);
     }
 }