TResult ICommandCenter.HandleWithResult <TCommand, TResult>(TCommand command)
        {
            try
            {
                return(_commandCenter.HandleWithResult <TCommand, TResult>(command));
            }
            catch (Exception e)
            {
                // 本身就是运行出现异常事件 则不再进一步处理,直接抛出,避免出现死循环。
                if (command is HandlerExceptionMahuaCommand)
                {
                    throw;
                }
                HandlerExceptionByMahuaCommad(e, command);
            }

            return(new TResult());
        }
Example #2
0
        TResult ICommandCenter.HandleWithResult <TCommand, TResult>(TCommand command)
        {
            try
            {
                return(_commandCenter.HandleWithResult <TCommand, TResult>(command));
            }
            catch (TargetInvocationException ex)
            {
                Logger.ErrorException("出现异常,捕获并忽略该异常,参考信息:https://github.com/newbe36524/Newbe.Mahua.Framework/issues/52", ex);
            }
            catch (Exception e)
            {
                // 本身就是运行出现异常事件 则不再进一步处理,直接抛出,避免出现死循环。
                if (command is HandlerExceptionMahuaCommand)
                {
                    throw;
                }

                HandlerExceptionByMahuaCommand(e, command);
            }

            return(new TResult());
        }
Example #3
0
        public string GetCookies()
        {
            var re = _commandCenter
                     .HandleWithResult <GetCookiesApiMahuaCommand, GetCookiesApiMahuaCommandResult>(
                new GetCookiesApiMahuaCommand());
            var cookies = re.Cookies;

            return(cookies);
        }
Example #4
0
        public IMessageCancelToken SendPrivateMessageWithCancelToken(string toQq, string message)
        {
            var re = _commandCenter
                     .HandleWithResult <SendPrivateMessageApiMahuaCommand, SendPrivateMessageApiMahuaCommandResult>(
                new SendPrivateMessageApiMahuaCommand
            {
                Message = message,
                ToQq    = toQq,
            });

            return(re.MessageCancelToken);
        }
        public bool DeleteMessage(long messageId, string toGroup, int type)
        {
            var re = _commandCenter
                     .HandleWithResult <DeleteMessageApiMahuaCommand, DeleteMessageApiMahuaCommandResult>(
                new DeleteMessageApiMahuaCommand
            {
                MessageId = messageId,
                TargetId  = toGroup,
                Type      = type
            });

            return(re.IsDeleted);
        }