private void OnDataAcquired(CollectedData data) { DeviceInfo di = DataContext as DeviceInfo; if (data.DataIsCollected) { if (data.D != null && data.D.Count > 0) { GenericDictionaryData <DriveInfo> dict = (GenericDictionaryData <DriveInfo>)data.D[0]; if (dict != null) { Dictionary <string, DriveInfo> d2 = dict.Data; di.monitoredDrives.Clear(); di.monitoredDrives.AddRange(new List <DriveInfo>(dict.Data.Values)); UpdateDriveList(); } } } else { string message = "Data collection failure"; if (string.IsNullOrEmpty(data.Message) == false) { message += "\n" + data.Message; } MessageBox.Show(message, "Drive list retrieval", MessageBoxButton.OK, MessageBoxImage.Error); } }
// Token: 0x060015CA RID: 5578 RVA: 0x00080E1C File Offset: 0x0007F01C protected void Load(string base64SyncData) { byte[] array = SyncCalendarSyncStateBase.ConvertBase64SyncStateData(base64SyncData); ExTraceGlobals.MethodEnterExitTracer.TraceDebug((long)this.GetHashCode(), "SyncCalendarSyncStateBase.Load called."); GenericDictionaryData <StringData, string, DerivedData <ICustomSerializableBuilder> > genericDictionaryData = null; try { if (array != null && array.Length > 0) { using (MemoryStream memoryStream = new MemoryStream(array)) { using (MemoryStream memoryStream2 = new MemoryStream()) { using (BinaryReader binaryReader = new BinaryReader(memoryStream2)) { ComponentDataPool componentDataPool = new ComponentDataPool(); byte[] transferBuffer = new byte[71680]; SerializationHelper.Decompress(memoryStream, memoryStream2, transferBuffer); memoryStream2.Seek(0L, SeekOrigin.Begin); GenericDictionaryData <StringData, string, DerivedData <ICustomSerializableBuilder> > genericDictionaryData2 = new GenericDictionaryData <StringData, string, DerivedData <ICustomSerializableBuilder> >(); genericDictionaryData2.DeserializeData(binaryReader, componentDataPool); genericDictionaryData = genericDictionaryData2; } } } if (genericDictionaryData == null) { throw new CorruptSyncStateException("No SyncStateDictionaryData", null); } } else { genericDictionaryData = new GenericDictionaryData <StringData, string, DerivedData <ICustomSerializableBuilder> >(new Dictionary <string, DerivedData <ICustomSerializableBuilder> >()); this.InitializeSyncState(genericDictionaryData.Data); } this.VerifySyncState(genericDictionaryData.Data); } catch (CustomSerializationException innerException) { throw new CorruptSyncStateException("SyncCalendarSyncStateBase.Load caught", innerException); } catch (ArgumentException innerException2) { throw new CorruptSyncStateException("SyncCalendarSyncStateBase.Load caught", innerException2); } catch (EndOfStreamException innerException3) { throw new CorruptSyncStateException("SyncCalendarSyncStateBase.Load caught", innerException3); } this.syncStateTable = genericDictionaryData; ExTraceGlobals.MethodEnterExitTracer.TraceDebug((long)this.GetHashCode(), "SyncCalendarSyncStateBase.Load successful."); }
public static Data Create(DataCollectorContext context, string value) { GenericDictionaryData <Process> d = new GenericDictionaryData <Process>(context); ProcessInfoBuilder builder = new ProcessInfoBuilder(); builder.Build(value); if (builder.Processes != null) { d.Data = builder.Processes; } return(d); }
public override CollectedData OnAcquire() { CollectedData cd = base.OnAcquire(); CollectedData return_data = new CollectedData(Context, false); if (cd.DataIsCollected) { List <DictionaryData> drive_data = cd.D.Select(w => w as DictionaryData).ToList(); List <Data> data = new List <Data>(); // Package the drive information into a single Data object that maps the drive letter to a DiskName // object that maintains the drive's values GenericDictionaryData <DriveInfo> d = new GenericDictionaryData <DriveInfo>(Context); while (drive_data.Count > 0) { DictionaryData usage = drive_data[0]; drive_data.RemoveAt(0); // Only report local disks. Don't do removeable (floppy or thumb drive), CDs, or network drives. int drive_type; if (int.TryParse(usage.Data["DriveType"], out drive_type) && drive_type == (int)EDriveType.LocalDisk && usage.Data.ContainsKey("Name") && usage.Data.ContainsKey("VolumeName")) { string drive_name = usage.Data["Name"].Trim(); string description = usage.Data["VolumeName"].Trim(); DriveInfo disk = new DriveInfo() { name = description, letter = drive_name, type = (EDriveType)drive_type }; d.Data[drive_name] = disk; } } if (d.Data.Count > 0) { return_data.DataIsCollected = true; return_data.D.Add(d); } } return(return_data); }
public static Data Create(DataCollectorContext context, string value) { Data d = null; var definition = new { Value = new Dictionary <string, DiskUsage>() }; var data = JsonConvert.DeserializeAnonymousType(value, definition); if (data != null) { d = new GenericDictionaryData <DiskUsage>(context) { Data = data.Value } } ; return(d); } }
private void OnDataAcquired(CollectedData data) { string message = string.Empty; bool success = false; if (data == null) { message = "Null collected data"; } else if (data.DataIsCollected) { success = true; foreach (Data d in data.D) { GenericDictionaryData <DriveInfo> dict = (GenericDictionaryData <DriveInfo>)d; if (dict != null) { Dictionary <string, DriveInfo> d2 = dict.Data; CollectorsControl.UpdateDrives(new List <DriveInfo>(d2.Values)); } if (!string.IsNullOrEmpty(message)) { message += "\n"; } message += JsonConvert.SerializeObject(d, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml }); } } else { message = "Data collection failure"; if (string.IsNullOrEmpty(data.Message) == false) { message += "\n" + data.Message; } } MessageBox.Show(message, "Connection test", MessageBoxButton.OK, success ? MessageBoxImage.Information : MessageBoxImage.Error); }
public override CollectedData OnAcquire() { CollectedData cd = base.OnAcquire(); CollectedData return_data = new CollectedData(Context, false); if (cd.DataIsCollected) { List <DictionaryData> usage_data = cd.D.Select(w => w as DictionaryData).ToList(); //MonitoredDrivesRequest request = new MonitoredDrivesRequest(Context.Name); //RequestBus.Instance.MakeRequest(request); List <Data> data = new List <Data>(); // Package the drive information into a single Data object that maps the drive letter to a DiskUsage // object that maintains the capacity/free/used values for that drive. GenericDictionaryData <DiskUsage> d = new GenericDictionaryData <DiskUsage>(Context); //data.Add(d); // Unfortunately, there's no way to determine the drive type when determining the disk speeds (see DiskSpeed class). // So that we're reporting the same drives, record the drive letters here, then match them when we do the disk speed. // And we also want to keep track of the drive letter => name ("C:" => "OSDisk", for example), so let's grab that now // as well. Dictionary <string, string> drive_descriptions = new Dictionary <string, string>(); while (usage_data.Count > 0) { DictionaryData usage = usage_data[0]; usage_data.RemoveAt(0); // Only report local disks. Don't do removeable (floppy or thumb drive), CDs, or network drives. if (int.TryParse(usage.Data["DriveType"], out int drive_type) && drive_type == (int)EDriveType.LocalDisk && usage.Data.ContainsKey("Size") && usage.Data.ContainsKey("FreeSpace") && usage.Data.ContainsKey("Name") && usage.Data.ContainsKey("VolumeName")) { string drive_name = usage.Data["Name"].Trim(); string description = usage.Data["VolumeName"].Trim(); drive_descriptions[drive_name] = description; if (ulong.TryParse(usage.Data["Size"], out ulong c) && ulong.TryParse(usage.Data["FreeSpace"], out ulong f)) { d.Data[drive_name] = new DiskUsage() { CapacityNum = c, FreeNum = f }; } } } if (d.Data.Count > 0) { return_data.DataIsCollected = true; return_data.D.Add(d); } // Record the drive descriptions as an attribute in the database. We will also use this to get the drive letters // when needed. string json = JsonConvert.SerializeObject(drive_descriptions); AttributeRequest attr_request = new AttributeRequest(Context.ID.Name + ".all.drives.descriptions", false) { Value = json }; RequestBus.Instance.MakeRequest(attr_request); } return(return_data); }
public void SerializeData(BinaryWriter writer, ComponentDataPool componentDataPool) { GenericDictionaryData <DerivedData <RecipientInfoCacheSyncItemId>, RecipientInfoCacheSyncItemId, Int64Data, long> genericDictionaryData = new GenericDictionaryData <DerivedData <RecipientInfoCacheSyncItemId>, RecipientInfoCacheSyncItemId, Int64Data, long>(); genericDictionaryData.Bind(this.cacheEntryIdToLastUpdateTime).SerializeData(writer, componentDataPool); DateTimeData dateTimeData = new DateTimeData(this.LastModifiedTime); dateTimeData.SerializeData(writer, componentDataPool); }
public void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool) { GenericDictionaryData <DerivedData <RecipientInfoCacheSyncItemId>, RecipientInfoCacheSyncItemId, Int64Data, long> genericDictionaryData = new GenericDictionaryData <DerivedData <RecipientInfoCacheSyncItemId>, RecipientInfoCacheSyncItemId, Int64Data, long>(); genericDictionaryData.DeserializeData(reader, componentDataPool); this.cacheEntryIdToLastUpdateTime = genericDictionaryData.Data; DateTimeData dateTimeData = new DateTimeData(); dateTimeData.DeserializeData(reader, componentDataPool); this.lastModifiedTime = dateTimeData.Data; }
static void HandleData(Data d) { WriteLine(JsonConvert.SerializeObject(d, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml })); switch (d.Type) { case ECollectorType.Memory: break; case ECollectorType.Disk: if (d is GenericDictionaryData <DiskUsage> ) { Dictionary <string, DiskUsage> value = ((GenericDictionaryData <DiskUsage>)d).Data; DiskSpaceStatus ds_status = new DiskSpaceStatus(80, 90); EStatusType status = EStatusType.AdequateDiskSpace; foreach (string drive in value.Keys) { DiskUsage data = value[drive]; Tuple <EStatusType, double> drive_status = ds_status.GetStatus(data.UsedNum, data.CapacityNum); status = status.DiskSpaceCompare(drive_status.Item1); WriteLine($"{drive} -- {drive_status.Item2:0.0} %"); } WriteLine($"Status: {status}"); } break; case ECollectorType.CPUUsage: break; case ECollectorType.NICUsage: break; case ECollectorType.Uptime: break; case ECollectorType.LastBootTime: break; case ECollectorType.Processes: GenericDictionaryData <gov.sandia.sld.common.data.wmi.Process> processes = d as GenericDictionaryData <gov.sandia.sld.common.data.wmi.Process>; ulong working_set = 0; ulong working_set_private = 0; ulong private_bytes = 0; ulong memory = 0; foreach (gov.sandia.sld.common.data.wmi.Process process in processes.Data.Values) { memory += process.MemoryNum; working_set += process.WorkingSetNum; working_set_private += process.WorkingSetPrivateNum; private_bytes += process.PrivateBytesNum; } WriteLine($"Total memory: {memory} bytes, {memory / (float)(1024 * 1024)} MB"); WriteLine($"Total working set: {working_set} bytes, {working_set / (float)(1024 * 1024)} MB"); WriteLine($"Total private working set: {working_set_private} bytes, {working_set_private / (float)(1024 * 1024)} MB"); WriteLine($"Total private bytes: {private_bytes} bytes, {private_bytes / (float)(1024 * 1024)} MB"); break; case ECollectorType.Ping: break; case ECollectorType.InstalledApplications: break; case ECollectorType.Services: break; case ECollectorType.SystemErrors: break; case ECollectorType.ApplicationErrors: break; case ECollectorType.DatabaseSize: break; case ECollectorType.UPS: break; case ECollectorType.DiskSpeed: break; case ECollectorType.Configuration: break; case ECollectorType.SMART: break; //case CollectorType.AntiVirus: // break; //case CollectorType.Firewall: // break; case ECollectorType.Unknown: break; default: break; } }
// Token: 0x060015CD RID: 5581 RVA: 0x00081040 File Offset: 0x0007F240 protected void InitializeSyncStateTable() { GenericDictionaryData <StringData, string, DerivedData <ICustomSerializableBuilder> > genericDictionaryData = new GenericDictionaryData <StringData, string, DerivedData <ICustomSerializableBuilder> >(new Dictionary <string, DerivedData <ICustomSerializableBuilder> >()); this.InitializeSyncState(genericDictionaryData.Data); this.syncStateTable = genericDictionaryData; }
internal void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool) { lock (this.instanceLock) { DateTimeData dateTimeDataInstance = componentDataPool.GetDateTimeDataInstance(); dateTimeDataInstance.DeserializeData(reader, componentDataPool); this.LastCleanTime = dateTimeDataInstance.Data; GenericDictionaryData <StringData, string, MeetingOrganizerEntryData, MeetingOrganizerEntry> genericDictionaryData = new GenericDictionaryData <StringData, string, MeetingOrganizerEntryData, MeetingOrganizerEntry>(); genericDictionaryData.DeserializeData(reader, componentDataPool); this.map = genericDictionaryData.Data; this.IsDirty = false; if (this.LastCleanTime - (ExDateTime)TimeProvider.UtcNow > MeetingOrganizerInfo.AllowedClockSkew) { throw new CorruptSyncStateException(new LocalizedString("DeviceBehavior.DeserializeData"), null); } this.CleanIfNecessary(); } }
// Token: 0x060008E7 RID: 2279 RVA: 0x00035378 File Offset: 0x00033578 public virtual void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool) { if (componentDataPool.ExternalVersion < 1) { GenericDictionaryData <StringData, string, StoreObjectIdData, StoreObjectId> genericDictionaryData = new GenericDictionaryData <StringData, string, StoreObjectIdData, StoreObjectId>(); genericDictionaryData.DeserializeData(reader, componentDataPool); Dictionary <string, StoreObjectId> data = genericDictionaryData.Data; this.syncIdToMailboxIdTable = new Dictionary <string, ISyncItemId>(data.Count); using (Dictionary <string, StoreObjectId> .Enumerator enumerator = data.GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <string, StoreObjectId> keyValuePair = enumerator.Current; this.syncIdToMailboxIdTable[keyValuePair.Key] = MailboxSyncItemId.CreateForNewItem(keyValuePair.Value); } goto IL_92; } } GenericDictionaryData <StringData, string, DerivedData <ISyncItemId>, ISyncItemId> genericDictionaryData2 = new GenericDictionaryData <StringData, string, DerivedData <ISyncItemId>, ISyncItemId>(); genericDictionaryData2.DeserializeData(reader, componentDataPool); this.syncIdToMailboxIdTable = genericDictionaryData2.Data; IL_92: this.mailboxIdToSyncIdTable = new Dictionary <ISyncItemId, string>(this.syncIdToMailboxIdTable.Count); foreach (KeyValuePair <string, ISyncItemId> keyValuePair2 in this.syncIdToMailboxIdTable) { this.mailboxIdToSyncIdTable.Add(keyValuePair2.Value, keyValuePair2.Key); } GenericListData <StringData, string> genericListData = new GenericListData <StringData, string>(); genericListData.DeserializeData(reader, componentDataPool); this.deletedItems = genericListData.Data; genericListData.DeserializeData(reader, componentDataPool); this.addedItems = genericListData.Data; this.uniqueCounter = reader.ReadInt64(); }
internal void SerializeData(BinaryWriter writer, ComponentDataPool componentDataPool) { lock (this.instanceLock) { componentDataPool.GetDateTimeDataInstance().Bind(this.LastCleanTime).SerializeData(writer, componentDataPool); GenericDictionaryData <StringData, string, MeetingOrganizerEntryData, MeetingOrganizerEntry> genericDictionaryData = new GenericDictionaryData <StringData, string, MeetingOrganizerEntryData, MeetingOrganizerEntry>(this.map); genericDictionaryData.SerializeData(writer, componentDataPool); } }
public void DeserializeData(BinaryReader reader, ComponentDataPool componentDataPool) { GenericDictionaryData <DerivedData <ISyncItemId>, ISyncItemId, FolderTree.FolderInfo> genericDictionaryData = new GenericDictionaryData <DerivedData <ISyncItemId>, ISyncItemId, FolderTree.FolderInfo>(); genericDictionaryData.DeserializeData(reader, componentDataPool); this.folderTree = genericDictionaryData.Data; }
public override CollectedData OnAcquire() { // The number of cores will be different for each of the devices that we monitor, so we have to get this // inside each RunningProcessesData object, not globally. But at least it won't change so we can just get it once. if (m_cores == 0) { WMIRetriever retriever = new WMIRetriever(new WMIContext("Win32_Processor", "NumberOfCores", WmiContext.RemoteInfo), new WMIRetrieverOptions()); WMIRetriever.RetrievalContext retrieval_context = retriever.Retrieve(null); if (retrieval_context != null && retrieval_context.RetrievedData.Count > 0) { Dictionary <string, object> r = retrieval_context.RetrievedData[0]; uint.TryParse(r["NumberOfCores"].ToString(), out m_cores); } } if (m_cores == 0) { throw new Exception("Unable to determine the # of cores on the machine"); } Dictionary <string, Process> collected_data = new Dictionary <string, Process>(); // We do this twice...I found that sometimes the first time we'd try and get the data we'd get nothing, // but the second attempt would work. Go figure. OnAcquireDelegate(dict => { }); OnAcquireDelegate( dict => { string name = dict["Name"].ToString(); string percent_processor_time = dict["PercentProcessorTime"].ToString(); string working_set = dict["WorkingSet"].ToString(); string working_set_private = dict["WorkingSetPrivate"].ToString(); string pool_nonpaged_bytes = dict["PoolNonpagedBytes"].ToString(); string pool_paged_bytes = dict["PoolPagedBytes"].ToString(); string private_bytes = dict["PrivateBytes"].ToString(); if (!ulong.TryParse(percent_processor_time, out ulong cpu) || !ulong.TryParse(working_set, out ulong set) || !ulong.TryParse(working_set_private, out ulong set_private) || !ulong.TryParse(pool_nonpaged_bytes, out ulong pool_nonpaged) || !ulong.TryParse(pool_paged_bytes, out ulong pool_paged) || !ulong.TryParse(private_bytes, out ulong priv) || string.Compare(name, "_Total", true) == 0 || string.Compare(name, "Idle", true) == 0) { return; } // Sometimes an app will have multiple parts to it. For example, // Chrome will often report chrome, chrome#1, chrome#2, chrome#3, etc. // This is to combine all of those together into a single 'chrome' report. // We sum up the percentages, which I think is OK. Match m = m_process_suffix.Match(name); if (m.Success) { name = m.Groups[1].Value; if (collected_data.TryGetValue(name, out Process p)) { p.Add(cpu, set, set_private, pool_nonpaged, pool_paged, priv); } else { collected_data[name] = new Process(name, cpu, set, set_private, pool_nonpaged, pool_paged, priv); } } else { collected_data[name] = new Process(name, cpu, set, set_private, pool_nonpaged, pool_paged, priv); } } ); // Package the process information into a single Data object that contains a double-dictionary. The dictionary will contain // a mapping from process name to process information, and the process information is itself a dictionary mapping a string // ("Memory", "CPU") to the number representing that. GenericDictionaryData <Process> d = new GenericDictionaryData <Process>(Context); foreach (KeyValuePair <string, Process> process in collected_data) { Process p = process.Value; // The percentage is based on the capacity of a single core, so we have to divide by the # of cores // to get the overall capacity. ulong percent = (ulong)((double)p.CPUNum / (double)m_cores + 0.5f); p.CPUNum = percent; d.Data[p.Name] = p; } return(new CollectedData(Context, d.Data.Count > 0, d)); }
// Token: 0x0600184E RID: 6222 RVA: 0x0008E9FC File Offset: 0x0008CBFC private void UpdateFilter(Dictionary <StoreObjectId, string> mapping, DateTimeCustomSyncFilter dateTimeFilter, Dictionary <string, CommonNode> items) { foreach (StoreObjectId storeObjectId in mapping.Keys) { string key = mapping[storeObjectId]; CommonNode commonNode = items[key]; ISyncItemId syncItemId = MailboxSyncItemId.CreateForNewItem(storeObjectId); if (commonNode.IsCalendar) { dateTimeFilter.UpdateFilterStateWithAddOrChange(syncItemId, true, true, commonNode.EndTime); } ChangeTrackingNode[] array; if (commonNode.IsEmail) { array = new ChangeTrackingNode[] { ChangeTrackingNode.AllOtherNodes, new ChangeTrackingNode("Email", "Read") }; } else { array = new ChangeTrackingNode[] { ChangeTrackingNode.AllNodes }; } GenericDictionaryData <DerivedData <ISyncItemId>, ISyncItemId, FolderSync.ClientStateInformation> genericDictionaryData = (GenericDictionaryData <DerivedData <ISyncItemId>, ISyncItemId, FolderSync.ClientStateInformation>) this.syncState[SyncStateProp.ClientState]; if (!genericDictionaryData.Data.ContainsKey(syncItemId)) { genericDictionaryData.Data[syncItemId] = new FolderSync.ClientStateInformation(); } FolderSync.ClientStateInformation clientStateInformation = genericDictionaryData.Data[syncItemId]; clientStateInformation.ChangeTrackingInformation = new int?[array.Length]; clientStateInformation.ClientHasItem = true; } }
// Token: 0x060006CE RID: 1742 RVA: 0x00025F84 File Offset: 0x00024184 private void FillFidMapping(GetSyncStateResult results, MailboxSession session) { foreach (DeviceData deviceData in results.Devices) { foreach (SyncStateFolderData syncStateFolderData in deviceData.SyncFolders) { if (syncStateFolderData != null && !string.IsNullOrEmpty(syncStateFolderData.SyncStateBlob)) { syncStateFolderData.FolderMapping = new List <FolderMappingData>(); using (PooledMemoryStream pooledMemoryStream = new PooledMemoryStream(102400)) { byte[] array = Convert.FromBase64String(syncStateFolderData.SyncStateBlob); pooledMemoryStream.Write(array, 0, array.Length); pooledMemoryStream.Flush(); pooledMemoryStream.Position = 0L; int num; int num2; long num3; long num4; Dictionary <string, bool> dictionary; GenericDictionaryData <ConstStringData, string, DerivedData <ICustomSerializableBuilder> > genericDictionaryData = SyncState.InternalDeserializeData(pooledMemoryStream, out num, out num2, out num3, out num4, out dictionary); FolderIdMapping folderIdMapping = genericDictionaryData.Data["IdMapping"].Data as FolderIdMapping; IDictionaryEnumerator syncIdIdEnumerator = folderIdMapping.SyncIdIdEnumerator; while (syncIdIdEnumerator.MoveNext()) { string shortId = syncIdIdEnumerator.Key as string; ISyncItemId syncItemId = syncIdIdEnumerator.Value as ISyncItemId; StoreObjectId storeObjectId = syncItemId.NativeId as StoreObjectId; try { using (Folder folder = Folder.Bind(session, storeObjectId, new PropertyDefinition[] { FolderSchema.DisplayName })) { DefaultFolderType defaultFolderType = session.IsDefaultFolderType(folder.Id); syncStateFolderData.FolderMapping.Add(new FolderMappingData { ShortId = shortId, LongId = storeObjectId.ToString(), Name = folder.DisplayName, DefaultFolderType = defaultFolderType.ToString(), Exception = null }); } } catch (Exception ex) { syncStateFolderData.FolderMapping.Add(new FolderMappingData { ShortId = shortId, LongId = "[Error]", Name = "[Error]", DefaultFolderType = "[Error]", Exception = ex.ToString() }); } } } } } } }