Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string nick = "nick";
            if (Request.Cookies["nick"] != null)
            {
                nick = HttpUtility.UrlDecode(Request.Cookies["nick"].Value); //"nick";
            }
            else
            {
                if (Session["snick"] != null)
                {
                    nick = Session["snick"].ToString();
                }
            }

            IList <CateInfo> cateList = new CateService().SelectAllCateByNick(nick);
            DDL_SellCate.DataSource     = cateList;
            DDL_SellCate.DataTextField  = "CateName";
            DDL_SellCate.DataValueField = "CateId";
            DDL_SellCate.DataBind();

            DDL_SellCate.Items.Insert(0, new ListItem("全部", "0"));

            //Rpt_GoodsList.DataSource = goodsDal.SelectAllGoodsByNick(nick);
            //Rpt_GoodsList.DataBind();
            Bind("", "");
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(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 (nick == "")
        {
            Response.Write("请重新登录");
            return;
        }

        IList <CateInfo> cateList = new CateService().SelectAllCateByNick(nick);

        DDL_Cate.DataSource     = cateList;
        DDL_Cate.DataTextField  = "CateName";
        DDL_Cate.DataValueField = "CateId";
        DDL_Cate.DataBind();
    }
Exemplo n.º 3
0
    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"]));
            }
        }
    }
Exemplo n.º 4
0
 public CateController()
 {
     _cateService = Singleton<CateService>.GetInstance();
 }
Exemplo n.º 5
0
    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");
    }
Exemplo n.º 6
0
    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");
    }