コード例 #1
0
        public ActionResult FeeDetail(long adsCustomizedId)
        {
            AdsCustomizeModel customized = Backend.Models.DataAccess.AdvertisementDAO.GetAdsCustomizeItem(adsCustomizedId);
            IEnumerable <AdsCustomizeAccountSet> model = customized.AdsCustomizeAccountSet;

            return(View(model));
        }
コード例 #2
0
        /// <summary>
        /// 自訂廣告管理 編輯
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="menuId"></param>
        /// <param name="Advertisement_ID">廣告區 ID</param>
        /// <param name="id">AdsCustomize.ID 自訂廣告管理ID</param>
        /// <returns></returns>
        public ActionResult AdsCustomizeEdit(long siteId, long menuId, long Advertisement_ID, long?id)
        {
            ViewBag.IsEdit = false;
            AdsCustomizeModel item = null;

            if (id != null) //如果有傳 id 進來的話
            {
                item = AdvertisementDAO.GetAdsCustomizeItem((long)id);

                // 20180621 neil
                // 如果 item 有抓到東西,代表本來就存進資料庫裡
                if (item != null)
                {
                    ViewBag.IsEdit = true;
                }
                // 如果 item 沒有抓到東西,代表目前的 id 是之前產生的,但尚未存入資料庫。
                // 主要用處是在自訂廣告編輯頁時會增加點擊事件、廣告主以及費用設定三項資料,
                // 因為上述三項資料和本筆資料的 table 不同加上儲存時會重新整理本頁,所以原先設定是需先存入,取得本筆資料 ID 後才能夠新增上述三項資料,
                // 但流程上貌似不順,所以改為在本頁編輯時,要能夠新增上述資料,新增後本頁重新整理時會再回傳之前產生的 id ,再用來抓取之前儲存的資料。
                else
                {
                    string clickEvent = "";
                    AdsCustomizeToVideoModel video = AdvertisementDAO.GetAdsCustomizeVideoItem((long)id);
                    AdsCustomizeToLinkModel  link  = AdvertisementDAO.GetAdsCustomizeLinkItem((long)id);
                    if (video != null)
                    {
                        clickEvent = "Video";
                    }
                    else if (link != null)
                    {
                        clickEvent = "Link";
                    }

                    item = new AdsCustomizeModel
                    {
                        ID = (long)id,
                        Advertisement_ID = Advertisement_ID,
                        IsIssue          = true,
                        ClickEvent       = clickEvent
                    };
                }
            }
            if (item == null)
            {
                item = new AdsCustomizeModel
                {
                    ID = WorkLib.GetItem.NewSN(),
                    Advertisement_ID = Advertisement_ID,
                    ClickEvent       = ClickEvent.None,
                    IsIssue          = true
                }
            }
            ;

            ViewBag.UploadUrl        = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId);
            ViewBag.Advertisement_ID = Advertisement_ID;
            ViewBag.SiteID           = siteId;
            ViewBag.MenuID           = menuId;
            return(View(item));
        }
コード例 #3
0
        public ActionResult AdsCustomizeEdit(AdsCustomizeModel model)
        {
            AdsCustomizeEditSaveImage(model.SiteID, model.MenuID, model);

            AdvertisementDAO.SetCustomizeItem(model);
            ViewBag.SiteID           = model.SiteID;
            ViewBag.MenuID           = model.MenuID;
            ViewBag.Advertisement_ID = model.Advertisement_ID;
            ViewBag.IsEdit           = true;
            ViewBag.Exit             = true;

            return(View(model));
        }
コード例 #4
0
        // 廣告成效詳細內容頁
        public ActionResult Detail(AdsDetailStatisticsSearchModel search, int?index)
        {
            DateTime          today = DateTime.Now;
            DateTime          firstDayOfCurrentMonth = new DateTime(today.Year, today.Month, 1);
            DateTime          endDayOfCurrentMonth   = firstDayOfCurrentMonth.AddMonths(1).AddDays(-1);
            AdsCustomizeModel adCustomize            = AdvertisementDAO.GetAdsCustomizeItem(search.AdsCustomId);

            adCustomize = adCustomize ?? new AdsCustomizeModel();

            if (Request.HttpMethod == "GET")
            {
                if (index == null)
                {
                    Utility.ClearSearchValue();
                    search.StartDate = search.StartDate != DateTime.MinValue ? search.StartDate : firstDayOfCurrentMonth;
                    search.EndDate   = search.EndDate != DateTime.MinValue ? search.EndDate : endDayOfCurrentMonth;
                    Session["ExportDetailSearch"] = search;
                }
                else
                {
                    AdsDetailStatisticsSearchModel prevSearch = Utility.GetSearchValue <AdsDetailStatisticsSearchModel>();
                    if (prevSearch != null)
                    {
                        search = prevSearch;
                    }
                }
            }
            else if (Request.HttpMethod == "POST")
            {
                Utility.SetSearchValue(search);
                Session["ExportDetailSearch"] = search;
            }

            if (index == null)
            {
                index = 1;
            }

            int pageSize    = 20;
            int recordCount = 0;
            List <AdsStatisticsDetailViewModel> statisticsData = AdvertisementStatisticsDAO.GetStatisticsDetail(search, pageSize, (int)index, out recordCount);

            ViewBag.Pagination = new Pagination {
                PageSize = pageSize, PageIndex = (int)index, TotalRecord = recordCount
            };
            ViewBag.Search    = search;
            ViewBag.StartDate = firstDayOfCurrentMonth;
            ViewBag.EndDate   = endDayOfCurrentMonth;
            ViewBag.AdsCustomizeDescription = adCustomize.Description;
            return(View(statisticsData));
        }
コード例 #5
0
        void AdsCustomizeEditSaveImage(long siteId, long menuId, AdsCustomizeModel item)
        {
            if (!string.IsNullOrWhiteSpace(item.PCPicture))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.PCPicture);
                if (imgModel.ID == 0)
                {
                    // 新上傳的圖片
                    HttpPostedFileBase postedFile              = Request.Files["fPCPicture"];
                    string             postedFileBase64        = Request.Form["fPCPictureBase64"];
                    string             postedFileBase64_Resize = Request.Form["fPCPictureBase64_Resize"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.PCPicture = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, postedFileBase64, postedFileBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.PCPicture = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(item.MobilePicture))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.MobilePicture);
                if (imgModel.ID == 0)
                {
                    // 新上傳的圖片
                    HttpPostedFileBase postedFile              = Request.Files["fMobilePicture"];
                    string             postedFileBase64        = Request.Form["fMobilePictureBase64"];
                    string             postedFileBase64_Resize = Request.Form["fMobilePictureBase64_Resize"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.MobilePicture = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, postedFileBase64, postedFileBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.MobilePicture = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }
        }
コード例 #6
0
        public string IsDurationOverlapped(long ID, long AdsCustomize_ID, DateTime startTime, DateTime endTime)
        {
            List <AdsCustomizeAccountSet> accountSet      = new List <AdsCustomizeAccountSet>();
            AdsCustomizeModel             adsCustomizeObj = AdvertisementDAO.GetAdsCustomizeItem(AdsCustomize_ID);

            if (adsCustomizeObj == null)
            {
                accountSet = AdvertisementDAO.QueryAccountSetByAdsCustomizeID(AdsCustomize_ID);
            }
            else
            {
                accountSet = adsCustomizeObj.AdsCustomizeAccountSet.ToList();
            }


            foreach (var item in accountSet)
            {
                // 區間不完整不計算
                if (item.IssueStart == null || item.IssueEnd == null)
                {
                    continue;
                }

                // 如果本身儲存時沒有修改時間的話不計算
                if (item.ID == ID)
                {
                    continue;
                }

                List <DateTime> timePoints = new List <DateTime>();
                timePoints.Add(startTime);
                timePoints.Add(endTime);
                timePoints.Add((DateTime)item.IssueStart);
                timePoints.Add((DateTime)item.IssueEnd);

                if (AdvertisementDAO.IsDurationOverlapped(startTime, endTime, (DateTime)item.IssueStart, (DateTime)item.IssueEnd))
                {
                    return("1");
                }
            }

            return("0");
        }