Пример #1
0
        public M_Advertisement GetModelFromReader(DataRow rdr)
        {
            M_Advertisement model = new M_Advertisement();

            model.ADID        = Convert.ToInt32(rdr["ADID"]);
            model.UserID      = Convert.ToInt32(rdr["UserID"]);
            model.ADType      = ConvertToInt(rdr["ADType"]);
            model.ADName      = ConverToStr(rdr["ADName"]);
            model.ImgUrl      = ConverToStr(rdr["ImgUrl"]);
            model.ImgWidth    = ConverToStr(rdr["ImgWidth"]);
            model.ImgHeight   = ConverToStr(rdr["ImgHeight"]);
            model.FlashWmode  = ConvertToInt(rdr["FlashWmode"]);
            model.ADIntro     = ConverToStr(rdr["ADIntro"]);
            model.LinkUrl     = ConverToStr(rdr["LinkUrl"]);
            model.LinkTarget  = ConvertToInt(rdr["LinkTarget"]);
            model.LinkAlt     = ConverToStr(rdr["LinkAlt"]);
            model.Priority    = ConvertToInt(rdr["Priority"]);
            model.Setting     = ConverToStr(rdr["Setting"]);
            model.CountView   = Convert.ToBoolean(rdr["CountView"]);
            model.Views       = ConvertToInt(rdr["Views"]);
            model.CountClick  = ConverToBool(rdr["CountClick"]);
            model.Clicks      = ConvertToInt(rdr["Clicks"]);
            model.Passed      = ConverToBool(rdr["Passed"]);
            model.OverdueDate = ConvertToDate(rdr["OverdueDate"]);
            model.ImgUrl1     = ConverToStr(rdr["ImgUrl1"]);
            model.ImgHeight1  = ConverToStr(rdr["ImgHeight1"]);
            model.ImgWidth1   = ConverToStr(rdr["ImgWidth1"]);
            model.LinkUrl1    = ConverToStr(rdr["LinkUrl1"]);
            model.LinkTarget1 = ConvertToInt(rdr["LinkTarget1"]);
            model.LinkAlt1    = ConverToStr(rdr["LinkAlt1"]);
            model.ADIntro1    = ConverToStr(rdr["ADIntro1"]);
            model.FlashWmode1 = ConvertToInt(rdr["FlashWmode1"]);
            return(model);
        }
Пример #2
0
        public override SqlParameter[] GetParameters()
        {
            M_Advertisement model = this;

            SqlParameter[] sp = GetSP();
            sp[0].Value  = model.ADID;
            sp[1].Value  = model.UserID;
            sp[2].Value  = model.ADType;
            sp[3].Value  = model.ADName;
            sp[4].Value  = model.ImgUrl;
            sp[5].Value  = model.ImgWidth;
            sp[6].Value  = model.ImgHeight;
            sp[7].Value  = model.FlashWmode;
            sp[8].Value  = model.ADIntro;
            sp[9].Value  = model.LinkUrl;
            sp[10].Value = model.LinkTarget;
            sp[11].Value = model.LinkAlt;
            sp[12].Value = model.Priority;
            sp[13].Value = model.Setting;
            sp[14].Value = model.CountView;
            sp[15].Value = model.Views;
            sp[16].Value = model.CountClick;
            sp[17].Value = model.Clicks;
            sp[18].Value = model.Passed;
            sp[19].Value = model.OverdueDate;
            sp[20].Value = model.ImgUrl1;
            sp[21].Value = model.ImgHeight1;
            sp[22].Value = model.ImgWidth1;
            sp[23].Value = model.LinkUrl1;
            sp[24].Value = model.LinkTarget1;
            sp[25].Value = model.LinkAlt1;
            sp[26].Value = model.ADIntro1;
            sp[27].Value = model.FlashWmode1;
            return(sp);
        }
Пример #3
0
 /// <summary>
 /// 创建广告版位JS
 /// </summary>
 /// <param name="adZoneInfo"></param>
 /// <param name="advertisementInfoList"></param>
 public void CreateJS(M_Adzone adZoneInfo, IList<M_Advertisement> advertisementInfoList)
 {
     //将当前版位对象设置为要操作的版位对象
     this.zoneInfo = adZoneInfo;
     //读取模板基本代码
     StringBuilder builder = new StringBuilder(this.GetZoneJSTemplate());
     //定义版位对象
     builder.Append("var ZoneAD_" + adZoneInfo.ZoneID + "=new ");
     builder.Append(string.Concat(new object[] { this.zoneConfig[adZoneInfo.ZoneType], "ZoneAD(\"ZoneAD_", adZoneInfo.ZoneID, "\");" }));
     //将广告对象定义加入到JS代码中
     for (int i = 0; i < advertisementInfoList.Count; i++)
     {
         this.advertisementInfo = advertisementInfoList[i];
         this.advertisementInfo.ZoneID = adZoneInfo.ZoneID;
         if (this.advertisementInfo.Passed && (this.advertisementInfo.Days >= 0))
         {
             builder.Append(this.CreatAdvertisementJS());
         }
     }
     //加入版位属性定义
     builder.Append(this.CreateADZoneJS());
     FileSystemObject.WriteFile(VirtualPathUtility.AppendTrailingSlash(HttpContext.Current.Server.MapPath("~/" + SiteConfig.SiteOption.AdvertisementDir)) + adZoneInfo.ZoneJSName, builder.ToString());
 }
Пример #4
0
 /// <summary>
 /// 添加广告
 /// </summary>
 /// <param name="Advertisement"></param>
 /// <param name="StrZoneID"></param>
 /// <returns></returns>
 public bool Advertisement_Add(M_Advertisement Advertisement)
 {
     SqlParameter[] parameter = this.GetParameter(Advertisement);
     return (SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "dt_Advertisement_Add", parameter)>0);
 }
Пример #5
0
 private M_Advertisement GetInfoFromReader(SqlDataReader rdr)
 {
     M_Advertisement info = new M_Advertisement();
     info.AdId = DataConverter.CLng(rdr["ADID"]);
     info.UserId = DataConverter.CLng(rdr["UserID"]);
     info.AdType = DataConverter.CLng(rdr["ADType"]);
     info.AdName = rdr["ADName"].ToString();
     info.ImgUrl = rdr["ImgUrl"].ToString();
     info.ImgWidth = DataConverter.CLng(rdr["ImgWidth"]);
     info.ImgHeight = DataConverter.CLng(rdr["ImgHeight"]);
     info.FlashWmode = DataConverter.CLng(rdr["FlashWmode"]);
     info.ADIntro = rdr["ADIntro"].ToString();
     info.LinkUrl = rdr["LinkUrl"].ToString();
     info.LinkTarget = DataConverter.CLng(rdr["LinkTarget"]);
     info.LinkAlt = rdr["LinkAlt"].ToString();
     info.Priority = DataConverter.CLng(rdr["Priority"]);
     info.Setting = rdr["Setting"].ToString();
     info.CountView = DataConverter.CBool(rdr["CountView"].ToString());
     info.Views = DataConverter.CLng(rdr["Views"]);
     info.CountClick = DataConverter.CBool(rdr["CountClick"].ToString());
     info.Clicks = DataConverter.CLng(rdr["Clicks"]);
     info.Passed = DataConverter.CBool(rdr["Passed"].ToString());
     info.OverdueDate = DataConverter.CDate(rdr["OverdueDate"]);
     return info;
 }
Пример #6
0
        private SqlParameter[] GetParameter(M_Advertisement adv)
        {
            SqlParameter[] sp = new SqlParameter[] {
                new SqlParameter("@ADID", SqlDbType.Int),
                new SqlParameter("@UserID",SqlDbType.Int),
                new SqlParameter("@ADType",SqlDbType.Int),
                new SqlParameter("@ADName",SqlDbType.NVarChar,100),
                new SqlParameter("@ImgUrl",SqlDbType.NVarChar,255),
                new SqlParameter("@ImgWidth",SqlDbType.Int),
                new SqlParameter("@ImgHeight",SqlDbType.Int),
                new SqlParameter("@FlashWmode",SqlDbType.Int),
                new SqlParameter("@ADIntro",SqlDbType.NText),
                new SqlParameter("@LinkUrl",SqlDbType.NVarChar,255),
                new SqlParameter("@LinkTarget",SqlDbType.Int),
                new SqlParameter("@LinkAlt",SqlDbType.NVarChar,255),
                new SqlParameter("@Priority",SqlDbType.Int),
                new SqlParameter("@Setting",SqlDbType.NText),
                new SqlParameter("@CountView",SqlDbType.Bit),
                new SqlParameter("@Views",SqlDbType.Int),
                new SqlParameter("@CountClick",SqlDbType.Bit),
                new SqlParameter("@Clicks",SqlDbType.Int),
                new SqlParameter("@Passed",SqlDbType.Int),
                new SqlParameter("@OverdueDate",SqlDbType.DateTime)
            };

            sp[0].Value = adv.AdId;
            sp[1].Value = adv.UserId;
            sp[2].Value = adv.AdType;
            sp[3].Value = adv.AdName;
            sp[4].Value = adv.ImgUrl;
            sp[5].Value = adv.ImgWidth;
            sp[6].Value = adv.ImgHeight;
            sp[7].Value = adv.FlashWmode;
            sp[8].Value = adv.ADIntro;
            sp[9].Value = adv.LinkUrl;
            sp[10].Value = adv.LinkTarget;
            sp[11].Value = adv.LinkAlt;
            sp[12].Value = adv.Priority;
            sp[13].Value = adv.Setting;
            sp[14].Value = adv.CountView;
            sp[15].Value = adv.Views;
            sp[16].Value = adv.CountClick;
            sp[17].Value = adv.Clicks;
            sp[18].Value = adv.Passed;
            sp[19].Value = adv.OverdueDate;
            return sp;
        }
Пример #7
0
        protected void EBtnSubmit_Click(object sender, EventArgs e)
        {
            string adZoneIdList = this.GetAdZoneIdList();
            if (this.Page.IsValid)
            {
                M_Advertisement adv = new M_Advertisement();
                adv.UserId = 0;
                adv.AdName = DataSecurity.HtmlEncode(this.TxtADName.Text.Trim());
                adv.AdType = DataConverter.CLng(this.RadlADType.SelectedValue);
                adv.Priority = DataConverter.CLng(this.TxtPriority.Text.Trim());
                adv.Passed = this.ChkPassed.Checked;
                adv.CountView = this.ChkCountView.Checked;
                adv.Views = DataConverter.CLng(this.TxtViews.Text.Trim());
                adv.CountClick = this.ChkCountClick.Checked;
                adv.Clicks = DataConverter.CLng(this.TxtClicks.Text.Trim());
                //adv.ZoneID = adZoneIdList;
                adv.AdId = DataConverter.CLng(this.HdnID.Value.Trim());
                adv.OverdueDate = DataConverter.CDate(this.txtOverdueDate.Text);
                adv.Setting = "";
                switch (adv.AdType)
                {
                    case 1:
                    {
                        adv.ImgUrl = this.txtpic.Text.Trim();
                        if (string.IsNullOrEmpty(adv.ImgUrl))
                        {
                            function.WriteErrMsg("图片广告的图片地址不能为空!");
                        }
                        adv.ImgHeight = DataConverter.CLng(this.TxtImgHeight.Text.Trim());
                        adv.ImgWidth = DataConverter.CLng(this.TxtImgWidth.Text.Trim());
                        string str2 = this.TxtLinkUrl.Text.Trim();
                        adv.LinkUrl = str2;
                        adv.LinkTarget = DataConverter.CLng(this.RadlLinkTarget.SelectedValue);
                        adv.LinkAlt = this.TxtLinkAlt.Text.Trim();
                        adv.ADIntro = this.TxtADIntro.Text.Trim();
                        break;
                    }
                    case 2:
                        adv.ImgUrl = this.txtFlashPath.Text.Trim();
                        if (string.IsNullOrEmpty(adv.ImgUrl))
                        {
                            function.WriteErrMsg("动画广告的Flash地址不能为空");
                        }
                        adv.ImgHeight = DataConverter.CLng(this.TxtFlashHeight.Text.Trim());
                        adv.ImgWidth = DataConverter.CLng(this.TxtFlashWidth.Text.Trim());
                        adv.FlashWmode = DataConverter.CLng(this.RadlFlashMode.SelectedValue);
                        break;

                    case 3:
                        adv.ADIntro = this.TxtADText.Text.Trim();
                        break;

                    case 4:
                        adv.ADIntro = this.TxtADCode.Text.Trim();
                        break;

                    case 5:
                        adv.ADIntro = this.TxtWebFileUrl.Text.Trim();
                        break;
                }
                bool flag = false;
                if (adv.AdId>0)
                {
                    flag=B_Advertisement.Advertisement_Update(adv);
                }
                else
                {
                    adv.AdId = B_Advertisement.MaxID();
                    flag = B_Advertisement.Advertisement_Add(adv);
                }
                if (flag)
                {
                    int zid = 0;
                    if (!string.IsNullOrEmpty(adZoneIdList))
                    {
                        string[] arr = adZoneIdList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        for (int s = 0; s < arr.Length; s++)
                        {
                            zid = DataConverter.CLng(arr[s]);
                            if (!B_Advertisement.IsExistZoneAdv(zid, adv.AdId))
                                B_Advertisement.Add_Zone_Advertisement(zid, adv.AdId);
                        }
                        B_ADZone.CreateJS(adZoneIdList);
                    }
                    Response.Write("<script>alert('广告信息保存成功!');window.document.location.href='ADManage.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('广告信息保存失败!');</script>");
                }
            }
        }
Пример #8
0
        private void InitShowPanel(M_Advertisement adv)
        {
            switch (adv.AdType)
            {
                case 1:
                    this.ADContent1.Attributes.Add("style", "display: ");
                    this.txtpic.Text = adv.ImgUrl;
                    this.TxtImgWidth.Text = adv.ImgWidth.ToString();
                    this.TxtImgHeight.Text = adv.ImgHeight.ToString();
                    this.TxtLinkUrl.Text = adv.LinkUrl;
                    this.TxtLinkAlt.Text = adv.LinkAlt;
                    this.RadlLinkTarget.SelectedValue= adv.LinkTarget.ToString();
                    this.TxtADIntro.Text = adv.ADIntro;
                    return;

                case 2:
                    this.ADContent2.Attributes.Add("style", "display: ");
                    this.txtFlashPath.Text = adv.ImgUrl;
                    this.TxtFlashWidth.Text = adv.ImgWidth.ToString();
                    this.TxtFlashHeight.Text = adv.ImgHeight.ToString();
                    this.RadlFlashMode.SelectedValue= adv.FlashWmode.ToString();
                    return;

                case 3:
                    this.ADContent3.Attributes.Add("style", "display: ");
                    this.TxtADText.Text = adv.ADIntro;
                    return;

                case 4:
                    this.ADContent4.Attributes.Add("style", "display: ");
                    this.TxtADCode.Text = adv.ADIntro;
                    return;

                case 5:
                    this.ADContent5.Attributes.Add("style", "display: ");
                    this.TxtWebFileUrl.Text = adv.ADIntro;
                    return;
            }
            this.ADContent1.Attributes.Add("style", "display: ");
        }
Пример #9
0
 /// <summary>
 /// 添加广告
 /// </summary>
 /// <param name="Advertisement"></param>
 /// <returns></returns>
 public static bool Advertisement_Add(M_Advertisement Advertisement)
 {
     return advertisement.Advertisement_Add(Advertisement);
 }
Пример #10
0
        public static string GetAdContent(M_Advertisement advertisementInfo)
        {
            StringBuilder builder2;
            StringBuilder builder = new StringBuilder();
            switch (advertisementInfo.AdType)
            {
                case 1:
                    {
                        builder2 = new StringBuilder();
                        builder2.Append("<img src=\"");
                        string imgUrl = advertisementInfo.ImgUrl;
                        if (((!imgUrl.StartsWith("/") && !imgUrl.StartsWith("~/")) && !imgUrl.StartsWith("http", StringComparison.CurrentCultureIgnoreCase)) && !imgUrl.StartsWith("https", StringComparison.CurrentCultureIgnoreCase))
                        {
                            builder2.Append(VirtualPathUtility.AppendTrailingSlash(HttpContext.Current.Request.ApplicationPath));
                            //builder2.Append(VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir));
                            builder2.Append(imgUrl);
                            break;
                        }
                        builder2.Append(imgUrl);
                        break;
                    }
                case 2:
                    builder.Append("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"");
                    if (advertisementInfo.ImgWidth > 0)
                    {
                        builder.Append(" width=\"");
                        builder.Append(advertisementInfo.ImgWidth);
                        builder.Append("\"");
                    }
                    if (advertisementInfo.ImgHeight > 0)
                    {
                        builder.Append("  height=\"");
                        builder.Append(advertisementInfo.ImgHeight);
                        builder.Append("\"");
                    }
                    builder.Append("><param name=\"movie\" value=\"");
                    builder.Append(VirtualPathUtility.AppendTrailingSlash(HttpContext.Current.Request.ApplicationPath));
                    builder.Append(advertisementInfo.ImgUrl);
                    builder.Append("\">");
                    if (advertisementInfo.FlashWmode == 1)
                    {
                        builder.Append("<param name=\"wmode\" value=\"transparent\">");
                    }
                    builder.Append("<param name=\"quality\" value=\"autohigh\">");
                    builder.Append("<embed src=\"");
                    builder.Append(VirtualPathUtility.AppendTrailingSlash(HttpContext.Current.Request.ApplicationPath));
                    //builder.Append(VirtualPathUtility.AppendTrailingSlash(SiteConfig.SiteOption.UploadDir));
                    builder.Append(advertisementInfo.ImgUrl);
                    builder.Append("\" quality=\"autohigh\"  pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"");
                    if (advertisementInfo.FlashWmode == 1)
                    {
                        builder.Append(" wmode=\"transparent\" ");
                    }
                    if (advertisementInfo.ImgWidth > 0)
                    {
                        builder.Append(" width=\"");
                        builder.Append(advertisementInfo.ImgWidth);
                        builder.Append("\"");
                    }
                    if (advertisementInfo.ImgHeight > 0)
                    {
                        builder.Append("  height=\"");
                        builder.Append(advertisementInfo.ImgHeight);
                        builder.Append("\"");
                    }
                    builder.Append("></embed></object>");
                    goto Label_04B5;

                case 3:
                    builder.Append(advertisementInfo.ADIntro);
                    goto Label_04B5;

                case 4:
                    builder.Append(advertisementInfo.ADIntro);
                    goto Label_04B5;

                case 5:
                    builder.Append("<iframe id=\"AD_");
                    builder.Append(advertisementInfo.AdId);
                    builder.Append("\" marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no width=100% height=100% src=\"");
                    builder.Append(advertisementInfo.ADIntro);
                    builder.Append("\">AD</iframe>");
                    goto Label_04B5;

                default:
                    goto Label_04B5;
            }
            builder2.Append("\"");
            if (advertisementInfo.ImgWidth > 0)
            {
                builder2.Append(" width=\"");
                builder2.Append(advertisementInfo.ImgWidth);
                builder2.Append("\"");
            }
            if (advertisementInfo.ImgHeight > 0)
            {
                builder2.Append("  height=\"");
                builder2.Append(advertisementInfo.ImgHeight);
                builder2.Append("\"");
            }
            builder2.Append(" border=\"0\"></img>");
            if (!string.IsNullOrEmpty(advertisementInfo.LinkUrl))
            {
                builder.Append("<a href=\"");
                builder.Append(advertisementInfo.LinkUrl);
                builder.Append("\"");
                if (advertisementInfo.LinkTarget == 0)
                {
                    builder.Append(" target=\"_self\"");
                }
                else
                {
                    builder.Append(" target=\"_blank\"");
                }
                builder.Append(" title=\"");
                builder.Append(advertisementInfo.LinkAlt);
                builder.Append("\"");
                builder.Append(">");
                builder.Append(builder2.ToString());
                builder.Append("</a>");
            }
            else
            {
                builder = builder2;
            }
            Label_04B5:
            return builder.ToString();
        }
Пример #11
0
 /// <summary>
 /// 修改广告
 /// </summary>
 /// <param name="Advertisement"></param>
 /// <returns></returns>
 public static bool Advertisement_Update(M_Advertisement Advertisement)
 {
     return advertisement.Advertisement_Update(Advertisement);
 }