Exemplo n.º 1
0
        public async Task <string> CompleteAdoption([FromQuery] string petId, string pettype)
        {
            try
            {
                Console.WriteLine($"[{AWSXRayRecorder.Instance.GetEntity().TraceId}] - In CompleteAdoption Action method - PetId:{petId} - PetType:{pettype}");
                AWSXRayRecorder.Instance.AddAnnotation("PetId", petId);
                AWSXRayRecorder.Instance.AddAnnotation("PetType", pettype);

                _sqlConnection.ConnectionString = await GetConnectionString();

                var sqlCommandText = $"INSERT INTO [dbo].[transactions] ([PetId], [Transaction_Id], [Adoption_Date]) VALUES ('{petId}', '{Guid.NewGuid().ToString()}', '{DateTime.Now.ToString()}')";

                AWSXRayRecorder.Instance.AddMetadata("Query", sqlCommandText);

                using (_sqlConnection)
                {
                    using var command = new TraceableSqlCommand(sqlCommandText, _sqlConnection);
                    command.Connection.Open();
                    command.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }

            AWSXRayRecorder.Instance.TraceMethod("UpdateAvailability", () => UpdateAvailability(petId, pettype));

            return("Success");
        }
        private void QuerySql(int id)
        {
            var connectionString = ConfigurationManager.AppSettings["RDS_CONNECTION_STRING"];

            using (var sqlConnection = new SqlConnection(connectionString))
                using (var sqlCommand = new TraceableSqlCommand("SELECT " + id, sqlConnection))
                {
                    sqlCommand.Connection.Open();
                    sqlCommand.ExecuteNonQuery();
                }
        }
        private void QuerySql(int id)
        {
            var connectionString = ""; // Configure Connection string -> Format : "Data Source=(RDS endpoint),(port number);User ID=(your user name);Password=(your password);"

            using (var sqlConnection = new SqlConnection(connectionString))
                using (var sqlCommand = new TraceableSqlCommand("SELECT " + id, sqlConnection))
                {
                    sqlCommand.Connection.Open();
                    sqlCommand.ExecuteNonQuery();
                }
        }
Exemplo n.º 4
0
        public async Task CleanupAdoptions()
        {
            _sqlConnection.ConnectionString = await GetConnectionString();

            var sqlCommandText = $"DELETE FROM [dbo].[transactions]";

            AWSXRayRecorder.Instance.AddMetadata("Query", sqlCommandText);

            using (_sqlConnection)
            {
                using var command = new TraceableSqlCommand(sqlCommandText, _sqlConnection);
                command.Connection.Open();
                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 5
0
        public void CleanupAdoptions()
        {
            _sqlConnection.ConnectionString = _configuration["rdsconnectionstring"];

            var sqlCommandText = $"DELETE FROM [dbo].[transactions]";

            AWSXRayRecorder.Instance.AddMetadata("Query", sqlCommandText);

            using (_sqlConnection)
            {
                using var command = new TraceableSqlCommand(sqlCommandText, _sqlConnection);
                command.Connection.Open();
                command.ExecuteNonQuery();
            }
        }