public void Save(GroupFilter obj, bool onlyconditions = false)
 {
     lock (obj)
     {
         if (!onlyconditions)
         {
             obj.GroupsIdsString =
                 Newtonsoft.Json.JsonConvert.SerializeObject(obj.GroupsIds.ToDictionary(a => a.Key,
                                                                                        a => a.Value.ToList()));
             obj.GroupsIdsVersion = GroupFilter.GROUPFILTER_VERSION;
             obj.SeriesIdsString  =
                 Newtonsoft.Json.JsonConvert.SerializeObject(obj.SeriesIds.ToDictionary(a => a.Key,
                                                                                        a => a.Value.ToList()));
             obj.SeriesIdsVersion = GroupFilter.SERIEFILTER_VERSION;
         }
         obj.GroupConditions        = Newtonsoft.Json.JsonConvert.SerializeObject(obj._conditions);
         obj.GroupConditionsVersion = GroupFilter.GROUPCONDITIONS_VERSION;
         using (var session = JMMService.SessionFactory.OpenSession())
         {
             // populate the database
             using (var transaction = session.BeginTransaction())
             {
                 session.SaveOrUpdate(obj);
                 transaction.Commit();
             }
         }
         Cache.Update(obj);
         Types[obj.GroupFilterID] = obj.Types;
         Changes.AddOrUpdate(obj.GroupFilterID);
     }
 }
Example #2
0
        public static List <SelectListItem> GetDaySequences(this GroupFilter groupFilter)
        {
            var dayShifts = groupFilter.DayShifts;
            var result    = new List <SelectListItem>();

            result.Add(
                new SelectListItem {
                Value = string.Empty,
                Text  = "Все равно"
            });
            result.Add(new SelectListItem {
                Value = DaySequences.Saturday,
                Text  = DaySequences.GetName(DaySequences.Saturday)
            });

            result.Add(new SelectListItem {
                Value = DaySequences.Sunday,
                Text  = DaySequences.GetName(DaySequences.Sunday)
            });

            foreach (var daySequence in result)
            {
                daySequence.Selected = groupFilter.DaySequenceTC ==
                                       daySequence.Value;
            }
            return(result);
        }
        public override int GetHashCode()
        {
            var hash = 3;

            hash = (hash * 2) + EnableLdapAuthentication.GetHashCode();
            hash = (hash * 2) + StartTls.GetHashCode();
            hash = (hash * 2) + Server.GetHashCode();
            hash = (hash * 2) + UserDN.GetHashCode();
            hash = (hash * 2) + PortNumber.GetHashCode();
            hash = (hash * 2) + UserFilter.GetHashCode();
            hash = (hash * 2) + LoginAttribute.GetHashCode();
            hash = (hash * 2) + FirstNameAttribute.GetHashCode();
            hash = (hash * 2) + SecondNameAttribute.GetHashCode();
            hash = (hash * 2) + MailAttribute.GetHashCode();
            hash = (hash * 2) + TitleAttribute.GetHashCode();
            hash = (hash * 2) + MobilePhoneAttribute.GetHashCode();
            hash = (hash * 2) + LocationAttribute.GetHashCode();
            hash = (hash * 2) + GroupMembership.GetHashCode();
            hash = (hash * 2) + GroupDN.GetHashCode();
            hash = (hash * 2) + GroupNameAttribute.GetHashCode();
            hash = (hash * 2) + GroupFilter.GetHashCode();
            hash = (hash * 2) + UserAttribute.GetHashCode();
            hash = (hash * 2) + GroupAttribute.GetHashCode();
            hash = (hash * 2) + Authentication.GetHashCode();
            hash = (hash * 2) + Login.GetHashCode();
            return(hash);
        }
Example #4
0
        public async Task <IActionResult> Get(GroupFilter filter, CancellationToken cancellationToken = default)
        {
            var groups = await authorizationAppService.FindGroupBy(filter, cancellationToken);


            return(Ok(groups));
        }
Example #5
0
        public virtual ActionResult SearchSubmit([ModelBinder(typeof(DateTimeBinder))] GroupFilter filter)
        {
            if (filter.DayShiftTC == string.Empty)
            {
                filter.DayShiftTC = null;
            }
            if (filter.DaySequenceTC == string.Empty)
            {
                filter.DaySequenceTC = null;
            }

            filter.CourseTC = CourseService.GetAllActiveCourseNames()
                              .Where(x => x.Value == filter.CourseName).Select(x => x.Key)
                              .FirstOrDefault();


            filter.CourseName = null;
            filter.DayShifts  = null;
            filter.Complexes  = null;
            filter.Sections   = null;
            filter.Employees  = null;

            return(RedirectToAction <GroupController>(
                       x => x.List(filter, 1)));
        }
        public IPagedList <Group> GetGroups(string userId, GroupFilter filter, Page page)
        {
            switch (filter)
            {
            case GroupFilter.All:
            {
                return(groupRepository.GetPage(page, x => true, order => order.GroupName));
            }

            case GroupFilter.MyGroups:
            {
                var groupsIds = groupUserrepository.GetMany(gru => gru.UserId == userId && gru.Admin).Select(gru => gru.GroupId);
                return(groupRepository.GetPage(page, where => groupsIds.Contains(where.GroupId), order => order.CreatedDate));
            }

            case GroupFilter.MyFollowingsGroups:
            {
                var userIds  = followUserrepository.GetMany(g => g.FromUserId == userId).Select(x => x.ToUserId);
                var groupIds = from item in userIds from gruser in groupUserrepository.GetMany(g => g.UserId == item) select gruser.GroupId;
                return(groupRepository.GetPage(page, where => groupIds.Contains(where.GroupId), order => order.CreatedDate));
            }

            case GroupFilter.MyFollowedGroups:
            {
                var groupIds = groupUserrepository.GetMany(g => (g.UserId == userId) && (g.Admin == false)).Select(item => item.GroupId);
                return(groupRepository.GetPage(page, where => groupIds.Contains(where.GroupId), order => order.CreatedDate));
            }

            default:
            {
                throw new ApplicationException("Filter not understood");
            }
            }
        }
        public override int GetHashCode()
        {
            var hash = 3;

            hash = (hash * 2) + EnableLdapAuthentication.GetHashCode();
            hash = (hash * 2) + StartTls.GetHashCode();
            hash = (hash * 2) + Ssl.GetHashCode();
            hash = (hash * 2) + SendWelcomeEmail.GetHashCode();
            hash = (hash * 2) + Server.GetHashCode();
            hash = (hash * 2) + UserDN.GetHashCode();
            hash = (hash * 2) + PortNumber.GetHashCode();
            hash = (hash * 2) + UserFilter.GetHashCode();
            hash = (hash * 2) + LoginAttribute.GetHashCode();
            hash = (hash * 2) + GroupMembership.GetHashCode();
            hash = (hash * 2) + GroupDN.GetHashCode();
            hash = (hash * 2) + GroupNameAttribute.GetHashCode();
            hash = (hash * 2) + GroupFilter.GetHashCode();
            hash = (hash * 2) + UserAttribute.GetHashCode();
            hash = (hash * 2) + GroupAttribute.GetHashCode();
            hash = (hash * 2) + Authentication.GetHashCode();
            hash = (hash * 2) + Login.GetHashCode();

            foreach (var pair in LdapMapping)
            {
                hash = (hash * 2) + pair.Value.GetHashCode();
            }

            foreach (var pair in AccessRights)
            {
                hash = (hash * 2) + pair.Value.GetHashCode();
            }

            return(hash);
        }
Example #8
0
 public static void Init()
 {
     JMMUser.Populate(a => a.JMMUserID);
     CloudAccount.Populate(a => a.CloudID);
     ImportFolder.Populate(a => a.ImportFolderID);
     AniDB_Anime.Populate(a => a.AniDB_AnimeID);
     AniDB_Episode.Populate(a => a.AniDB_EpisodeID);
     AniDB_File.Populate(a => a.AniDB_FileID);
     AniDB_Anime_Title.Populate(a => a.AniDB_Anime_TitleID);
     AniDB_Anime_Tag.Populate(a => a.AniDB_Anime_TagID);
     AniDB_Tag.Populate(a => a.AniDB_TagID);
     CustomTag.Populate(a => a.CustomTagID);
     CrossRef_CustomTag.Populate(a => a.CrossRef_CustomTagID);
     CrossRef_File_Episode.Populate(a => a.CrossRef_File_EpisodeID);
     VideoLocalPlace.Populate(a => a.VideoLocal_Place_ID);
     VideoLocal.Populate(a => a.VideoLocalID);
     VideoLocalUser.Populate(a => a.VideoLocal_UserID);
     GroupFilter.Populate(a => a.GroupFilterID);
     AnimeEpisode.Populate(a => a.AnimeEpisodeID);
     AnimeEpisode_User.Populate(a => a.AnimeEpisode_UserID);
     AnimeSeries.Populate(a => a.AnimeSeriesID);
     AnimeSeries_User.Populate(a => a.AnimeSeries_UserID);
     AnimeGroup.Populate(a => a.AnimeGroupID);
     AnimeGroup_User.Populate(a => a.AnimeGroup_UserID);
     GroupFilter.PostProcess();
     CleanUpMemory();
 }
Example #9
0
        private static void CreateContinueWatchingGroupFilter()
        {
            // group filters
            GroupFilterRepository          repFilters = new GroupFilterRepository();
            GroupFilterConditionRepository repGFC     = new GroupFilterConditionRepository();

            using (var session = JMMService.SessionFactory.OpenSession())
            {
                // check if it already exists
                List <GroupFilter> lockedGFs = repFilters.GetLockedGroupFilters(session);

                if (lockedGFs != null)
                {
                    // if it already exists we can leave
                    foreach (GroupFilter gfTemp in lockedGFs)
                    {
                        if (gfTemp.FilterType == (int)GroupFilterType.ContinueWatching)
                        {
                            return;
                        }
                    }

                    // the default value when the column was added to the database was '1'
                    // this is only needed for users of a migrated database
                    foreach (GroupFilter gfTemp in lockedGFs)
                    {
                        if (gfTemp.GroupFilterName.Equals(Constants.GroupFilterName.ContinueWatching, StringComparison.InvariantCultureIgnoreCase) &&
                            gfTemp.FilterType != (int)GroupFilterType.ContinueWatching)
                        {
                            FixContinueWatchingGroupFilter_20160406();
                            return;
                        }
                    }
                }

                GroupFilter gf = new GroupFilter();
                gf.GroupFilterName = Constants.GroupFilterName.ContinueWatching;
                gf.Locked          = 1;
                gf.SortingCriteria = "4;2";           // by last watched episode desc
                gf.ApplyToSeries   = 0;
                gf.BaseCondition   = 1;               // all
                gf.FilterType      = (int)GroupFilterType.ContinueWatching;

                repFilters.Save(gf);

                GroupFilterCondition gfc = new GroupFilterCondition();
                gfc.ConditionType      = (int)GroupFilterConditionType.HasWatchedEpisodes;
                gfc.ConditionOperator  = (int)GroupFilterOperator.Include;
                gfc.ConditionParameter = "";
                gfc.GroupFilterID      = gf.GroupFilterID;
                repGFC.Save(gfc);

                gfc = new GroupFilterCondition();
                gfc.ConditionType      = (int)GroupFilterConditionType.HasUnwatchedEpisodes;
                gfc.ConditionOperator  = (int)GroupFilterOperator.Include;
                gfc.ConditionParameter = "";
                gfc.GroupFilterID      = gf.GroupFilterID;
                repGFC.Save(gfc);
            }
        }
Example #10
0
        /// <summary>
        /// Action to load groups list
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public ActionResult GroupList(GroupFilter filter = GroupFilter.All, int page = 1)
        {
            // Get a paged list of groups
            var groups = groupService.GetGroups(User.Identity.GetUserId(), filter, new Page(page, 8));

            // map it to a paged list of models.
            var groupsViewModel = Mapper.Map <IPagedList <Group>, IPagedList <GroupsItemViewModel> >(groups);

            foreach (var item in groupsViewModel)
            {
                var groupAdminId   = groupUserService.GetAdminId(item.GroupId);
                var groupUserAdmin = userService.GetUser(groupAdminId);
                item.UserId   = groupUserAdmin.Id;
                item.UserName = groupUserAdmin.UserName;
            }
            var groupsList = new GroupsPageViewModel {
                GroupList = groupsViewModel, Filter = filter
            };

            // If its an ajax request, just return the table
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_GroupsTable", groupsList));
            }
            return(View("ListOfGroups", groupsList));
        }
Example #11
0
        public ActionResult Index(string category, PageSizeFilter pageSizeFilter, SortFilter sortFilter,
                                  ProducersFilter producerFilter, PageFilter pageFilter,
                                  [ModelBinder(typeof(GroupFilterBinder))] GroupFilter groupFilter)
        {
            try
            {
                var url = ProducerRedirect.GetUrl(Request.Url, category, producerFilter);
                if (url != string.Empty)
                {
                    return(RedirectPermanent(url));
                }

                ViewModel = new FilterViewModelBase(category, pageSizeFilter, sortFilter, producerFilter, pageFilter,
                                                    groupFilter);

                var categoryObj = categoryRepository.Find(category);
                if (categoryObj == null)
                {
                    throw new Exception("Invalid category name.");
                }

                ViewModel.CategoryObj = categoryObj;
                IQueryable <Product> entities = productRepository.GetProductsWithProducerByProductName(category);
                entities = StartInitialize(entities);
                EndInitialize(entities);

                return(View(ViewModel));
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(RedirectToAction("index", "error", new { statusCode = 404 }));
            }
        }
        private List <GroupFilter> GetListOfNodes(List <GroupFilter> cmnt)
        {
            List <GroupFilter> allComments = cmnt;

            List <GroupFilter> comments = new List <GroupFilter>();

            foreach (GroupFilter sourceComment in allComments)
            {
                GroupFilter c = new GroupFilter();
                c.Id    = sourceComment.Id;
                c.Title = sourceComment.Title;
                if (sourceComment.ParentId != null)
                {
                    c.Parent    = new GroupFilter();
                    c.Parent.Id = (int)sourceComment.ParentId;
                }
                c.CategoriesGroupFilters = sourceComment.CategoriesGroupFilters;
                c.FilterItems            = new List <FilterItem>();
                foreach (var item in sourceComment.FilterItems)
                {
                    c.FilterItems.Add(item);
                }
                c.FilterItems = sourceComment.FilterItems;
                comments.Add(c);
            }
            return(comments);
        }
        private List <string> RenderAsText(GroupFilter gl, PhotoDetailCollection input = null)
        {
            var result = new List <string>();

            if (gl.IsLast)
            {
                result.Add(RenderRow(gl, input));
            }
            else
            {
                foreach (var pv in gl.ParameterValues.SelectedValues)
                {
                    var renderedRows = RenderAsText(gl.NextGroupFilter, gl.Filter(pv as string, input)) as List <string>;
                    foreach (var row in renderedRows)
                    {
                        result.Add(string.Format("{0} | {1}", (pv as string).PadLeft(20), row));
                    }
                }

                // parallel execution might destroy the sort order defined by the user
                //Parallel.ForEach(
                //    gf.ParameterValues.SelectedValues,
                //    x =>
                //        {
                //            var pv = x;
                //            var renderedRows = RenderAsText(gf.NextGroupFilter, gf.Filter(pv as string, input));
                //            foreach (var row in renderedRows)
                //            {
                //                result.Add(string.Format("{0} | {1}", (pv as string).PadLeft(30), row));
                //            }
                //        });
            }

            return(result);
        }
        public async Task <DataWithCount <ICollection <GroupInfo> > > PageAsync(GroupFilter filter)
        {
            var groups = DbSet.AsNoTracking();

            if (filter.GroupTypeIds?.Any() == true)
            {
                groups = groups.Where(_ => filter.GroupTypeIds.Contains(_.GroupTypeId));
            }

            if (!string.IsNullOrWhiteSpace(filter.Search))
            {
                groups = groups.Where(_ => _.Name.Contains(filter.Search) ||
                                      (_.User.FirstName + " " + _.User.LastName).Contains(filter.Search));
            }

            var count = await groups.CountAsync();

            var groupList = await groups
                            .OrderBy(_ => _.Name)
                            .ApplyPagination(filter)
                            .ProjectTo <GroupInfo>(_mapper.ConfigurationProvider)
                            .ToListAsync();

            return(new DataWithCount <ICollection <GroupInfo> >
            {
                Data = groupList,
                Count = count
            });
        }
Example #15
0
        public static void Init()
        {
            JMMUser.Populate();
            CloudAccount.Populate();
            ImportFolder.Populate();
            AniDB_Anime.Populate();
            AniDB_Episode.Populate();
            AniDB_File.Populate();
            AniDB_Anime_Title.Populate();
            AniDB_Anime_Tag.Populate();
            AniDB_Tag.Populate();
            CustomTag.Populate();
            CrossRef_CustomTag.Populate();
            CrossRef_File_Episode.Populate();
            VideoLocalPlace.Populate();
            VideoLocal.Populate();
            VideoLocalUser.Populate();
            GroupFilter.Populate();
            AnimeEpisode.Populate();
            AnimeEpisode_User.Populate();
            AnimeSeries.Populate();
            AnimeSeries_User.Populate();
            AnimeGroup.Populate();
            AnimeGroup_User.Populate();

            // Update Contracts if necessary
            try
            {
                JMMUser.RegenerateDb();
                CloudAccount.RegenerateDb();
                ImportFolder.RegenerateDb();
                AniDB_Anime.RegenerateDb();
                AniDB_Episode.RegenerateDb();
                AniDB_File.RegenerateDb();
                AniDB_Anime_Title.RegenerateDb();
                AniDB_Anime_Tag.RegenerateDb();
                AniDB_Tag.RegenerateDb();
                CustomTag.RegenerateDb();
                CrossRef_CustomTag.RegenerateDb();
                CrossRef_File_Episode.RegenerateDb();
                VideoLocalPlace.RegenerateDb();
                VideoLocal.RegenerateDb();
                VideoLocalUser.RegenerateDb();
                AnimeEpisode.RegenerateDb();
                AnimeEpisode_User.RegenerateDb();
                AnimeSeries.RegenerateDb();
                AnimeSeries_User.RegenerateDb();
                AnimeGroup.RegenerateDb();
                AnimeGroup_User.RegenerateDb();

                GroupFilter.RegenerateDb();
                GroupFilter.PostProcess();
            }
            catch (Exception e)
            {
                LogManager.GetCurrentClassLogger().Error(e, "There was an error starting the Database Factory");
            }
            CleanUpMemory();
        }
Example #16
0
 public static List <SelectListItem> GetStudyTypes(this GroupFilter groupFilter)
 {
     return(GroupFilter.StudyTypes.Select(x => new SelectListItem {
         Selected = x.Key == groupFilter.StudyTypeId,
         Value = x.Key.ToString(),
         Text = x.Value
     }).ToList());
 }
Example #17
0
        public void Ctor_SingleFilter_ReturnsITextFilter()
        {
            var filter = new MockTextFilter(true);

            var obj = new GroupFilter(filter);

            Assert.IsAssignableFrom <ITextFilter>(obj);
        }
 public ICollection <PrimaryWorkitem> GetActivePrimaryWorkitems()
 {
     return(processor.GetPrimaryWorkitems(
                GroupFilter.And(
                    Filter.Equal("AssetState", AssetState.Active),
                    Filter.Equal("Timebox.State.Code", "ACTV")
                    ), SortBy.Ascending("Order")).Cast <PrimaryWorkitem>().ToList());
 }
Example #19
0
 public object GetGroupsData(GroupFilter filter,
                             string[] sorts,
                             string[] fields,
                             int page,
                             int limit, bool countTotal, ClaimsPrincipal principal, string roleManagerId)
 {
     return(Groups.GetData(filter, sorts, fields, page, limit, countTotal, principal, roleManagerId));
 }
Example #20
0
        public ActionResult DeleteConfirmed(int id)
        {
            GroupFilter groupFilter = db.GroupFilters.Find(id);

            db.GroupFilters.Remove(groupFilter);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #21
0
 private void InitDictionary(GroupFilter filter)
 {
     filter           = filter ?? new GroupFilter();
     filter.DayShifts = DayShiftService.GetAll().ToList();
     filter.Complexes = ComplexService.List().Select(x => x.Value).Where(c => c.IsPublished).ToList();
     filter.Sections  = SectionService.GetSectionsTree();
     filter.Employees = EmployeeService.GetAllTrainers();
 }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            GroupFilter groupFilter = await db.GroupFilter.FindAsync(id);

            db.GroupFilter.Remove(groupFilter);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #23
0
        public void Ctor_Filters_ReturnsITextFilter()
        {
            var filter1 = new MockTextFilter(true);
            var filter2 = new MockTextFilter(true);

            var obj = new GroupFilter(filter1, filter2);

            Assert.IsAssignableFrom <ITextFilter>(obj);
        }
Example #24
0
        public virtual ActionResult ListPdf(GroupFilter filter)
        {
            filter.ForPrint = true;
            filter.ForPdf   = true;
            var x      = this.Html.Action("List", filter);
            var result = PdfCreator.Create(x.ToString());

            DownloadResult.AddContentDisposition(this.Response, "расписание.pdf");
            return(File(result, "application/pdf"));
        }
Example #25
0
        public void ShouldChangeText_FilterReturnsResult_ReturnsExpected(
            bool filter1Result,
            bool filter2Result,
            bool expectedResult)
        {
            var filter1     = new MockTextFilter(filter1Result);
            var filter2     = new MockTextFilter(filter2Result);
            var groupFilter = new GroupFilter(filter1, filter2);

            var result = groupFilter.ShouldChangeText(null !, string.Empty, default, string.Empty);
Example #26
0
        private GroupFilterControl AddGroupFilterControl(GroupFilter root)
        {
            var glc = new GroupFilterControl(root);

            glc.Height             = tableLayoutPanel1.Height - 2;
            glc.Width              = 205;
            glc.buttonClose.Click += RemoveGroupControl;
            tableLayoutPanel1.Controls.Add(glc);
            return(glc);
        }
Example #27
0
        public static List <SortPropOrFieldAndDirection> GetSortDescriptions(GroupFilter gf)
        {
            List <SortPropOrFieldAndDirection> sortlist = new List <SortPropOrFieldAndDirection>();

            foreach (GroupFilterSortingCriteria gfsc in gf.SortCriteriaList)
            {
                sortlist.Add(GetSortDescription(gfsc.SortType, gfsc.SortDirection));
            }
            return(sortlist);
        }
Example #28
0
 public ActionResult Edit([Bind(Include = "GroupFilterId,ToDoId")] GroupFilter groupFilter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(groupFilter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(groupFilter));
 }
        public object Render(GroupFilter f)
        {
            string s    = string.Empty;
            var    rows = RenderAsText(f, f.Input);

            foreach (var row in rows)
            {
                s += row + "\r\n";
            }
            return(s);
        }
 public ICollection <Workitem> GetActiveSecondaryWorkitems()
 {
     return(processor.GetWorkitems(
                VersionOneProcessor.WorkitemType,
                GroupFilter.And(
                    Filter.OfTypes(VersionOneProcessor.TaskType, VersionOneProcessor.TestType),
                    Filter.Equal("Parent.AssetType", VersionOneProcessor.PrimaryWorkitemType),
                    Filter.Equal("Parent.AssetState", AssetState.Active),
                    Filter.Equal("AssetState", AssetState.Active),
                    Filter.Equal("Parent.Timebox.State.Code", "ACTV"))));
 }
    /// <summary>
    /// This function returns groups for the given filters
    /// </summary>
    /// <param name="filters"></param>
    /// <returns></returns>
    public IEnumerable<CandidateGroup> GetGroups(GroupFilter filters)
    {
        var context = new dbDataContext();
        var groups = (from t in context.tbl_Groups
                      join j in context.tbl_Users on t.UserId equals j.UserId 
                      select new CandidateGroup
                          {
                              GroupId = t.GroupId,
                              UserId = t.UserId,
                              IsPublic = t.IsPublic,
                              Name = t.Name,
                              Count = filters.NeedCount ? GetGroupUserCount(t.GroupId) : 0,
                              ClientUserName = j.Forename + " " + j.Surname,
                              CreatedDate = t.CreatedDate
                          });

        if (filters.UserId > 0)
            groups = groups.Where(t => t.UserId == filters.UserId || t.IsPublic);
        return groups;
    }
 private bool FilterWonders(GroupFilter filter, BuildingInfo info)
 {
     throw new NotImplementedException("FilterWonders is target of redirection and is not implemented.");
 }
        private PoolList<GroupInfo> CollectAssets(GroupFilter filter, Comparison<GroupInfo> comparison)
        {
            PoolList<GroupInfo> poolList = PoolList<GroupInfo>.Obtain();
            if (filter.IsFlagSet(GroupFilter.Net))
            {
                // TAM Edit Start
                poolList.AddRange(CollectAssetsNetInfoGroups().ToArray());
                // TAM Edit End
            }

            if (filter.IsFlagSet(GroupFilter.Building) || 
                filter.IsFlagSet(GroupFilter.Wonder))
            {
                uint num2 = 0u;
                while ((ulong)num2 < (ulong)((long)PrefabCollection<BuildingInfo>.LoadedCount()))
                {
                    BuildingInfo loaded2 = PrefabCollection<BuildingInfo>.GetLoaded(num2);
                    if (loaded2 != null && this.FilterWonders(filter, loaded2) && this.IsServiceValid(loaded2) && this.IsPlacementRelevant(loaded2))
                    {
                        this.AddGroup(poolList, loaded2);
                    }
                    num2 += 1u;
                }
            }

            if (filter.IsFlagSet(GroupFilter.Transport))
            {
                uint num3 = 0u;
                while ((ulong)num3 < (ulong)((long)PrefabCollection<TransportInfo>.LoadedCount()))
                {
                    TransportInfo loaded3 = PrefabCollection<TransportInfo>.GetLoaded(num3);
                    if (loaded3 != null && this.IsServiceValid(loaded3) && this.IsPlacementRelevant(loaded3))
                    {
                        this.AddGroup(poolList, loaded3);
                    }
                    num3 += 1u;
                }
            }

            if (filter.IsFlagSet(GroupFilter.Tree))
            {
                uint num4 = 0u;
                while ((ulong)num4 < (ulong)((long)PrefabCollection<TreeInfo>.LoadedCount()))
                {
                    TreeInfo loaded4 = PrefabCollection<TreeInfo>.GetLoaded(num4);
                    if (loaded4 != null && this.IsServiceValid(loaded4) && this.IsPlacementRelevant(loaded4))
                    {
                        this.AddGroup(poolList, loaded4);
                    }
                    num4 += 1u;
                }
            }

            if (filter.IsFlagSet(GroupFilter.Prop))
            {
                uint num5 = 0u;
                while ((ulong)num5 < (ulong)((long)PrefabCollection<PropInfo>.LoadedCount()))
                {
                    PropInfo loaded5 = PrefabCollection<PropInfo>.GetLoaded(num5);
                    if (loaded5 != null && this.IsServiceValid(loaded5) && this.IsPlacementRelevant(loaded5))
                    {
                        this.AddGroup(poolList, loaded5);
                    }
                    num5 += 1u;
                }
            }

            poolList.Sort(comparison);
            return poolList;
        }
Example #34
0
 public IPagedList<Group> GetGroups(string userId, GroupFilter filter, Page page)
 {
     switch (filter)
     {
         case GroupFilter.All:
         {
             return groupRepository.GetPage(page,x=>true,order=>order.GroupName);
         }
         case GroupFilter.MyGroups:
         {
             var groupsIds = groupUserrepository.GetMany(gru => gru.UserId == userId && gru.Admin).Select(gru => gru.GroupId);
             return groupRepository.GetPage(page, where => groupsIds.Contains(where.GroupId), order => order.CreatedDate);
         }
         case GroupFilter.MyFollowingsGroups:
         {
             var userIds = followUserrepository.GetMany(g => g.FromUserId == userId).Select(x => x.ToUserId);
             var groupIds = from item in userIds from gruser in groupUserrepository.GetMany(g => g.UserId == item) select gruser.GroupId;
             return groupRepository.GetPage(page, where => groupIds.Contains(where.GroupId), order => order.CreatedDate);
         }
         case GroupFilter.MyFollowedGroups:
         {
             var groupIds = groupUserrepository.GetMany(g => (g.UserId == userId) && (g.Admin == false)).Select(item => item.GroupId);
             return groupRepository.GetPage(page, where => groupIds.Contains(where.GroupId), order => order.CreatedDate);
         }
         default:
         {
             throw new ApplicationException("Filter not understood");
         }
     }
 }
Example #35
0
 public static Selector GenSelector(string expression) {
     //devive the group selector
     var exprs = expression.Split(',');
     if (exprs.Length == 1) {
         return new Selector(expression,GenContainFilter(expression));
     }
     JQuery.GroupFilter groupFilter = new GroupFilter();
     foreach (var exprstr in exprs) {
         var exprstr1 = exprstr.Trim();
         if (exprstr1 == string.Empty) continue;
         var filter = GenContainFilter(exprstr);
         groupFilter.Filters.Add(filter);
     }
     if (groupFilter.Filters.Count == 0) throw new JQuery.SelectorExpressionException(expression);
     return new Selector(expression,groupFilter);
 }
Example #36
0
        private static void EnsureBlogPostGroupExists(string groupKey, IAuthor author, ICommentService cs)
        {
            GroupFilter groupFilter = new GroupFilter();
            groupFilter.GroupKey.Add(groupKey);
            var group = cs.GetGroups(groupFilter).SingleOrDefault();

            if (group == null)
            {
                var groupProxy = new GroupProxy("Group title", "blog posts in provider", author) { Key = groupKey };
                group = cs.CreateGroup(groupProxy);
            }
        }
Example #37
0
        /// <summary>
        /// Action to load groups list 
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public ActionResult GroupList(GroupFilter filter = GroupFilter.All, int page = 1)
        {
            // Get a paged list of groups
            var groups = groupService.GetGroups(User.Identity.GetUserId(), filter, new Page(page,8));
            
            // map it to a paged list of models.
            var groupsViewModel = Mapper.Map<IPagedList<Group>, IPagedList<GroupsItemViewModel>>(groups);

            foreach (var item in groupsViewModel)
            {
                var groupAdminId = groupUserService.GetAdminId(item.GroupId);
                var groupUserAdmin = userService.GetUser(groupAdminId);
                item.UserId = groupUserAdmin.Id;
                item.UserName = groupUserAdmin.UserName;
            }
            var groupsList = new GroupsPageViewModel {GroupList = groupsViewModel, Filter = filter};

            // If its an ajax request, just return the table
            if (Request.IsAjaxRequest())
            {
                return PartialView("_GroupsTable", groupsList);
            }
            return View("ListOfGroups", groupsList);
        }