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 string GetTitle(string adsId) { IList <SiteAdsInfo> list = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == adsId).ToList(); if (list.Count == 0) { return(""); } //return ""; return(list[0].AdsPosition);// }
protected string GetSite(string adsId) { IList <SiteAdsInfo> list = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == adsId).ToList(); if (list.Count == 0) { return(""); } //return ""; return(CacheCollection.GetAllSiteList().Where(o => o.SiteId == list[0].SiteId).ToList()[0].SiteName); }
protected string GetSize(string adsId) { IList <SiteAdsInfo> list = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id.ToString() == adsId).ToList(); if (list.Count == 0) { return(""); } IList <AdsInfo> alist = CacheCollection.GetAllAdsInfo().Where(o => o.AdsId == list[0].AdsId).ToList(); if (alist.Count == 0) { return(""); } return(alist[0].AdsSize); }
protected void RPT_AdsList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Up") { SiteAdsInfo info = CacheCollection.GetAllSiteAdsInfo().Where(o => o.Id == new Guid(e.CommandArgument.ToString())).ToList()[0]; TB_AdsName.Text = info.AdsPosition; DDL_AdsList.SelectedValue = info.AdsId.ToString(); TB_PostCode.Text = info.PositionCode.ToString(); TB_Count.Text = info.AdsCount.ToString(); BTN_Up.Visible = true; BTN_Add.Visible = false; ViewState["siteadsId"] = info.Id; } if (e.CommandName == "De") { adsSiteDal.DeleteAds(new Guid(e.CommandArgument.ToString())); CacheCollection.RemoveCacheByKey(CacheCollection.KEY_ALLADSINFO); Response.Redirect("AddAds.aspx?siteid=" + (string.IsNullOrEmpty(Request.QueryString["siteid"]) ? DDL_SiteList.SelectedValue : Request.QueryString["siteid"])); } }
protected void DDL_AdsType_TextChanged(object sender, EventArgs e) { if (DDL_App.SelectedValue == Guid.Empty.ToString()) { return; } if (DDL_AdsType.SelectedValue == Guid.Empty.ToString()) { return; } if (DDL_AdsType.SelectedItem.Text == "瀑布流广告") { DDL_Position.DataSource = CacheCollection.GetAllSiteAdsInfo().Where(o => o.SiteId.ToString() == DDL_App.SelectedValue).Where(o => o.PositionCode == 6 || o.PositionCode == 7).ToList(); } if (DDL_AdsType.SelectedItem.Text == "首页切换大广告") { DDL_Position.DataSource = CacheCollection.GetAllSiteAdsInfo().Where(o => o.SiteId.ToString() == DDL_App.SelectedValue).Where(o => o.PositionCode == 0 && o.AdsPosition == "首页头部").ToList(); } if (DDL_AdsType.SelectedItem.Text == "首页大图") { DDL_Position.DataSource = CacheCollection.GetAllSiteAdsInfo().Where(o => o.SiteId.ToString() == DDL_App.SelectedValue).Where(o => o.PositionCode == 0 && o.AdsPosition == "首页中部").ToList(); } if (DDL_AdsType.SelectedItem.Text == "分类页切换大广告") { DDL_Position.DataSource = CacheCollection.GetAllSiteAdsInfo().Where(o => o.SiteId.ToString() == DDL_App.SelectedValue).Where(o => o.PositionCode > 0 && o.PositionCode < 6 && o.AdsPosition.Contains("头部")).ToList(); } if (DDL_AdsType.SelectedItem.Text == "分类页大图") { DDL_Position.DataSource = CacheCollection.GetAllSiteAdsInfo().Where(o => o.SiteId.ToString() == DDL_App.SelectedValue).Where(o => o.PositionCode > 0 && o.PositionCode < 6 && o.AdsPosition.Contains("中部")).ToList(); } DDL_Position.DataTextField = "AdsPosition"; DDL_Position.DataValueField = "Id"; DDL_Position.DataBind(); }
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 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"); }