Exemplo n.º 1
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");
        }