protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DDL_SiteList.DataSource = adsSiteDal.SelectAllSite(); DDL_SiteList.DataValueField = "SiteId"; DDL_SiteList.DataTextField = "SiteName"; DDL_SiteList.DataBind(); DDL_SiteList.Items.Insert(0, new ListItem("所有", Guid.Empty.ToString())); //显示网站名称和地址 if (!string.IsNullOrEmpty(Request.QueryString["siteid"])) { try { DDL_SiteList.SelectedValue = Request.QueryString["siteid"]; IList <SiteAdsInfo> list = new SiteAdsService().SelectSiteAdsById(new Guid(DDL_SiteList.SelectedValue)); RPT_AdsList.DataSource = list; RPT_AdsList.DataBind(); } catch (Exception ex) { } } DDL_AdsList.DataSource = CacheCollection.GetAllAdsInfo(); DDL_AdsList.DataValueField = "AdsId"; DDL_AdsList.DataTextField = "AdsName"; DDL_AdsList.DataBind(); } }
protected string GetSize(string adsId) { IList <AdsInfo> list = CacheCollection.GetAllAdsInfo().Where(o => o.AdsId.ToString() == adsId).ToList(); if (list.Count == 0) { return(""); } return(list[0].AdsSize); }
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 string GetAdsType(string adsId) { IList <AdsInfo> list = CacheCollection.GetAllAdsInfo().Where(o => o.AdsId.ToString() == adsId).ToList(); if (list.Count == 0) { return(""); } if (list[0].AdsType == 1) { return("列表-图文"); } return("单个投放"); }
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 string GetAdsType(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(""); } if (alist[0].AdsType == 1) { return("瀑布流"); } return("大图直接展示"); }
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 string GetAdsName(string adsId) { AdsInfo info = CacheCollection.GetAllAdsInfo().Where(o => o.AdsId.ToString() == adsId).ToList()[0]; return(info.AdsName); }
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(); } 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; } IList <BuyInfo> buyList = CacheCollection.GetAllBuyInfo().Where(o => o.Nick == nick).ToList(); //投放的广告 IList <UserAdsInfo> useradsList = userAdsDal.SelectAllUserAds(nick); //购买类型 foreach (BuyInfo binfo in buyList) { //未过期的 if (!binfo.IsExpied) { //收费类型 FeeInfo feeInfo = CacheCollection.GetAllFeeInfo().Where(o => o.FeeId == binfo.FeeId).ToList()[0]; if (feeInfo.AdsCount > 0) { int count = feeInfo.AdsCount > list.Count ? list.Count : feeInfo.AdsCount; //已经投放了的该收费类型的广告集合 IList <UserAdsInfo> myUseradsList = useradsList.Where(o => o.FeeId == feeInfo.FeeId && o.UserAdsState == 1).ToList(); //真正可以添加的广告数量 int realcount = 0; if (feeInfo.AdsCount - myUseradsList.Count <= 0) { realcount = 0; } else { realcount = (feeInfo.AdsCount - myUseradsList.Count) >= count ? count : feeInfo.AdsCount - myUseradsList.Count; } if (realcount > 0) { if (feeInfo.AdsType == 5) { //这里需要查询空闲的广告(或者说是可以用的广告位) IList <UserAdsInfo> usedadsList = userAdsDal.SelectAllUsedAds(); IList <AdsInfo> allads = CacheCollection.GetAllAdsInfo().Where(o => o.AdsType == 5).ToList(); if (allads.Count > usedadsList.Count) { //得到没有使用的广告位 IList <AdsInfo> hasads = new List <AdsInfo>(); foreach (AdsInfo ainfo in allads) { if (usedadsList.Where(o => o.AdsId == ainfo.AdsId).ToList().Count == 0) { hasads.Add(ainfo); } } for (int i = 0; i < realcount; i++) { list[i].AddTime = DateTime.Now; list[i].AdsId = GetRand(hasads); //不需要旺旺 list[i].AliWang = ""; //nick; list[i].FeeId = binfo.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, ref taoId); } } else { Page.RegisterStartupScript("通知", "<script>alert('请联系我们的客服人员为您添加广告');</script>"); } continue; } //可以放多少个 for (int i = 0; i < realcount; i++) { list[i].AddTime = DateTime.Now; list[i].AdsId = GetRand(CacheCollection.GetAllAdsInfo().Where(o => o.AdsType == 1).ToList()); list[i].AliWang = nick; list[i].FeeId = binfo.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); } } } } } foreach (UserAdsInfo info in list) { userAdsDal.InsertUserAds(info); } Response.Redirect("UserAdsList.aspx?istou=1"); }
protected void RPT_AdsList_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "De") { Guid id = new Guid(e.CommandArgument.ToString()); uasDal.DelteUserAds(id); Response.Redirect("UserAdsList.aspx"); } if (e.CommandName == "Insert") { Guid id = new Guid(e.CommandArgument.ToString()); UserAdsInfo info = uasDal.SelectUserAdsById(id); string nick = ""; if (Request.Cookies["nick"] != null) { nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); //"nick"; } else { nick = Session["snick"].ToString(); } IList <BuyInfo> buyList = CacheCollection.GetAllBuyInfo().Where(o => o.Nick == nick).ToList(); bool noads = true; //投放的广告 IList <UserAdsInfo> useradsList = uasDal.SelectAllUserAds(nick); //购买类型 foreach (BuyInfo binfo in buyList) { //未过期的 if (!binfo.IsExpied) { //收费类型 FeeInfo feeInfo = CacheCollection.GetAllFeeInfo().Where(o => o.FeeId == binfo.FeeId).ToList()[0]; if (feeInfo.AdsCount > 0) { //已经投放了的该收费类型的广告集合 IList <UserAdsInfo> myUseradsList = useradsList.Where(o => o.FeeId == feeInfo.FeeId && o.UserAdsState == 1).ToList(); //真正可以添加的广告数量 int realcount = feeInfo.AdsCount - myUseradsList.Count; if (realcount > 0) { if (feeInfo.AdsType == 5) { //这里需要查询空闲的广告(或者说是可以用的广告位) IList <UserAdsInfo> usedadsList = uasDal.SelectAllUsedAds(); IList <AdsInfo> allads = CacheCollection.GetAllAdsInfo().Where(o => o.AdsType == 5).ToList(); if (allads.Count > usedadsList.Count) { //得到没有使用的广告位 IList <AdsInfo> hasads = new List <AdsInfo>(); foreach (AdsInfo ainfo in allads) { if (usedadsList.Where(o => o.AdsId == ainfo.AdsId).ToList().Count == 0) { hasads.Add(ainfo); } } info.AddTime = DateTime.Now; info.AdsId = GetRand(hasads); //不需要旺旺 info.AliWang = ""; //nick; info.FeeId = binfo.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, ref taoId); } else { Page.RegisterStartupScript("通知", "<script>alert('请联系我们的客服人员为您添加广告');</script>"); } continue; } info.AddTime = DateTime.Now; info.AdsId = info.AdsId == Guid.Empty ? GetRand(CacheCollection.GetAllAdsInfo().Where(o => o.AdsType == 1).ToList()) : info.AdsId; info.AliWang = nick; info.FeeId = binfo.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, ref taoId); info.Id = id; uasDal.UpdateUserAdsState(info); // noads = false; break; } } } } if (noads) { Response.Redirect("/qubie.html"); } else { Response.Redirect("UserAdsList.aspx?istou=1"); } } if (e.CommandName == "Result") { Guid id = new Guid(e.CommandArgument.ToString()); Response.Redirect("ShowClick.aspx?id=" + id); } if (e.CommandName == "See") { Guid id = new Guid(e.CommandArgument.ToString()); Response.Redirect("ShowAds.aspx?adsid=" + id); } if (e.CommandName == "Stop") { Guid id = new Guid(e.CommandArgument.ToString()); uasDal.StopUserAds(2, id); Response.Redirect("UserAdsList.aspx"); } if (e.CommandName == "Add") { } }
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(); } //购买类型 IList <BuyInfo> buyList = CacheCollection.GetAllBuyInfo().Where(o => o.Nick == nick).ToList(); //投放的广告 IList <UserAdsInfo> useradsList = userAdsDal.SelectAllUserAds(nick); bool notou = true; foreach (BuyInfo binfo in buyList) { //未过期的 if (!binfo.IsExpied) { //收费类型 FeeInfo feeInfo = CacheCollection.GetAllFeeInfo().Where(o => o.FeeId == binfo.FeeId).ToList()[0]; if (feeInfo.AdsCount > 0) { //已经投放了的该收费类型的广告集合 IList <UserAdsInfo> myUseradsList = useradsList.Where(o => o.FeeId == feeInfo.FeeId && o.UserAdsState == 1).ToList(); //真正可以添加的广告数量 int realcount = feeInfo.AdsCount - myUseradsList.Count; 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 (realcount > 0) { if (feeInfo.AdsType == 5) { //这里需要查询空闲的广告(或者说是可以用的广告位) IList <UserAdsInfo> usedadsList = userAdsDal.SelectAllUsedAds(); IList <AdsInfo> allads = CacheCollection.GetAllAdsInfo().Where(o => o.AdsType == 5).ToList(); if (allads.Count > usedadsList.Count) { //得到没有使用的广告位 IList <AdsInfo> hasads = new List <AdsInfo>(); foreach (AdsInfo ainfo in allads) { if (usedadsList.Where(o => o.AdsId == ainfo.AdsId).ToList().Count == 0) { hasads.Add(ainfo); } } info.AddTime = DateTime.Now; info.AdsId = GetRand(hasads); //不需要旺旺 info.AliWang = ""; //nick; info.FeeId = binfo.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>"); } } if (feeInfo.AdsType == 1) { info.AddTime = DateTime.Now; info.AdsId = GetRand(CacheCollection.GetAllAdsInfo().Where(o => o.AdsType == 1).ToList()); info.AliWang = nick; info.FeeId = binfo.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; } userAdsDal.InsertUserAds(info); break; } } } if (notou) { Response.Redirect("UserAdsList.aspx"); } else { Response.Redirect("UserAdsList.aspx?istou=1"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IList <AdsInfo> adsList = CacheCollection.GetAllAdsInfo(); Random rand = new Random(); AdsInfo info = adsList[rand.Next(adsList.Count)]; IList <UserAdsInfo> list = uasDal.SelectAllUserAdsByAdsId(info.AdsId, 1); IList <ClickInfo> clickList = clickDal.SelectAllClickCount(DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("yyyyMMdd")); //获取访问IP string ip = Request.ServerVariables["REMOTE_ADDR"]; //获取当天已经访问来了的IP IList <ClickIPInfo> ipList = clickDal.SelectAllClickIPByDate(DateTime.Now.ToString("yyyyMMdd")); //和当前IP相同的 ipList = ipList.Where(o => o.VisitIP == ip).ToList(); foreach (ClickIPInfo ipinfo in ipList) { //已经访问了该广告 IList <UserAdsInfo> hadlist = list.Where(o => o.Id == ipinfo.UserAdsId).ToList(); if (hadlist.Count > 0) { list.Remove(hadlist[0]); } } if (list.Count == 0) { return; } foreach (ClickInfo cinfo in clickList) { if (cinfo.ClickCount >= rand.Next(6, 15))//10) { IList <UserAdsInfo> hadlist = list.Where(o => o.Id == cinfo.UserAdsId).ToList(); if (hadlist.Count > 0) { FeeInfo finfo = CacheCollection.GetAllFeeInfo().Where(o => o.FeeId == hadlist[0].FeeId).ToList()[0]; if (finfo.AdsType == 1) { if (finfo.AdsCount == 1) { list.Remove(hadlist[0]); } else { if (cinfo.ClickCount >= rand.Next(14, 23))//18) { list.Remove(hadlist[0]); } } } if (finfo.AdsType == 5) { if (cinfo.ClickCount >= rand.Next(22, 33)) //27) { list.Remove(hadlist[0]); } } } } } if (list.Count == 0) { return; } UserAdsInfo uinfo = list[0]; if (list.Count > 1) { uinfo = list[rand.Next(list.Count)]; } ClickIPInfo iinfo = new ClickIPInfo(); iinfo.VisitIP = ip; iinfo.ClickId = Guid.NewGuid(); iinfo.VisitDate = DateTime.Now.ToString("yyyyMMdd"); iinfo.UserAdsId = uinfo.Id; clickDal.InsertClickIP(iinfo); string param = "id=" + uinfo.Id + "&url=" + uinfo.AdsUrl; Response.Redirect("getclick.aspx?" + HttpUtility.UrlEncode(param)); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IList <AdsInfo> adsList = CacheCollection.GetAllAdsInfo(); Random rand = new Random(); //AdsInfo info = adsList[rand.Next(adsList.Count)]; //IList<UserAdsInfo> list = uasDal.SelectAllUserAdsByAdsId(info.AdsId, 1); IList <UserAdsInfo> list = uasDal.SelectAllUserAdsClick(DateTime.Now); //获取访问IP string ip = Request.ServerVariables["REMOTE_ADDR"]; //if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 9) //{ // IList<ClickInfo> clickList = clickDal.SelectAllClickCount(DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("yyyyMMdd")); // //获取当天已经访问来了的IP // IList<ClickIPInfo> ipList = clickDal.SelectAllClickIPByDate(DateTime.Now.ToString("yyyyMMdd")); // //和当前IP相同的 // ipList = ipList.Where(o => o.VisitIP == ip).ToList(); // for (int i = 0; i < ipList.Count; i++) // { // //已经访问了该广告 // IList<UserAdsInfo> hadlist = list.Where(o => o.Id == ipList[i].UserAdsId).ToList(); // if (hadlist.Count > 0) // {qin // list.Remove(hadlist[0]); // } // } //} if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 12) { IList <Guid> clickIPlist = uasDal.SelectAllClickIP(DateTime.Now, ip); foreach (Guid gid in clickIPlist) { IList <UserAdsInfo> hadlist = list.Where(o => o.Id == gid).ToList(); if (hadlist.Count > 0) { list.Remove(hadlist[0]); } } } if (list.Count == 0) { return; } int suiCount = 0; if ((int)DateTime.Now.DayOfWeek == 1) { suiCount = rand.Next(3, 6); } if ((int)DateTime.Now.DayOfWeek == 2) { suiCount = rand.Next(6, 8); } if ((int)DateTime.Now.DayOfWeek == 3) { suiCount = rand.Next(8, 10); } if ((int)DateTime.Now.DayOfWeek == 4) { suiCount = rand.Next(10, 12); } if ((int)DateTime.Now.DayOfWeek == 5) { suiCount = rand.Next(8, 10); } if ((int)DateTime.Now.DayOfWeek == 6) { suiCount = rand.Next(6, 8); } if ((int)DateTime.Now.DayOfWeek == 0) { suiCount = rand.Next(1, 3); } if (list.Where(o => o.IsSend < (10 + suiCount)).ToList().Count > 0) { list = list.Where(o => o.IsSend < (10 + suiCount)).ToList(); } //for (int i = 0; i < clickList.Count; i++) //{ // if (clickList[i].ClickCount >= num1)//10) // { // IList<UserAdsInfo> hadlist = list.Where(o => o.Id == clickList[i].UserAdsId).ToList(); // if (hadlist.Count > 0) // { // FeeInfo finfo = CacheCollection.GetAllFeeInfo().Where(o => o.FeeId == hadlist[0].FeeId).ToList()[0]; // if (finfo.AdsType == 1) // { // if (finfo.AdsCount == 1) // list.Remove(hadlist[0]); // else // { // if (clickList[i].ClickCount >= num2)//18) // list.Remove(hadlist[0]); // } // } // if (finfo.AdsType == 5) // { // if (clickList[i].ClickCount >= num3) //27) // list.Remove(hadlist[0]); // } // } // } //} if (list.Count == 0) { return; } UserAdsInfo uinfo = list[0]; if (list.Count > 1) { uinfo = list[rand.Next(list.Count)]; } ClickIPInfo iinfo = new ClickIPInfo(); iinfo.VisitIP = ip; iinfo.ClickId = Guid.NewGuid(); iinfo.VisitDate = DateTime.Now.ToString("yyyyMMdd"); iinfo.UserAdsId = uinfo.Id; clickDal.InsertClickIP(iinfo); string param = "id=" + uinfo.Id + "&url=" + uinfo.AdsUrl; Response.Redirect("getclick.aspx?" + HttpUtility.UrlEncode(param)); } }
protected void Btn_AddAds_Click(object sender, EventArgs e) { if (TB_Password.Text == "tuituiguang!(**gansibangtuiguang") { IList <BuyInfo> list = CacheCollection.GetAllBuyInfo(); if (list.Where(o => o.Nick == TB_Nick.Text.Trim()).ToList().Count > 0) { IList <GoodsInfo> glist = new GoodsService().SelectAllGoodsByNick(TB_Nick.Text.Trim()); if (glist.Count != 0) { GoodsInfo ginfo = null; if (glist.Count == 1) { ginfo = glist[0]; } else { ginfo = glist[new Random().Next(0, glist.Count)]; } UserAdsInfo info = new UserAdsInfo(); info.AdsTitle = ginfo.GoodsName; info.Id = Guid.NewGuid(); info.UserAdsState = 1; info.AdsUrl = "http://item.taobao.com/item.htm?id=" + ginfo.GoodsId; string cateId = ginfo.CateId; TaoBaoGoodsClassInfo tcinfo = new TaoBaoGoodsClassService().SelectGoodsClass(cateId); info.CateIds = ginfo.TaoBaoCId; string cname = tcinfo == null ? "" : tcinfo.name; info.SellCateName = GetTaoBaoCName(info.CateIds, cname); info.AliWang = TB_Nick.Text.Trim(); info.Nick = TB_Nick.Text.Trim(); info.AdsPic = ginfo.GoodsPic; info.Price = ginfo.GoodsPrice; info.AddTime = DateTime.Now; info.AdsId = GetRand(CacheCollection.GetAllAdsInfo().Where(o => o.AdsType == 1).ToList()); info.FeeId = list[0].FeeId; info.AdsShowStartTime = DateTime.Now; info.AdsShowFinishTime = DateTime.Now.AddDays(7); info.UserAdsState = 1; string taoId = info.CateIds; info.CateIds = GetTaoBaoCId(taoId, taoId); info.IsSend = 1; //表示是赠送的 //new UserAdsService().InsertUserAds(info); GoodPingService pingDal = new GoodPingService(); IList <GoodPingInfo> pinginfoList = pingDal.GetGoodPingByNick(TB_Nick.Text.Trim()); if (pinginfoList.Count == 0) { GoodPingInfo pingInfo = new GoodPingInfo(); pingInfo.AddIP = Request.ServerVariables["REMOTE_ADDR"]; pingInfo.Nick = TB_Nick.Text.Trim(); pingInfo.PingDate = DateTime.Now; pingInfo.PingTimes = 1; pingDal.InsertGoodPing(pingInfo); } else { pinginfoList[0].AddIP = Request.ServerVariables["REMOTE_ADDR"]; pinginfoList[0].PingDate = DateTime.Now; pinginfoList[0].PingTimes = pinginfoList[0].PingTimes + 1; pingDal.UpdatePingInfo(pinginfoList[0]); } Page.RegisterStartupScript("恭喜", "<script>alert('赠送广告成功');</script>"); Response.Redirect("/SendUserAds.aspx"); } } else { Page.RegisterStartupScript("Error", "<script>alert('没有购买记录');</script>"); } } }