Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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));
        }