コード例 #1
0
ファイル: click.aspx.cs プロジェクト: TheProjecter/wgiadunion
    protected void Page_Load(object sender, EventArgs e)
    {
        //预览链接不操作
        if (Request["preview"] == "1")
        {
            Response.Write("测试成功!请拷贝广告代码至自己的网站合适的位置。");
            return;
        }

        //step1:得到用户id,用户网站id,广告id,广告主id,广告类型,付费类型
        int shopid, adid, siteid, userid, paytype, adtype;
        if (int.TryParse(Request["shopid"], out shopid) && int.TryParse(Request["adid"], out adid) && int.TryParse(Request["userid"], out userid) && int.TryParse(Request["siteid"], out siteid) && int.TryParse(Request["paytype"], out paytype) && int.TryParse(Request["adtype"], out adtype))
        {
            //写入数据库
            wgiAdUnionSystem.Model.wgi_adv_statis model = new wgiAdUnionSystem.Model.wgi_adv_statis();
            model.advid = adid;
            model.advtype = paytype;//广告类型即为付费类型,而不是文字、图片之类的类型
            model.companyid = shopid;
            model.ip = CommonData.GetIp(this.Page);
            model.recordtime = DateTime.Now;
            model.siteid = siteid;
            model.statistype = 2;//1表示点击数
            model.userid = userid;

            try
            {
                new wgiAdUnionSystem.BLL.wgi_adv_statis().Add(model);
            }
            catch (Exception)
            {
                //throw:
            }

            finally
            {
                //本次点击重定向到广告主自设的cookie记录页,并传过去从广告ID得到的广告地址
                string adurl = new wgiAdUnionSystem.BLL.wgi_adv().GetModel(adid).advlink;
                string destination = new wgiAdUnionSystem.BLL.wgi_adhost().GetModel(shopid).cookiepage;

                destination += "?union=wgiadunion&siteid=" + siteid + "&userid=" + userid + "&shopid=" + shopid + "&url=" + adurl;
                Response.Clear();
                Response.Redirect(destination);
                Response.End();
            }
        }
        else
        {
            Response.Redirect("/member/default.aspx");
        }
    }
コード例 #2
0
ファイル: adnew.aspx.cs プロジェクト: TheProjecter/wgiadunion
    //保存广告内容
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        wgiAdUnionSystem.BLL.wgi_adv badv = new wgiAdUnionSystem.BLL.wgi_adv();
        wgiAdUnionSystem.Model.wgi_adv madv = new wgiAdUnionSystem.Model.wgi_adv();
        madv.companyid = base.companyid;
        //广告参数
        madv.advname = txtname.Text;//关键描述
        madv.advstart = Helper.HelperDateTime.InputDateTime(txtbegin.Text);//开始时间
        madv.advend = Helper.HelperDateTime.InputDateTime(txtend.Text);//截止时间
        madv.advuptime = DateTime.Now;//添加时间
        madv.advpaytype = Helper.HelperDigit.ConvertToInt32(ddlPayType.SelectedValue, 1);//付费类型
        madv.advtype = Helper.HelperDigit.ConvertToInt32(ddlDisplayType.SelectedValue, 1);//显示类型

        madv.advstatus = 1;//默认审核通过
        madv.advinvalid = 1;//默认投放状态

        switch (madv.advtype)
        {
            case 1://文字广告
                madv.advlink = txtUrl.Text;
                madv.advcont = txtTilte.Text;
                break;
            case 2://图片广告
                madv.advlink = txtPicUrl.Text;
                if (ddlChange.SelectedIndex == 0)//外部地址
                {
                    madv.advcont = txtRemotePic.Text;
                }
                else
                {
                    //madv.advcont =fupload.s //上传图片地址
                }
                break;
            case 3://FLASH广告
                madv.advlink = txtSwfUrl.Text;

                if (ddlFlash.SelectedIndex == 0)//外部地址
                {
                    madv.advcont = txtRemoteSwf.Text;
                }
                else
                {
                    //madv.advcont =fupload.s //上传FLASH地址
                }

                break;
        }
        try
        {
            //新增一条广告资源
            int advid = badv.Add(madv);

            if (advid > 0)
            {
                Response.Redirect("adlist.aspx");
            }
            else
            {
                lblmsg.Text = "保存操作失败!";
            }
        }
        catch (Exception E)
        {
            lblmsg.Text = E.Message;
        }
    }
コード例 #3
0
    protected void genCode(object sender, EventArgs e)
    {
        if (ddlsite.SelectedIndex == 0)
        {
            this.lbltest.Text = "<b>请先选择网站!</b><br />";
            this.txtgcode.Text = "";
            return;
        }
        validateMember userobj = MasterPageOpration.getMasterControl(this.Page.Master, "Muser");

        //生成广告代码
        string ad = hidadid.Value;
        string adhost=hidadhost.Value;
        string site = ddlsite.SelectedValue;// userobj.siteid;
        string uname=userobj.suser.userid.ToString();
        int adtype = 0;
        int paytype = 0;
        try  //假如不带参数过来,int.Parse会抛错,正好利用它判断是否正常访问本页
        {
            adtype = int.Parse(hidadtype.Value);
            paytype = int.Parse(hidpaytype.Value);
        }
        catch (Exception)
        {
            Response.Redirect("/member/default.aspx");
        }

        Uri thisurl = Request.Url;
        //thisurl = thisurl.Remove(thisurl.IndexOf('?'));
        string port = thisurl.Port == 80 ? "" : (":" + thisurl.Port.ToString());
        string url = "http://" + thisurl.Host + port + "/click/click.aspx";
        string urlparams = "?shopid=" + adhost + "&adid=" + ad + "&siteid=" + site + "&userid=" + uname + "&paytype=" + paytype;
        url += urlparams;

        string url_ctr = "http://" + thisurl.Host + port + "/click/";

        wgiAdUnionSystem.BLL.wgi_adv bll = new wgi_adv();
        wgiAdUnionSystem.Model.wgi_adv model = bll.GetModel(int.Parse(ad));
        string adcont = model.advcont;

        //计费模式
        switch (paytype)
        {
            case 1:
                //广告类型
                switch (adtype)
                {
                    case 1:
                        url += "&adtype=1";
                        //预览
                        this.lbltest.Text = "<a href=\"" + url + "&preview=1" + "\" target=\"_blank\">" + adcont + "</a>";
                        url = "<a href=\""+url+"\" target=\"_blank\">"+adcont+"</a>";
                        break;
                    case 2:
                        url += "&adtype=2";
                        //取出图片预设宽高
                        string w = model.advwidth.ToString();
                        string h = model.advheight.ToString();
                        //预览
                        this.lbltest.Text = "<a href=\"" + url + "&preview=1" + "\" target=\"_blank\"><img src=\"" + adcont + "\" alt=\"\" style=\"border:none; width:"+w+"px; height:"+h+"px\" /></a>";
                        url = "<a href=\"" + url + "\" target=\"_blank\"><img src=\"" + adcont + "\" alt=\"\" style=\"border:none; width:" + w + "px; height:" + h + "px\" /></a>";
                        break;
                    case 3:
                        break;
                    default:
                        break;
                }
                break;
            case 2:
                break;
            case 3:
                break;
            case 4:
                break;
            default:
                break;
        }
        //接上统计露出数字串
        url += "<img src='http://" + thisurl.Host + port + "/click/showCtr.aspx" + urlparams + "&adtype=" + adtype + "' alt='' style='display:none;' />";
        this.txtgcode.Text = url;
    }