/// <summary>
        /// Updates the entries (via Remove and Add) in the ALL items collection
        /// with the entries in the <param name="viewModels"/> array parameter.
        /// </summary>
        /// <param name="viewModels"></param>
        private void UpdateAllEntries(params VM[] viewModels)
        {
            Logger.InfoFormat("_");

            _All.SuspendCollectionChangeNotification();
            try
            {
                var removeItems = _All.Where(vm => !viewModels.Contains(vm)).ToList();
                var addItems    = viewModels.Where(vm => !_All.Contains(vm)).ToList();

                foreach (var vm in removeItems)
                {
                    _All.Remove(vm);
                }

                foreach (var vm in addItems)
                {
                    _All.Add(vm);
                }
            }
            finally
            {
                _All.NotifyChanges();

                if (this.EntriesChanged != null)
                {
                    this.EntriesChanged(this, EventArgs.Empty);
                }
            }
        }
Пример #2
0
        private void updateEntries(params VM[] viewModels)
        {
            FastObservableCollection <VM> all = All as FastObservableCollection <VM>;

            all.SuspendCollectionChangeNotification();

            var removeItems = all.Where(vm => !viewModels.Contains(vm)).ToList();
            var addItems    = viewModels.Where(vm => !all.Contains(vm)).ToList();

            if (addItems.Count == 0 && removeItems.Count == 0)
            {
                return; //nothing to do here
            }
            foreach (var vm in removeItems)
            {
                all.Remove(vm);
            }

            foreach (var vm in addItems)
            {
                all.Add(vm);
            }

            _subItemList = all.ToArray().ToList();
            all.NotifyChanges();

            EntriesChanged?.Invoke(this, EventArgs.Empty);
        }
Пример #3
0
        private void updateEntries(params VM[] viewModels)
        {
            FastObservableCollection <VM> all = All as FastObservableCollection <VM>;

            all.SuspendCollectionChangeNotification();

            var removeItems = all.Where(vm => !viewModels.Contains(vm)).ToList();
            var addItems    = viewModels.Where(vm => !all.Contains(vm)).ToList();

            foreach (var vm in removeItems)
            {
                all.Remove(vm);
            }

            foreach (var vm in addItems)
            {
                all.Add(vm);
            }

            _subItemList = all.ToArray().ToList();
            all.NotifyChanges();

            if (EntriesChanged != null)
            {
                EntriesChanged(this, EventArgs.Empty);
            }
        }
Пример #4
0
        private void OnActiveFilterGroupChanged()
        {
            lock (_lock)
            {
                ResetEntriesCount();
                UpdateEntriesCount(_logEntries.Where(IsValidLogEntry).ToList());
            }

            ActiveFilterGroupChanged?.Invoke(this, EventArgs.Empty);
        }
Пример #5
0
        private async Task SubAddData(ItemTreeItemViewModel item, string conditionWave, string conditionAlarm, object[] objectWave, object[] objectAlarm, bool showmessagbox = true)
        {
            List <IBaseAlarmSlot> result = new List <IBaseAlarmSlot>();

            if (item.T_Item.ItemType == (int)ChannelType.WirelessVibrationChannelInfo)
            {
                result = await _databaseComponent.GetUniformHistoryData(item.T_Item.ItemType, item.ServerIP, item.T_Item.Guid, new string[] { "ACQDatetime", "Result", "Unit", "AlarmGrade" }, StartTime.Value, EndTime.Value, conditionWave, objectWave);
            }
            else if (item.T_Item.ItemType == (int)ChannelType.WirelessScalarChannelInfo)
            {
                result = await _databaseComponent.GetUniformHistoryData(item.T_Item.ItemType, item.ServerIP, item.T_Item.Guid, new string[] { "ACQDatetime", "Result", "Unit", "AlarmGrade" }, StartTime.Value, EndTime.Value, conditionAlarm, objectAlarm);
            }

            if (result == null || result.Count == 0)
            {
                if (showmessagbox == true)
                {
#if XBAP
                    MessageBox.Show("没有数据,请重新选择条件", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
#else
                    Xceed.Wpf.Toolkit.MessageBox.Show("没有数据,请重新选择条件", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
#endif
                }
                return;
            }
            for (int i = 0; i < result.Count; i++)
            {
                RMSObject amsObj = new RMSObject();
                if (item.BaseAlarmSignal != null)
                {
                    amsObj.OrganizationName = item.BaseAlarmSignal.OrganizationName;
                    amsObj.DeviceName       = item.BaseAlarmSignal.DeviceName;
                    amsObj.ItemName         = item.BaseAlarmSignal.ItemName;
                }
                else if (item.Parent is OrganizationTreeItemViewModel)//回收站
                {
                    amsObj.OrganizationName = "回收站";
                    amsObj.DeviceName       = item.ServerIP;
                    amsObj.ItemName         = item.Name;
                }

                amsObj.ACQDatetime = result[i].ACQDatetime;
                amsObj.Result      = result[i].Result.Value;
                amsObj.Unit        = result[i].Unit;
                amsObj.AlarmGrade  = (AlarmGrade)(result[i].AlarmGrade & 0x00ffff00);

                if (item.T_Item.ItemType == (int)ChannelType.WirelessVibrationChannelInfo)
                {
                    if (vInfoCollection.Where(p => p.OrganizationName == amsObj.OrganizationName &&
                                              p.DeviceName == amsObj.DeviceName &&
                                              p.ItemName == amsObj.ItemName &&
                                              p.ACQDatetime == amsObj.ACQDatetime).Count() == 0) //去重
                    {
                        vInfoCollection.Add(amsObj);
                    }
                }
                else if (item.T_Item.ItemType == (int)ChannelType.WirelessScalarChannelInfo)
                {
                    if (anInfoCollection.Where(p => p.OrganizationName == amsObj.OrganizationName &&
                                               p.DeviceName == amsObj.DeviceName &&
                                               p.ItemName == amsObj.ItemName &&
                                               p.ACQDatetime == amsObj.ACQDatetime).Count() == 0) //去重
                    {
                        anInfoCollection.Add(amsObj);
                    }
                }
            }
        }
Пример #6
0
        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
        }