Ejemplo n.º 1
0
        public static string AddLogEntry(DataConfig providerConfig, POCO.O365.AuditLogEntry logEntry)
        {
            DateTime logEntryDate;
            bool     isDateValid = DateTime.TryParse(logEntry.CreationTime, out logEntryDate);

            string tableSuffix = logEntryDate.ToString(Utils.TableSuffixDateFormatYM);

            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":
                AzureAuditLogEntry az = new AzureAuditLogEntry(logEntry);

                CloudTable table = Utils.GetCloudTable(providerConfig, AzureTableNames.O365AuditLogEntry + tableSuffix);

                TableOperation insertReplace = TableOperation.InsertOrReplace(az);

                // Execute the insert operation.
                Task tResult = table.ExecuteAsync(insertReplace);
                tResult.Wait();
                break;

            case "internal.mongodb":
                IMongoCollection <MongoAuditLogEntry> collection = Utils.GetMongoCollection <MongoAuditLogEntry>(providerConfig, MongoTableNames.O365AuditLogEntry + tableSuffix);
                MongoAuditLogEntry mongoObject = Utils.ConvertType <MongoAuditLogEntry>(logEntry);
                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);
        }
Ejemplo n.º 2
0
        public static string AddAuditableEventLogEntry(DataConfig providerConfig, AuditLogEntry logEntry, string auditLookupType)
        {
            string tableName = string.Empty;

            switch (providerConfig.ProviderType)
            {
            case "azure.tableservice":
                switch (auditLookupType)
                {
                case "byuser":
                {
                    tableName = AzureTableNames.O365AuditLogEntryActionableByUser;
                    break;
                }

                case "byday":
                {
                    tableName = AzureTableNames.O365AuditLogEntryActionableByDay;
                    break;
                }

                default:
                {
                    tableName = AzureTableNames.O365AuditLogEntryActionable;
                    break;
                }
                }

                AzureAuditLogEntry az = new AzureAuditLogEntry(logEntry);

                CloudTable table = Utils.GetCloudTable(providerConfig, tableName);

                TableOperation insertReplace = TableOperation.InsertOrReplace(az);

                // Execute the insert operation.
                Task tResult = table.ExecuteAsync(insertReplace);
                tResult.Wait();
                break;

            case "internal.mongodb":

                switch (auditLookupType)
                {
                case "byuser":
                {
                    tableName = MongoTableNames.O365AuditLogEntryActionableByUser;
                    break;
                }

                case "byday":
                {
                    tableName = MongoTableNames.O365AuditLogEntryActionableByDay;
                    break;
                }

                default:
                {
                    tableName = MongoTableNames.O365AuditLogEntryActionable;
                    break;
                }
                }

                IMongoCollection <MongoAuditLogEntry> collection = Utils.GetMongoCollection <MongoAuditLogEntry>(providerConfig, tableName);
                MongoAuditLogEntry mongoObject = Utils.ConvertType <MongoAuditLogEntry>(logEntry);
                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);
        }