public static string Add(DataConfig providerConfig, POCO.ProcessingBatchStatus processingStatus) { switch (providerConfig.ProviderType) { case "azure.tableservice": AzureProcessingBatchStatus az = new AzureProcessingBatchStatus(processingStatus); CloudTable table = Utils.GetCloudTable(providerConfig, AzureTableNames.SystemProcessingStatus); TableOperation operation = TableOperation.InsertOrMerge(az); Task tUpdate = table.ExecuteAsync(operation); tUpdate.Wait(); //TODO return the inserted record id/timestamp return(string.Empty); case "internal.mongodb": IMongoCollection <MongoProcessingBatchStatus> collection = Utils.GetMongoCollection <MongoProcessingBatchStatus>(providerConfig, MongoTableNames.SystemProcessingStatus); MongoProcessingBatchStatus mongoObject = Utils.ConvertType <MongoProcessingBatchStatus>(processingStatus); collection.InsertOne(mongoObject); return(string.Empty); default: throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType); } return(string.Empty); }
public static void Delete(DataConfig providerConfig, POCO.ProcessingBatchStatus processingBatchStatus) { List <Filter> filters = new List <Filter>(); Filter pk = new Filter("PartitionKey", processingBatchStatus.PartitionKey, "eq"); filters.Add(pk); Filter rk = new Filter("RowKey", processingBatchStatus.RowKey, "eq"); filters.Add(rk); Filter typekey = new Filter("ProcessType", processingBatchStatus.ProcessType, "eq"); filters.Add(typekey); switch (providerConfig.ProviderType) { case "azure.tableservice": AzureProcessingBatchStatus az = new AzureProcessingBatchStatus(processingBatchStatus); az.ETag = "*"; CloudTable table = Utils.GetCloudTable(providerConfig, AzureTableNames.SystemProcessingStatus); TableOperation operation = TableOperation.Delete(az); Task <TableResult> tDelete = table.ExecuteAsync(operation); tDelete.Wait(); // Check for "success with no status" code if (tDelete.Result.HttpStatusCode != 204) { // TODO bool isNotDeleted = true; } break; case "internal.mongodb": FilterDefinition <BsonDocument> filter = Utils.GenerateMongoFilter <BsonDocument>(filters); // Delete the rows IMongoCollection <BsonDocument> collection = Utils.GetMongoCollection <BsonDocument>(providerConfig, MongoTableNames.SystemProcessingStatus); DeleteResult result = collection.DeleteMany(filter); return; default: throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType); } return; }