コード例 #1
0
        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("");
        }
コード例 #2
0
ファイル: LogController.cs プロジェクト: jim-deng-git/Ask
        // GET: Backend/Log
        public ActionResult Log(int?index, SysLogSearchModel search)
        {
            if (Request.HttpMethod == "GET")
            {
                if (index == null)
                {
                    Utility.ClearSearchValue();
                    Session["LogSearch"] = null;
                }
                else
                {
                    SysLogSearchModel prevSearch = Utility.GetSearchValue <SysLogSearchModel>();
                    if (prevSearch != null)
                    {
                        search = prevSearch;
                    }
                }
            }
            else if (Request.HttpMethod == "POST")
            {
                Utility.SetSearchValue(search);
                Session["LogSearch"] = search;
            }

            string     KW         = search.KW ?? "";
            Pagination pagination = new Pagination
            {
                PageIndex = index ?? 1,
                PageSize  = WebInfo.PageSize
            };

            string SDate = !string.IsNullOrEmpty(search.SDate) ? search.SDate : "1911/1/1";
            string EDate = !string.IsNullOrEmpty(search.EDate) ? search.EDate : "9999/12/31";

            int totalRecord;

            List <SysLogModels> items = SysLogDAO.GetItems(pagination.PageSize, pagination.PageIndex, out totalRecord, Convert.ToDateTime(SDate), Convert.ToDateTime(EDate), KW, search.Actions, search.MemberId);

            foreach (SysLogModels item in items)
            {
                string siteSN = "", pageSN = "";
                if (item.SiteID.HasValue)
                {
                    WorkV3.Models.SitesModels siteModel = WorkV3.Models.DataAccess.SitesDAO.GetInfo(item.SiteID.Value);
                    if (siteModel != null)
                    {
                        siteSN = siteModel.SN;

                        if (item.SourceID.HasValue)
                        {
                            WorkV3.Areas.Backend.Models.PagesModels pageModel = WorkV3.Areas.Backend.Models.DataAccess.PagesDAO.GetPageInfo(item.SiteID.Value, item.SourceID.Value);
                            if (pageModel != null)
                            {
                                List <WorkV3.Areas.Backend.ViewModels.CardsViewModel> zoneModel = WorkV3.Areas.Backend.Models.DataAccess.CardsDAO.GetZoneByPageNo(item.SiteID.Value, item.SourceID.Value);
                                if (zoneModel.Count > 0)
                                {
                                    bool HasCardContent = true;
                                    foreach (WorkV3.Areas.Backend.ViewModels.CardsViewModel cardModel in zoneModel)
                                    {
                                        switch (cardModel.CardsType)
                                        {
                                        case "Article":
                                            var articleModel = WorkV3.Models.DataAccess.ArticleDAO.GetItemByCard(cardModel.No);
                                            if (articleModel == null)
                                            {
                                                HasCardContent = false;
                                            }
                                            break;
                                        }
                                        if (!HasCardContent)
                                        {
                                            break;
                                        }
                                    }
                                    if (HasCardContent)
                                    {
                                        pageSN = pageModel.SN;
                                    }
                                    else
                                    {
                                        item.IsDeleted = true;
                                    }
                                }
                                else
                                {
                                    item.IsDeleted = true;
                                }
                            }
                            else
                            {
                                if (item.MgrNo == (byte)WorkV3.Golbal.SysMgrNo.Page)
                                {
                                    item.IsDeleted = true;
                                }
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(siteSN) && !string.IsNullOrEmpty(pageSN))
                {
                    item.PageUrl = Url.Action("Index", "Home", new { SiteSN = siteSN, PageSN = pageSN, area = string.Empty });
                }
            }
            pagination.TotalRecord = totalRecord;

            ViewBag.Pagination = pagination;
            ViewBag.Search     = search;

            return(View(items));
        }