private IEnumerable <CalendarLogAnalysis> LoadMailboxLogs(IEnumerable <CalendarLog> logs) { if (this.principal == null) { throw new InvalidOperationException("The Analyzer was not provided with session objects during construction and cannot connect to the specified mailbox"); } List <CalendarLogAnalysis> list = new List <CalendarLogAnalysis>(); using (MailboxSession mailboxSession = StoreTasksHelper.OpenMailboxSession(this.principal, "Get-CalendarDiagnosticLogs")) { foreach (CalendarLog calendarLog in logs) { CalendarLogId calendarLogId = calendarLog.Identity as CalendarLogId; if (calendarLogId != null) { UriHandler uriHandler = new UriHandler(calendarLogId.Uri); if (uriHandler.IsValidLink && !uriHandler.IsFileLink) { CalendarLogAnalysis calendarLogAnalysis = this.LoadFromMailbox(calendarLogId, uriHandler, mailboxSession); if (calendarLogAnalysis != null) { list.Add(calendarLogAnalysis); } } } } } return(list); }
private CalendarLogAnalysis LoadFromMailbox(CalendarLogId id, UriHandler handler, MailboxSession session) { StoreObjectId storeId = StoreObjectId.Deserialize(handler.Id); CalendarLogAnalysis result; using (Item item = Item.Bind(session, storeId)) { IEnumerable <PropertyDefinition> displayProperties = AnalysisDetailLevels.GetDisplayProperties(this.detailLevel); item.Load(displayProperties.ToArray <PropertyDefinition>()); result = new CalendarLogAnalysis(id, item, displayProperties); } return(result); }
public static T GetPropertyValue <T>(this CalendarLogAnalysis log, PropertyDefinition prop) { object obj = null; if (log.InternalProperties.TryGetValue(prop, out obj)) { try { return((T)((object)obj)); } catch (InvalidCastException) { return(default(T)); } } return(default(T)); }
internal IEnumerable <CalendarLogAnalysis> AnalyzeLogs(IEnumerable <CalendarLog> calendarLogs) { CalendarLog calendarLog = calendarLogs.FirstOrDefault <CalendarLog>(); IEnumerable <CalendarLogAnalysis> enumerable; if (calendarLog != null && calendarLog.IsFileLink) { enumerable = this.LoadMsgLogs(calendarLogs); } else { enumerable = this.LoadMailboxLogs(calendarLogs); } string[] array = null; if (!this.VerifyItemCohesion(enumerable, out array)) { throw new InvalidLogCollectionException(); } enumerable.OrderBy((CalendarLogAnalysis f) => f, CalendarLogAnalysis.GetComparer()); return(this.PerformAnalysis(enumerable)); }
private IEnumerable <CalendarLogAnalysis> LoadMsgLogs(IEnumerable <CalendarLog> logs) { List <CalendarLogAnalysis> list = new List <CalendarLogAnalysis>(); foreach (CalendarLog calendarLog in logs) { CalendarLogId calendarLogId = calendarLog.Identity as CalendarLogId; if (calendarLogId != null) { UriHandler uriHandler = new UriHandler(calendarLogId.Uri); if (uriHandler.IsValidLink && uriHandler.IsFileLink) { CalendarLogAnalysis calendarLogAnalysis = this.LoadFromFile(calendarLogId, uriHandler); if (calendarLogAnalysis != null) { list.Add(calendarLogAnalysis); } } } } return(list); }
internal static string Serialize(IEnumerable <CalendarLogAnalysis> logs, OutputType outputType, AnalysisDetailLevel detailLevel, bool showAll) { IEnumerable <PropertyDefinition> propertyMask = showAll ? new List <PropertyDefinition>() : CalendarLogAnalysisSerializer.FindUnchangedProperties(logs); LogSerializer logSerializer; switch (outputType) { case OutputType.HTML: logSerializer = new HtmlLogSerializer(propertyMask); goto IL_42; case OutputType.XML: logSerializer = new XmlLogSerializer(propertyMask); goto IL_42; } logSerializer = new CsvLogSerializer(propertyMask); IL_42: IEnumerable <PropertyDefinition> properties = AnalysisDetailLevels.GetDisplayProperties(detailLevel).Union(CalendarLogAnalysis.GetDisplayProperties(logs)); logs.OrderBy((CalendarLogAnalysis f) => f, CalendarLogAnalysis.GetComparer()); return(logSerializer.Serialize(logs, properties, null)); }