protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["adsid"])) { IList <SiteAdsInfo> list = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == Request.QueryString["adsid"]).ToList(); if (list.Count > 0) { SiteAdsInfo info = list[0]; IList <SiteInfo> sitelist = CacheCollection.GetAllSiteList().Where(o => o.SiteId == info.SiteId).ToList(); Lbl_AppName.Text = sitelist[0].SiteName; if (info.AdsPosition == "最新" || info.AdsPosition == "热卖") { Lbl_show.Text = "点击"; } else { Lbl_show.Text = "在"; } Lbl_AdsPosition.Text = info.AdsPosition; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { RPT_SiteList.DataSource = CacheCollection.GetAllSiteList(); RPT_SiteList.DataBind(); } }
protected string GetSite(string adsId) { IList <AdsInfo> list = CacheCollection.GetAllAdsInfo().Where(o => o.AdsId.ToString() == adsId).ToList(); if (list.Count == 0) { return(""); } return(CacheCollection.GetAllSiteList().Where(o => o.SiteId == list[0].SiteId).ToList()[0].SiteUrl); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string nick = ""; if (Request.Cookies["nick"] != null) { nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); //"nick"; } else { nick = Session["snick"].ToString(); } if (nick == "") { Response.Write("请重新登录"); return; } DDL_App.DataSource = CacheCollection.GetAllSiteList(); DDL_App.DataTextField = "SiteName"; DDL_App.DataValueField = "SiteId"; DDL_AdsType.DataSource = CacheCollection.GetAllAdsInfo(); DDL_AdsType.DataTextField = "AdsName"; DDL_AdsType.DataValueField = "AdsId"; DDL_App.DataBind(); DDL_App.Items.Insert(0, new ListItem("请选择", Guid.Empty.ToString())); DDL_AdsType.DataBind(); DDL_AdsType.Items.Insert(0, new ListItem("请选择", Guid.Empty.ToString())); IList <CateInfo> cateList = new CateService().SelectAllCateByNick(nick); DDL_GoodsClass.DataSource = cateList; DDL_GoodsClass.DataTextField = "CateName"; DDL_GoodsClass.DataValueField = "CateId"; DDL_GoodsClass.DataBind(); DDL_GoodsClass.Items.Insert(0, new ListItem("全部", "0")); //IList<GoodsInfo> list = goodsDal.SelectAllGoodsByNick(nick); //Rpt_GoodsList.DataSource = list; //Rpt_GoodsList.DataBind(); if (string.IsNullOrEmpty(Request.QueryString["start"])) { Bind(Request.QueryString["goods"], Request.QueryString["gclass"], DateTime.MinValue, DateTime.MinValue); } else { Bind(Request.QueryString["goods"], Request.QueryString["gclass"], DateTime.Parse(Request.QueryString["start"]), DateTime.Parse(Request.QueryString["end"])); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string nick = ""; if (Request.Cookies["nick"] != null) { nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); //"nick"; } else { nick = Session["snick"].ToString(); } if (nick == "") { Response.Write("请重新登录"); return; } DDL_App.DataSource = CacheCollection.GetAllSiteList(); DDL_App.DataTextField = "SiteName"; DDL_App.DataValueField = "SiteId"; DDL_AdsType.DataSource = CacheCollection.GetAllAdsInfo(); DDL_AdsType.DataTextField = "AdsName"; DDL_AdsType.DataValueField = "AdsId"; DDL_App.DataBind(); DDL_App.Items.Insert(0, new ListItem("请选择", Guid.Empty.ToString())); DDL_AdsType.DataBind(); DDL_AdsType.Items.Insert(0, new ListItem("请选择", Guid.Empty.ToString())); TaoBaoShopInfo info = new ShopService().SelectShopByNick(nick); ViewState["shopcid"] = "50023878"; if (info != null) { ViewState["shopcid"] = info.CateId; TB_ShppName.Text = info.Name; TB_Description.Text = info.Description; TB_ShowUrl.Text = "http://shop" + info.ShopId + ".taobao.com/"; ViewState["logourl"] = " http://logo.taobao.com/shop-logo" + info.ShopLogo; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!string.IsNullOrEmpty(Request.QueryString["adsid"])) { IList <AdsInfo> list = CacheCollection.GetAllAdsInfo().Where(o => o.AdsId.ToString() == Request.QueryString["adsid"]).ToList(); if (list.Count > 0) { AdsInfo info = list[0]; ViewState["ImgUrl"] = info.AdsPic; IList <SiteInfo> sitelist = CacheCollection.GetAllSiteList().Where(o => o.SiteId == info.SiteId).ToList(); LB_SiteUrl1.Text = sitelist[0].SiteUrl; ViewState["SiteUrl"] = sitelist[0].SiteUrl; } } } }
protected void BTN_Tui_Click(object sender, EventArgs e) { string nick = ""; if (Request.Cookies["nick"] != null) { nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); //"nick"; } else { nick = Session["snick"].ToString(); } if (DDL_AdsType.SelectedValue == Guid.Empty.ToString() || DDL_App.SelectedValue == Guid.Empty.ToString() || DDL_Position.SelectedValue == Guid.Empty.ToString()) { Page.RegisterStartupScript("通知", "<script>alert('请选择投放的应用,类型以及位置,请按您购买的服务类型选择!');</script>"); return; } //购买类型 IList <BuyInfo> buyList = CacheCollection.GetAllBuyInfo().Where(o => o.Nick == nick).ToList(); //投放的广告 IList <UserAdsInfo> useradsList = userAdsDal.SelectAllUserAds(nick); bool notou = true; //新的添加广告方法 if (buyList.Count > 0) { if (!buyList[0].IsExpied) { SiteAdsInfo sadsinfo = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == DDL_Position.SelectedValue).ToList()[0]; FeeInfo feeInfo = CacheCollection.GetAllFeeInfo().Where(o => o.FeeId == buyList[0].FeeId).ToList()[0]; //已经投放了的该收费类型的广告集合 IList <UserAdsInfo> myUseradsList = useradsList.Where(o => o.FeeId == feeInfo.FeeId && o.UserAdsState == 1).ToList(); int calScore = 0; calScore = feeInfo.Score; for (int i = 0; i < myUseradsList.Count; i++) { SiteAdsInfo sainfo = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id == myUseradsList[i].AdsId).ToList()[0]; calScore -= sainfo.Score; } UserAdsInfo info = new UserAdsInfo(); info.AdsTitle = TB_ShppName.Text.Trim(); info.Id = Guid.NewGuid(); info.UserAdsState = 0; info.AdsUrl = TB_ShowUrl.Text.Trim(); string cateId = ViewState["shopcid"].ToString(); TaoBaoGoodsClassInfo tcinfo = new TaoBaoGoodsClassService().SelectGoodsClass(cateId); info.CateIds = ViewState["shopcid"].ToString(); string cname = tcinfo == null ? "" : tcinfo.name; info.SellCateName = GetTaoBaoCName(info.CateIds, cname); info.AliWang = nick; info.Nick = nick; info.AdsPic = ShopImg; //店铺图标 if (FUD_Img.HasFile && CheckImg()) { Guid imgurl = Guid.NewGuid(); FUD_Img.SaveAs(Server.MapPath("~/adsimg") + "/" + imgurl + ".jpg"); info.AdsPic = "/adsimg/" + imgurl + ".jpg"; } //不能继续投放 if (calScore < sadsinfo.Score) { } //可以投放 else { if (sadsinfo.AdsCount != -1) { //这里需要查询空闲的广告(或者说是可以用的广告位) IList <UserAdsInfo> usedadsList = userAdsDal.SelectAllUsedAds(); IList <SiteAdsInfo> allads = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == DDL_Position.SelectedValue).ToList(); if (allads.Count > 0 && allads[0].AdsCalCount > 0) { info.AddTime = DateTime.Now; info.AdsId = new Guid(DDL_Position.SelectedValue); //不需要旺旺 info.AliWang = ""; //nick; info.FeeId = buyList[0].FeeId; info.AdsShowStartTime = DateTime.Now; info.AdsShowFinishTime = DateTime.Now.AddDays(feeInfo.ShowDays); info.Nick = nick; info.UserAdsState = 1; //不需要分类 //string taoId = list[i].CateIds; info.CateIds = ""; // GetTaoBaoCId(taoId, ref taoId); } else { Page.RegisterStartupScript("通知", "<script>alert('请联系我们的客服人员为您添加广告');</script>"); } } else { info.AddTime = DateTime.Now; info.AdsId = new Guid(DDL_Position.SelectedValue); info.AliWang = nick; info.FeeId = buyList[0].FeeId; info.AdsShowStartTime = DateTime.Now; info.AdsShowFinishTime = DateTime.Now.AddDays(feeInfo.ShowDays); info.Nick = nick; info.UserAdsState = 1; string taoId = info.CateIds; info.CateIds = GetTaoBaoCId(taoId, taoId); } notou = false; } string uid = CacheCollection.GetAllSiteList().Where(o => o.SiteId.ToString() == DDL_App.SelectedValue).ToList()[0].SiteUrl; int area = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == DDL_Position.SelectedValue).ToList()[0].PositionCode; int typ = 0; if (DDL_AdsType.SelectedValue == "1A4AB7A8-49A1-41FC-A5A6-788FD582DB82" || DDL_AdsType.SelectedValue == "7CE41706-582D-4270-82C4-81420F923D6A") { typ = 0; } if (DDL_AdsType.SelectedValue == "68A5E23C-6CFD-427D-BD0E-1E2B1B160875" || DDL_AdsType.SelectedValue == "C1F928EF-CA82-4FED-B960-CA33FCE417E9") { typ = 1; } if (DDL_AdsType.SelectedValue == "813F256D-D83A-43CE-8CC4-273C965DBF84") { typ = 2; } Guid ggid = Guid.Empty; if (info.AdsId != Guid.Empty) { ggid = PostIphone.InsertAds(uid, area, typ, info.AdsPic, info.AdsUrl, info.Price, info.AdsTitle); if (ggid == Guid.Empty) { Page.RegisterStartupScript("通知", "<script>alert('发送添加广告错误');</script>"); return; } userAdsDal.InsertUserAds(info, ggid); } } } //if (notou) // Response.Redirect("UserAdsList.aspx"); //else Response.Redirect("UserAdsList.aspx?istou=1"); }
protected string GetSiteName(string siteId) { return(CacheCollection.GetAllSiteList().Where(o => o.SiteId == new Guid(siteId)).ToList()[0].SiteName); }
protected void BTN_ShowGoods_Click(object sender, EventArgs e) { IList <UserAdsInfo> list = new List <UserAdsInfo>(); string nick = ""; if (Request.Cookies["nick"] != null) { nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); //"nick"; } else { nick = Session["snick"].ToString(); } if (DDL_AdsType.SelectedValue == Guid.Empty.ToString() || DDL_App.SelectedValue == Guid.Empty.ToString() || DDL_Position.SelectedValue == Guid.Empty.ToString()) { Page.RegisterStartupScript("通知", "<script>alert('请选择投放的应用,类型以及位置,请按您购买的服务类型选择!');</script>"); return; } CateService cateDal = new CateService(); IList <CateInfo> cateList = cateDal.SelectAllCateByNick(nick).ToList(); UserAdsService userAdsDal = new UserAdsService(); foreach (RepeaterItem item in Rpt_GoodsList.Items) { CheckBox cb = (CheckBox)item.FindControl("CBOX_Goods"); if (cb.Checked) { UserAdsInfo info = new UserAdsInfo(); info.AdsTitle = ((Label)item.FindControl("LB_GoodsName")).Text; info.Id = Guid.NewGuid(); info.UserAdsState = 0; info.AdsUrl = "http://item.taobao.com/item.htm?id=" + ((Label)item.FindControl("LB_GoodsId")).Text; string cateId = ((Label)item.FindControl("LB_CateId")).Text; IList <CateInfo> thiscList = cateList.Where(o => o.CateId == cateId).ToList(); info.CateIds = ((Label)item.FindControl("LB_TaoBaoCId")).Text; string cname = thiscList.Count == 0 ? "" : thiscList[0].CateName; info.SellCateName = GetTaoBaoCName(info.CateIds, cname); info.AliWang = nick; info.Nick = nick; info.AdsPic = ((Label)item.FindControl("LB_Img")).Text; info.Price = decimal.Parse(((Label)item.FindControl("LB_Price")).Text); list.Add(info); } } if (list.Count == 0) { return; } SiteAdsInfo sadsinfo = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == DDL_Position.SelectedValue).ToList()[0]; int needScore = sadsinfo.Score * list.Count; //购买类型 IList <BuyInfo> buyList = CacheCollection.GetAllBuyInfo().Where(o => o.Nick == nick).ToList(); //投放的广告 IList <UserAdsInfo> useradsList = userAdsDal.SelectAllUserAds(nick); //新的添加广告方法 if (buyList.Count > 0) { if (!buyList[0].IsExpied) { FeeInfo feeInfo = CacheCollection.GetAllFeeInfo().Where(o => o.FeeId == buyList[0].FeeId).ToList()[0]; //已经投放了的该收费类型的广告集合 IList <UserAdsInfo> myUseradsList = useradsList.Where(o => o.FeeId == feeInfo.FeeId && o.UserAdsState == 1).ToList(); int calScore = 0; calScore = feeInfo.Score; for (int i = 0; i < myUseradsList.Count; i++) { SiteAdsInfo sainfo = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id == myUseradsList[i].AdsId).ToList()[0]; calScore -= sainfo.Score; } int canTou = calScore / needScore; //可以投放的个数 if (canTou > 0) { canTou = canTou > list.Count ? list.Count : canTou; } //不能继续投放 if (canTou == 0) { Page.RegisterStartupScript("通知", "<script>alert('您不能投放该类型广告');</script>"); } //可以投放 else { if (sadsinfo.AdsCount != -1) { //这里需要查询空闲的广告(或者说是可以用的广告位) IList <UserAdsInfo> usedadsList = userAdsDal.SelectAllUsedAds(); IList <SiteAdsInfo> allads = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == DDL_Position.SelectedValue).ToList(); if (allads.Count > 0 && allads[0].AdsCalCount > 0) { //可以放多少个 for (int i = 0; i < canTou; i++) { list[i].AddTime = DateTime.Now; list[i].AliWang = nick; list[i].FeeId = feeInfo.FeeId; list[i].AdsShowStartTime = DateTime.Now; list[i].AdsShowFinishTime = DateTime.Now.AddDays(feeInfo.ShowDays); list[i].Nick = nick; list[i].UserAdsState = 1; string taoId = list[i].CateIds; list[i].CateIds = GetTaoBaoCId(taoId, taoId); list[i].AdsId = new Guid(DDL_Position.SelectedValue); } } else { Page.RegisterStartupScript("通知", "<script>alert('请联系我们的客服人员为您添加广告');</script>"); } } else { //可以放多少个 for (int i = 0; i < canTou; i++) { list[i].AddTime = DateTime.Now; list[i].AliWang = nick; list[i].FeeId = feeInfo.FeeId; list[i].AdsShowStartTime = DateTime.Now; list[i].AdsShowFinishTime = DateTime.Now.AddDays(feeInfo.ShowDays); list[i].Nick = nick; list[i].UserAdsState = 1; string taoId = list[i].CateIds; list[i].CateIds = GetTaoBaoCId(taoId, taoId); list[i].AdsId = new Guid(DDL_Position.SelectedValue); } } } } } string uid = CacheCollection.GetAllSiteList().Where(o => o.SiteId.ToString() == DDL_App.SelectedValue).ToList()[0].SiteUrl; int area = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == DDL_Position.SelectedValue).ToList()[0].PositionCode; int typ = 0; if (DDL_AdsType.SelectedValue.ToLower() == "1A4AB7A8-49A1-41FC-A5A6-788FD582DB82".ToLower() || DDL_AdsType.SelectedValue.ToLower() == "7CE41706-582D-4270-82C4-81420F923D6A".ToLower()) { typ = 0; } if (DDL_AdsType.SelectedValue.ToLower() == "68A5E23C-6CFD-427D-BD0E-1E2B1B160875".ToLower() || DDL_AdsType.SelectedValue.ToLower() == "C1F928EF-CA82-4FED-B960-CA33FCE417E9".ToLower()) { typ = 1; } if (DDL_AdsType.SelectedValue.ToLower() == "813F256D-D83A-43CE-8CC4-273C965DBF84".ToLower()) { typ = 2; } foreach (UserAdsInfo info in list) { Guid ggid = info.Id; if (info.AdsId != Guid.Empty) { ggid = PostIphone.InsertAds(uid, area, typ, info.AdsPic, info.AdsUrl, info.Price, info.AdsTitle); if (ggid == Guid.Empty) { Page.RegisterStartupScript("通知", "<script>alert('发送添加广告错误');</script>"); continue; } userAdsDal.InsertUserAds(info, ggid); } } Response.Redirect("UserAdsList.aspx?istou=1"); }