Пример #1
0
        public static List <GroupFilterVM> GetAllGroupFilters()
        {
            List <GroupFilterVM> gfs = new List <GroupFilterVM>();

            try
            {
                /*List<JMMServerBinary.Contract_GroupFilterExtended> gf_cons = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupFiltersExtended(1);
                 * foreach (JMMServerBinary.Contract_GroupFilterExtended gf_con in gf_cons)
                 * {
                 *      GroupFilterVM gf = new GroupFilterVM();
                 *      gf.Populate(gf_con);
                 *      gfs.Add(gf);
                 * }*/

                List <JMMServerBinary.Contract_GroupFilter> gf_cons = JMMServerVM.Instance.clientBinaryHTTP.GetAllGroupFilters();
                foreach (JMMServerBinary.Contract_GroupFilter gf_con in gf_cons)
                {
                    GroupFilterVM gf = new GroupFilterVM(gf_con);
                    gfs.Add(gf);
                }
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write(ex.ToString());
            }

            gfs.Sort();
            return(gfs);
        }
Пример #2
0
        public static List <SortPropOrFieldAndDirection> GetSortDescriptions(GroupFilterVM gf)
        {
            List <SortPropOrFieldAndDirection> sortlist = new List <SortPropOrFieldAndDirection>();

            foreach (GroupFilterSortingCriteria gfsc in gf.SortCriteriaList)
            {
                sortlist.Add(GetSortDescription(gfsc.SortType, gfsc.SortDirection));
            }
            return(sortlist);
        }
Пример #3
0
        public static List <AnimeGroupVM> GetAnimeGroupsForFilter(GroupFilterVM groupFilter)
        {
            DateTime start = DateTime.Now;

            List <AnimeGroupVM> allGroups = new List <AnimeGroupVM>();

            if (JMMServerVM.Instance.CurrentUser == null)
            {
                return(allGroups);
            }

            try
            {
                List <JMMServerBinary.Contract_AnimeGroup> rawGrps = JMMServerVM.Instance.clientBinaryHTTP.GetAnimeGroupsForFilter(groupFilter.GroupFilterID.Value,
                                                                                                                                   JMMServerVM.Instance.CurrentUser.JMMUserID, BaseConfig.Settings.SingleSeriesGroups);
                if (rawGrps == null)
                {
                    return(allGroups);
                }

                foreach (JMMServerBinary.Contract_AnimeGroup contract in rawGrps)
                {
                    allGroups.Add(new AnimeGroupVM(contract));
                }

                // apply sorting
                List <SortPropOrFieldAndDirection> sortCriteria = GroupFilterHelper.GetSortDescriptions(groupFilter);
                if (sortCriteria.Count == 0)
                {
                    // default sort by name
                    SortPropOrFieldAndDirection sortProp = GroupFilterHelper.GetSortDescription(GroupFilterSorting.SortName, GroupFilterSortDirection.Asc);
                    sortCriteria.Add(sortProp);
                }

                allGroups = Sorting.MultiSort <AnimeGroupVM>(allGroups, sortCriteria);

                foreach (SortPropOrFieldAndDirection scrit in sortCriteria)
                {
                    BaseConfig.MyAnimeLog.Write(string.Format("Sorting: {0} / {1} / {2}", scrit.sPropertyOrFieldName, scrit.fSortDescending, scrit.sortType));
                }

                TimeSpan ts  = DateTime.Now - start;
                string   msg = string.Format("JMMServerHelper: Got groups for filter: {0} - {1} in {2} ms", groupFilter.GroupFilterName, allGroups.Count, ts.TotalMilliseconds);
                BaseConfig.MyAnimeLog.Write(msg);
            }
            catch (Exception ex)
            {
                BaseConfig.MyAnimeLog.Write(ex.ToString());
            }
            return(allGroups);
        }