public static string AddFile(DataConfig providerConfig, POCO.System system, POCO.SakaiSite sourceSite, POCO.SakaiContentResource sourceDocument)
        {
            // Set the PartitionKey and RowKey
            string sakaiUIDocument = "/" + sourceSite.SITE_ID + sourceDocument.RESOURCE_ID;
            string pkey            = Utils.CleanTableKey(sakaiUIDocument);
            string rkey            = Utils.CleanTableKey(sourceDocument.TimeLastModified.ToString(Utils.ISODateFormat));

            // Get the file name from the file path
            string fileName = sourceDocument.RESOURCE_ID.Substring(sourceDocument.RESOURCE_ID.LastIndexOf("/") + 1);

            POCO.SakaiFile sakaifile = new SakaiFile(pkey, rkey);
            //sakaifile.BatchGuid = string.Empty;
            sakaifile.BatchStatus       = string.Empty;
            sakaifile.CPFolderStatus    = string.Empty;
            sakaifile.CreationTime      = sourceDocument.TimeCreated;
            sakaifile.ItemCount         = 0;
            sakaifile.ItemUri           = sakaiUIDocument;
            sakaifile.LastModifiedTime  = sourceDocument.TimeLastModified;
            sakaifile.Name              = fileName;
            sakaifile.ServerRelativeUrl = sourceDocument.FILE_PATH;
            sakaifile.SizeInBytes       = sourceDocument.FILE_SIZE;
            sakaifile.SourceFileName    = fileName;
            sakaifile.SourceRelativeUrl = sakaiUIDocument;
            sakaifile.UniqueId          = sourceDocument.RESOURCE_UUID;
            sakaifile.Version           = 0;

            //POCO.SakaiDocumentEntity docEntity = new SakaiDocumentEntity(Utils.CleanTableKey(sourceSite.SITE_ID), Utils.CleanTableKey(sourceDocument.FILE_PATH));
            //docEntity.CPStatus = string.Empty;
            //docEntity.UniqueId = sourceDocument.RESOURCE_ID;
            //docEntity.ItemCount = 0;
            //docEntity.Name = fileName;
            //docEntity.ServerRelativeUrl = sourceDocument.FILE_PATH;
            //docEntity.TimeCreated = sourceDocument.TimeCreated;
            //docEntity.TimeLastModified = sourceDocument.TimeLastModified;
            //docEntity.Title = fileName;

            return(SakaiSite.AddFile(providerConfig, sakaifile));
        }
        public static void Patch001_UpdateRecordAssociationDataRowKey(DataConfig providerConfig, POCO.SakaiSite sakaiSite, SakaiContentResource sakaiResource, SakaiFile currentSakaiFile, string sakaiUIPath, string recordAssociationSuffix)
        {
            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("RowKey", Utils.CleanTableKey(currentSakaiFile.RowKey), "eq");
                filters.Add(pkFilter);
                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, "recordassociation" + recordAssociationSuffix);
                UpdateResult result = collection.UpdateMany(filter, updateDoc);
                break;

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

            //TODO return id of new object if supported
            return;
        }