コード例 #1
0
        /// <summary>
        /// 生成关键字或标题等
        /// </summary>
        /// <param name="info">信息</param>
        /// <param name="subDefaults">SetSubDefaultValue的ID集合,用逗号隔开</param>
        /// <param name="originStr">传入的字符串</param>
        /// <param name="div">分隔符,','用在关键字和描述,'-'用在网页标题</param>
        /// <param name="isKeyword">是否是关键字,如果是生成关键字,则会再加上ContentKeyWord的内容</param>
        /// <returns>生成之后的字符串</returns>
        public string GetKeyWordOrTitleOrDes(string infoID, string infoTypeID, string subDefaultIds, string originStr, char div, bool isKeyword)
        {
            if (subDefaultIds.Trim().Length == 0)
            {
                return(originStr);
            }
            string[] subDefaults = subDefaultIds.Split(new char[] { ',' });
            string   criteira    = "ID IN(";

            for (int i = 0; i < subDefaults.Length; i++)
            {
                criteira += subDefaults[i] + ",";
            }
            criteira = criteira.Remove(criteira.Length - 1, 1) + ")";

            long currentPage = 1;
            long pageCount   = 0;

            Tz888.BLL.Info.SetSubDefaultValueRule obj = new SetSubDefaultValueRule();
            DataView dv = obj.GetList("*", criteira, "Seq", ref currentPage, -1, ref pageCount);

            DataView dvInfo = Tz888.BLL.Info.Common.GetListByInfoType(infoTypeID,
                                                                      "*",
                                                                      "InfoID=" + infoID,
                                                                      "",
                                                                      ref currentPage,
                                                                      1,
                                                                      ref pageCount
                                                                      );

            if (dvInfo.Count == 0)
            {
                throw new Exception("没有找到id=" + infoID.ToString() + "信息.");
            }

            string contentKeyWord = "";

            if (isKeyword)
            {
                contentKeyWord = dvInfo[0]["contentKeyWord"].ToString();
            }

            //生成关键字

            string returnStr = GetStr(dv, originStr, dvInfo, div, contentKeyWord);

            return(returnStr);
        }
コード例 #2
0
        public static string GetPreString(string infoID, string infoTypeID, string defaultValueID, string useDefault, string subDefaultIds, string originStr, string strDiv, string defType)
        {
            Tz888.BLL.Info.SetSubDefaultValueRule obj = new SetSubDefaultValueRule();

            long     pageCount   = 0;
            long     currentPage = 1;
            DataView dv          = null;

            try
            {
                dv = obj.GetList("ID,Seq,DefType,IsNeeded,IsDefaultSelect", "SetDefaultValueID=" + defaultValueID, "Seq", ref currentPage, -1, ref pageCount);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            string[] subDefaults = subDefaultIds.Split(new char[] { ',' });
            dv.Sort = "seq";
            bool isKeyword = false;

            switch (defType)
            {
            case "1":    //网页标题
                dv.RowFilter = "DefType=1 OR DefType=3 OR DefType=5 OR DefType=7";
                break;

            case "2":    //关键字
                dv.RowFilter = "DefType=2 OR DefType=3 OR DefType=6 OR DefType=7";
                isKeyword    = true;
                break;

            case "4":    //描述
                dv.RowFilter = "DefType=4 OR DefType=5 OR DefType=6 OR DefType=7";
                break;

            default:
                break;
            }
            string subDefaultIDStr = "";

            if (useDefault.Trim() == "1")//使用缺省值
            {
                for (int i = 0; i < dv.Count; i++)
                {
                    if (Convert.ToBoolean(dv[i]["IsNeeded"]) || Convert.ToBoolean(dv[i]["IsDefaultSelect"]))
                    {
                        subDefaultIDStr += dv[i]["ID"].ToString().Trim() + ",";
                    }
                }
            }
            else
            {
                for (int i = 0; i < dv.Count; i++)
                {
                    if (subDefaults[i] == "1")
                    {
                        subDefaultIDStr += dv[i]["ID"].ToString().Trim() + ",";
                    }
                }
            }
            if (subDefaultIDStr != "")
            {
                subDefaultIDStr = subDefaultIDStr.TrimEnd(new char[] { ',' });
            }
            else
            {
                return(originStr);
            }
            char div = strDiv.ToCharArray()[0];

            try
            {
                Tz888.BLL.Info.InfoDefaultDEFRule infoDef = new InfoDefaultDEFRule();

                return(infoDef.GetKeyWordOrTitleOrDes(infoID, infoTypeID, subDefaultIDStr, originStr, div, isKeyword));
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
コード例 #3
0
        public static string[][] InitKeywordTitleDes(System.Web.UI.Page page, long infoID, Tz888.Model.Info.MainInfoModel model, CheckBoxList chkKeyWord, CheckBoxList chkTitles, CheckBoxList chkDes, ref string defaultValueID)
        {
            bool           isPostback    = page.IsPostBack;//初始化时需要判断是否是PostBack
            ArrayList      disableInputs = new ArrayList();
            PageIniControl pic           = new PageIniControl();

            //注册ajax脚本
            if (page.IsClientScriptBlockRegistered("ajaxInvokeadfsf") == false)
            {
                page.RegisterClientScriptBlock("ajaxInvokeadfsf", ajaxInvoke);
            }

            DataTable dt = null;

            if (isPostback == false)                       // || defaultValueID == null || defaultValueID == "" || defaultValueID == "0" )
            {
                dt = pic.DefaultViewDataBind(model).Table; //Load对应信息类型的关键字等设置
                if (dt != null && dt.Rows.Count > 0)
                {
                    defaultValueID = dt.Rows[0]["ID"].ToString();
                }
                else
                {
                    return(new string[][] { new string[] {},
                                            new string[] {},
                                            new string[] {} });
                }
            }
            else
            {
                if (defaultValueID == null || defaultValueID == "" || defaultValueID == "0")
                {
                    return(new string[][] { new string[] {},
                                            new string[] {},
                                            new string[] {} });                    //返回空串
                }
                long currentPage = 1;
                long pageCount   = 0;
                Tz888.BLL.Info.SetSubDefaultValueRule ssdv = new SetSubDefaultValueRule();
                dt = (ssdv.GetList("ID as SubDefaultID,DefType,IsNeeded,IsDefaultSelect", "SetDefaultValueID=" + defaultValueID, "", ref currentPage, -1, ref pageCount)).Table;
            }

            bool isFirst = true;//这条信息第一次加载

            //Load该信息的关键字等设置

            Tz888.BLL.Info.InfoDefaultDEFRule infoDefault = new InfoDefaultDEFRule();

            DataView dvInfoDefault = infoDefault.GetList(infoID, 0);
            DataView dvKeyWord     = new DataView(dt);

            if (isPostback == false)
            {
                dvKeyWord.Sort        = "Seq";
                dvKeyWord.RowFilter   = "DefType=2 OR DefType=3 OR DefType=6 OR DefType=7";
                chkKeyWord.DataSource = dvKeyWord;
                chkKeyWord.DataBind();

                //该信息的定义

                dvInfoDefault.RowFilter = "DefType = 2";
                for (int i = 0; i < dvInfoDefault.Count; i++)
                {
                    string   subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim();
                    ListItem li = chkKeyWord.Items.FindByValue(subDefaultValueID);
                    if (li != null)
                    {
                        li.Selected = true;
                        isFirst     = false;
                    }
                }
            }
            ArrayList keyDefaults = new ArrayList();//默认选择和必填项,ID的集合

            //默认选择
            for (int i = 0; i < dvKeyWord.Count; i++)
            {
                bool   isDefaultSelect = Convert.ToBoolean(dvKeyWord[i]["IsDefaultSelect"]);
                bool   isNeeded        = Convert.ToBoolean(dvKeyWord[i]["IsNeeded"]);
                string subDefaultID    = dvKeyWord[i]["SubDefaultID"].ToString().Trim();
                if (isDefaultSelect || isNeeded)
                {
                    keyDefaults.Add(subDefaultID);
                }
                if ((isDefaultSelect && isFirst) || isNeeded)
                {
                    ListItem li = chkKeyWord.Items.FindByValue(subDefaultID);
                    if (li != null)
                    {
                        if (isPostback == false)
                        {
                            li.Selected = true;
                        }
                        if (isNeeded)
                        {
                            disableInputs.Add(chkKeyWord.ClientID + "_" + chkKeyWord.Items.IndexOf(li).ToString());
                        }
                    }
                }
            }


            dvKeyWord = null;
            //绑定Title
            isFirst = true;                            //这条信息第一次加载
            ArrayList titleDefaults = new ArrayList(); //默认选择和必填项,ID的集合
            DataView  dvTitle       = new DataView(dt);

            if (isPostback == false)
            {
                dvTitle.Sort         = "Seq";
                dvTitle.RowFilter    = "DefType=1 OR DefType=3 OR DefType=5 OR DefType=7";
                chkTitles.DataSource = dvTitle;
                chkTitles.DataBind();
                dvInfoDefault.RowFilter = "DefType = 1";
                for (int i = 0; i < dvInfoDefault.Count; i++)
                {
                    string   subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim();
                    ListItem li = chkTitles.Items.FindByValue(subDefaultValueID);
                    if (li != null)
                    {
                        li.Selected = true;
                        isFirst     = false;
                    }
                }
            }
            //默认选择
            for (int i = 0; i < dvTitle.Count; i++)
            {
                bool   isDefaultSelect = Convert.ToBoolean(dvTitle[i]["IsDefaultSelect"]);
                bool   isNeeded        = Convert.ToBoolean(dvTitle[i]["IsNeeded"]);
                string subDefaultID    = dvTitle[i]["SubDefaultID"].ToString().Trim();
                if (isDefaultSelect || isNeeded)
                {
                    titleDefaults.Add(subDefaultID);
                }
                if ((isDefaultSelect && isFirst) || isNeeded)
                {
                    ListItem li = chkTitles.Items.FindByValue(subDefaultID);
                    if (li != null)
                    {
                        if (isPostback == false)
                        {
                            li.Selected = true;
                        }
                        if (isNeeded)
                        {
                            disableInputs.Add(chkTitles.ClientID + "_" + chkTitles.Items.IndexOf(li).ToString());
                        }
                    }
                }
            }

            dvTitle = null;
            //绑定描述
            isFirst = true;//这条信息第一次加载
            DataView dvDes = new DataView(dt);

            if (isPostback == false)
            {
                dvDes.Sort        = "Seq";
                dvDes.RowFilter   = "DefType=4 OR DefType=5 OR DefType=6 OR DefType=7";
                chkDes.DataSource = dvDes;
                chkDes.DataBind();
                dvInfoDefault.RowFilter = "DefType = 4";
                for (int i = 0; i < dvInfoDefault.Count; i++)
                {
                    string   subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim();
                    ListItem li = chkDes.Items.FindByValue(subDefaultValueID);
                    if (li != null)
                    {
                        li.Selected = true;
                        isFirst     = false;
                    }
                }
            }
            //默认选择
            ArrayList desDefaults = new ArrayList();//默认选择和必填项,ID的集合

            for (int i = 0; i < dvDes.Count; i++)
            {
                bool   isDefaultSelect = Convert.ToBoolean(dvDes[i]["IsDefaultSelect"]);
                bool   isNeeded        = Convert.ToBoolean(dvDes[i]["IsNeeded"]);
                string subDefaultID    = dvDes[i]["SubDefaultID"].ToString().Trim();
                if (isDefaultSelect || isNeeded)
                {
                    desDefaults.Add(subDefaultID);
                }
                if ((isDefaultSelect && isFirst) || isNeeded)
                {
                    ListItem li = chkDes.Items.FindByValue(subDefaultID);
                    if (li != null)
                    {
                        if (isPostback == false)
                        {
                            li.Selected = true;
                        }

                        if (isNeeded)
                        {
                            disableInputs.Add(chkDes.ClientID + "_" + chkDes.Items.IndexOf(li).ToString());
                        }
                    }
                }
            }

            dvDes = null;

            string disableInputStr = "";

            for (int i = 0; i < disableInputs.Count; i++)
            {
                disableInputStr += @"'" + disableInputs[i].ToString() + @"',";
            }
            if (disableInputStr != "")//注册禁用必选项的脚本
            {
                disableInputStr = disableInputStr.TrimEnd(new char[] { ',' });
                if (page.IsStartupScriptRegistered("DisabledScript") == false)
                {
                    page.RegisterStartupScript("DisabledScritp", string.Format(DisableScript, disableInputStr));
                }
            }

            string[][] allDefaults = new string[3][];
            allDefaults[0] = new string[keyDefaults.Count];
            allDefaults[1] = new string[titleDefaults.Count];
            allDefaults[2] = new string[desDefaults.Count];
            keyDefaults.CopyTo(allDefaults[0]);
            titleDefaults.CopyTo(allDefaults[1]);
            desDefaults.CopyTo(allDefaults[2]);
            return(allDefaults);
        }