public static void UpdateMIMEType(DataConfig providerConfig, POCO.CPFileMIMEType mimeType) { string tableName = string.Empty; switch (providerConfig.ProviderType) { case "azure.tableservice": tableName = AzureTableNames.EOMessage; break; case "internal.mongodb": tableName = MongoTableNames.EOMessage; break; default: throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType); } // Call the update MIME type function File.UpdateMIMEType(providerConfig, mimeType, tableName); return; }
public static void UpdateMIMEType(DataConfig providerConfig, POCO.CPFileMIMEType mimeType, string tableName) { switch (providerConfig.ProviderType) { case "azure.tableservice": AzureFileMIMEType az = new AzureFileMIMEType(mimeType); CloudTable table = Utils.GetCloudTable(providerConfig, tableName); TableOperation operation = TableOperation.InsertOrMerge(az); Task tUpdate = table.ExecuteAsync(operation); tUpdate.Wait(); break; case "internal.mongodb": IMongoCollection <MongoFileMIMEType> collection = Utils.GetMongoCollection <MongoFileMIMEType>(providerConfig, tableName); //MongoSystemStatUpdate mongoObject = Utils.ConvertType<MongoSystemStatUpdate>(systemStat); // Create the update filter List <DataFactory.Filter> filters = new List <DataFactory.Filter>(); DataFactory.Filter pkFilter = new DataFactory.Filter("PartitionKey", Utils.CleanTableKey(mimeType.PartitionKey), "eq"); DataFactory.Filter rkFilter = new DataFactory.Filter("RowKey", Utils.CleanTableKey(mimeType.RowKey), "eq"); filters.Add(pkFilter); filters.Add(rkFilter); FilterDefinition <MongoFileMIMEType> filter = Utils.GenerateMongoFilter <MongoFileMIMEType>(filters); var update = Builders <MongoFileMIMEType> .Update .Set("MIMEType", mimeType.MIMEType); // Update the batch status UpdateResult result = collection.UpdateOne(filter, update); return; default: throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType); } return; }