Exemplo n.º 1
0
        private void Update(InterdepartResponse interdepart)
        {
            try
            {
                DateTime theDate  = DateTime.Now;
                string   response = theDate.ToString("yyyy-MM-dd H:mm:ss");

                string          Sql        = $"update InterdepartRequests set InterdepartStatusId = {interdepart.InterdepartStatusId}, Request = '{interdepart.Request}', Response = '{response}' where Id = {interdepart.Id}";
                MySqlConnection connection = new MySqlConnection("Server=localhost; Database=psychologyDB; Uid=psyappuser; Password=password");
                MySqlCommand    command    = new MySqlCommand(Sql, connection);
                connection.Open();

                MySqlDataReader reader = command.ExecuteReader();

                connection.Close();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void Send(InterdepartRequest interdepart, int status)
        {
            InterdepartResponse interdepartResponse = new InterdepartResponse(interdepart.Id, status);
            var factory = new ConnectionFactory();

            factory.Uri = new System.Uri(Settings.Uri);

            using var connection = factory.CreateConnection();
            using var channel    = connection.CreateModel();

            channel.QueueDeclare(queue: Settings.KeyResponse,
                                 durable: false,
                                 exclusive: false,
                                 autoDelete: false,
                                 arguments: null);

            string message = JsonConvert.SerializeObject(interdepartResponse);
            var    body    = System.Text.Encoding.UTF8.GetBytes(message);

            channel.BasicPublish(exchange: "", routingKey: Settings.KeyResponse, basicProperties: null, body: body);
        }