コード例 #1
0
ファイル: LoadSpecialData.cs プロジェクト: stonezhu870/istock
        /// <summary>
        /// 专题分类初始化
        /// </summary>
        /// <param name="iclist">专题类集合</param>
        /// <param name="dt">数据表</param>
        /// <param name="categrrycode">分类code</param>
        private static void InitSpecialTopicCategory(List <DataRow> iclist, DataTable dt,
                                                     String categrrycode)
        {
            if (dt == null || dt.Rows.Count == 0)
            {
                return;
            }
            List <DataRow> results = new List <DataRow>();
            List <DataRow> res     = new List <DataRow>();

            //DataTableExtentions.DataTableToArray(dt).Where(item => Normal.ParseString(item["CATEGORYCODE"]).Trim() == categrrycode.Trim()).ToList();
            foreach (DataRow dataRow in DataTableExtentions.DataTableToArray(dt))
            {
                if (Normal.ParseString(dataRow["CATEGORYCODE"]).Trim() == categrrycode.Trim())
                {
                    res.Add(dataRow);
                    break;
                }
            }
            if (res.Count > 0)
            {
                results.Add(res[0]);
                GetChildsSpecialtopicCategories(results, res.ToArray(), dt);
            }
            iclist.AddRange(results.ToArray());
            results.Clear();
            results = null;
            dt.AcceptChanges();
        }
コード例 #2
0
        /// <summary>
        /// 设置过滤log
        /// </summary>
        /// <param name="sourcename">数据源名称</param>
        /// <param name="modes">过滤条件集合</param>
        /// <param name="fields">数据列名</param>
        /// <param name="map">map</param>
        /// <param name="_orders">排序键值对</param>
        /// <param name="_needToGroup">是否要列重组</param>
        /// <param name="statisticsEngName">统计英文名</param>
        public static void SetFilterLog(String sourcename, List <FilterMode> modes, String[] fields,
                                        Dictionary <GROUPTYPE, String> map, Dictionary <String, bool> _orders, bool _needToGroup,
                                        String statisticsEngName)
        {
            if (FilterTable == null)
            {
                return;
            }
            String id          = "";
            String speicalname = "";

            if (modes != null)
            {
                foreach (var filter in modes)
                {
                    bool findRes = false;
                    foreach (DataRow item in DataTableExtentions.DataTableToArray(FilterTable))
                    {
                        if (item["DATASOURCENAME_EN"].ToString() == sourcename && item["STATICNAME_EN"].ToString() == statisticsEngName &&
                            item["FILTER_EN"] != null && item["FILTER_EN"].ToString() == filter.BindParam)
                        {
                            findRes = true;
                            break;
                        }
                    }
                    if (!findRes)
                    {
                        DataRow dr = FilterTable.NewRow();
                        dr["DATASOURCENAME_EN"] = sourcename;
                        dr["DATASOURCENAME_CN"] = sourcename;
                        dr["STATICNAME_CN"]     = statisticsEngName ?? "";
                        dr["STATICNAME_EN"]     = statisticsEngName ?? "";
                        dr["FILTER_EN"]         = filter.BindParam;
                        dr["ORDER_EN"]          = "";
                        dr["PROPERTY_CN"]       = "";
                        dr["ISSTATIC"]          = _needToGroup;
                        dr["ISBIGDATA"]         = false;
                        dr["SPECIALTOPICNAME"]  = String.Format("{0}&{1}", id, speicalname);
                        FilterTable.Rows.Add(dr);
                    }
                    //if (
                    //  DataTableExtentions.DataTableToArray(FilterTable).Where(
                    //    item =>
                    //    item["DATASOURCENAME_EN"].ToString() == sourcename && item["STATICNAME_EN"].ToString() == statisticsEngName &&
                    //    item["FILTER_EN"] != null && item["FILTER_EN"].ToString() == filter.BindParam).Count() == 0)
                    //{
                    //  DataRow dr = FilterTable.NewRow();
                    //  dr["DATASOURCENAME_EN"] = sourcename;
                    //  dr["DATASOURCENAME_CN"] = sourcename;
                    //  dr["STATICNAME_CN"] = statisticsEngName ?? "";
                    //  dr["STATICNAME_EN"] = statisticsEngName ?? "";
                    //  dr["FILTER_EN"] = filter.BindParam;
                    //  dr["ORDER_EN"] = "";
                    //  dr["PROPERTY_CN"] = "";
                    //  dr["ISSTATIC"] = _needToGroup;
                    //  dr["ISBIGDATA"] = false;
                    //  dr["SPECIALTOPICNAME"] = String.Format("{0}&{1}", id, speicalname);
                    //  FilterTable.Rows.Add(dr);
                    //}
                }
            }
            if (_orders != null && _orders.Count > 0)
            {
                foreach (KeyValuePair <String, bool> keyValuePair in _orders)
                {
                    bool findres = false;
                    if (FilterTable == null)
                    {
                        foreach (DataRow item in DataTableExtentions.DataTableToArray(FilterTable))
                        {
                            if (item["DATASOURCENAME_EN"].ToString() == sourcename && item["STATICNAME_EN"].ToString() == statisticsEngName &&
                                item["FILTER_EN"] != null && item["ORDER_EN"].ToString() == keyValuePair.Key)
                            {
                                findres = true;
                                break;
                            }
                        }
                    }
                    if (!findres)
                    {
                        DataRow dr = FilterTable.NewRow();
                        dr["DATASOURCENAME_EN"] = sourcename ?? "";
                        dr["DATASOURCENAME_CN"] = sourcename ?? "";
                        dr["STATICNAME_CN"]     = statisticsEngName ?? "";
                        dr["STATICNAME_EN"]     = statisticsEngName ?? "";
                        dr["FILTER_EN"]         = "";
                        dr["ORDER_EN"]          = keyValuePair.Key;
                        dr["PROPERTY_CN"]       = "";
                        dr["ISSTATIC"]          = _needToGroup;
                        dr["ISBIGDATA"]         = false;
                        dr["SPECIALTOPICNAME"]  = String.Format("{0}&{1}", id, speicalname);
                        FilterTable.Rows.Add(dr);
                    }
                    //if (DataTableExtentions.DataTableToArray(FilterTable)
                    //.Where(
                    //  item =>
                    //  item["DATASOURCENAME_EN"].ToString() == sourcename && item["STATICNAME_EN"].ToString() == statisticsEngName &&
                    //  item["FILTER_EN"] != null && item["ORDER_EN"].ToString() == keyValuePair.Key).Count() == 0)
                    //{
                    //  DataRow dr = FilterTable.NewRow();
                    //  dr["DATASOURCENAME_EN"] = sourcename ?? "";
                    //  dr["DATASOURCENAME_CN"] = sourcename ?? "";
                    //  dr["STATICNAME_CN"] = statisticsEngName ?? "";
                    //  dr["STATICNAME_EN"] = statisticsEngName ?? "";
                    //  dr["FILTER_EN"] = "";
                    //  dr["ORDER_EN"] = keyValuePair.Key;
                    //  dr["PROPERTY_CN"] = "";
                    //  dr["ISSTATIC"] = _needToGroup;
                    //  dr["ISBIGDATA"] = false;

                    //  dr["SPECIALTOPICNAME"] = String.Format("{0}&{1}", id, speicalname);
                    //  FilterTable.Rows.Add(dr);
                    //}
                }
            }
        }