Ejemplo n.º 1
0
        public void LoadCSSAndJSCode(System.Web.UI.Page p)
        {
            Model.ADModule.AD_Model admodel = adBll.GetModelByKeyValue(ADID);
            if (admodel == null)
            {
                return;
            }


            Model.ADModule.ADDisplayMode_Model addmModel = addmBll.GetModelByKeyValue(admodel.ADDisplayModeCode);
            if (null != addmModel)
            {
                RegisterCode(addmModel.CSSCode + "\n" + addmModel.JsCode, addmModel.ADDisplayModeCode, p);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取广告模板
        /// </summary>
        /// <returns></returns>
        public string GettTemplateCode()
        {
            string templatecode = string.Empty;

            Model.ADModule.AD_Model admodel = adBll.GetModelByKeyValue(ADID);
            if (admodel == null)
            {
                return(string.Empty);
            }


            Model.ADModule.ADDisplayMode_Model addmModel = addmBll.GetModelByKeyValue(admodel.ADDisplayModeCode);
            if (null != addmModel)
            {
                templatecode = addmModel.DisplayModeTemplateCode;
            }

            return(templatecode);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 解析模板
        /// </summary>
        /// <returns></returns>
        public string ParseTemplateCode()
        {
            string templatecode = string.Empty;

            Model.ADModule.AD_Model admodel = adBll.GetModelByKeyValue(ADID);
            if (admodel == null)
            {
                return(string.Empty);
            }


            Model.ADModule.ADDisplayMode_Model addmModel = addmBll.GetModelByKeyValue(admodel.ADDisplayModeCode);
            if (null != addmModel)
            {
                templatecode = addmModel.DisplayModeTemplateCode;
            }



            //Regex regex = new Regex("(?<=\\[ADList:loop\\])(.|\n)*?(?=\\[/ADList:loop\\])", RegexOptions.IgnoreCase);
            //MatchCollection matchcol = regex.Matches(tmeplatecode);

            Regex           regex    = new Regex("\\[ADList:loop\\](.|\n)*?\\[/ADList:loop\\]", RegexOptions.IgnoreCase);
            MatchCollection matchcol = regex.Matches(templatecode);


            string ADControlID = string.Format("ADControlID_{0}_{1}_{2}", admodel.ADID.ToString(), this.ID, new Random().Next(100000000).ToString());

            foreach (Match match in matchcol)
            {
                Regex  tempRegex = new Regex("(?<=\\[ADList:loop\\])(.|\n)*?(?=\\[/ADList:loop\\])", RegexOptions.IgnoreCase);
                string Ptempstr  = match.Value;
                Match  tempMatch = tempRegex.Match(Ptempstr);

                StringBuilder tempCodeSB = new StringBuilder();

                List <Model.ADModule.ADContentList_Model> adcontentlist = adlBll.GetList(100, "ADID=" + ADID, "");


                int index = 0;
                foreach (Model.ADModule.ADContentList_Model item in adcontentlist)
                {
                    string tempCode = tempMatch.Value;
                    index++;

                    tempCode = tempCode.Replace("#LinkUrl#", item.LinkUrl);
                    tempCode = tempCode.Replace("#index#", index.ToString());
                    tempCode = tempCode.Replace("#PicUrl#", item.PicUrl);
                    tempCode = tempCode.Replace("#ADText#", item.ADText);
                    tempCode = tempCode.Replace("#ToolTip#", item.ToolTip);
                    tempCode = tempCode.Replace("#Description#", item.Description);
                    tempCode = tempCode.Replace("#FlashUrl#", item.FlashUrl);
                    tempCode = tempCode.Replace("#DisplayHeight#", admodel.DisplayHeight.Value.ToString());
                    tempCode = tempCode.Replace("#DisplayWidth#", admodel.DisplayWidth.Value.ToString());
                    tempCode = tempCode.Replace("#DisplayPrickle#", admodel.DisplayPrickle);

                    tempCodeSB.Append(tempCode);
                }

                templatecode = templatecode.Replace(Ptempstr, tempCodeSB.ToString());
            }

            templatecode = templatecode.Replace("#ADControlID#", ADControlID);
            templatecode = templatecode.Replace("#DisplayHeight#", admodel.DisplayHeight.Value.ToString());
            templatecode = templatecode.Replace("#DisplayWidth#", admodel.DisplayWidth.Value.ToString());
            templatecode = templatecode.Replace("#DisplayPrickle#", admodel.DisplayPrickle);


            //if (IsLoadCommonCSSAndJsCode)
            //{
            //    templatecode = string.Format("{0} \n {1} \n {2}",addmModel.CSSCode,addmModel.JsCode,templatecode);
            //}

            //if (ViewState[admodel.ADDisplayModeCode] == null)
            //{


            //    ViewState[admodel.ADDisplayModeCode] = "true";
            //}


            return(templatecode);
        }