public UserDashboardViewModel GetActivitiesByDate(DateTime date) { var umbracoRepository = new UmbracoRepository(); var userDashboardViewModel = new UserDashboardViewModel(); //if this date then get first date if (date.ToString("yyyy-MM-dd") == "1987-05-10") { var userActivitiesDate = umbracoRepository.GetAvailableDates(); date = userActivitiesDate.ToArray()[0]; } var userActivities = umbracoRepository.GetUserActivities(date).ToArray(); foreach (var userActivityItem in userActivities) { var useractViewObj = new UserActivitiesViewModel(userActivityItem.Datestamp) { NodeId = userActivityItem.NodeId, LogComment = userActivityItem.LogComment, LogHeader = userActivityItem.LogHeader, Text = userActivityItem.Text, Username = userActivityItem.Username, UserTypeAlias = userActivityItem.UserTypeAlias }; userDashboardViewModel.UsersActivitiesLog.Add(useractViewObj); } return userDashboardViewModel; }
public DevDashboardViewModel GetViewModel() { var umbracoRepository = new UmbracoRepository(); var dashboardViewModel = new DevDashboardViewModel(); dashboardViewModel.HijackedRoutes = umbracoRepository.GetControllersAssignableFrom(typeof (IRenderMvcController), true) .Select(x => new HijackedRouteViewModel { Name = x.Name, Namespace = x.Namespace, ActionMethods = x.ActionMethods, }) .OrderBy(x => x.Name) .ToList(); dashboardViewModel.SurfaceControllers = umbracoRepository.GetControllersAssignableFrom(typeof(SurfaceController)) .Select(x => new SurfaceControllerViewModel { Name = x.Name, Namespace = x.Namespace, ActionMethods = x.ActionMethods, }) .OrderBy(x => x.Name) .ToList(); dashboardViewModel.ApplicationEventHandlers = umbracoRepository.GetApplicationEventHandlers() .Select(x => new ApplicationEventHandlerViewModel { Name = x.Name, Namespace = x.Namespace, }) .OrderBy(x => x.Name) .ToList(); dashboardViewModel.ContentFinders = umbracoRepository.GetContentFinders() .Select(x => new ContentFinderViewModel { Name = x.Name, Namespace = x.Namespace, }) .OrderBy(x => x.Name) .ToList(); dashboardViewModel.CustomEvents.AddRange(GetCustomEventsForType(umbracoRepository, ApplicationContext.Current.Services.ContentService, "ContentService")); dashboardViewModel.CustomEvents.AddRange(GetCustomEventsForType(umbracoRepository, ApplicationContext.Current.Services.MediaService, "MediaService")); dashboardViewModel.CustomEvents.AddRange(GetCustomEventsForType(umbracoRepository, ApplicationContext.Current.Services.MemberService, "MemberService")); return dashboardViewModel; }
public IEnumerable<string> GetAvailableDates() { var umbracoRepository = new UmbracoRepository(); var userDashboardViewModel = new UserDashboardViewModel(); var userActivitiesDate = umbracoRepository.GetAvailableDates().ToArray(); IList<string> itemTransform = new List<string>(); foreach (DateTime date in userActivitiesDate) { itemTransform.Add(date.ToString("yyyy-MM-dd")); } return itemTransform; }
private IEnumerable<CustomEventViewModel> GetCustomEventsForType(UmbracoRepository umbracoRepository, IService serviceInstance, string serviceName) { return umbracoRepository.GetCustomEvents(serviceInstance) .Select(x => new CustomEventViewModel { ServiceName = serviceName, EventName = x.EventName, Handlers = x.Handlers .Select(y => new CustomEventViewModel.Handler { Name = y.Name, Namespace = y.Namespace, }) .OrderBy(y => y.Name) }) .OrderBy(x => x.ServiceName) .ThenBy(x => x.EventName); }
public DashboardViewModel GetViewModel() { var umbracoRepository = new UmbracoRepository(); var dashboardViewModel = new DashboardViewModel(); var unpublishedContent = umbracoRepository.GetUnpublishedContent().ToArray(); var logItems = umbracoRepository.GetLatestLogItems().ToArray(); var nodesInRecyleBin = umbracoRepository.GetRecycleBinNodes().Select(x => x.Id).ToArray(); foreach (var logItem in logItems.Take(10)) { var user = GetUser(logItem.UserId); var contentNode = GetContent(logItem.NodeId); if (contentNode == null || !CurrentUserHasPermissions(contentNode)) continue; var activityViewModel = new ActivityViewModel { UserDisplayName = user.Name, UserAvatarUrl = UserAvatarProvider.GetAvatarUrl(user), NodeId = logItem.NodeId, NodeName = contentNode.Name, Message = logItem.Comment, LogItemType = logItem.LogType.ToString(), Timestamp = logItem.Timestamp }; var unpublishedVersionOfLogItem = unpublishedContent.FirstOrDefault(x => x.NodeId == logItem.NodeId && x.ReleaseDate != null); if (logItem.LogType == LogTypes.Save && unpublishedVersionOfLogItem != null && unpublishedVersionOfLogItem.UpdateDate != null) { if(logItem.Timestamp.IsSameMinuteAs(unpublishedVersionOfLogItem.UpdateDate.Value)) activityViewModel.LogItemType = "SavedAndScheduled"; activityViewModel.ScheduledPublishDate = unpublishedVersionOfLogItem.ReleaseDate; } if (logItem.LogType == LogTypes.UnPublish && nodesInRecyleBin.Contains(logItem.NodeId)) { activityViewModel.LogItemType = "UnPublishToRecycleBin"; } dashboardViewModel.Activities.Add(activityViewModel); } foreach (var item in unpublishedContent.Where(x => x.ReleaseDate == null)) { var user = GetUser(item.DocumentUser); var contentNode = GetContent(item.NodeId); // Checking for null, making sure that user has permissions and checking for this content node in the recycle bin. If its in the recycle bin // we should not return this as an unpublished node. if (contentNode == null || !CurrentUserHasPermissions(contentNode) || nodesInRecyleBin.Contains(contentNode.Id)) continue; var activityViewModel = new ActivityViewModel { UserDisplayName = user.Name, UserAvatarUrl = UserAvatarProvider.GetAvatarUrl(user), NodeId = item.NodeId, NodeName = contentNode.Name, Timestamp = item.UpdateDate != null ? item.UpdateDate.Value : (DateTime?) null }; dashboardViewModel.UnpublishedContent.Add(activityViewModel); } foreach (var item in logItems.Where(x => x.UserId == Security.CurrentUser.Id).Take(10)) { var contentNode = GetContent(item.NodeId); if (contentNode == null || !CurrentUserHasPermissions(contentNode)) continue; var activityViewModel = new ActivityViewModel { NodeId = item.NodeId, NodeName = contentNode.Name, LogItemType = item.LogType.ToString(), Timestamp = item.Timestamp }; dashboardViewModel.UserRecentActivity.Add(activityViewModel); } dashboardViewModel.CountPublishedNodes = umbracoRepository.CountPublishedNodes(); dashboardViewModel.CountTotalWebsiteMembers = umbracoRepository.CountMembers(); dashboardViewModel.CountNewMembersLastWeek = umbracoRepository.CountNewMember(); dashboardViewModel.CountContentInRecycleBin = nodesInRecyleBin.Count(); return dashboardViewModel; }