Example #1
0
        /// <summary>
        /// 在DrectSoftWordbooks.XML中根据指定的字典名搜索定义数据,创建字典实例
        /// XML文件的数据要符合Wordbook.XSD的定义。下面的处理流程是按XSD的定义进行的。
        /// </summary>
        /// <param name="name">字典名称</param>
        protected BaseWordbook(string name)
        {
            Schema.Wordbook source = WordbookStaticHandle.GetSourceWordbookByName(name);

            if (String.IsNullOrEmpty(source.WordbookName))
            {
                throw new ArgumentException("没有正确初始化字典,请检查基础数据");
            }

            // 开始处理字典的属性
            _wordbookName      = source.WordbookName;
            _caption           = source.Caption;
            _querySentence     = PersistentObjectFactory.GetQuerySentenceByName(source.QuerySentence);
            _codeField         = source.CodeField;
            _nameField         = source.NameField;
            _queryCodeField    = source.QueryCodeField;
            _codeFieldIsString = source.CodeFieldIsString;

            // 过滤参数
            _parameters          = new FilterParameterCollection();
            _showStyles          = new Collection <GridColumnStyleCollection>();
            _defaultFilterFields = new Collection <string>();

            if (source.FilterFieldCollection != null)
            {
                foreach (string field in source.FilterFieldCollection)
                {
                    _defaultFilterFields.Add(field);
                }
            }

            if (source.ParameterCollection != null)
            {
                _parameters.AddRange(source.ParameterCollection);
            }

            GridColumnStyleCollection columnStyle;

            foreach (GridColumnStyle[] style in source.ViewStyleCollection)
            {
                columnStyle = new GridColumnStyleCollection();
                columnStyle.AddRange(style);
                _showStyles.Add(columnStyle);
            }

            // 下列属性使用默认值
            SelectedStyleIndex = 0;
            ExtraCondition     = "";

            _currentMatchFields = new Collection <string>();
            foreach (string field in _defaultFilterFields)
            {
                _currentMatchFields.Add(field);
            }
        }
Example #2
0
 /// <summary>
 /// 获取指定字典的查询语句定义
 /// </summary>
 /// <param name="bookName">指定的字典名称</param>
 /// <returns>查询语句</returns>
 public static string GetWordbookQuerySentence(string bookName)
 {
     Schema.Wordbook book = GetSourceWordbookByName(bookName);
     if (book != null)
     {
         return(PersistentObjectFactory.GetQuerySentenceByName(book.QuerySentence));
     }
     else
     {
         throw new ArgumentOutOfRangeException("缺少指定字典的查询语句定义");
     }
 }