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);
        }
Example #2
0
        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);
        }