private async void Search() { var sw = Stopwatch.StartNew(); try { int number = 0; Status = ViewModelStatus.Querying; DevicesView = new ObservableCollection <DeviceRunInfo>(); var deviceTrees = _cardProcess.GetDevices(selectedOrganization); if (deviceTrees == null) { return; } bool newmethod = true; foreach (var deviceTree in deviceTrees) { DeviceRunInfo device = new DeviceRunInfo(); device.DeviceTreeItemViewModel = deviceTree; WaitInfo = "数据统计: " + number.ToString(); if (newmethod == true) { newmethod = await NewGetDeviceRunInfo(device, StartTime, SelectedDay);//优先使用新方法 } if (newmethod == false) { await GetDeviceRunInfo(device, StartTime, SelectedDay);//兼容没有统计方法的服务器 } number++; DevicesView.Add(device); } if (number > 0) { UpdateChart(); } } catch (Exception ex) { _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("设备数据-运行状态查询", ex)); } finally { Console.WriteLine("消耗时间" + sw.Elapsed.ToString()); Status = ViewModelStatus.None; } }
public DeviceRunAnalyzeListViewModel(IEventAggregator eventAggregator, IOrganizationService organizationService, ISignalProcess signalProcess, ICardProcess cardProcess, IDatabaseComponent databaseComponent) { _eventAggregator = eventAggregator; _organizationService = organizationService; _signalProcess = signalProcess; _cardProcess = cardProcess; _databaseComponent = databaseComponent; InitTree(); var deviceTrees = _cardProcess.GetDevices(OrganizationTreeItems); StartTime = Convert.ToDateTime(DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd")); }
public void SelectedTreeChanged(object para) { if (para is DeviceTreeItemViewModel) { OrganizationNames = _cardProcess.GetDevices(para as OrganizationTreeItemViewModel).Select(p => p.FullName).ToList(); SelectedOrganization = para as OrganizationTreeItemViewModel; Refresh(); } else if (para is OrganizationTreeItemViewModel) { if ((para as OrganizationTreeItemViewModel).Children != null && (para as OrganizationTreeItemViewModel).Children.Count > 0 && (para as OrganizationTreeItemViewModel).Children[0] is DeviceTreeItemViewModel) { OrganizationNames = _cardProcess.GetDevices(para as OrganizationTreeItemViewModel).Select(p => p.FullName).ToList(); SelectedOrganization = para as OrganizationTreeItemViewModel; Refresh(); } else { OrganizationNames = new List <string>(); Refresh(); } } }
private async void Search() { var sw = Stopwatch.StartNew(); try { int number = 0; Status = ViewModelStatus.Querying; DevicesView.Clear(); resultDevices.Clear(); DeviceHourlySelectedResult.Clear(); for (int i = 0; i < SelectedDay; i++) { DeviceHourlySelectedResult.Add(new DeviceHourlySelectedResult() { DateTime = StartTime.AddDays(i), IsChecked = true }); } var deviceTrees = _cardProcess.GetDevices(selectedOrganization); if (deviceTrees == null) { return; } foreach (var deviceTree in deviceTrees) { WaitInfo = "数据统计: " + number.ToString(); List <DeviceHourlyDataInfo> devices = new List <DeviceHourlyDataInfo>(); DateTime start = StartTime; for (int day = SelectedDay; day > 0;) { int dayRange = day > 30 ? 30 : day; devices.AddRange(await GetDeviceHourlyData(deviceTree, start, dayRange)); day = day - dayRange; start = start.AddDays(dayRange); } if (devices == null) { continue; } devices.ForEach(p => p.DeviceTreeItemViewModel = deviceTree); resultDevices.Add(devices); DeviceHourlyDataInfo device = devices.FirstOrDefault(); number++; DevicesView.Add(device); } } catch (Exception ex) { _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("设备数据-运行状态查询", ex)); } finally { Console.WriteLine("消耗时间" + sw.Elapsed.ToString()); Status = ViewModelStatus.None; } }
private async void Search() { var sw = Stopwatch.StartNew(); try { int number = 0; Status = ViewModelStatus.Querying; DevicesView = new ObservableCollection <DeviceRunInfo>(); var deviceTrees = _cardProcess.GetDevices(selectedOrganization); if (deviceTrees == null) { return; } bool newmethod = true; foreach (var deviceTree in deviceTrees) { DeviceRunInfo device = new DeviceRunInfo(); device.DeviceTreeItemViewModel = deviceTree; WaitInfo = "数据统计: " + number.ToString(); if (newmethod == true) { newmethod = await NewGetDeviceRunInfo(device, StartTime, SelectedDay);//优先使用新方法 } if (newmethod == false) { await GetDeviceRunInfo(device, StartTime, SelectedDay);//兼容没有统计方法的服务器 } number++; DevicesView.Add(device); } Dictionary <Guid, Tuple <Guid, DateTime> > recordLabsWirelessVibration = new Dictionary <Guid, Tuple <Guid, DateTime> >();//需要修改,扩展除了无限振动卡 foreach (var device in DevicesView) { if (device.RecordLab == new Guid()) { continue; } if (device.ItemType == (int)ChannelType.WirelessVibrationChannelInfo) { recordLabsWirelessVibration.Add(device.RecordLab, Tuple.Create <Guid, DateTime>(device.T_Item_Guid, device.ACQDatetime)); } } if (DevicesView.Count > 0) { var waves = await _databaseComponent.GetHistoryWaveformData <D_WirelessVibrationSlot_Waveform>(DevicesView[0].DeviceTreeItemViewModel.ServerIP, recordLabsWirelessVibration); foreach (var wave in waves.GroupBy(p => p.T_Item_Guid)) { DeviceRunInfo device = DevicesView.Where(p => p.T_Item_Guid == wave.FirstOrDefault().T_Item_Guid).First(); string diagnosticInfo; string diagnosticAdvice; DiagnosticInfoClass.GetDiagnosticInfo(wave.FirstOrDefault().AlarmGrade, device.T_Item_Guid, wave.FirstOrDefault(), device.RPM, out diagnosticInfo, out diagnosticAdvice); device.DiagnosticInfo = diagnosticInfo; device.DiagnosticAdvice = diagnosticAdvice; } } if (number > 0) { UpdateChart(); GetConclusion(); } } catch (Exception ex) { _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("设备数据-运行状态查询", ex)); } finally { Console.WriteLine("消耗时间" + sw.Elapsed.ToString()); Status = ViewModelStatus.None; } }