private static void SerializeTagQueryFilter(XmlWriter xmlWriter, TagQueryFilter filter)
 {
     xmlWriter.WriteStartElement("Filter", "");
     xmlWriter.WriteElementString("Key", "", S3Transforms.ToXmlStringValue(filter.Key));
     xmlWriter.WriteStartElement("Or", "");
     foreach (string item in filter.Or)
     {
         xmlWriter.WriteElementString("Value", "", S3Transforms.ToXmlStringValue(item));
     }
     xmlWriter.WriteEndElement();
     xmlWriter.WriteEndElement();
 }
Example #2
0
        /// <summary>
        /// 根据条件得到测点集合  测点属性之间逗号分隔 id,点名,描述,单位,数值
        /// </summary>
        /// <param name="flag">是否实时值</param>
        /// <returns></returns>
        public List<string> GetPointList(string filterexp, bool flag, DateTime time)
        {
            try {
                if (String.IsNullOrEmpty(filterexp) || !filterexp.Contains(",")) {
                    return null;
                }

                String[] temp = filterexp.Split(',');
                if (null == temp || 0 >= temp.Length) {
                    return null;
                }
                TagQueryFilter filter = new TagQueryFilter();
                PropField propField = (from p in TagTypeSystem.BasePropFields
                                       where p.PropName == "Name"
                                       select p).First<PropField>();

                filter.Conditions.InsertAndCompileExpression(new TagQueryExpression(propField,
                    TagQueryExpression.CompareOperator.Equal, temp[0]));
                filter.StartNode = rootNode;
                filter.Fields = null;
                TagVector tagVector = GetPointListByTagName(temp[0]);
                if (null == tagVector) {
                    return null;
                }
                else {
                    List<String> result = new List<String>();
                    if (flag) {
                        RealDataSet realDataSet = new RealDataSet();
                        BatchResults results = DataIO.Snapshot(dbConnector, tagVector, realDataSet);
                        foreach (var item in realDataSet) {
                            String tagName = tagVector.First(x => x.TagId == item.TagId).TagName;
                            String tagStringValue = null != item.Value ? item.Value.ToString() : "0";
                            String tagDesc = tagVector.First(x => x.TagId == item.TagId).Properties["Desc"].ToString();
                            String tagEngunit = tagVector.First(x => x.TagId == item.TagId).Properties["ENGINEERINGUNIT"].ToString();

                            result.Add(String.Format("{0},{1},{2},{3},{4}", item.TagId, tagName, tagDesc, tagEngunit, tagStringValue));
                        }
                    }
                    else {
                        HisDataSet realDataSet = new HisDataSet();
                        BatchResults results = DataIO.ReadRaw(dbConnector, tagVector, time.AddSeconds(-1), time, realDataSet);
                        foreach (var item in realDataSet) {
                            String tagName = tagVector.First(x => x.TagId == item.TagId).TagName;
                            String tagStringValue = "0";
                            if (null != item.Data && 0 < item.Data.Count) {
                                tagStringValue = null != item.Data[0].Value ? item.Data[0].Value.ToString() : "0";
                            }
                            String tagDesc = tagVector.First(x => x.TagId == item.TagId).Properties["Desc"].ToString();
                            String tagEngunit = tagVector.First(x => x.TagId == item.TagId).Properties["ENGINEERINGUNIT"].ToString();

                            result.Add(String.Format("{0},{1},{2},{3},{4}", item.TagId, tagName, tagDesc, tagEngunit, tagStringValue));
                        }
                    }
                    return result;
                }
            }
            catch (Exception ex) {
                _ErrorInfo = ex.Message;
                return null;
            }
        }
Example #3
0
        /// <summary>
        /// 根据点名称获取点列表
        /// </summary>
        /// <param name="tagName"></param>
        /// <returns></returns>
        private TagVector GetPointListByTagName(String tagName)
        {
            try {
                TagQueryFilter filter = new TagQueryFilter();
                PropField propField = (from p in TagTypeSystem.BasePropFields
                                       where p.PropName == "LongName"
                                       select p).First<PropField>();

                //filter.Conditions.InsertAndCompileExpression(new TagQueryExpression(propField,
                //    TagQueryExpression.CompareOperator.Equal, tagName));
                List<PropField> list = new List<PropField>();
                list.Add(propField);
                //filter.StartNode = rootNode;
                //filter.Fields = null;
                ITag tag = tagManager.GetTagByName(tagName, list);
                if (null == tag) {
                    return null;
                }
                filter = null;
                propField = null;
                list = null;
                TagVector tagVector = new TagVector();
                tagVector.Add(tag);
                return tagVector;
            }
            catch (Exception ex) {
                _ErrorInfo = ex.Message;
                return null;
            }
        }