/// <summary> /// Entry point for attributes to notify about a change (modified, added, removed). /// </summary> /// <param name="name">The name of the attribute that has been changed.</param> internal override void OnAttributeChanged(String name) { if (name.Equals(AttributeNames.Rel, StringComparison.Ordinal)) { RelList.Update(Rel); } else { base.OnAttributeChanged(name); } }
/// <summary> /// Gets an IEnumerable{SelectListItem} of project statuses, as a default /// SelectList doesn't add option value attributes. /// </summary> public IEnumerable <Activity> WhatsHotList() { List <Activity> WhatsHotList = new List <Activity>(); DateTime filter = DateTime.Now.AddDays(-28); IEnumerable <Page> PageList; PageList = AllPages(); PageList = PageList.Where(x => x.ModifiedOn.Date > filter).ToList(); PageList = PageList.OrderByDescending(x => x.ModifiedOn).ToList(); foreach (Page page in PageList) { IEnumerable <Relationship> RelList; RelList = GetRelByPage(page.Id); int RelCount = RelList.Count(); Activity activity = new Activity(); activity.id = RelCount; activity.projectName = page.Title; activity.projectId = page.Id; activity.orgName = GetOrgByID(page.orgID).OrgName; WhatsHotList.Add(activity); } WhatsHotList = WhatsHotList.OrderByDescending(x => x.id).ToList(); WhatsHotList = WhatsHotList.Take(3).ToList(); return(WhatsHotList); }
/// <summary> /// Gets an IEnumerable{SelectListItem} of project statuses, as a default /// SelectList doesn't add option value attributes. /// </summary> public IEnumerable <Activity> ActivityViewList() { IEnumerable <Relationship> RelList; RelList = FindAllRels(); RelList = RelList.OrderByDescending(x => x.relDateTime); RelList = RelList.Take(10).ToList(); List <Activity> items = new List <Activity>(); foreach (Relationship rel in RelList) { bool fail = false; Activity item = new Activity(); try { User user = new User(); user = GetUserById(rel.userid); item.userNames = user?.Firstname + " " + user?.Lastname; } catch { fail = true; } try { RelationshipType reltype = new RelationshipType(); reltype = GetRelTypeByID(rel.relTypeId); string activityPastTense = ""; if (reltype.relTypeText == "Like") { activityPastTense = "liked"; } if (reltype.relTypeText == "Join") { activityPastTense = "joined"; } if (reltype.relTypeText == "Watcher") { activityPastTense = "watched"; } if (reltype.relTypeText == "Contributer") { activityPastTense = "contributed to"; } item.activityName = activityPastTense; } catch { fail = true; } try { item.activityDateTime = rel.relDateTime; } catch { fail = true; } try { //get the page the relationship is related to Page page = new Page(); page = GetPageById(rel.pageId); item.projectName = page.Title; item.projectId = page.Id; //get the orgainsation that owns the page Organisation org = new Organisation(); org = GetOrgByID(page.orgID); item.orgName = org.OrgName; } catch { fail = true; } if (fail == false) { items.Add(item); } } IEnumerable <Page> PageList; PageList = AllPages(); PageList = PageList.OrderByDescending(x => x.ModifiedOn).ToList(); PageList = PageList.Take(10).ToList(); foreach (Page page in PageList) { Activity item = new Activity(); try { User user = new User(); user = GetUserByUsername(page.ModifiedBy); item.userNames = user?.Firstname + " " + user?.Lastname; } catch { } try { string activityPastTense = ""; if (page.ModifiedOn == page.CreatedOn) { activityPastTense = "added"; } else { activityPastTense = "edited"; } item.activityName = activityPastTense; } catch { } try { item.activityDateTime = page.ModifiedOn; } catch { } try { item.projectName = page.Title; item.projectId = page.Id; //get the orgainsation that owns the page Organisation org = new Organisation(); org = GetOrgByID(page.orgID); item.orgName = org.OrgName; } catch { } items.Add(item); } DateTime filter = new DateTime(2014, 10, 1); IEnumerable <User> UserList; UserList = AllUsers(); UserList.OrderByDescending(x => x.createdOn); UserList = UserList.Where(x => x.createdOn.Date > filter).ToList(); //UserList = UserList.Take(10).ToList(); foreach (User user in UserList) { Activity item = new Activity(); item.userNames = user.Firstname + " " + user.Lastname; item.activityName = "signup"; item.activityDateTime = user.createdOn; item.projectName = ""; item.projectId = 0; //get the orgainsation that owns the page Organisation org = new Organisation(); org = GetOrgByID(user.orgID); var orgname = string.Empty; if (org != null) { orgname = org.OrgName; } if (orgname.Contains("_") != true) { item.orgName = " from " + orgname; } items.Add(item); } items = items.OrderByDescending(x => x.activityDateTime).ToList(); items = items.Take(15).ToList(); return(items); }