Exemplo n.º 1
0
 public ActionResult Delete(long siteID, long id, string DeleteAll)
 {
     WorkV3.Areas.Backend.Models.MenusModels item = WorkV3.Areas.Backend.Models.DataAccess.MenusDAO.GetInfo(siteID, id);
     MenusDAO.DeleteMenu(item, (DeleteAll == "1"));
     SysLog.SaveLog(SysActions.Del, SysMgrNo.Menu, item.Title, item.SiteID, id);
     TempData["refreshData"] = SysActions.Edit;
     return(Json("success"));
 }
        public string GetAnalysisItemsContent(long siteID, AnalysisType analysisType, string analysisItems)
        {
            switch (analysisType)
            {
            case AnalysisType.Page:
                if (string.IsNullOrEmpty(analysisItems))
                {
                    return("全部選單");
                }
                else
                {
                    string   pathInfo   = "";
                    string[] pagesArray = analysisItems.Split(';');
                    for (int i = 0; i < pagesArray.Length; i++)
                    {
                        //if (!string.IsNullOrEmpty(pagesArray[i]))
                        //{
                        MenusModels menu = DataAccess.StatisticConditionDAO.GetMenuInfo(long.Parse(pagesArray[i]));
                        if (menu == null)
                        {
                            PagesModels page = DataAccess.PagesDAO.GetPageInfo(siteID, long.Parse(pagesArray[i]));
                            if (page != null)
                            {
                                pathInfo += (string.IsNullOrEmpty(pathInfo) ? "" : ">") + page.Title;
                            }
                        }
                        else
                        {
                            pathInfo += (string.IsNullOrEmpty(pathInfo) ? "" : ">") + menu.Title;
                        }
                        //}
                    }
                    return(pathInfo);
                }

            case AnalysisType.Age:
                if (string.IsNullOrEmpty(analysisItems))
                {
                    return("全部");
                }
                else
                {
                    string ageInfo = "";
                    if (analysisItems.Contains("other"))
                    {
                        ageInfo += string.IsNullOrEmpty(ageInfo) ? "" : "、";
                        string[] ages = analysisItems.Split(':');
                        ageInfo = "自訂:" + ages[1];
                    }
                    string[] pagesArray = analysisItems.Split(';');
                    for (int i = 0; i < pagesArray.Length; i++)
                    {
                        if (ViewModels.AnalysisPageLogViewModel.Ages.Keys.Contains(pagesArray[i]))
                        {
                            ageInfo += string.IsNullOrEmpty(ageInfo) ? "" : "、";
                            if (ViewModels.AnalysisPageLogViewModel.Ages[pagesArray[i]][0] == 0)
                            {
                                ageInfo += string.Format("{0}歲以下",
                                                         ViewModels.AnalysisPageLogViewModel.Ages[pagesArray[i]][1].ToString());
                            }
                            else if (ViewModels.AnalysisPageLogViewModel.Ages[pagesArray[i]][1] == 99)
                            {
                                ageInfo += string.Format("{0}歲以上",
                                                         ViewModels.AnalysisPageLogViewModel.Ages[pagesArray[i]][0].ToString());
                            }
                            else
                            {
                                ageInfo += string.Format("{0}-{1}歲",
                                                         ViewModels.AnalysisPageLogViewModel.Ages[pagesArray[i]][0].ToString(),
                                                         ViewModels.AnalysisPageLogViewModel.Ages[pagesArray[i]][1].ToString());
                            }
                        }
                    }
                    return(ageInfo);
                }

            case AnalysisType.Career:
            case AnalysisType.Education:
            case AnalysisType.Favority:
            case AnalysisType.Identity:
            case AnalysisType.Marriage:
                if (string.IsNullOrEmpty(analysisItems))
                {
                    return("全部");
                }
                else
                {
                    string   itemInfo   = "";
                    string[] pagesArray = analysisItems.Split(';');
                    for (int i = 0; i < pagesArray.Length; i++)
                    {
                        CategoryModels cate = DataAccess.CategoryDAO.GetItem(long.Parse(pagesArray[i]));

                        if (cate != null)
                        {
                            itemInfo += string.IsNullOrEmpty(itemInfo) ? "" : "、";
                            itemInfo += cate.Title;
                        }
                    }
                    return(itemInfo);
                }

            case AnalysisType.Location:
                int[] regionList = null;
                if (analysisItems != string.Empty)
                {
                    regionList = Newtonsoft.Json.JsonConvert.DeserializeObject <int[]>(analysisItems);
                }
                var regions = WorkV3.Models.DataAccess.WorldRegionDAO.GetRegions(regionList);
                if (regions != null && regions.Count() > 0)
                {
                    string itemInfo = "";
                    for (int i = 0; i < regions.Count(); i++)
                    {
                        itemInfo += regions.ElementAt(i).Name;
                    }
                    return(itemInfo);
                }
                return(analysisItems);

            case AnalysisType.Sex:
            case AnalysisType.Browser:
            case AnalysisType.Machine:
                if (string.IsNullOrEmpty(analysisItems))
                {
                    return("全部");
                }
                else
                {
                    string   itemInfo   = "";
                    string[] pagesArray = analysisItems.Split(';');
                    return(string.Join("、", pagesArray));
                }

            case AnalysisType.Manager:
                if (string.IsNullOrEmpty(analysisItems))
                {
                    return("全部");
                }
                else
                {
                    string   itemInfo   = "";
                    string[] pagesArray = analysisItems.Split(';');
                    for (int i = 0; i < pagesArray.Length; i++)
                    {
                        MemberModels manager = DataAccess.ManagerDAO.GetItem(long.Parse(pagesArray[i]));

                        if (manager != null)
                        {
                            itemInfo += string.IsNullOrEmpty(itemInfo) ? "" : "、";
                            itemInfo += manager.Name;
                        }
                        if (i >= 3)
                        {
                            itemInfo += "...(" + pagesArray.Length.ToString() + ")";
                            break;
                        }
                    }
                    return(itemInfo);
                }

            case AnalysisType.OrderEpaper:
                break;
            }
            return("");
        }
Exemplo n.º 3
0
        public static bool DeleteMenu(WorkV3.Areas.Backend.Models.MenusModels item, bool isDeleteAll)
        {
            var childMenus = WorkV3.Areas.Backend.Models.DataAccess.MenusDAO.GetChildren(item.ID);

            if (isDeleteAll) // 若全部刪除, 連子項目一併刪除, 否 => 模組模式不作處理
            {
                //
                var pageItem = WorkV3.Areas.Backend.Models.DataAccess.PagesDAO.GetPageInfo(item.ID); // 選單鍵值=頁面鍵值 => 模組選單頁
                if (pageItem != null)
                {
                    var pageZones = WorkV3.Models.DataAccess.ZonesDAO.GetPageData(pageItem.SiteID, pageItem.No);
                    if (pageZones != null && pageZones.Count() > 0)
                    {
                        bool DeletePage = false;
                        foreach (WorkV3.Models.ZonesModels child in pageZones)
                        {
                            var pageCards = WorkV3.Models.DataAccess.CardsDAO.GetZoneData(child.SiteID, child.No);
                            if (pageCards != null && pageCards.Count > 0)
                            {
                                int totalCount = 0;
                                foreach (WorkV3.Models.CardsModels child_card in pageCards)
                                {
                                    switch (child_card.CardsType)
                                    {
                                    case "Article":
                                        var articleList = WorkV3.Models.DataAccess.ArticleDAO.GetItems(item.ID, (long?)null, int.MaxValue, 1, out totalCount);
                                        if (articleList != null && articleList.Count() > 0)
                                        {
                                            var deleteIDs = articleList.Select(s => s.ID);
                                            WorkV3.Areas.Backend.Models.DataAccess.ArticleDAO.Delete(deleteIDs);     // 該方法會連同 cars, zones, pages, 一併刪除
                                        }
                                        break;

                                    case "ArticleIntro":
                                        var articleIntro = WorkV3.Models.DataAccess.ArticleIntroDAO.GetItem(child_card.No);
                                        if (articleIntro != null)
                                        {
                                            WorkV3.Areas.Backend.Models.DataAccess.ArticleIntroDAO.Delete(articleIntro.ID);     // 該方法會連同 cars, zones, pages, 一併刪除
                                            DeletePage = true;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        if (!DeletePage)
                        {
                            WorkV3.Areas.Backend.Models.DataAccess.PagesDAO.DelPagesByMenuID(pageItem.MenuID);
                        }
                    }
                }
            }
            if (childMenus != null && childMenus.Count() > 0)
            {
                if (isDeleteAll) // 若全部刪除, 連子項目一併刪除
                {
                    foreach (WorkV3.Areas.Backend.Models.MenusModels child in childMenus)
                    {
                        DeleteMenu(child, isDeleteAll);
                    }
                }
                else //否, 則全部上移
                {
                    UpdateParentID(childMenus.ToList(), item.ParentID);
                }
            }
            return(Delete(item.ID) > 0);
        }