public void GetItemFromDatabase(string ip)////测试,废弃 { //从数据库取出,去重复 var treeitems = _cardProcess.GetItems(OrganizationTreeItems); if (treeitems != null) { foreach (var t_item in _databaseComponent.GetItemData(ip).Where(p => p.Is_Disabled == false)) { var item = (from p in treeitems where p.T_Organization.Guid == t_item.Guid select p).FirstOrDefault(); if (item != null) { item.RecoverBind(t_item); } } } }
private async void AddData(object para) { if (SelectedTreeItem == null) { #if XBAP MessageBox.Show("请选中要查询的组织机构", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); #else Xceed.Wpf.Toolkit.MessageBox.Show("请选中要查询的组织机构", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); #endif return; } if (Unit == null || Unit == "") { #if XBAP MessageBox.Show("请选择要查询的测点的数据类型", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); #else Xceed.Wpf.Toolkit.MessageBox.Show("请选择要查询的测点的数据类型", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); #endif return; } if (SelectedTreeItem is ItemTreeItemViewModel) { if ((SelectedTreeItem as ItemTreeItemViewModel).T_Item != null && (SelectedTreeItem as ItemTreeItemViewModel).T_Item.ItemType == (int)ChannelType.WirelessScalarChannelInfo) { AnInfoSelected = true; } if ((SelectedTreeItem as ItemTreeItemViewModel).T_Item != null && (SelectedTreeItem as ItemTreeItemViewModel).T_Item.ItemType == (int)ChannelType.WirelessVibrationChannelInfo) { VInfoSelected = true; } } string conditionWave; string conditionAlarm; object[] objectWave; object[] objectAlarm; ConditionClass.GetConditionStr(out conditionWave, out conditionAlarm, out objectWave, out objectAlarm, AllowNormal, AllowPreWarning, AllowWarning, AllowDanger, AllowInvalid, AllowRPMFilter, Unit, DownRPMFilter, UpRPMFilter); string selectedip = _cardProcess.GetOrganizationServer(SelectedTreeItem); #region 分频 var divfre = SelectedTreeItem as DivFreTreeItemViewModel; if (divfre != null) { try { WaitInfo = "获取数据中"; Status = ViewModelStatus.Querying; var item_parent = divfre.Parent as ItemTreeItemViewModel; var divfreinfo = divfre.T_DivFreInfo; if (divfreinfo == null) { return; } //var channel = _cardProcess.GetChannel(_hardwareService.ServerTreeItems, item_parent.T_Item); //if (channel == null || channel.IChannel == null) //{ // return; //} var result = await _databaseComponent.GetHistoryData <D1_DivFreInfo>(selectedip, divfreinfo.Guid, null, StartTime.Value, EndTime.Value, null, null); if (result.Count == 0) { #if XBAP MessageBox.Show("没有数据,请重新选择条件", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); #else Xceed.Wpf.Toolkit.MessageBox.Show("没有数据,请重新选择条件", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); #endif return; } List <IBaseDivfreSlot> slotdata = null; switch (item_parent.T_Item.ItemType) { case (int)ChannelType.IEPEChannelInfo: { var resultslot = await _databaseComponent.GetHistoryData <D_IEPESlot>(selectedip, item_parent.T_Item.Guid, null, StartTime.Value, EndTime.Value, null, null); if (resultslot.Count == 0) { return; } slotdata = resultslot.Select(p => p as IBaseDivfreSlot).ToList(); break; } case (int)ChannelType.EddyCurrentDisplacementChannelInfo: { var resultslot = await _databaseComponent.GetHistoryData <D_EddyCurrentDisplacementSlot>(selectedip, item_parent.T_Item.Guid, null, StartTime.Value, EndTime.Value, null, null); if (resultslot.Count == 0) { return; } slotdata = resultslot.Select(p => p as IBaseDivfreSlot).ToList(); break; } case (int)ChannelType.WirelessVibrationChannelInfo: { string unit = Unit; var resultslot = await _databaseComponent.GetHistoryData <D_WirelessVibrationSlot>(selectedip, item_parent.T_Item.Guid, null, StartTime.Value, EndTime.Value, conditionWave, new object[] { unit, DownRPMFilter, UpRPMFilter }); if (resultslot.Count == 0) { return; } slotdata = resultslot.Select(p => p as IBaseDivfreSlot).ToList(); break; } default: return; } if (slotdata == null) { return; } for (int i = 0; i < result.Count; i++) { DivFreObject divFreObj = new DivFreObject(); divFreObj.OrganizationName = item_parent.BaseAlarmSignal.OrganizationName; divFreObj.DeviceName = item_parent.BaseAlarmSignal.DeviceName; divFreObj.ItemName = item_parent.BaseAlarmSignal.ItemName; divFreObj.DivFreName = divfre.Name; var data = (from p in slotdata where p.RecordLab == result[i].RecordLab select new { p.ACQDatetime, p.Unit }).SingleOrDefault(); if (data == null) { return; } divFreObj.ACQDatetime = data.ACQDatetime; divFreObj.DescriptionFre = result[i].DescriptionFre; divFreObj.Result = result[i].Result.Value; //divFreObj.Phase = result[i].Phase; divFreObj.Unit = data.Unit; if (divFreCollection.Where(p => p.OrganizationName == divFreObj.OrganizationName && p.DeviceName == divFreObj.DeviceName && p.ItemName == divFreObj.ItemName && p.DivFreName == divFreObj.DivFreName && p.ACQDatetime == divFreObj.ACQDatetime).Count() == 0) //去重 { divFreCollection.Add(divFreObj); } } } catch (Exception ex) { _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-分频查询", ex)); } finally { Status = ViewModelStatus.None; } return; } #endregion #region 测点 var item = SelectedTreeItem as ItemTreeItemViewModel; if (item != null) { if (item.T_Item != null && item.T_Item.ItemType != 0) { try { WaitInfo = "获取数据中"; Status = ViewModelStatus.Querying; await SubAddData(item, conditionWave, conditionAlarm, objectWave, objectAlarm); } catch (Exception ex) { _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-测点查询", ex)); } finally { Status = ViewModelStatus.None; } return; } else { #if XBAP MessageBox.Show("该测点没绑定或无信息", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); #else Xceed.Wpf.Toolkit.MessageBox.Show("该测点无信息", "提示", MessageBoxButton.OK, MessageBoxImage.Warning); #endif return; } } #endregion #region 组织机构 if (SelectedTreeItem != null) { try { WaitInfo = "获取数据中"; Status = ViewModelStatus.Querying; var items = _cardProcess.GetItems(SelectedTreeItem).Where(p => p.IsPaired); foreach (var subitem in items) { await SubAddData(subitem, conditionWave, conditionAlarm, objectWave, objectAlarm, false); } } catch (Exception ex) { _eventAggregator.GetEvent <ThrowExceptionEvent>().Publish(Tuple.Create <string, Exception>("数据回放-测点批量查询", ex)); } finally { Status = ViewModelStatus.None; } return; } #endregion }