Ejemplo n.º 1
0
        /// <summary>
        /// Detail view of the ad view by campaign id and ad id
        /// </summary>
        /// <param name="CampaignId"></param>
        /// <param name="AdId"></param>
        /// <returns></returns>
        public ActionResult AdView(int?CampaignId, int?AdId)
        {
            if (AdId == 0)
            {
                ViewBag.ViewMode = "Add";
            }
            if (Session["CampaignId"] == null)
            {
                Session["CampaignId"] = CampaignId;
            }
            ACM.Model.Ad ad = new Model.Ad();
            ad.CampaignId = Convert.ToInt32(CampaignId);
            ad.AdId       = Convert.ToInt32(AdId);

            //ad.CampaignId = CampaignId;
            // ad.AdId = 14001;

            var adInq = adServiceClient.AdInq(ad);

            if (adInq == null)
            {
                adInq            = new Model.Ad();
                adInq.CampaignId = (Int32)Session["CampaignId"];
            }
            return(View(adInq));
        }
Ejemplo n.º 2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                Model.Ad modelAd = new Model.Ad();
                modelAd.AdPositionID = Convert.ToInt32(ucAdPreview.PositionID);
                modelAd.AdType = Convert.ToInt32(Request["AdType"]);
                modelAd.Title = txtTitle.Text;
                modelAd.Link = txtLink.Text;
                modelAd.Price = Convert.ToDecimal(txtPrice.Text);
                modelAd.ApprovedState = Convert.ToInt32(ddlApprovedState.SelectedValue);

                switch (ucAdPreview.AdType)
                {
                    case "0":
                        modelAd.ImgUrl = ucUploadImg.UcImageUrl;
                        break;
                    case "1":
                        modelAd.flashUrl = ucUploadFlash.UcImageUrl;
                        break;
                    case "2":
                        modelAd.TxtContent = txtContent.Text;
                        break;
                    case "3":
                        modelAd.CodeContent = txtCodeContent.Text;
                        break;
                }
                if (Convert.ToInt32(Request["AdType"]) == (int)lv_ZPB.BLL.TypeEnum.AdType.友情链接)
                {
                    modelAd.ImgUrl = ucUploadImg.UcImageUrl;
                }
                if (txtBeginDate.Text != "")
                {
                    modelAd.BeginDate = Convert.ToDateTime(txtBeginDate.Text);
                }
                else
                {
                    modelAd.BeginDate = DateTime.Now;
                }
                if (txtEndDate.Text != "")
                {
                    modelAd.EndDate = Convert.ToDateTime(txtEndDate.Text);
                }
                else
                {
                    modelAd.EndDate = DateTime.Now.AddYears(1);
                }
                DateTime newBeginTime = Convert.ToDateTime(modelAd.BeginTime.ToShortDateString() + " " + ddlBeginTimeHour.SelectedValue + ":" + ddlBeginTimeMin.SelectedValue);
                DateTime newEndTime = Convert.ToDateTime(modelAd.EndTime.ToShortDateString() + " " + ddlEndTimeHour.SelectedValue + ":" + ddlEndTimeMin.SelectedValue);
                modelAd.BeginTime = newBeginTime;
                modelAd.EndTime = newEndTime;
                bllAd.Add(modelAd);
                lv_Common.MessageBox.ShowAndRedirect(this.Page, "新增成功", "List.aspx?adType=" + Request["adType"]);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Post Method to Load Dashboard grid
        /// </summary>
        /// <param name="sidx">the index id to be used in sorting</param>
        /// <param name="sord"> the sort order either ASC or DESC</param>
        /// <param name="page">the current page number</param>
        /// <param name="rows">the number of rows expected in the </param>
        /// <param name="CampaignId">the Campaign ID expected in the </param>
        ///   /// <param name="adStatus">the adStatus expected in the </param>
        /// <returns>as defined by the rowNum option or as selected by the user</returns>

        public JsonResult GetAdDashboardData(string sidx, string sord, int page, int rows, string CampaignId, string adStatus, int deploymentPeriodId, bool disableSorting = false)
        {
            queue.Enqueue(sidx);
            List <ACM.Model.CustomModel.AdInfo_Result> AcmAds = new List <ACM.Model.CustomModel.AdInfo_Result>();

            ACM.Model.Ad ad = new Model.Ad();
            ad.CampaignId = Convert.ToInt32(CampaignId);
            Session["DeploymentPeriodId"] = deploymentPeriodId;
            if (ad.CampaignId < 1)
            {
                var no_records_result = new
                {
                    total   = 0,    //number of pages
                    page    = page, //current page
                    records = 0,    //total items
                    rows    = new
                    {
                        CampaignId  = "",
                        AdId        = "",
                        AdName      = "",
                        AdLocation  = "",
                        Restriction = "",
                        Template    = "N/A",
                        StaticMedia = "N/A",
                        Status      = "",
                        Action      = ""
                    }
                };
                return(Json(no_records_result, JsonRequestBehavior.AllowGet));
            }

            AcmAds = adServiceClient.AdsByCampaign(ad.CampaignId, deploymentPeriodId);

            //if (String.Equals(adStatus, "Cancelled"))
            //    AcmAds = AcmAds.Where(i => i.AdStatus == "Cancelled").ToList();
            //else if (String.Equals(adStatus, "Active"))
            //    AcmAds = AcmAds.Where(i => i.AdStatus != "Cancelled").ToList();

            // Sort the items
            if (disableSorting)
            {
                sidx = queue.Peek();
                if (sidx == "Status")
                {
                    sidx = "None";
                }
            }
            switch (sidx.Trim())
            {
            case "AdId":
                AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdId).ToList() : AcmAds.OrderByDescending(i => i.AdId).ToList();
                break;

            case "AdName":
                AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdName).ToList() : AcmAds.OrderByDescending(i => i.AdName).ToList();
                break;

            case "AdLocation":
                AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdLocationDesc).ToList() : AcmAds.OrderByDescending(i => i.AdLocationDesc).ToList();
                break;

            case "Restriction":
                AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.RestrictionNames).ToList() : AcmAds.OrderByDescending(i => i.RestrictionNames).ToList();
                break;

            case "Status":
                AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdStatus).ToList() : AcmAds.OrderByDescending(i => i.AdStatus).ToList();
                break;

            case "None":
                break;

            default:
                AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdName).ToList() : AcmAds.OrderByDescending(i => i.AdName).ToList();
                break;
            }


            var totalRecords = AcmAds.Count();
            var assets       = from a in AcmAds
                               select new
            {
                CampaignId  = a.CampaignId,
                AdId        = a.AdId,
                AdName      = a.AdName,
                AdLocation  = a.AdLocationDesc,
                Restriction = a.RestrictionNames,
                Template    = "N/A",
                StaticMedia = "N/A",
                Status      = a.AdStatus,
                Action      = ""
            };
            var result = new
            {
                total   = (totalRecords + rows - 1) / rows, //number of pages
                page    = page,                             //current page
                records = totalRecords,                     //total items
                rows    = assets.AsEnumerable().Skip((page - 1) * rows).Take(rows)
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Post Method to Load Dashboard grid
        /// </summary>
        /// <param name="sidx">the index id to be used in sorting</param>
        /// <param name="sord"> the sort order either ASC or DESC</param>
        /// <param name="page">the current page number</param>
        /// <param name="rows">the number of rows expected in the </param>
        /// <param name="CampaignId">the Campaign ID expected in the </param>
        ///   /// <param name="adStatus">the adStatus expected in the </param>
        /// <returns>as defined by the rowNum option or as selected by the user</returns>
        public JsonResult GetAdDashboardData(string sidx, string sord, int page, int rows, string CampaignId, string adStatus, int deploymentPeriodId, bool disableSorting=false)
        {
            queue.Enqueue(sidx);
            List<ACM.Model.CustomModel.AdInfo_Result> AcmAds = new List<ACM.Model.CustomModel.AdInfo_Result>();
            ACM.Model.Ad ad = new Model.Ad();
            ad.CampaignId = Convert.ToInt32(CampaignId);
            Session["DeploymentPeriodId"] = deploymentPeriodId;
            if (ad.CampaignId < 1)
            {
                var no_records_result = new
                {
                    total = 0, //number of pages
                    page = page, //current page
                    records = 0, //total items
                    rows = new
                    {
                        CampaignId = "",
                        AdId = "",
                        AdName = "",
                        AdLocation = "",
                        Restriction = "",
                        Template = "N/A",
                        StaticMedia = "N/A",
                        Status = "",
                        Action = ""
                    }
                };
                return Json(no_records_result, JsonRequestBehavior.AllowGet);

            }

            AcmAds = adServiceClient.AdsByCampaign(ad.CampaignId, deploymentPeriodId);

            //if (String.Equals(adStatus, "Cancelled"))
            //    AcmAds = AcmAds.Where(i => i.AdStatus == "Cancelled").ToList();
            //else if (String.Equals(adStatus, "Active"))
            //    AcmAds = AcmAds.Where(i => i.AdStatus != "Cancelled").ToList();

            // Sort the items
            if (disableSorting)
            {
                sidx = queue.Peek();
                if (sidx == "Status")
                    sidx = "None";
            }
            switch (sidx.Trim())
            {
                case "AdId":
                    AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdId).ToList() : AcmAds.OrderByDescending(i => i.AdId).ToList();
                    break;
                case "AdName":
                    AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdName).ToList() : AcmAds.OrderByDescending(i => i.AdName).ToList();
                    break;
                case "AdLocation":
                    AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdLocationDesc).ToList() : AcmAds.OrderByDescending(i => i.AdLocationDesc).ToList();
                    break;
                case "Restriction":
                    AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.RestrictionNames).ToList() : AcmAds.OrderByDescending(i => i.RestrictionNames).ToList();
                    break;
                case "Status":
                    AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdStatus).ToList() : AcmAds.OrderByDescending(i => i.AdStatus).ToList();
                    break;
                case "None":
                    break;
                default:
                    AcmAds = (sord == "asc") ? AcmAds.OrderBy(i => i.AdName).ToList() : AcmAds.OrderByDescending(i => i.AdName).ToList();
                    break;

            }

            var totalRecords = AcmAds.Count();
            var assets = from a in AcmAds
                         select new
                         {
                             CampaignId = a.CampaignId,
                             AdId = a.AdId,
                             AdName = a.AdName,
                             AdLocation = a.AdLocationDesc,
                             Restriction = a.RestrictionNames,
                             Template = "N/A",
                             StaticMedia = "N/A",
                             Status = a.AdStatus,
                             Action = ""
                         };
            var result = new
            {
                total = (totalRecords + rows - 1) / rows, //number of pages
                page = page, //current page
                records = totalRecords, //total items
                rows = assets.AsEnumerable().Skip((page - 1) * rows).Take(rows)
            };
            return Json(result, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Detail view of the ad view by campaign id and ad id
        /// </summary>
        /// <param name="CampaignId"></param>
        /// <param name="AdId"></param>
        /// <returns></returns>
        public ActionResult AdView(int? CampaignId, int? AdId)
        {
            if (AdId == 0)
                ViewBag.ViewMode = "Add";
            if (Session["CampaignId"] == null)
                Session["CampaignId"] = CampaignId;
            ACM.Model.Ad ad = new Model.Ad();
            ad.CampaignId = Convert.ToInt32(CampaignId);
            ad.AdId = Convert.ToInt32(AdId);

            //ad.CampaignId = CampaignId;
            // ad.AdId = 14001;

            var adInq = adServiceClient.AdInq(ad);

            if (adInq == null)
            {
                adInq = new Model.Ad();
                adInq.CampaignId = (Int32)Session["CampaignId"];
            }
            return View(adInq);
        }