protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            Title = (!String.IsNullOrEmpty(Title) ? Title : Resources.Resource.RecentActivity);

            var activityBox = (RecentActivityBox)TemplateControl.LoadControl(RecentActivityBox.Location);

            activityBox.userActivityList = UserActivityManager.GetUserActivities(
                TenantId,
                UserId,
                ProductId,
                new[] { ModuleId },
                UserActivityConstants.AllActionType,
                null,
                0, MaxItems);
            activityBox.MaxLengthTitle = 20;
            activityBox.ItemCSSClass   = ItemCSSClass;
            Controls.Add(activityBox);

            Controls.Add(new LiteralControl
            {
                Text =
                    string.Format("<div style='margin:10px 20px 0 20px;'><a href='{0}'>{1}</a></div>",
                                  WhatsNew.GetUrlForModule(ProductId, ModuleId),
                                  Resources.Resource.ToWhatsNewPage)
            });
        }
Example #2
0
        public static List <DocServiceParams.RecentDocument> GetRecentEditedDocument(bool forEdit, int count, string crumbsSeporator, IFileDao fileDao)
        {
            var recent = new List <DocServiceParams.RecentDocument>();

            var activity = UserActivityManager.GetUserActivities(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID,
                                                                 ProductEntryPoint.ID, null, UserActivityConstants.AllActionType,
                                                                 new[] { "OpenEditorFile" }, 0, 100);

            foreach (var entryId in activity.Select(userActivity => userActivity.ContentID.Substring("file_".Length)))
            {
                if (recent.Exists(r => r.ID.Equals(entryId)))
                {
                    continue;
                }

                var fileAct = fileDao.GetFile(entryId);

                if (fileAct.RootFolderType == FolderType.TRASH)
                {
                    continue;
                }

                if (!FileUtility.UsingHtml5(fileAct.Title))
                {
                    continue;
                }

                if (!Global.GetFilesSecurity().CanRead(fileAct))
                {
                    continue;
                }

                string uri;
                if (forEdit && Global.GetFilesSecurity().CanEdit(fileAct))
                {
                    uri = CommonLinkUtility.GetFileWebEditorUrl(fileAct.ID);
                }
                else
                {
                    uri = CommonLinkUtility.GetFileWebViewerUrl(fileAct.ID);
                }

                var fileBreadCrumbs = Global.GetBreadCrumbs(fileAct.FolderID);
                recent.Add(new DocServiceParams.RecentDocument
                {
                    ID         = entryId,
                    Title      = fileAct.Title,
                    Uri        = CommonLinkUtility.GetFullAbsolutePath(uri),
                    FolderPath = string.Join(crumbsSeporator, fileBreadCrumbs.Select(folder => folder.Title).ToArray())
                });

                if (recent.Count == count)
                {
                    break;
                }
            }
            return(recent);
        }
Example #3
0
        private static IList <object[]> BuildUserActivityReport(ReportFilter filter)
        {
            var result = new List <object[]>();
            var users  = new List <UserInfo>();

            if (filter.UserId != Guid.Empty)
            {
                users.Add(CoreContext.UserManager.GetUsers(filter.UserId));
            }
            else if (filter.DepartmentId != Guid.Empty)
            {
                users.AddRange(CoreContext.UserManager.GetUsersByGroup(filter.DepartmentId));
            }
            else
            {
                users.AddRange(CoreContext.UserManager.GetUsers());
            }

            foreach (var u in users.OrderBy(u => u, UserInfoComparer.Default))
            {
                var tasks       = 0;
                var milestones  = 0;
                var discussions = 0;
                var files       = 0;
                var pid         = ProductEntryPoint.ID;
                var fromDate    = filter.GetFromDate(true);
                var toDate      = filter.GetToDate(true);

                UserActivityManager.GetUserActivities(
                    TenantProvider.CurrentTenantID, u.ID, pid, new[] { pid }, UserActivityConstants.AllActionType, null, fromDate, toDate)
                .ForEach(a =>
                {
                    var data = a.AdditionalData.Split(new[] { '|' })[0];
                    if (a.ActionType == UserActivityConstants.ContentActionType && data == EntityType.Task.ToString())
                    {
                        tasks++;
                    }
                    if (a.ActionType == UserActivityConstants.ContentActionType && data == EntityType.Milestone.ToString())
                    {
                        milestones++;
                    }
                    if (a.ActionType == UserActivityConstants.ContentActionType && data == EntityType.Message.ToString())
                    {
                        discussions++;
                    }
                    if (a.ActionType == UserActivityConstants.ActivityActionType && data == EntityType.File.ToString())
                    {
                        files++;
                    }
                });

                result.Add(new object[] { u.ID, tasks, milestones, discussions, files, tasks + milestones + discussions + files });
            }

            return(result);
        }
        /// <summary>
        /// Gets specified user activities for the Community product.
        /// </summary>
        /// <param name="userID">UserID. If the UserID is null returns activities for all of the users.</param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public IList <WhatsNewUserActivity> GetUserActivities(Guid?userID, DateTime startDate, DateTime endDate)
        {
            var activities = UserActivityManager.GetUserActivities(TenantProvider.CurrentTenantID, null, CommunityProduct.ID, null, UserActivityConstants.ContentActionType, null, startDate, endDate);

            var userContentActivities = activities.ConvertAll(a => new UserContentActivity(a));

            userContentActivities = (from u in userContentActivities
                                     orderby u.ModuleName ascending, u.Date descending
                                     select u).ToList <UserContentActivity>();

            var whatsNewUserActivities = Convert(userContentActivities);

            return(whatsNewUserActivities);
        }
Example #5
0
        public IList <WhatsNewUserActivity> GetUserActivities(Guid?userID, DateTime startDate, DateTime endDate)
        {
            var result = new List <WhatsNewUserActivity>();

            var activities = UserActivityManager.GetUserActivities(TenantProvider.CurrentTenantID, null, ProductEntryPoint.ID, new[] { ProductEntryPoint.ID }, UserActivityConstants.ContentActionType, null, startDate, endDate).ToList();

            if (userID.HasValue)
            {
                var ids = Global.EngineFactory.GetProjectEngine()
                          .GetByParticipant(userID.Value)
                          .Select(p => p.ID)
                          .Union(Global.EngineFactory.GetParticipantEngine().GetFollowingProjects(userID.Value));
                activities = activities.FindAll(a => ids.Contains(Convert.ToInt32(a.ContainerID)));
            }

            if (activities.Count != 0)
            {
                activities.Sort((x, y) =>
                {
                    var proj1   = int.Parse(x.ContainerID);
                    var proj2   = int.Parse(y.ContainerID);
                    var compare = proj1.CompareTo(proj2);
                    return(compare != 0 ? compare : DateTime.Compare(x.Date, y.Date));
                });

                activities.ForEach(a =>
                {
                    var parts = a.AdditionalData.Split(new[] { '|' });
                    if (3 <= parts.Length)
                    {
                        var projectTitle = parts[2];
                        var timeLineType = (EntityType)Enum.Parse(typeof(EntityType), parts[0]);

                        result.Add(new WhatsNewUserActivity
                        {
                            Title           = a.Title,
                            Date            = a.Date,
                            URL             = CommonLinkUtility.GetFullAbsolutePath(a.URL),
                            UserAbsoluteURL = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(a.UserID, CommonLinkUtility.GetProductID())),
                            UserName        = DisplayUserSettings.GetFullUserName(a.UserID),
                            BreadCrumbs     = new List <String> {
                                string.Format("[{0}]", projectTitle), ResourceEnumConverter.ConvertToString(timeLineType)
                            }
                        });
                    }
                });
            }
            return(result);
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UserID == Guid.Empty)
            {
                UserID = SecurityContext.CurrentAccount.ID;
            }


            var filter = new TaskFilter {
                ParticipantId = UserID, MyProjects = true
            };
            var tasks    = Global.EngineFactory.GetTaskEngine().GetByFilter(filter);
            var projects = Global.EngineFactory.GetProjectEngine().GetByParticipant(UserID).Select(prj => new ProjectVm(prj)).OrderBy(r => r.ProjectTitle).ToList();

            foreach (var project in projects)
            {
                project.OpenedTasksCount = tasks.Count(t => t.Project.ID == project.ProjectId && t.Status == TaskStatus.Open);
                project.ClosedTasksCount = tasks.Count(t => t.Project.ID == project.ProjectId && t.Status == TaskStatus.Closed);
            }

            ProjectsRepeater.DataSource = projects;
            ProjectsRepeater.DataBind();

            //load user activity
            //
            var activities = UserActivityManager.GetUserActivities(
                TenantProvider.CurrentTenantID,
                UserID,
                ProductEntryPoint.ID,
                new[] { ProductEntryPoint.ID },
                UserActivityConstants.AllActionType,
                null,
                0, 10);

            LastActivityRepeater.DataSource = activities.ConvertAll(a => new ActivityVm(a));
            LastActivityRepeater.DataBind();
        }
        public AjaxResponse ShowRecentActivity(Guid productId, List <Guid> moduleIds, string strFromDate, string strToDate, int type, int currentPage, Guid userOrDeptID)
        {
            if (!SecurityContext.AuthenticateMe(CookiesManager.GetCookies(CookiesType.AuthKey)))
            {
                throw new UnauthorizedAccessException("Unauthorized");
            }

            var resp = new AjaxResponse();

            var fromDate   = Convert.ToDateTime(strFromDate);
            var toDate     = Convert.ToDateTime(strToDate);
            var actionType = UserActivityConstants.ActivityActionType;

            if (type == 0)
            {
                actionType = UserActivityConstants.AllActionType;
            }
            if (type == 1)
            {
                actionType = UserActivityConstants.ContentActionType;
            }

            var userActivity = UserActivityManager.GetUserActivities(
                TenantProvider.CurrentTenantID,
                userOrDeptID,
                productId,
                moduleIds,
                actionType,
                null,
                fromDate,
                toDate.AddDays(1));

            var activityContainer = userActivity.ConvertAll(rec => new ActivityContainer
            {
                UserProfileLink = ASC.Core.Users.StudioUserInfoExtension.RenderProfileLink(ASC.Core.CoreContext.UserManager.GetUsers(rec.UserID), rec.ProductID),
                ActionText      = rec.ActionText.ToLower(),
                URL             = CommonLinkUtility.GetFullAbsolutePath(rec.URL),
                Title           = rec.Title.HtmlEncode(),
                ModuleName      = GetModuleName(rec),
                ModuleIconUrl   = GetModuleIconUrl(rec),
                Date            = rec.Date.ToString(DateTimeExtension.DateFormatPattern),
                AgoSentence     = GetAgoSentence(rec.Date)
            });


            var CountShowOnPage = 15;

            var countTotal = activityContainer.Count;
            var amountPage = Convert.ToInt32(Math.Ceiling(countTotal / (CountShowOnPage * 1.0)));

            currentPage = currentPage > 0 ? currentPage : 1;
            if (amountPage != 0)
            {
                currentPage = currentPage <= amountPage ? currentPage : amountPage;
            }

            resp.rs10 = "5"; //CountVisiblePage
            resp.rs11 = amountPage.ToString();
            resp.rs12 = currentPage.ToString();
            resp.rs13 = Resource.BackButton;
            resp.rs14 = Resource.NextButton;

            var result = new List <ActivityContainer>();

            for (var i = (currentPage - 1) * CountShowOnPage; i < currentPage * CountShowOnPage && i < activityContainer.Count; i++)
            {
                result.Add(activityContainer[i]);
            }

            resp.rs1 = JavaScriptSerializer.Serialize(result);
            return(resp);
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ((CommunityMasterPage)this.Master).DisabledSidePanel = true;

            this.Title = Resources.CommunityResource.MainPageTitle;

            if (ShowEmptyScreen())
            {
                var dashboardEmptyScreen = (DashboardEmptyScreen)Page.LoadControl(DashboardEmptyScreen.Location);

                AddContent.Controls.Add(dashboardEmptyScreen);

                return;
            }


            _widgetTabControl = new WidgetTab(new Guid("{57DAD9FA-BBB8-4a3a-B208-D3CD58691D35}"),
                                              ColumnSchemaType.Schema_25_50_25,
                                              "communityDashboard"
                                              );

            var modules = new List <ASC.Web.Core.ModuleManagement.Module>();

            foreach (var item in WebItemManager.Instance.GetSubItems(CommunityProduct.ID))
            {
                if ((item is ASC.Web.Core.ModuleManagement.Module) == false)
                {
                    continue;
                }

                var module = item as ASC.Web.Core.ModuleManagement.Module;
                modules.Add(module);


                foreach (var widget in module.Widgets)
                {
                    try
                    {
                        _widgetTabControl.WidgetCollection.Add(GetWidgetControl(module, widget));
                    }
                    catch (Exception ex)
                    {
                        //TODO: draw error control or something
                        _widgetTabControl.WidgetCollection.Add(GetBrokenWidgetControl(ex));
                    }
                }
            }

            _widgetTabControl.WidgetCollection.Add(new Widget(BirthdayReminderWidget.WidgetID,
                                                              new BirthdayReminderWidget()
            {
                ProductID = CommunityProduct.ID
            },
                                                              Resources.CommunityResource.BirthdayReminderWidgetName,
                                                              Resources.CommunityResource.BirthdayReminderWidgetDescription)
            {
                ImageURL             = WebImageSupplier.GetAbsoluteWebPath("birthday_widget.png"),
                SettingsProviderType = typeof(StudioWidgetSettingsProvider),
                UsePositionAttribute = true
            });

            _widgetTabControl.WidgetCollection.Add(new Widget(NewEmployeeWidget.WidgetID,
                                                              new NewEmployeeWidget()
            {
                ProductID = CommunityProduct.ID
            },
                                                              CustomNamingPeople.Substitute <Resources.CommunityResource>("NewEmployeeWidgetName"),
                                                              Resources.CommunityResource.NewEmployeeWidgetDescription)
            {
                ImageURL             = WebImageSupplier.GetAbsoluteWebPath("newemp_widget.png"),
                SettingsProviderType = typeof(StudioWidgetSettingsProvider),
                UsePositionAttribute = true
            });

            var widgetSettings = SettingsManager.Instance.LoadSettingsFor <ProductActivityWidgetSettings>(SecurityContext.CurrentAccount.ID);

            ProductActivity productActivityControl = (ProductActivity)LoadControl(ProductActivity.Location);

            productActivityControl.ProductId  = CommunityProduct.ID;
            productActivityControl.Activities = UserActivityManager.GetUserActivities(
                TenantProvider.CurrentTenantID, null, CommunityProduct.ID, null, UserActivityConstants.ContentActionType, null, 0, widgetSettings.CountActivities)
                                                .ConvertAll(a => new UserContentActivity(a));


            _widgetTabControl.WidgetCollection.Add(new Widget(ProductActivity.WidgetID,
                                                              productActivityControl,
                                                              Resources.CommunityResource.CommunityActivityWidgetName,
                                                              Resources.CommunityResource.CommunityActivityWidgetDescription)
            {
                ImageURL             = WebImageSupplier.GetAbsoluteWebPath("lastadded_widget.png"),
                SettingsProviderType = typeof(StudioWidgetSettingsProvider),
                Position             = new Point(0, 2),
                WidgetURL            = WhatsNew.GetUrlForModule(Product.CommunityProduct.ID, null)
            });


            WidgetsContent.Controls.Add(_widgetTabControl);

            NavigationPanel NavigationPanel = (NavigationPanel)this.LoadControl(NavigationPanel.Location);

            NavigationPanelContent.Controls.Add(NavigationPanel);

            if (SecurityContext.CurrentAccount.IsAuthenticated)
            {
                NavigationPanel.addButton(Resources.CommunityResource.BtnCustomizeWidgets, WebImageSupplier.GetAbsoluteWebPath("btn_managewidgets.png"), "javascript:communityDashboard.ShowSettings()", 3);
                if (modules.Count > 0)
                {
                    NavigationPanel.addButton(Resources.CommunityResource.BtnAddContent, WebImageSupplier.GetAbsoluteWebPath("btn_addcontent.png"), "javascript:StudioManager.ShowAddContentDialog()", 2);
                    AddContentControl AddCntnt = (AddContentControl)this.LoadControl(AddContentControl.Location);

                    foreach (var module in modules)
                    {
                        try
                        {
                            AddCntnt.Types.Add(new AddContentControl.ContentTypes {
                                Link = module.Context.GetCreateContentPageAbsoluteUrl(), Icon = (module as IWebItem).GetIconAbsoluteURL(), Label = module.Name
                            });
                        }
                        catch (Exception)
                        {
                            AddCntnt.Types.Add(new AddContentControl.ContentTypes {
                                Link = "#", Icon = string.Empty, Label = "Error loading " + module.Name
                            });
                        }
                    }


                    AddContent.Controls.Add(AddCntnt);
                }
            }
        }
Example #9
0
        public void ProcessRequest(HttpContext context)
        {
            //Process authorization
            if (!ProcessAuthorization(context))
            {
                AccessDenied(context);
                return;
            }
            var productId    = Helpers.ParseGuid(context.Request[ProductParam]);
            var moduleIds    = Helpers.ParseGuids(context.Request[ModuleParam]);
            var actionType   = Helpers.ParseInt(context.Request[ActionTypeParam]);
            var containerIds = Helpers.Tokenize(context.Request[ContainerParam]);
            var title        = context.Request[TitleParam];

            if (string.IsNullOrEmpty(title))
            {
                title = Resources.Resource.RecentActivity;
            }
            var userIds = Helpers.ParseGuid(context.Request[UserParam]);

            if (userIds.HasValue)
            {
                throw new NotImplementedException();
            }

            var userActivity = UserActivityManager.GetUserActivities(
                TenantProvider.CurrentTenantID,
                null,
                productId.GetValueOrDefault(),
                moduleIds,
                actionType.GetValueOrDefault(),
                containerIds,
                0, 100);

            var feedItems = userActivity.Select(x =>
            {
                var user        = CoreContext.UserManager.GetUsers(x.UserID);
                var veloContext = Formatter.PrepareContext(x, user);
                var item        = new SyndicationItem(
                    HttpUtility.HtmlDecode(Formatter.Format(context, "title.txt", veloContext)),
                    SyndicationContent.CreateHtmlContent(Formatter.Format(context, "pattern.html", veloContext)),
                    new Uri(CommonLinkUtility.GetFullAbsolutePath(x.URL)),
                    x.ID.ToString(),
                    new DateTimeOffset(TenantUtil.DateTimeToUtc(x.Date)))
                {
                    PublishDate = x.Date,
                    Summary     = SyndicationContent.CreatePlaintextContent(Formatter.Format(context, "pattern.txt", veloContext))
                };
                var person = new SyndicationPerson(user.Email)
                {
                    Name = user.UserName
                };
                if (productId.HasValue)
                {
                    person.Uri = CommonLinkUtility.GetUserProfile(user.ID, productId.Value);
                }
                item.Authors.Add(person);
                return(item);
            });

            var lastUpdate = new DateTimeOffset(DateTime.UtcNow);

            if (userActivity.Count > 0)
            {
                lastUpdate = new DateTimeOffset(userActivity.Max(x => x.Date));
            }

            var feed = new SyndicationFeed(
                title,
                Resources.Resource.RecentActivity,
                new Uri(context.Request.GetUrlRewriter(), VirtualPathUtility.ToAbsolute(Studio.WhatsNew.PageUrl)),
                TenantProvider.CurrentTenantID.ToString(),
                lastUpdate, feedItems);

            var rssFormatter = new Atom10FeedFormatter(feed);

            //Set writer settings
            var settings = new XmlWriterSettings();

            settings.CheckCharacters  = false;
            settings.ConformanceLevel = ConformanceLevel.Document;
            settings.Encoding         = Encoding.UTF8;
            settings.Indent           = true;


            using (var writer = XmlWriter.Create(context.Response.Output, settings))
            {
                rssFormatter.WriteTo(writer);
            }
            context.Response.Charset     = Encoding.UTF8.WebName;
            context.Response.ContentType = "application/atom+xml";
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     ltRecentActivity.Text       = Resources.Resource.RecentActivity;
     uaRecentActivity.Activities = UserActivityManager.GetUserActivities(TenantProvider.CurrentTenantID, UserID, ProductID, null, UserActivityConstants.AllActionType, null, 0, 10)
                                   .ConvertAll <UserContentActivity>(a => new UserContentActivity(a));
 }