using AWS DynamoDB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
First off, I'm just trying to add shared database functionality to my add-in - if there's a different/easier provider anyone can recommend, with sample code, go for it. 🙂
per .NET code examples - Amazon DynamoDB I added 4 lines to app.config:
<appSettings>
<add key="AWSProfileName" value="default"/>
<add key="AWSRegion" value="us-west-2" />
</appSettings>
I then made a button to call the test function based on Hello DynamoDB. I added a few TaskDialogs to try to see progress along the way.
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
public class TestAWSDynamoDB : IExternalCommand
{
public static string message = "";
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
TaskDialog.Show("TestAWSDynamoDB", "Testing...");
TaskDialog.Show("TestAWSDynamoDB", message);
/*
AmazonDynamoDBConfig clientConfig = new AmazonDynamoDBConfig();
// This client will access the US East 1 region.
clientConfig.RegionEndpoint = RegionEndpoint.USEast1;
AmazonDynamoDBClient client = new AmazonDynamoDBClient(clientConfig);*/
Task task = Test();
TaskDialog.Show("TestAWSDynamoDB", "...testing");
return Result.Succeeded;
}
static async Task Test()
{
var dynamoDbClient = new AmazonDynamoDBClient();
message += "Hello Amazon Dynamo DB! Following are some of your tables:\n\n";
TaskDialog.Show("TestAWSDynamoDB", message);
// You can use await and any of the async methods to get a response.
// Let's get the first five tables.
var response = await dynamoDbClient.ListTablesAsync(
new ListTablesRequest()
{
Limit = 1
});
message += "response.ContentLength: " + response.ContentLength + "\n\n";
TaskDialog.Show("TestAWSDynamoDB", "response.ContentLength: " + response.ContentLength);
foreach (var table in response.TableNames)
{
TaskDialog.Show("TestAWSDynamoDB", $"\tTable: {table}");
//Console.WriteLine($"\tTable: {table}");
//Console.WriteLine();
}
}
}
I see the first "Testing..." and the blank (message) dialogs, then after a pause the "...testing" dialog, but none of the dialogs from within the Test() method. And when I click the button a second time, message is still blank.
I don't have any thread experience in C# (and it's been MANY years since I've done Java), so I'm mostly going by the sample code and VisualStudio's hints (for the await, async, & Task task =). I would like to have it be threaded eventually (so the user doesn't have to wait for saves to the DB), but at this point I'd be fine with it being single threaded and locking the UI until done. I've considered just using text files on the server, but I'd like to also get info from users' home machines...
Lionel J. Camara
BIM Manager at KAI Hawaii, Inc. - Structural and Forensic Engineers
Autodesk Certified Professional