public static void UpdateFileSize(DataConfig providerConfig, POCO.CPFileSize fileSize)
        {
            DataFactory.File.UpdateFileSize(providerConfig, "ntfsfiles", fileSize);

            return;
        }
示例#2
0
        internal static void UpdateFileSize(DataConfig providerConfig, string tableName, POCO.CPFileSize fileSize)
        {
            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":

                AzureFileSize az = new AzureFileSize(fileSize);

                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(fileSize.PartitionKey), "eq");
                DataFactory.Filter        rkFilter = new DataFactory.Filter("RowKey", Utils.CleanTableKey(fileSize.RowKey), "eq");
                filters.Add(pkFilter);
                filters.Add(rkFilter);
                FilterDefinition <MongoFileMIMEType> filter = Utils.GenerateMongoFilter <MongoFileMIMEType>(filters);

                var update = Builders <MongoFileMIMEType> .Update
                             .Set("SizeInBytes", fileSize.SizeInBytes);

                // Update the batch status
                UpdateResult result = collection.UpdateOne(filter, update);

                return;

            default:
                throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType);
            }
            return;
        }