示例#1
0
 public void AddRange(RangeCondition rc)
 {
     if (rangeConList == null)
         rangeConList = new List<RangeCondition>();
     rangeConList.Add(rc);
 }
示例#2
0
        public void ReadXml(XmlReader reader)
        {
            string startElementName = reader.Name;
            string currentElementName,currentNodeName,currentItemName;
            string table,field,from,to;
            bool interval;
            List<string> itemList=new List<string>();
            this.queryInfo.FilterList.Clear();
            this.queryInfo.ExcludeList.Clear();
            this.queryInfo.RangeList.Clear();
            do
            {
                currentElementName = reader.Name;
                if (currentElementName == startElementName && (reader.MoveToContent() == XmlNodeType.EndElement || reader.IsEmptyElement))
                {
                    reader.Read();
                    break;
                }
                switch (currentElementName)
                {
                    case "PageNum":
                        this.pageNum = int.Parse(reader.ReadElementString());
                        break;

                    case "PageSize":
                        this.pageSize = int.Parse(reader.ReadElementString());
                        break;
                    case "HighLight":
                        this.highLight = bool.Parse(reader.ReadElementString());
                        break;
                    case "Filter":
                        this.filter = reader.ReadElementString();
                        break;
                    case "QueryInfo":
                        this.queryInfo.IndexNames = SupportClass.FileUtil.GetXmlAttribute(reader,"IndexNames",typeof(string));
                        this.queryInfo.QueryAts = SupportClass.FileUtil.GetXmlAttribute(reader, "QueryAts", typeof(string));
                        this.queryInfo.WordsAllContains = SupportClass.FileUtil.GetXmlAttribute(reader, "WordsAllContains", typeof(string));
                        this.queryInfo.ExactPhraseContain = SupportClass.FileUtil.GetXmlAttribute(reader, "ExactPhraseContain", typeof(string));
                        this.queryInfo.OneOfWordsAtLeastContain = SupportClass.FileUtil.GetXmlAttribute(reader, "OneOfWordsAtLeastContain", typeof(string));
                        this.queryInfo.WordNotInclude = SupportClass.FileUtil.GetXmlAttribute(reader, "WordNotInclude", typeof(string));
                        do
                        {
                            currentNodeName = reader.Name;
                            if (currentNodeName == currentElementName && (reader.MoveToContent() == XmlNodeType.EndElement || reader.IsEmptyElement))
                            {
                                break;
                            }
                            switch (currentNodeName)
                            {
                                case "FilterCondition":
                                    table = SupportClass.FileUtil.GetXmlAttribute(reader, "Table", typeof(string));
                                    field = SupportClass.FileUtil.GetXmlAttribute(reader, "Field", typeof(string));
                                    itemList.Clear();
                                    do 
                                    {
                                        currentItemName=reader.Name;
                                        if (currentItemName == currentNodeName && (reader.MoveToContent() == XmlNodeType.EndElement || reader.IsEmptyElement))
                                        {
                                            break;
                                        }
                                        switch (currentItemName)
                                        {
                                            case "Item":
                                                itemList.Add(reader.ReadElementString());
                                                reader.Read();
                                                break;
                                            default :
                                                reader.Read();
                                                break;
                                        }
                                    } while (true);
                                    this.queryInfo.FilterList.Add(new FilterCondition(table, field, itemList.ToArray()));
                                    reader.Read();
                                    break;
                                case "ExcludeCondition":
                                    table = SupportClass.FileUtil.GetXmlAttribute(reader, "Table", typeof(string));
                                    field = SupportClass.FileUtil.GetXmlAttribute(reader, "Field", typeof(string));
                                    itemList.Clear();
                                    do
                                    {
                                        currentItemName = reader.Name;
                                        if (currentItemName == currentNodeName && (reader.MoveToContent() == XmlNodeType.EndElement || reader.IsEmptyElement))
                                        {
                                            break;
                                        }
                                        switch (currentItemName)
                                        {
                                            case "Item":
                                                itemList.Add(reader.ReadElementString());
                                                reader.Read();
                                                break;
                                            default:
                                                reader.Read();
                                                break;
                                        }
                                    } while (true);
                                    this.queryInfo.ExcludeList.Add(new ExcludeCondition(table, field, itemList.ToArray()));
                                    reader.Read();
                                    break;
                                case "RangeCondition":
                                    table = SupportClass.FileUtil.GetXmlAttribute(reader, "Table", typeof(string));
                                    field = SupportClass.FileUtil.GetXmlAttribute(reader, "Field", typeof(string));
                                    from = SupportClass.FileUtil.GetXmlAttribute(reader, "From", typeof(string));
                                    to = SupportClass.FileUtil.GetXmlAttribute(reader, "To", typeof(string));
                                    interval = bool.Parse(SupportClass.FileUtil.GetXmlAttribute(reader, "Interval", typeof(bool)));
                                    RangeCondition rc = new RangeCondition(table, field, from, to);
                                    rc.IntervalType = interval;
                                    this.queryInfo.RangeList.Add(rc);
                                    reader.Read();
                                    break;
                                default:
                                    reader.Read();
                                    break;
                            }
                        } while (true);
                        reader.Read();
                        break;
                    default:
                        reader.Read();
                        break;

                }
            } while (true);
        }