示例#1
0
 public void WriteServerResults(StreamWriter writer)
 {
     string[] array = new string[]
     {
         "Server",
         "Host",
         "IP Address",
         "Average Unique Devices",
         "Hits",
         "Total Bytes Sent",
         "Total Bytes Received"
     };
     ExportMobileSyncLog.AirSyncLogParser.WriteCSVLine(writer, array);
     string[] array2 = new string[array.Length];
     string[] array3 = new string[this.serverTable.Count];
     this.serverTable.Keys.CopyTo(array3, 0);
     Array.Sort <string>(array3);
     foreach (string key in array3)
     {
         ExportMobileSyncLog.ServerRow serverRow = this.serverTable[key];
         Array.Clear(array2, 0, array2.Length);
         uint num  = 0U;
         uint num2 = 0U;
         foreach (Dictionary <string, bool> dictionary in serverRow.DevicesPerDay.Values)
         {
             num  += 1U;
             num2 += (uint)dictionary.Count;
         }
         uint num3 = 0U;
         if (num > 0U)
         {
             num3 = num2 / num;
         }
         array2[0] = serverRow.ComputerName;
         array2[1] = serverRow.HostName;
         array2[2] = serverRow.IPAddress;
         array2[3] = num3.ToString();
         array2[4] = serverRow.Hits.ToString();
         array2[5] = serverRow.BytesSent.ToString();
         array2[6] = serverRow.BytesReceived.ToString();
         ExportMobileSyncLog.AirSyncLogParser.WriteCSVLine(writer, array2);
     }
 }
示例#2
0
            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;
                    }
                }
            }