Beispiel #1
0
 public RecordCreationDate(POCO.Record record)
 {
     this.PartitionKey = record.PartitionKey;
     this.RowKey       = record.RowKey;
     this.Created      = record.Created;
 }
Beispiel #2
0
 public RecordIdUpdate(POCO.Record record)
 {
     this.PartitionKey = record.PartitionKey;
     this.RowKey       = record.RowKey;
     this.RecordId     = record.RecordId;
 }
Beispiel #3
0
        internal static List <POCO.Files.CPFile> GetFilesAssociatedToRecordForBatchProcessing(DataConfig dataConfig, POCO.System system, POCO.Record record)
        {
            List <POCO.Files.CPFile> filesToProcess = new List <POCO.Files.CPFile>();

            // Create the filter
            string recordUri = record.RowKey;

            if (!recordUri.EndsWith("|"))
            {
                recordUri += "|";
            }                                                   // Standardise the url to end in a pipe '|' to help match files via partial Uri

            List <DataFactory.Filter> filters = new List <DataFactory.Filter>();

            DataFactory.Filter pkGTEFilter = new DataFactory.Filter("PartitionKey", recordUri, "ge");
            DataFactory.Filter pkLTFilter  = new DataFactory.Filter("PartitionKey", Utils.GetLessThanFilter(recordUri), "lt");
            filters.Add(pkGTEFilter);
            filters.Add(pkLTFilter);

            // Check the system type
            string thisPageId = string.Empty;
            string nextPageId = string.Empty;

            switch (system.Type)
            {
            case POCO.SystemType.SharePointOnline:
            case POCO.SystemType.SharePointTeam:
            case POCO.SystemType.SharePointOneDrive:
            {
                do
                {
                    List <POCO.SPFile> spfiles = DataFactory.SharePointOnline.GetFiles(dataConfig, filters, thisPageId, 1000, out nextPageId);

                    // Convert to ICPFile format
                    foreach (POCO.SPFile fileToConvert in spfiles)
                    {
                        // Convert to ICPFile compatible object
                        POCO.Files.SPFile file = JsonConvert.DeserializeObject <POCO.Files.SPFile>(JsonConvert.SerializeObject(fileToConvert));
                        filesToProcess.Add(file);
                    }

                    thisPageId = nextPageId;
                }while (nextPageId != string.Empty);


                break;
            }

            case POCO.SystemType.GoogleDrive:
            {
                List <POCO.Files.GoogleFile> googlefiles = DataFactory.Google.GetFiles(dataConfig, filters);

                // Convert to ICPFile format
                foreach (POCO.Files.GoogleFile fileToConvert in googlefiles)
                {
                    // Convert to ICPFile compatible object
                    POCO.Files.GoogleFile file = JsonConvert.DeserializeObject <POCO.Files.GoogleFile>(JsonConvert.SerializeObject(fileToConvert));
                    filesToProcess.Add(file);
                }

                break;
            }

            case POCO.SystemType.NTFSShare:

                List <POCO.NTFSFile> ntfsFiles = DataFactory.NTFS.GetFiles(dataConfig, filters);

                // Convert to ICPFile format
                foreach (POCO.NTFSFile fileToConvert in ntfsFiles)
                {
                    // Convert to ICPFile compatible object
                    POCO.Files.NTFSFile ntfsfile = JsonConvert.DeserializeObject <POCO.Files.NTFSFile>(JsonConvert.SerializeObject(fileToConvert));
                    filesToProcess.Add(ntfsfile);
                }

                break;

            case POCO.SystemType.Basecamp:
                // Get the Basecamp files

                // URL format of the basecamp project is:  https://<basecamp api>/<account number>/projects/<project id>.json
                // all data for a project is in "buckets": https://<basecamp api>/<account number>/buckets/<project id>/<type of bucket>/<id>.json
                // any data matching should use the buckets/<project id>>
                string basecampFilesUri = record.RecordUri.Replace("projects", "buckets");
                if (basecampFilesUri.ToLower().EndsWith(".json"))
                {
                    basecampFilesUri = basecampFilesUri.Substring(0, basecampFilesUri.Length - 5);
                }
                if (!basecampFilesUri.EndsWith("|"))
                {
                    basecampFilesUri += "|";
                }

                List <DataFactory.Filter> basecampFilters = new List <DataFactory.Filter>();

                string             pk         = Utils.CleanTableKey(basecampFilesUri);
                DataFactory.Filter basecampPK = new DataFactory.Filter("PartitionKey", pk, "eq");
                basecampFilters.Add(basecampPK);

                //DataFactory.Filter basecampPKLT = new DataFactory.Filter("PartitionKey", Utils.GetLessThanFilter(pk), "lt");
                //basecampFilters.Add(basecampPKGE);
                //basecampFilters.Add(basecampPKLT);

                DataFactory.DataConfig             basecampDataConfig = dataConfig;
                List <POCO.BasecampDocumentEntity> basecampFiles      = DataFactory.BasecampProject.GetFiles(basecampDataConfig, basecampFilters);

                // Convert to ICPFile format
                foreach (POCO.BasecampDocumentEntity fileToConvert in basecampFiles)
                {
                    // Convert to ICPFile compatible object
                    //BasecampFile basefile = JsonConvert.DeserializeObject<BasecampFile>(JsonConvert.SerializeObject(fileToConvert));

                    POCO.Files.BasecampFile bf = new POCO.Files.BasecampFile();
                    bf.BatchGuid             = Guid.Empty;
                    bf.BatchStatus           = null;
                    bf.CreationTime          = fileToConvert.TimeCreated;
                    bf.FolderUri             = fileToConvert.PartitionKey;
                    bf.ItemUri               = fileToConvert.ServerRelativeUrl;
                    bf.JsonFileProcessResult = null;
                    bf.LastModifiedTime      = fileToConvert.TimeLastModified;
                    bf.Name              = fileToConvert.Name;
                    bf.OrganisationId    = Guid.Empty;
                    bf.PartitionKey      = fileToConvert.PartitionKey;
                    bf.RowKey            = fileToConvert.RowKey;
                    bf.SiteUrl           = fileToConvert.ServerRelativeUrl;
                    bf.SourceFileName    = fileToConvert.Name;
                    bf.SourceRelativeUrl = fileToConvert.ServerRelativeUrl;
                    bf.Title             = fileToConvert.Title;
                    bf.UniqueId          = fileToConvert.UniqueId;

                    filesToProcess.Add(bf);
                }

                break;

            default:
            {
                throw new NotImplementedException("Unknown system type: " + system.Type);
            }
            }

            return(filesToProcess);
        }
Beispiel #4
0
        public static List <POCO.OntologyAssigned> GetRecordAssignedOntology(DataConfig providerConfig, POCO.Record record)
        {
            List <POCO.OntologyAssigned> ontologies = new List <POCO.OntologyAssigned>();

            List <Filter> filters      = new List <Filter>();
            Filter        systemFilter = new Filter("PartitionKey", Utils.CleanTableKey(record.PartitionKey), "eq");

            filters.Add(systemFilter);

            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":

                string combinedFilter = Utils.GenerateAzureFilter(filters);

                List <AzureOntologyAssigned> azs             = new List <AzureOntologyAssigned>();
                AzureTableAdaptor <AzureOntologyAssigned> az = new AzureTableAdaptor <AzureOntologyAssigned>();
                azs = az.ReadTableData(providerConfig, AzureTableNames.RecordsAssignedOntology, combinedFilter);

                foreach (var doc in azs)
                {
                    ontologies.Add(doc.Value);
                }

                return(ontologies);

            case "internal.mongodb":
                var collection = Utils.GetMongoCollection <MongoOntologyAssigned>(providerConfig, MongoTableNames.RecordsAssignedOntology);

                FilterDefinition <MongoOntologyAssigned> filter = Utils.GenerateMongoFilter <MongoOntologyAssigned>(filters);

                var documents = collection.Find(filter).ToList();

                foreach (var ontology in documents)
                {
                    ontologies.Add(ontology);
                }
                break;

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

            return(ontologies);
        }
Beispiel #5
0
        public static List <POCO.RecordAuthorityFilter> GetAssignedForRecord(DataConfig providerConfig, POCO.Record record)
        {
            List <POCO.RecordAuthorityFilter> assignedrecordauthoritys = new List <POCO.RecordAuthorityFilter>();

            List <Filter> filters  = new List <Filter>();
            Filter        pkFilter = new Filter("PartitionKey", record.RowKey, "eq");

            filters.Add(pkFilter);

            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":

                string combinedFilter = Utils.GenerateAzureFilter(filters);

                List <AzureRecordAuthorityFilter> azdata = new List <AzureRecordAuthorityFilter>();
                AzureTableAdaptor <AzureRecordAuthorityFilter> adaptor = new AzureTableAdaptor <AzureRecordAuthorityFilter>();
                azdata = adaptor.ReadTableData(providerConfig, AzureTableNames.RecordsAssignedRecordsAuthority, combinedFilter);

                foreach (var doc in azdata)
                {
                    assignedrecordauthoritys.Add(doc.Value);
                }

                break;

            case "internal.mongodb":
                var collection = Utils.GetMongoCollection <MongoRecordAuthorityFilter>(providerConfig, MongoTableNames.RecordsAssignedRecordsAuthority);

                FilterDefinition <MongoRecordAuthorityFilter> filter = Utils.GenerateMongoFilter <MongoRecordAuthorityFilter>(filters);

                var documents = collection.Find(filter).ToList();

                foreach (var assignedra in documents)
                {
                    assignedrecordauthoritys.Add(assignedra);
                }
                break;

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

            return(assignedrecordauthoritys);
        }
Beispiel #6
0
        public static string GetMIMEType(DataConfig providerConfig, POCO.System system, POCO.Record record, RecordToRecordAssociation recordAssocEntity, ILogger logger)
        {
            string mimeType = string.Empty;

            List <DataFactory.Filter> filters = new List <Filter>();

            DataFactory.Filter pkFilter = new Filter("PartitionKey", recordAssocEntity.RowKey, "eq");
            filters.Add(pkFilter);
            //DataFactory.Filter rkFilter = new Filter("RowKey", , "eq");
            //filters.Add(rkFilter);

            string nextPageId = string.Empty;

            string tableName = string.Empty;

            // Check which System the file is from
            switch (system.Type)
            {
            case SystemType.SharePoint2010:
                switch (providerConfig.ProviderType)
                {
                case "azure.tableservice":
                    tableName = TableNames.Azure.SharePoint.SPFile;
                    break;

                case "internal.mongodb":
                    tableName = TableNames.Mongo.SharePoint.SPFile;
                    break;
                }
                break;

            case SystemType.SharePoint2013:
                switch (providerConfig.ProviderType)
                {
                case "azure.tableservice":
                    tableName = TableNames.Azure.SharePoint.SPFile;
                    break;

                case "internal.mongodb":
                    tableName = TableNames.Mongo.SharePoint.SPFile;
                    break;
                }
                break;

            case SystemType.SharePointOnline:
            case SystemType.SharePointOneDrive:
            case SystemType.SharePointTeam:
                switch (providerConfig.ProviderType)
                {
                case "azure.tableservice":
                    tableName = TableNames.Azure.SharePointOnline.SPFile;
                    break;

                case "internal.mongodb":
                    tableName = TableNames.Mongo.SharePointOnline.SPFile;
                    break;
                }
                break;

            case SystemType.NTFSShare:
                switch (providerConfig.ProviderType)
                {
                case "azure.tableservice":
                    tableName = TableNames.Azure.NTFS.NTFSFiles;
                    break;

                case "internal.mongodb":
                    tableName = TableNames.Mongo.NTFS.NTFSFiles;
                    break;
                }
                break;

            case SystemType.SakaiAlliance:
                switch (providerConfig.ProviderType)
                {
                case "azure.tableservice":
                    tableName = TableNames.Azure.Sakai.SakaiFiles;
                    break;

                case "internal.mongodb":
                    tableName = TableNames.Mongo.Sakai.SakaiFiles;
                    break;
                }
                break;

            default:
                throw new NotImplementedException();
                break;
            }

            List <POCO.CPFileMIMEType> mimetypes = new List <POCO.CPFileMIMEType>();

            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":

                string combinedFilter = Utils.GenerateAzureFilter(filters);

                List <AzureFileMIMEType> azdata = new List <AzureFileMIMEType>();
                AzureTableAdaptor <AzureFileMIMEType> adaptor = new AzureTableAdaptor <AzureFileMIMEType>();
                azdata = adaptor.ReadTableData(providerConfig, tableName, combinedFilter);

                foreach (var doc in azdata)
                {
                    mimetypes.Add(doc.Value);
                }

                break;

            case "internal.mongodb":
                var collection = Utils.GetMongoCollection <MongoFileMIMEType>(providerConfig, tableName);

                FilterDefinition <MongoFileMIMEType> filter = Utils.GenerateMongoFilter <MongoFileMIMEType>(filters);

                var documents = collection.Find(filter).ToList();

                foreach (var doc in documents)
                {
                    mimetypes.Add(doc);
                }
                break;

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

            if (mimetypes.Count > 0)
            {
                mimeType = mimetypes[0].MIMEType;
            }

            return(mimeType);
        }