//查找服务树上的通道 public ChannelTreeItemViewModel GetChannel(IList <ServerTreeItemViewModel> servers, T1_Item item) { if (servers == null || servers.Count == 0) { return(null); } if ((item.ItemType == (int)ChannelType.WirelessScalarChannelInfo) || (item.ItemType == (int)ChannelType.WirelessVibrationChannelInfo)) { var channels = GetChannels(servers, WireType.Wireless); ChannelTreeItemViewModel channel = (from p in channels where (p.Parent.Parent.Parent.Parent as MainCardTreeItemViewModel).MainControlCardIP == item.IP && (p.Parent.Parent as TransmissionCardTreeItemViewModel).SlaveIdentifier == item.SlaveIdentifier && (p.Parent as SlotTreeItemViewModel).SlotNum == item.SlotNum && p.CHNum == item.CHNum && p.ServerIP == item.ServerIP//服务器IP匹配20180306 select p).FirstOrDefault(); return(channel); } else { var channels = GetChannels(servers, WireType.Wire); ChannelTreeItemViewModel channel = (from p in channels where (p.Parent.Parent.Parent as MainCardTreeItemViewModel).MainControlCardIP == item.IP && (p.Parent.Parent as WireMatchingCardTreeItemViewModel).CardNum == item.CardNum && (p.Parent as SlotTreeItemViewModel).SlotNum == item.SlotNum && p.CHNum == item.CHNum && p.ServerIP == item.ServerIP//服务器IP匹配20180306 select p).FirstOrDefault(); return(channel); } }
//查找服务树上的通道 private ChannelTreeItemViewModel GetChannel(IList <ServerTreeItemViewModel> servers, string ip, int cardNum, int slotNum, int chnNum) { if (servers == null || servers.Count == 0) { return(null); } var channels = from p in GetChannels(servers) select p; ChannelTreeItemViewModel channel = (from p in channels where (p.Parent.Parent.Parent as MainCardTreeItemViewModel).MainControlCardIP == ip && (p.Parent.Parent as WireMatchingCardTreeItemViewModel).CardNum == cardNum && (p.Parent as SlotTreeItemViewModel).SlotNum == slotNum && p.CHNum == chnNum select p).FirstOrDefault(); return(channel); }
public ItemTreeItemViewModel GetRecycledItem(string ip, ChannelTreeItemViewModel channeltree, OrganizationTreeItemViewModel recycledTreeItem) { if (channeltree.IChannel is WirelessVibrationChannelInfo || channeltree.IChannel is WirelessScalarChannelInfo) { var slaveIdentifier = (channeltree.Parent.Parent as TransmissionCardTreeItemViewModel).TransmissionCard.SlaveIdentifier; var slotNum = (channeltree.Parent as SlotTreeItemViewModel).SlotNum; var chNum = channeltree.CHNum; //var channelHDID = ip + "_" + slaveIdentifier + "_" + slotNum + "_" + chNum; var channelHDID = slaveIdentifier.PadLeft(4, '0') + "_" + slotNum + "_" + chNum + "_0" + "@" + ip; var recycledItem = recycledTreeItem.Children.Where(p => (p as ItemTreeItemViewModel).T_Item.ChannelHDID == channelHDID).OrderByDescending(p => (p as ItemTreeItemViewModel).T_Item.Modify_Time).Select(p => p as ItemTreeItemViewModel).FirstOrDefault(); return(recycledItem); } else { var cardNum = (channeltree.Parent.Parent as WireMatchingCardTreeItemViewModel).CardNum; var slotNum = (channeltree.Parent as SlotTreeItemViewModel).SlotNum; var chNum = channeltree.CHNum; //var channelHDID = ip + "_" + cardNum + "_" + slotNum + "_" + chNum; var channelHDID = cardNum.ToString("0000") + "_" + slotNum + "_" + chNum + "_0" + "@" + ip; var recycledItem = recycledTreeItem.Children.Where(p => (p as ItemTreeItemViewModel).T_Item.ChannelHDID == channelHDID).OrderByDescending(p => (p as ItemTreeItemViewModel).T_Item.Modify_Time).Select(p => p as ItemTreeItemViewModel).FirstOrDefault(); return(recycledItem); } }
public void BindTemp(ChannelTreeItemViewModel channel, string ip, string identifier, string serverIP, T1_Organization organization) { SaveTempData(); if (channel.IChannel is WirelessVibrationChannelInfo || channel.IChannel is WirelessScalarChannelInfo) { TempData.SlaveIdentifier = (channel.Parent.Parent as TransmissionCardTreeItemViewModel).TransmissionCard.SlaveIdentifier; TempData.SlotNum = (channel.Parent as SlotTreeItemViewModel).SlotNum; TempData.CHNum = channel.CHNum; TempData.ChannelHDID = TempData.SlaveIdentifier.PadLeft(4, '0') + "_" + TempData.SlotNum + "_" + TempData.CHNum + "_0" + "@" + ip; if (channel.IChannel is WirelessVibrationChannelInfo) { TempData.ItemType = (int)ChannelType.WirelessVibrationChannelInfo; } else if (channel.IChannel is WirelessScalarChannelInfo) { TempData.ItemType = (int)ChannelType.WirelessScalarChannelInfo; } } else { TempData.CardNum = (channel.Parent.Parent as WireMatchingCardTreeItemViewModel).CardNum; TempData.SlotNum = (channel.Parent as SlotTreeItemViewModel).SlotNum; TempData.CHNum = channel.CHNum; TempData.ChannelHDID = TempData.CardNum.Value.ToString("0000") + "_" + TempData.SlotNum + "_" + TempData.CHNum + "_0" + "@" + ip; if (channel.IChannel is IEPEChannelInfo) { TempData.ItemType = (int)ChannelType.IEPEChannelInfo; } else if (channel.IChannel is EddyCurrentDisplacementChannelInfo) { TempData.ItemType = (int)ChannelType.EddyCurrentDisplacementChannelInfo; } else if (channel.IChannel is EddyCurrentKeyPhaseChannelInfo) { TempData.ItemType = (int)ChannelType.EddyCurrentKeyPhaseChannelInfo; } else if (channel.IChannel is DigitTachometerChannelInfo) { TempData.ItemType = (int)ChannelType.DigitTachometerChannelInfo; } else if (channel.IChannel is AnalogRransducerInChannelInfo) { TempData.ItemType = (int)ChannelType.AnalogRransducerInChannelInfo; } else if (channel.IChannel is RelayChannelInfo) { TempData.ItemType = (int)ChannelType.RelayChannelInfo; } else if (channel.IChannel is DigitRransducerInChannelInfo) { TempData.ItemType = (int)ChannelType.DigitRransducerInChannelInfo; } else if (channel.IChannel is DigitRransducerOutChannelInfo) { TempData.ItemType = (int)ChannelType.DigitRransducerOutChannelInfo; } else if (channel.IChannel is AnalogRransducerOutChannelInfo) { TempData.ItemType = (int)ChannelType.AnalogRransducerOutChannelInfo; } } TempData.IP = ip; TempData.Identifier = identifier; TempData.ServerIP = serverIP;//废弃ServerIP,但数据库不允许为空,依旧填充//改为初始化时候填充,覆盖数据库的ServerIP。 TempData.Is_Disabled = false; TempData.Modify_Time = DateTime.Now; TempData.Name = organization.Name; TempData.T_Device_Guid = organization.Parent_Guid.Value; TempData.T_Device_Code = organization.Parent_Code; }