Exemplo n.º 1
0
        private string GetAdminTileFilterInfo(string userName, string teamGuid, bool isAdmin)
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();
            // TileManager tm = new TileManager();

            TileFilterListViewModel filterViewModel = new TileFilterListViewModel();

            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                ICategoryRepository _categoryRepository = new CategoryRepository(context);
                ITagRepository      _tagRepository      = new TeamTagRepository(context);
                ITileRepository     _tileRepository     = new TileRepository(context);
                ITeamRepository     _teamRepository     = new TeamRepository(context);
                IReportRepository   _reportRepository   = new ReportRepository(context);
                IUserRepository     _userRepository     = new UserRepository(context);

                TileServices tileService = new TileServices(_tileRepository, _teamRepository, _reportRepository, _userRepository, _tagRepository, _categoryRepository, null);

                //Owner
                IEnumerable <UserLoginApp> userList = tileService.GetOwnerList(userName, teamGuid, isAdmin);
                filterViewModel.Owner = userList.OrderBy(_ => _.UserName).Distinct <UserLoginApp>(new UserComparer());


                //Category
                IEnumerable <AppCategory> categoryList = tileService.GetCategoryList();
                filterViewModel.SubCategory = categoryList.OrderBy(_ => _.CategoryName).Distinct <AppCategory>(new CategoryComparer());


                //Tag
                IEnumerable <AppTeamTag> tagList = tileService.GetTagListByTeam(teamGuid).Distinct <AppTeamTag>(new TagComparer());
                filterViewModel.Tag = tagList;
            }



            return(jss.Serialize(filterViewModel));
        }
        private void SetAppTitleLogic(string logicString, AppTile appTile)
        {
            using (MainDBUnitWorkContext context = new MainDBUnitWorkContext())
            {
                TileRepository   repository        = new TileRepository(context);
                ReportRepository _reportRepository = new ReportRepository(context);

                if (!string.IsNullOrEmpty(logicString))
                {
                    EditReportService reportService = new EditReportService(null, null, null, null, null, null);

                    switch (appTile.logicType)
                    {
                    case LogicType.Static:
                        appTile.BasicLogic = null;
                        break;

                    case LogicType.Selected:
                        List <int> cataIDList = logicString.Split(',').Select(_ => Convert.ToInt32(_)).ToList();
                        appTile.BasicLogic = (new ReportDataId()).In(cataIDList);
                        break;

                    case LogicType.Filtered:
                        ReportFilter filer = new ReportFilter();

                        JavaScriptSerializer jss = new JavaScriptSerializer();

                        #region Deserialize
                        TileFilterListViewModel vm = new TileFilterListViewModel();
                        if (!String.IsNullOrEmpty(logicString))
                        {
                            vm = jss.Deserialize <TileFilterListViewModel>(logicString);
                        }

                        #endregion

                        #region Get ReportFilter
                        filer.OwnerIdCollection = (from o in vm.Owner select o.Id).ToList();
                        //filer.CatalogTypeIdCollection = (from c in vm.CatelogType select c.Id).ToList();
                        filer.TagsIdCollection        = (from t in vm.Tag select t.Id.Value).ToList();
                        filer.SubCategoryIdCollection = (from c in vm.SubCategory select c.Id.Value).ToList();
                        #endregion

                        appTile.BasicLogic = reportService.GenerateLogicByFilter(filer);
                        break;

                    case LogicType.Tagged:
                        List <int> tagIds = logicString.Split(',').Select(i => int.Parse(i.Trim())).ToList();
                        appTile.BasicLogic = (new TagId()).In(tagIds);
                        break;

                    case LogicType.AllReports:
                        appTile.BasicLogic = null;
                        break;
                    }
                }
                else
                {
                    appTile.BasicLogic = null;
                }
            }
        }
Exemplo n.º 3
0
        private static string GetlogicStringFromLogic(AppTile appTile)
        {
            string logicString = string.Empty;

            switch (appTile.logicType)
            {
            case LogicType.Selected:
                logicString = string.Join(",", (appTile.BasicLogic as IN <int>).FieldValue.GetValue());
                break;

            case LogicType.Filtered:

                List <Logic> elements = (appTile.BasicLogic as AND).LogicElements;
                if (elements != null && elements.Count > 0)
                {
                    #region Get ReportFilter from Logic
                    ReportFilter filer = new ReportFilter();
                    foreach (var t in elements)
                    {
                        if (t as IN <int> != null)
                        {
                            if ((t as IN <int>).Field is TagId)
                            {
                                filer.TagsIdCollection = (t as IN <int>).FieldValue.GetValue();
                            }
                            if ((t as IN <int>).Field is SubCategoryId)
                            {
                                filer.SubCategoryIdCollection = (t as IN <int>).FieldValue.GetValue();
                            }
                        }

                        if ((t as IN <string>) != null)
                        {
                            if ((t as IN <string>).Field is ReportOwnerId)
                            {
                                filer.OwnerIdCollection = (t as IN <string>).FieldValue.GetValue();
                            }
                        }
                    }
                    #endregion

                    #region Get TileFilterListViewModel from ReportFilter
                    TileFilterListViewModel vm = new TileFilterListViewModel();

                    if (filer.TagsIdCollection != null && filer.TagsIdCollection.Count > 0)
                    {
                        vm.Tag = filer.TagsIdCollection.Select(id => new AppTeamTag {
                            Id = id
                        });
                    }
                    if (filer.SubCategoryIdCollection != null && filer.SubCategoryIdCollection.Count > 0)
                    {
                        vm.SubCategory = filer.SubCategoryIdCollection.Select(id => new AppCategory {
                            Id = id
                        });
                    }

                    if (filer.OwnerIdCollection != null && filer.OwnerIdCollection.Count > 0)
                    {
                        vm.Owner = filer.OwnerIdCollection.Select(id => new UserLoginApp {
                            Id = id
                        });
                    }
                    #endregion

                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    logicString = jss.Serialize(vm);
                }
                break;

            case LogicType.Tagged:
                logicString = string.Join(",", (appTile.BasicLogic as IN <int>).FieldValue.GetValue());
                break;

            default:
                break;
            }
            return(logicString);
        }