예제 #1
0
        /// <summary>
        /// 将客户端传递过来的jason串转换为习文过滤对象需要的字符串
        /// </summary>
        /// <param name="objfilter">习文过滤对象</param>
        /// <param name="parameters">客户端传入的jason串</param>
        /// <returns>习文过滤对象返回的结果</returns>
        private string FillCustomFilterString(FilterSrv objfilter, Dictionary <string, string> parameters)
        {
            string filterString = string.Empty;

            if (parameters.Keys.Contains("queryParams"))
            {
                filterString = parameters["queryParams"];
                if (string.IsNullOrEmpty(filterString))
                {
                    return(objfilter.GetSQLWhere());
                }
            }
            else
            {
                return(objfilter.GetSQLWhere());
            }
            return(this.FillCustomFilterString(objfilter, filterString));
        }
예제 #2
0
        /// <summary>
        /// 重载方法,用以解析下载时传入的参数
        /// </summary>
        /// <param name="filterString"></param>
        /// <returns></returns>
        private string FillCustomFilterString(FilterSrv objfilter, string filterString)
        {
            if (string.IsNullOrEmpty(filterString))
            {
                return(string.Empty);
            }
            string parameter;

            try
            {
                var doc1 = JsonTransfer.Json2Xml(filterString);
                parameter = doc1.SelectSingleNode("root").OuterXml;
            }
            catch
            {
                parameter = "<root>" + filterString + "</root>";
            }
            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(parameter);
            // 这里需要将前台传入的字符串赋值到习文过滤控件中
            var doc = xmlDocument.DocumentElement;

            if (doc == null)
            {
                return(string.Empty);
            }
            foreach (XmlNode node in doc.ChildNodes)
            {
                try
                {
                    if (!(node.HasChildNodes && node.ChildNodes.Count > 1))
                    {
                        string nodeName = this.ConvertStr(node.Name);
                        nodeName = JsonTransfer.VTransfer(nodeName);
                        objfilter.FilterList[nodeName].varValue = node.InnerText;
                        ReportFilterService.FilterItem item = new ReportFilterService.FilterItem(nodeName, node.InnerText);
                        _filter.FltDAESrv.Add(item);
                        _filter.FltSrv.Add(item);
                    }
                    else
                    {
                        foreach (XmlNode childnode in node.ChildNodes)
                        {
                            string varValue1 = "", varValue2 = "";
                            string nodeName = this.ConvertStr(node.Name);
                            nodeName = JsonTransfer.VTransfer(nodeName);
                            if (childnode.Name == "start")
                            {
                                objfilter.FilterList[nodeName].varValue = childnode.InnerText;
                                varValue1 = childnode.InnerText;
                            }
                            else if (childnode.Name == "end")
                            {
                                objfilter.FilterList[nodeName].varValue2 = childnode.InnerText;
                                varValue2 = childnode.InnerText;
                            }
                            ReportFilterService.FilterItem item = new ReportFilterService.FilterItem(nodeName, varValue1, varValue2);
                            _filter.FltSrv.Add(item);
                            _filter.FltDAESrv.Add(item);
                        }
                    }
                }
                catch
                {
                }
            }
            return(objfilter.GetSQLWhere());
        }