• 使用全局DataSet来优化性能


    在视频列表后面显示改视频所属的三级分类,也有特殊如下:
    1.如果视频有三级分类的获取三级分类,
    2.没有的取上一级分类,
    3.同时取出改分类的链接地址级

        由于视频可能归属的类别级数不受限制,由用户自己定义级别及分配视频;所以视频可能分配在5,6级以下的分类,也有可能分配到顶级分类中;这样就只能为每条记录单独获取三级分类信息。
        如果每次往返数据库的话,性能受到很大影响,所以我采用Cache跟DataSet查询来做!

    DataRow[] Dr;
    DataSet DsType;

    object obj = this.GetCache("DsType");
            if (obj == null)
            {

                obj = Public.SqlHelper.ExecuteDataset(ConnStr, CommandType.StoredProcedure, "PROC_ChanNel_List", new SqlParameter("@Fld_Rank", "114"));
                this.SetCache("DsType", obj);
            }

            DsType = (DataSet)obj;//该顶级下的所以分类

    if (Ds.Tables[0].Rows.Count > 0)//信息列表循环
            {
                for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                {
                    _vFld_VID = Ds.Tables[0].Rows[i]["Fld_VID"].ToString();
                    _vFld_LTitle = Ds.Tables[0].Rows[i]["Fld_Title"].ToString().Trim();
                    _vFld_Picture1 = Ds.Tables[0].Rows[i]["Fld_Picture1"].ToString();
                    _vFld_Title = GreenChina.Public.Function.CutString(_vFld_LTitle, 13, "..");
                    _vFld_Rank = Ds.Tables[0].Rows[i]["Fld_Rank"].ToString();
                    ll = _vFld_Rank.Length > 9 ? 9 : _vFld_Rank.Length;
                    Dr = DsType.Tables[0].Select("Fld_Rank='" + _vFld_Rank.Substring(0, ll) + "'");//如果有三级分类则取三级分类,否则取二级或者顶级分类
                     
                    _vFld_URL = Dr[0]["Fld_URL"].ToString();
                    _vFld_CID = Dr[0]["Fld_CID"].ToString();
                    _vFld_BTitle = Dr[0]["Fld_Title"].ToString();
                    _vFld_Sign = Dr[0]["Fld_Sign"].ToString();

                    if (_vFld_URL == "")
                        _vFld_URL = "wslmlist.aspx?tid=" + _vFld_CID + "&ty=" + _vFld_Sign;

                    _vPlay_URL = Public.Function.GetPlay(_vFld_Rank.Substring(0, 3));
                    _vPlay_URL = _vPlay_URL + "?id=" + _vFld_VID;

                    hddWslm.Text += "<tr>";
                    hddWslm.Text += "<td height='20' class='zi2'>&nbsp;·&nbsp;<a href='" + Server.HtmlEncode(_vPlay_URL) + "' title='" + _vFld_LTitle + "' target='_blank' class='menu_huang'>" + Server.HtmlEncode(_vFld_Title) + "</a>&nbsp;</td><td width='80'><a href='" + _vFld_URL + "' class='menu_lan' target='_blank'>[" + _vFld_BTitle + "]</a></td>";
                    hddWslm.Text += "</tr>";
                }
            }
            else
            {
                hddWslm.Text = "";
            }


  • 相关阅读:
    [Swift]LeetCode1093. 大样本统计 | Statistics from a Large Sample
    [Swift]鸡尾酒排序 | Cocktail Sort
    [Swift]插入排序 | Insertion sort
    [Swift]求最大公约数和最小公倍数
    [Swift]LeetCode1087. 字母切换 | Permutation of Letters
    [Swift]LeetCode1086. 前五科的均分 | High Five
    [Swift]LeetCode1088. 易混淆数 II | Confusing Number II
    [Swift]LeetCode1090. 受标签影响的最大值 | Largest Values From Labels
    [Swift]LeetCode1091. 二进制矩阵中的最短路径 | Shortest Path in Binary Matrix
    [Swift]LeetCode1092. 最短公共超序列 | Shortest Common Supersequence
  • 原文地址:https://www.cnblogs.com/goooto/p/1059319.html
Copyright © 2020-2023  润新知