public static string AddFile(DataConfig providerConfig, POCO.SakaiFile ntfsFile)
        {
            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":

                AzureSakaiFile az = new AzureSakaiFile(ntfsFile);

                CloudTable     table     = Utils.GetCloudTable(providerConfig, SakaiResource.AzureTableNames.SakaiFiles);
                TableOperation operation = TableOperation.InsertOrMerge(az);
                Task           tUpdate   = table.ExecuteAsync(operation);
                tUpdate.Wait();

                break;

            case "internal.mongodb":
                IMongoCollection <MongoSakaiFile> collection = Utils.GetMongoCollection <MongoSakaiFile>(providerConfig, SakaiResource.MongoTableNames.SakaiFiles);
                MongoSakaiFile mongoObject = Utils.ConvertType <MongoSakaiFile>(ntfsFile);
                collection.InsertOne(mongoObject);
                return(string.Empty);

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

            //TODO return id of new object if supported
            return(string.Empty);
        }
        public static bool ForceRescan(DataConfig providerConfig, POCO.SakaiFile file)
        {
            POCO.FileBatchStatus batchstatus = new FileBatchStatus(file.PartitionKey, file.RowKey);
            batchstatus.BatchGuid             = Guid.Empty;
            batchstatus.BatchStatus           = string.Empty;
            batchstatus.JsonFileProcessResult = "{}";

            DataFactory.File.UpdateFileBatchStatus(providerConfig, batchstatus, "ntfsfiles");

            return(true);
        }
        public static string AddFile(DataConfig providerConfig, POCO.SakaiFile document)
        {
            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":
                throw new NotImplementedException();
                break;


            case "internal.mongodb":
                IMongoCollection <MongoSakaiFile> collection = Utils.GetMongoCollection <MongoSakaiFile>(providerConfig, MongoTableNames.SakaiFiles);
                MongoSakaiFile mongoObject = Utils.ConvertType <MongoSakaiFile>(document);
                collection.InsertOne(mongoObject);
                return(string.Empty);

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

            //TODO return id of new object if supported
            return(string.Empty);
        }
        public static void Patch001_UpdateRecordToRecordAssociation(DataConfig providerConfig, POCO.SakaiSite sakaiSite, POCO.SakaiContentResource sakaiResource, POCO.SakaiFile currentSakaiFile, string sakaiUIPath)
        {
            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":
                throw new NotImplementedException();
                break;


            case "internal.mongodb":

                // Create the update filter
                List <DataFactory.Filter> filters  = new List <DataFactory.Filter>();
                DataFactory.Filter        pkFilter = new DataFactory.Filter("PartitionKey", Utils.CleanTableKey(sakaiSite.SITE_ID), "eq");
                filters.Add(pkFilter);
                DataFactory.Filter rkFilter = new DataFactory.Filter("RowKey", currentSakaiFile.RowKey, "eq");
                filters.Add(rkFilter);
                FilterDefinition <MongoSakaiUpdatePatch001> filter = Utils.GenerateMongoFilter <MongoSakaiUpdatePatch001>(filters);

                // Create the update
                string       updateParam = "{$set: {RowKey: '" + Utils.CleanTableKey(sakaiUIPath) + "'}}";
                BsonDocument updateDoc   = BsonDocument.Parse(updateParam);

                // Update
                IMongoCollection <MongoSakaiUpdatePatch001> collection = Utils.GetMongoCollection <MongoSakaiUpdatePatch001>(providerConfig, Record.MongoTableNames.RecordToRecordAssociation);
                UpdateResult result = collection.UpdateOne(filter, updateDoc);
                break;

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

            //TODO return id of new object if supported
            return;
        }
        public static long PATCH003_UpdateSakaiFileItemUri(DataConfig providerConfig, POCO.SakaiFile file)
        {
            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":

                throw new NotImplementedException();

                break;

            case "internal.mongodb":
                IMongoCollection <MongoSakaiUpdatePatch003> collection = Utils.GetMongoCollection <MongoSakaiUpdatePatch003>(providerConfig, MongoTableNames.SakaiFiles);

                // Create the update filter
                List <DataFactory.Filter> filters  = new List <DataFactory.Filter>();
                DataFactory.Filter        pkFilter = new DataFactory.Filter("PartitionKey", Utils.CleanTableKey(file.PartitionKey), "eq");
                DataFactory.Filter        rkFilter = new DataFactory.Filter("RowKey", Utils.CleanTableKey(file.RowKey), "eq");
                filters.Add(pkFilter);
                filters.Add(rkFilter);
                FilterDefinition <MongoSakaiUpdatePatch003> filter = Utils.GenerateMongoFilter <MongoSakaiUpdatePatch003>(filters);

                //string updateParam = "{$set: {ItemUri: '" + file.SourceRelativeUrl.ToString() + "'}}";
                //BsonDocument updateDoc = BsonDocument.Parse(updateParam);

                var updateDoc = Builders <MongoSakaiUpdatePatch003> .Update
                                .Set("ItemUri", file.SourceRelativeUrl.ToString());

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

                if (result.IsAcknowledged && result.IsModifiedCountAvailable)
                {
                    return(result.ModifiedCount);
                }
                else
                {
                    return(0);
                }

                break;

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

            return(0);
        }