//private static bool AddO365AuditContent(POCO.Config.DbConnectionConfig cpConfig, POCO.O365.AuditContentEntity auditContentFile, ILogger _logger) //{ // bool isRecordAdded = false; // _logger.LogDebug("GetAuditLogs: Add O365 audit file: " + auditContentFile.contentId); // // Set the table entity information // string partitionKey = Utils.CleanTableKey(auditContentFile.contentId); // string rowKey = Utils.CleanTableKey(auditContentFile.contentCreated); // auditContentFile.PartitionKey = partitionKey; // auditContentFile.RowKey = rowKey; // try // { // CloudTable table = Utils.GetCloudTable(cpConfig, "stlpo365auditcontentfiles", _logger); // //log.Info("Creating record entity"); // // Create the TableOperation that inserts or merges the entry. // //log.Verbose("Creating table operation"); // TableOperation insertMergeOperation = TableOperation.InsertOrMerge(auditContentFile); // // Execute the insert operation. // //log.Verbose("Executing table operation"); // Task tResult = table.ExecuteAsync(insertMergeOperation); // tResult.Wait(); // } // catch (Microsoft.WindowsAzure.Storage.StorageException ex) // { // var requestInformation = ex.RequestInformation; // //Console.WriteLine("http status msg: " + requestInformation.HttpStatusMessage); // // get more details about the exception // var information = requestInformation.ExtendedErrorInformation; // // if you have aditional information, you can use it for your logs // if (information != null) // { // var errorCode = information.ErrorCode; // var errMessage = string.Format("({0}) {1}", // errorCode, // information.ErrorMessage); // // var errDetails = information // //.AdditionalDetails // //.Aggregate("", (s, pair) => // //{ // // return s + string.Format("{0}={1},", pair.Key, pair.Value); // //}); // _logger.LogError(errMessage); // } // } // catch (Exception ex) // { // _logger.LogError("GetAuditLogs: AddO365AuditContent - Error adding entry to table: " + ex.Message); // } // isRecordAdded = true; // return isRecordAdded; //} public static List <POCO.O365.AuditContentEntity> GetAuditContentFile(DataConfig providerConfig, POCO.O365.AuditContentEntity auditContentFile) { List <DataFactory.Filter> filters = new List <Filter>(); string partitionKey = Utils.CleanTableKey(auditContentFile.contentId); string rowKey = Utils.CleanTableKey(auditContentFile.contentCreated); DataFactory.Filter pkfilt = new Filter("PartitionKey", partitionKey, "eq"); filters.Add(pkfilt); DataFactory.Filter rkfilt = new Filter("RowKey", rowKey, "eq"); filters.Add(rkfilt); return(GetAuditContentFile(providerConfig, filters)); }
public static string UpdateAuditContentFileProcessStatus(DataConfig providerConfig, POCO.O365.AuditContentEntity contentFile) { switch (providerConfig.ProviderType) { // AZURE case "azure.tableservice": // Create an update object POCO.O365.AuditContentEntityUpdateStatus updateStatus = new AuditContentEntityUpdateStatus(); updateStatus.PartitionKey = contentFile.PartitionKey; updateStatus.RowKey = contentFile.RowKey; updateStatus.ProcessStatus = contentFile.ProcessStatus; AzureAuditContentEntityUpdateStatus az = new AzureAuditContentEntityUpdateStatus(updateStatus); az.ETag = "*"; CloudTable table = Utils.GetCloudTable(providerConfig, AzureTableNames.AuditContentFiles); TableOperation merge = TableOperation.InsertOrMerge(az); // Execute the insert operation. Task tResult = table.ExecuteAsync(merge); tResult.Wait(); break; // MONGO case "internal.mongodb": // Create the update filter List <DataFactory.Filter> filters = new List <DataFactory.Filter>(); DataFactory.Filter pkFilter = new DataFactory.Filter("PartitionKey", Utils.CleanTableKey(contentFile.PartitionKey), "eq"); DataFactory.Filter rkFilter = new DataFactory.Filter("RowKey", Utils.CleanTableKey(contentFile.RowKey), "eq"); filters.Add(pkFilter); filters.Add(rkFilter); FilterDefinition <MongoAuditContentEntityUpdateStatus> filter = Utils.GenerateMongoFilter <MongoAuditContentEntityUpdateStatus>(filters); IMongoCollection <MongoAuditContentEntityUpdateStatus> collection = Utils.GetMongoCollection <MongoAuditContentEntityUpdateStatus>(providerConfig, MongoTableNames.AuditContentFiles); var update = Builders <MongoAuditContentEntityUpdateStatus> .Update .Set("ProcessStatus", contentFile.ProcessStatus); // Update the batch status UpdateResult result = collection.UpdateOne(filter, update); return(string.Empty); default: throw new ApplicationException("Data provider not recognised: " + providerConfig.ProviderType); } //TODO return id of new object if supported return(string.Empty); }