Beispiel #1
0
        public async Task <ActionResult> GetAsync()
        {
            var helloWord = new HelloWord();

            helloWord.Username = "******";
            helloWord.Date     = DateTime.Now;
            var html = await _razorRenderService.ViewToStringAsync("HelloWordView.cshtml", helloWord);

            return(Ok(html));
        }
 public static HelloWord GetHelloWord(int id, string data)
 {
     if (m_allHelloWord.ContainsKey(id))
     {
         return(m_allHelloWord[id]);
     }
     string[] allLines = data.Split('\n');
     for (int i = 2; i < allLines.Length; i++)
     {
         string singalString = allLines[i];
         if (singalString.Length != 0)
         {
             HelloWord temp = new HelloWord(singalString);
             m_allHelloWord[temp.Id] = temp;
         }
     }
     return(m_allHelloWord[id]);
 }
Beispiel #3
0
        public IActionResult GetHelloWord()
        {
            try
            {
                HelloWord helloWord = new HelloWord(
                    Guid.NewGuid(),
                    "Hello World!",
                    DateTime.Now.ToString("yyyyMMddHHmmssffff"));

                var factory = new ConnectionFactory()
                {
                    HostName = "localhost"
                };
                using (var connection = factory.CreateConnection())
                    using (var channel = connection.CreateModel())
                    {
                        channel.QueueDeclare(queue: "hello",
                                             durable: false,
                                             exclusive: false,
                                             autoDelete: false,
                                             arguments: null);

                        var filaMessage = JsonSerializer.Serialize(helloWord);
                        var body        = Encoding.UTF8.GetBytes(filaMessage);

                        channel.BasicPublish(exchange: "",
                                             routingKey: "hello",
                                             basicProperties: null,
                                             body: body);
                        Console.WriteLine(" [x] Sent {0}", filaMessage);
                    }

                return(Accepted(helloWord));
            }
            catch (Exception ex)
            {
                _logger.LogError("Erro ao tentar executar mensagem", ex);

                return(new StatusCodeResult(500));
            }
        }
 private void doJob(string str, HelloWord HelloWord_Methon)
 {
     HelloWord_Methon(str);
 }