public async Task DeleteItemsAsync <T>(List <string> hashKeys) { DocumentBatchWrite batchWrite = InternalTable.CreateBatchWrite(); hashKeys.ForEach(key => batchWrite.AddKeyToDelete(key)); await batchWrite.ExecuteAsync(); }
public async Task PutItemsAsync <T>(List <T> itemsToPut) { DocumentBatchWrite batchWrite = InternalTable.CreateBatchWrite(); itemsToPut.ForEach(item => { batchWrite.AddDocumentToPut(GetDocument(item)); }); await batchWrite.ExecuteAsync(); }
public async Task InsertBatchItems(List <Profile> profiles) { try { DocumentBatchWrite request = _table.CreateBatchWrite(); foreach (var profile in profiles) { request.AddDocumentToPut(ConvertToDocument(profile)); } await request.ExecuteAsync(); Console.WriteLine("Items created successfully"); } catch (Exception ex) { Console.WriteLine(ex); } }
public async Task StoreEvents(List <MDBTimelineEvent> timelineEvents) { try { Table table = Table.LoadTable(client, "TimelineEvents"); DocumentBatchWrite batchWrite = table.CreateBatchWrite(); foreach (MDBTimelineEvent tlevent in timelineEvents) { batchWrite.AddDocumentToPut(tlevent.AsDynamoDocument()); } await batchWrite.ExecuteAsync(); } catch (Exception ex) { Console.WriteLine("StoreEvents ERROR: " + ex.Message); throw ex; } }
public async Task InsertNewItems(List <Profile> profiles) { try { List <Document> documents = profiles.Select(ConvertToDocument).ToList(); DocumentBatchWrite batchWrite = _table.CreateBatchWrite(); foreach (var document in documents) { batchWrite.AddDocumentToPut(document); } await batchWrite.ExecuteAsync(); Console.WriteLine("Documents have been inserted successfully"); } catch (AmazonDynamoDBException ex) { Console.WriteLine(ex); } catch (Exception ex) { Console.WriteLine(ex); } }
public async Task <IActionResult> Get([FromHeader] string key, [FromHeader] string payload) { try { return(Ok()); if (key != "enginekey") { return(BadRequest("bad")); } AmazonDynamoDBClient client = new AmazonDynamoDBClient(); Table table = Table.LoadTable(client, "OrderBook"); List <Document> docs = new List <Document>(); int bids = payload.IndexOf("bids"); for (int i = 0; i < payload.Length; i++) { if (payload[i] != '[') { continue; } Document doc = new Document(); string price = new string(""); string volume = new string(""); i += 1; while (true && i < payload.Length) { if (payload[i] == ',') { i += 1; break; } price += payload[i]; i += 1; } while (true && i < payload.Length) { if (payload[i] == ']') { break; } volume += payload[i]; i += 1; } doc["Price"] = price; doc["Volume"] = volume; doc["Side"] = i < bids ? "Buy" : "Sell"; docs.Add(doc); } DocumentBatchWrite write = table.CreateBatchWrite(); foreach (Document doc in docs) { write.AddDocumentToPut(doc); } await write.ExecuteAsync(); return(Ok()); } catch { return(BadRequest("something went wrong")); } }