/// <summary> /// Persists the relationships. /// </summary> /// <param name="item">Item.</param> protected override void PersistRelationships(Order item) { Log.WriteLine(Log.Layer.DAL, this.GetType(), "Save Order Parameters (" + item.Id + "): " + item.Parameters.Count); if (item.OrderType == null) { item.OrderType = DL.PhoenixDatabase.GetItem <OrderType> (item.OrderTypeId); if (item.OrderType != null) { item.OrderType.Parameters = DL.PhoenixDatabase.GetOrderTypeParameters(item.OrderTypeId); } } if (item.Parameters.Count > 0) { int i = 0; foreach (OrderParameter param in item.Parameters) { param.OrderId = item.Id; param.DisplayValue = param.Value; if (item.OrderType != null && item.OrderType.Parameters.Count > i) { OrderParameterType paramType = item.OrderType.Parameters [i]; if (paramType.InfoType > 0) { try { InfoData info = DL.PhoenixDatabase.GetInfoDataByGroupIdAndNexusId(paramType.InfoType, Int32.Parse(param.Value)); if (info != null) { param.DisplayValue = info.ToString(); } } catch { } } } DL.PhoenixDatabase.SaveItemIfNew <OrderParameter> (param); i += 1; } } }
private InfoData GetInfo() { var result = new InfoData(); var ramMBUsage = new PerformanceCounter("Memory", "Available MBytes"); var hddPerUsage = new PerformanceCounter("LogicalDisk", "% Free Space", "_Total", true); var hddMBUsage = new PerformanceCounter("LogicalDisk", "Free Megabytes", "_Total", true); result.ServerName = _servername; result.RabbitDate = DateTime.Now; result.CPUUsagePercent = _cpuUsage.NextValue(); result.RAMFreeMB = ramMBUsage.NextValue(); result.HDDFreePercent = hddPerUsage.NextValue(); result.HDDFreeMB = hddMBUsage.NextValue(); result.HDDHigh = false; result.RAMHigh = false; result.CPUHigh = false; PerformanceCounter.CloseSharedResources(); result.ListDetails = HelperProcess.GetProcessTop(); if (_lstDTO != null) { if (_lstDTO.Count >= _secondCheck) { int cpu = 0; int ram = 0; int hdd = 0; foreach (var item in _lstDTO) { if (item.CPUUsagePercent > _cpuHighPercent) { cpu += 2; } else if (item.CPUUsagePercent > _cpuHighPercent - 5) { cpu++; } if (item.RAMFreeMB / (_totalPhysicalMemory / 100) < _ramHighPercent) { ram += 2; } else if (item.RAMFreeMB / (_totalPhysicalMemory / 100) < _ramHighPercent + 5) { ram++; } if (item.HDDFreePercent < _hddHighPercent) { hdd += 2; } else if (item.HDDFreePercent < _hddHighPercent + 5) { hdd++; } } if (result.CPUUsagePercent > _cpuHighPercent) { cpu += 2; } else if (result.CPUUsagePercent > _cpuHighPercent - 5) { cpu++; } if (result.RAMFreeMB / (_totalPhysicalMemory / 100) < _ramHighPercent) { ram += 2; } else if (result.RAMFreeMB / (_totalPhysicalMemory / 100) < _ramHighPercent + 5) { ram++; } if (result.HDDFreePercent < _hddHighPercent) { hdd += 2; } else if (result.HDDFreePercent < _hddHighPercent + 5) { hdd++; } var check = ((_secondCheck + 1) * 2) - ((_secondCheck + 1) / 4); result.CPUHigh = cpu >= check; result.RAMHigh = ram >= check; result.HDDHigh = hdd >= check; if (_islog) { LogInfo(string.Format("CPU:{1}>={0} RAM:{2}>={0} HDD:{3}>={0}", check, cpu, ram, hdd)); } _lstDTO.RemoveAt(_lstDTO.Count - 1); } _lstDTO.Insert(0, new InfoData { ServerName = result.ServerName, RabbitDate = result.RabbitDate, CPUUsagePercent = result.CPUUsagePercent, RAMFreeMB = result.RAMFreeMB, HDDFreePercent = result.HDDFreePercent, HDDFreeMB = result.HDDFreeMB, HDDHigh = result.HDDHigh, RAMHigh = result.RAMHigh, CPUHigh = result.CPUHigh }); } WriteToFile(result.ToString()); return(result); }