public static void InitializeWithReader(XmlDictionaryReader reader) { DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(AuditUploaderConfigSchema)); if (reader != null) { try { try { AuditUploaderConfig.config = (AuditUploaderConfigSchema)dataContractSerializer.ReadObject(reader, true); } catch (SerializationException ex) { EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_InvalidConfigFile, ex.Message, new object[0]); AuditUploaderConfig.InitializeDefault(); } goto IL_58; } finally { reader.Close(); } } AuditUploaderConfig.InitializeDefault(); IL_58: AuditUploaderConfig.InitializeParsingRules(); AuditUploaderConfig.GenerateDictionary(); }
public static void Initialize(string fileName) { try { using (FileStream fileStream = new FileStream(fileName, FileMode.Open)) { XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(fileStream, new XmlDictionaryReaderQuotas()); AuditUploaderConfig.InitializeWithReader(reader); fileStream.Close(); } } catch (DirectoryNotFoundException ex) { EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_ConfigFileNotFound, fileName, new object[] { ex.Message }); AuditUploaderConfig.InitializeWithReader(null); } catch (FileNotFoundException ex2) { EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_ConfigFileNotFound, fileName, new object[] { ex2.Message }); AuditUploaderConfig.InitializeWithReader(null); } }
public static Actions GetAction(string component, string tenant, string user, string operation) { if (AuditUploaderConfig.filteringRules == null) { EventLogger.Logger.LogEvent(LogUploaderEventLogConstants.Tuple_InvalidRuleCollection, "Audit Uploader rules collection was not properly generated.", new object[0]); AuditUploaderConfig.InitializeWithReader(null); } return(AuditUploaderConfig.filteringRules.GetOperation(component, tenant, user, operation, DateTime.UtcNow)); }
protected override void ProcessRowData(ParsedReadOnlyRow rowData) { ReadOnlyRow unParsedRow = rowData.UnParsedRow; AuditLogRecordType field = unParsedRow.GetField <AuditLogRecordType>(3); string field2 = unParsedRow.GetField <string>(4); AuditRecord auditRecord = this.RecordSerializer.Read <AuditRecord>(field2, field); switch (AuditUploaderConfig.GetAction(auditRecord.RecordType.ToString(), auditRecord.OrganizationName, auditRecord.UserId, auditRecord.Operation)) { case Actions.LetThrough: this.records.Add(auditRecord); break; case Actions.Skip: case Actions.SkipAndLogEvent: break; default: return; } }