예제 #1
0
        /// <summary>
        /// Request switch.
        /// </summary>
        /// <param name="singleSwitch">Command.</param>
        public void RequestSwitch(FunctionSwitch singleSwitch)
        {
            try
            {
                loggerPool.Log(singleSwitch.ServiceType.ServiceType, new LogContentEntity()
                {
                    Message = singleSwitch.Command.ToString()
                });

                commandInvoker.Invoke <ExecuteResult>(singleSwitch);

                callback.Notify(MessageEntity.NormalInfo(singleSwitch.ServiceType, singleSwitch.Command.ToString()));
            }
            catch (Exception ex)
            {
                var fex = new FaultException(new FaultReason(ex.Message), new FaultCode("002"), "RequestSwitch");

                loggerPool.Log(singleSwitch.ServiceType.ServiceType, new LogContentEntity(fex.Message + fex.StackTrace)
                {
                    Level = "Error"
                });

                throw fex;
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            var serviceProvider = new ServiceCollection()
                                  .AddLogging(config => config.AddConsole().SetMinimumLevel(LogLevel.Debug))
                                  .AddTaCqrs()
                                  .AddCommandHandler <AddCustomerCommandHandler, AddCustomerCommand>()
                                  .AddScoped <IContextDataProvider, ContextDataProvider>()
                                  .BuildServiceProvider();

            Stopwatch       stopwatch      = Stopwatch.StartNew();
            ILoggerFactory  loggerFactory  = serviceProvider.GetService <ILoggerFactory>();
            ILogger         logger         = loggerFactory.CreateLogger <Program>();
            ICommandInvoker commandInvoker = serviceProvider.GetService <ICommandInvoker>();

            for (int i = 0; i < 10; i++)
            {
                ExecutionResponse executionResponse = commandInvoker.Invoke(new AddCustomerCommand()
                {
                    Name = "Customer 1"
                }).Result;
                logger.LogDebug($"{executionResponse.AdditionalData.GetCreatedAt()}");
            }

            stopwatch.Stop();
            logger.LogDebug($"{stopwatch.Elapsed}");
            logger.LogDebug("Completed!, Press any key to exit");
            Console.WriteLine($"{stopwatch.Elapsed}");
            Console.ReadKey();
        }
예제 #3
0
        private async Task ProcessMessage(Message message)
        {
            var args = new TelegramMessageEventArgs
            {
                ChatId    = message.Chat.Id,
                MessageId = message.MessageId,
                From      = message.From,
                Message   = message
            };

            var results = await _invoker.Invoke(args);

            foreach (var result in results)
            {
                //сюда reply sender
            }
        }
예제 #4
0
        private async Task ProcessMessage(Message message)
        {
            var args = new TelegramMessageEventArgs
            {
                ChatId    = message.Chat.Id,
                MessageId = message.MessageId,
                From      = message.From,
                Message   = message
            };

            var results = await _invoker.Invoke(args);

            foreach (var result in results)
            {
                await _replySender.Send(result, args.ChatId);

                await Task.Delay(300);
            }
        }
예제 #5
0
    public void DoSomething()
    {
        var command = new ChangeNameCommand(1, "asdf");

        invoker.Invoke(command);
    }
예제 #6
0
 public void DeleteImage(string publicKey)
 {
     _commandInvoker.Invoke(new DeleteImage(_cloudinaryAdapter), publicKey);
 }
예제 #7
0
 public void OpenChooser()
 {
     ChooserResult = invoker.Invoke("ASCOM.Utilities.Chooser", "Choose", new[] { "" });
 }
예제 #8
0
 public void CreateContact(Contact contact)
 {
     _commandInvoker.Invoke(new SaveContact(_contactRepository), contact);
 }
예제 #9
0
 public object Invoke(CommandInvocation commandInvocation)
 {
     _actionBeforeInvocation(commandInvocation);
     return(_inner.Invoke(commandInvocation));
 }
예제 #10
0
 private static void DoSomething()
 {
     _commandInvoker.Invoke <IStoreAddressCommand>(x => x.Execute());
 }