public void WriteUserResults(StreamWriter writer) { string[] array = new string[] { "User Name", "Device ID", "Device Type", "Items Sent", "Items Received", "Hits", "Total Bytes Sent", "Total Bytes Received", "Total Emails Sent", "Total Emails Received", "Total Calendar Sent", "Total Calendar Received", "Total Contacts Sent", "Total Contacts Received", "Total Tasks Sent", "Total Tasks Received", "Total Notes Sent", "Total Notes Received", "Total OOF Messages Set by Client", "Total OOF Messages Retrieved from Server", "Total Searches requested", "Total SharePoint Access", "Total UNC Access", "Total Attachment Downloads", "Total Attachment Size", "Currently Compliant with Policy" }; string[] array2 = new string[] { "Unknown", "Compliant", "Partially Compliant", "Not Compliant" }; ExportMobileSyncLog.AirSyncLogParser.WriteCSVLine(writer, array); string[] array3 = new string[array.Length]; ulong num = 0UL; ulong num2 = 0UL; ulong num3 = 0UL; ulong num4 = 0UL; ulong num5 = 0UL; string[] array4 = new string[this.userTable.Count]; this.userTable.Keys.CopyTo(array4, 0); Array.Sort <string>(array4); foreach (string key in array4) { ExportMobileSyncLog.UserRow userRow = this.userTable[key]; Array.Clear(array3, 0, array3.Length); array3[0] = userRow.Alias; array3[1] = userRow.DeviceID; array3[2] = userRow.DeviceType; array3[3] = userRow.ItemsSent.ToString(); array3[4] = userRow.ItemsReceived.ToString(); array3[5] = userRow.Hits.ToString(); array3[6] = userRow.BytesSent.ToString(); array3[7] = userRow.BytesReceived.ToString(); array3[8] = userRow.EmailsSent.ToString(); array3[9] = userRow.EmailsReceived.ToString(); array3[10] = userRow.CalendarsSent.ToString(); array3[11] = userRow.CalendarsReceived.ToString(); array3[12] = userRow.ContactsSent.ToString(); array3[13] = userRow.ContactsReceived.ToString(); array3[14] = userRow.TasksSent.ToString(); array3[15] = userRow.TasksReceived.ToString(); array3[16] = userRow.NotesSent.ToString(); array3[17] = userRow.NotesReceived.ToString(); array3[18] = userRow.NumberOfOOFSet.ToString(); array3[19] = userRow.NumberOfOOFGet.ToString(); array3[20] = userRow.SearchRequests.ToString(); array3[21] = userRow.SharePointHits.ToString(); array3[22] = userRow.UncHits.ToString(); array3[23] = userRow.AttachmentHits.ToString(); array3[24] = userRow.AttachmentBytes.ToString(); array3[25] = array2[(int)userRow.PolicyCompliance]; ExportMobileSyncLog.AirSyncLogParser.WriteCSVLine(writer, array3); num += userRow.ItemsSent; num2 += userRow.ItemsReceived; num3 += userRow.Hits; num4 += userRow.BytesSent; num5 += userRow.BytesReceived; } Array.Clear(array3, 0, array3.Length); array3[0] = "*** Total ***"; array3[3] = num.ToString(); array3[4] = num2.ToString(); array3[5] = num3.ToString(); array3[6] = num4.ToString(); array3[7] = num5.ToString(); ExportMobileSyncLog.AirSyncLogParser.WriteCSVLine(writer, array3); }
public void ParseLine(string line) { Match match = null; if (line.Length == 0) { return; } if (line[0] == '#') { match = this.fieldsPattern.Match(line); if (match.Success) { string value = match.Groups[1].Value; MatchCollection matchCollection = this.valuesPattern.Matches(value); this.columnCount = matchCollection.Count; this.columnIndexToID = new ExportMobileSyncLog.ColumnID[this.columnCount]; for (int i = 0; i < this.columnCount; i++) { string key = matchCollection[i].Groups[1].Value.ToLower(CultureInfo.InvariantCulture); ExportMobileSyncLog.ColumnID columnID; if (this.columnNameToID.TryGetValue(key, out columnID)) { this.columnIndexToID[i] = columnID; } else { this.columnIndexToID[i] = ExportMobileSyncLog.ColumnID.maxColumn; } } } return; } if (this.columnCount == 0) { return; } this.columnValues = new string[13]; int num = 0; int num2 = 0; int j = 0; while (j < line.Length) { while (num2 < line.Length && line[num2] == ' ') { num2++; } j = num2; while (j < line.Length && line[j] != ' ') { j++; } if (j == num2) { break; } if (num >= this.columnCount) { return; } ExportMobileSyncLog.ColumnID columnID2 = this.columnIndexToID[num]; if (columnID2 != ExportMobileSyncLog.ColumnID.maxColumn) { string text = line.Substring(num2, j - num2); if (text.Length == 1 && text[0] == '-') { text = null; } this.columnValues[(int)columnID2] = text; } num++; num2 = j; } if (num != this.columnCount) { return; } string strA = this.columnValues[7]; if (string.Compare(strA, "/Microsoft-Server-ActiveSync", true, CultureInfo.InvariantCulture) != 0 && string.Compare(strA, "/Microsoft-Server-ActiveSync/default.eas", true, CultureInfo.InvariantCulture) != 0) { return; } string text2 = this.columnValues[0]; string text3 = this.columnValues[1]; if (text2 == null || text3 == null) { return; } DateTime dateTime; if (!DateTime.TryParse(text2 + " " + text3, out dateTime)) { return; } if (dateTime < this.startTime || dateTime > this.endTime) { return; } string text4 = this.columnValues[3]; string text5 = this.columnValues[2]; string text6 = this.columnValues[6]; string text7 = this.columnValues[8]; string text8 = this.columnValues[9]; string text9 = this.columnValues[11]; string text10 = this.columnValues[12]; string text11 = this.columnValues[10]; ulong num3 = 0UL; ulong num4 = 0UL; ulong.TryParse(this.columnValues[4], out num3); ulong.TryParse(this.columnValues[5], out num4); string strA2 = null; string text12 = null; string deviceType = null; uint num5 = 0U; uint num6 = 0U; uint num7 = 0U; uint num8 = 0U; string strA3 = null; uint num9 = 0U; uint num10 = 0U; uint num11 = 0U; uint num12 = 0U; uint num13 = 0U; uint num14 = 0U; if (text4 != null) { match = this.queryPattern.Match(text4); if (!match.Success) { return; } strA2 = match.Groups[1].Value; text12 = match.Groups[2].Value; deviceType = match.Groups[3].Value; strA3 = match.Groups[18].Value; uint.TryParse(match.Groups[19].Value, out num9); uint.TryParse(match.Groups[20].Value, out num10); uint.TryParse(match.Groups[21].Value, out num11); uint.TryParse(match.Groups[22].Value, out num12); uint.TryParse(match.Groups[23].Value, out num13); } string text13 = ""; if (!string.IsNullOrEmpty(text5)) { text13 += text5.ToLower(CultureInfo.InvariantCulture); } text13 += "_"; if (!string.IsNullOrEmpty(text12)) { text13 += text12.ToLower(CultureInfo.InvariantCulture); } if (text13.Length > 1) { ExportMobileSyncLog.UserRow userRow; if (!this.userTable.TryGetValue(text13, out userRow)) { userRow = new ExportMobileSyncLog.UserRow(); userRow.Alias = text5; userRow.DeviceID = text12; userRow.DeviceType = deviceType; this.userTable.Add(text13, userRow); } if (text4 != null) { int count = match.Groups[4].Captures.Count; if (count > 0) { int num15 = match.Groups[10].Captures.Count - 1; int num16 = match.Groups[5].Captures.Count - 1; for (int k = count - 1; k >= 0; k--) { num6 = (num5 = (num7 = (num8 = (num14 = 0U)))); int index = match.Groups[4].Captures[k].Index; string value2 = match.Groups[4].Captures[k].Value; if (num16 >= 0 && match.Groups[5].Captures.Count > num16 && index < match.Groups[5].Captures[num16].Index) { uint.TryParse(match.Groups[5].Captures[num16].Value, out num5); uint.TryParse(match.Groups[6].Captures[num16].Value, out num6); num16--; } if (num15 >= 0 && match.Groups[10].Captures.Count > num15 && index < match.Groups[10].Captures[num15].Index) { uint.TryParse(match.Groups[10].Captures[num15].Value, out num7); uint.TryParse(match.Groups[11].Captures[num15].Value, out num8); uint.TryParse(match.Groups[16].Captures[num15].Value, out num14); num15--; } userRow.ItemsSent += (ulong)(num7 + num8 + num14); userRow.ItemsReceived += (ulong)(num5 + num6); if (string.Compare(value2, "Em", false, CultureInfo.InvariantCulture) == 0) { userRow.EmailsSent += (ulong)(num7 + num14 + num8); } if (string.Compare(value2, "Ca", false, CultureInfo.InvariantCulture) == 0) { userRow.CalendarsSent += (ulong)(num7 + num8); userRow.CalendarsReceived += (ulong)(num5 + num6); } if (string.Compare(value2, "Co", false, CultureInfo.InvariantCulture) == 0) { userRow.ContactsSent += (ulong)(num7 + num8); userRow.ContactsReceived += (ulong)(num5 + num6); } if (string.Compare(value2, "Ta", false, CultureInfo.InvariantCulture) == 0) { userRow.TasksSent += (ulong)(num7 + num8); userRow.TasksReceived += (ulong)(num5 + num6); } if (string.Compare(value2, "Nt", false, CultureInfo.InvariantCulture) == 0) { userRow.NotesSent += (ulong)(num7 + num8); userRow.NotesReceived += (ulong)(num5 + num6); } } } else { uint.TryParse(match.Groups[5].Value, out num5); uint.TryParse(match.Groups[6].Value, out num6); uint.TryParse(match.Groups[10].Value, out num7); uint.TryParse(match.Groups[11].Value, out num8); userRow.ItemsSent += (ulong)(num7 + num8); userRow.ItemsReceived += (ulong)(num5 + num6); } } if (string.Compare(strA2, "SendMail", true, CultureInfo.InvariantCulture) == 0 || string.Compare(strA2, "SmartReply", true, CultureInfo.InvariantCulture) == 0 || string.Compare(strA2, "SmartForward", true, CultureInfo.InvariantCulture) == 0) { userRow.EmailsReceived += 1UL; } if (string.Compare(strA2, "Settings", true, CultureInfo.InvariantCulture) == 0) { if (string.Compare(strA3, "Set", true, CultureInfo.InvariantCulture) == 0) { userRow.NumberOfOOFSet += 1UL; } if (string.Compare(strA3, "Get", true, CultureInfo.InvariantCulture) == 0) { userRow.NumberOfOOFGet += 1UL; } } if (string.Compare(strA2, "Search", true, CultureInfo.InvariantCulture) == 0) { userRow.SearchRequests += 1UL; } userRow.Hits += 1UL; userRow.BytesSent += num3; userRow.BytesReceived += num4; userRow.SharePointHits += (ulong)num9; userRow.UncHits += (ulong)num10; userRow.AttachmentHits += (ulong)num11; userRow.AttachmentBytes += (ulong)num12; if (num13 > 0U && dateTime > userRow.LastPolicyTime) { userRow.LastPolicyTime = dateTime; userRow.PolicyCompliance = (ExportMobileSyncLog.PolicyCompliance)num13; } } StringBuilder stringBuilder = new StringBuilder(); if (text6 != null) { stringBuilder.Append(text6.ToLower(CultureInfo.InvariantCulture)); } stringBuilder.Append('_'); if (text7 != null) { stringBuilder.Append(text7.ToLower(CultureInfo.InvariantCulture)); } stringBuilder.Append('_'); if (text8 != null) { stringBuilder.Append(text8.ToLower(CultureInfo.InvariantCulture)); } if (stringBuilder.Length > 2) { string key2 = stringBuilder.ToString(); ExportMobileSyncLog.ServerRow serverRow; if (!this.serverTable.TryGetValue(key2, out serverRow)) { serverRow = new ExportMobileSyncLog.ServerRow(); serverRow.DevicesPerDay = new Dictionary <string, Dictionary <string, bool> >(); serverRow.ComputerName = text6; serverRow.HostName = text7; serverRow.IPAddress = text8; this.serverTable.Add(key2, serverRow); } if (text12 != null) { Dictionary <string, bool> dictionary; if (!serverRow.DevicesPerDay.TryGetValue(text2, out dictionary)) { dictionary = new Dictionary <string, bool>(); serverRow.DevicesPerDay.Add(text2, dictionary); } dictionary[text12] = true; } serverRow.Hits += 1UL; serverRow.BytesSent += num3; serverRow.BytesReceived += num4; } ExportMobileSyncLog.HourlyRow hourlyRow = this.hourlyTable[(int)(dateTime.DayOfWeek * (DayOfWeek)24 + dateTime.Hour)]; if (text12 != null) { hourlyRow.Devices[text12] = true; } if (string.Compare(strA2, "Sync", true, CultureInfo.InvariantCulture) == 0 || string.Compare(strA2, "GetItemEstimate", true, CultureInfo.InvariantCulture) == 0) { hourlyRow.SyncCount += 1UL; } string text14 = ""; if (text9 != null) { text14 = text9.PadLeft(3, '0'); } text14 += "_"; if (text10 != null) { text14 += text10.PadLeft(11, '0'); } if (text14.Length > 1) { ExportMobileSyncLog.StatusRow statusRow; if (!this.statusTable.TryGetValue(text14, out statusRow)) { statusRow = new ExportMobileSyncLog.StatusRow(); statusRow.Status = text9; statusRow.SubStatus = text10; this.statusTable.Add(text14, statusRow); } statusRow.Hits += 1UL; } if (text11 != null) { ExportMobileSyncLog.UserAgentRow userAgentRow; if (!this.userAgentTable.TryGetValue(text11, out userAgentRow)) { userAgentRow = new ExportMobileSyncLog.UserAgentRow(); userAgentRow.Devices = new Dictionary <string, bool>(); userAgentRow.UserAgent = text11; this.userAgentTable.Add(text11, userAgentRow); } userAgentRow.Hits += 1UL; if (text12 != null) { userAgentRow.Devices[text12] = true; } } }