コード例 #1
0
        public static List <String> GetWorkBoxURLsVisitedSinceTickTime(UserProfile profile, long ticksAtLastUpdate)
        {
            WBLogging.TimerTasks.Verbose("In GetWorkBoxURLsModidifiedSinceTickTime(): Looking at work boxes recently visited by: " + profile.DisplayName);

            List <String> listOfWorkBoxURLs = new List <string>();

            UserProfileValueCollection workBoxesRecentlyVisited = profile[WorkBox.USER_PROFILE_PROPERTY__MY_RECENTLY_VISITED_WORK_BOXES];
            String recentlyVisitedDetails = workBoxesRecentlyVisited.Value.WBxToString();

            if (!String.IsNullOrEmpty(recentlyVisitedDetails))
            {
                string[] recentWorkBoxes = recentlyVisitedDetails.Split(';');

                if (recentWorkBoxes.Length > 0)
                {
                    WBLogging.TimerTasks.Verbose("In GetWorkBoxURLsModidifiedSinceTickTime(): Found recently visited work boxes: " + recentWorkBoxes.Length);

                    List <String> updatedRecentWorkBoxes = new List <String>();

                    foreach (string recentWorkBoxLinkDetails in recentWorkBoxes)
                    {
                        WBLink workBoxLink = new WBLink(recentWorkBoxLinkDetails);
                        if (!workBoxLink.IsOK)
                        {
                            continue;
                        }

                        try
                        {
                            long ticksWhenVisited = 0;
                            if (workBoxLink.UsingTicksWhenVisited)
                            {
                                string ticksWhenVisitedString = workBoxLink.TicksWhenVisitedString;
                                ticksWhenVisited = Convert.ToInt64(workBoxLink.TicksWhenVisitedString);

                                if (ticksWhenVisited > ticksAtLastUpdate)
                                {
                                    listOfWorkBoxURLs.Add(workBoxLink.URL);
                                }
                            }
                        }
                        catch (Exception exception)
                        {
                            WBLogging.Teams.Unexpected("In GetWorkBoxURLsModidifiedSinceTickTime(): Something went wrong when looking for recently changed work boxes", exception);
                        }
                    }
                }
            }

            return(listOfWorkBoxURLs);
        }
コード例 #2
0
        public static void CheckTitlesOfFavouriteWorkBoxes(SPSite cacheSite, SPList cacheList, UserProfile profile)
        {
            WBLogging.TimerTasks.Verbose("Checking titles of favourite work boxes of: " + profile.DisplayName);

            UserProfileValueCollection favouriteWorkBoxesPropertyValue = profile[WorkBox.USER_PROFILE_PROPERTY__MY_FAVOURITE_WORK_BOXES];
            String favouriteWBDetails = favouriteWorkBoxesPropertyValue.Value.WBxToString();

            if (!String.IsNullOrEmpty(favouriteWBDetails))
            {
                string[] favouriteWorkBoxes = favouriteWBDetails.Split(';');

                if (favouriteWorkBoxes.Length > 0)
                {
                    WBLogging.TimerTasks.Verbose("Found favourite work boxes: " + favouriteWorkBoxes.Length);

                    bool hasChangesToSave = false;

                    List <String> updatedFavouriteWorkBoxes = new List <String>();

                    foreach (string favouriteWorkBoxLinkDetails in favouriteWorkBoxes)
                    {
                        WBLink workBoxLink = new WBLink(favouriteWorkBoxLinkDetails);
                        if (!workBoxLink.IsOK)
                        {
                            continue;
                        }

                        /*
                         * string[] details = favouriteWorkBoxLinkDetails.Split('|');
                         * string workBoxTitle = details[0];
                         * string workBoxUrl = details[1];
                         * string workBoxUniqueID = details[2];
                         * string workBoxGUID = details[3];
                         */

                        try
                        {
                            WBQuery query = new WBQuery();
                            query.AddEqualsFilter(WBColumn.WorkBoxGUID, workBoxLink.SPWebGUID);
                            query.AddViewColumn(WBColumn.Title);

                            SPListItemCollection items = cacheList.WBxGetItems(cacheSite, query);

                            if (items.Count > 0)
                            {
                                String cachedWBTitle = items[0].WBxGetAsString(WBColumn.Title);
                                if (cachedWBTitle != workBoxLink.Title)
                                {
                                    WBLogging.TimerTasks.Verbose("Updating work box title in favourite list: " + workBoxLink.Title + " -> " + cachedWBTitle);
                                    workBoxLink.Title = cachedWBTitle;
                                    hasChangesToSave  = true;
                                }
                            }
                        }
                        catch (Exception exception)
                        {
                            WBLogging.Teams.Monitorable("Something went wrong when searching for a favourite work box" + exception.Message);
                        }


                        updatedFavouriteWorkBoxes.Add(workBoxLink.ToString());
                    }


                    if (hasChangesToSave)
                    {
                        profile[WorkBox.USER_PROFILE_PROPERTY__MY_FAVOURITE_WORK_BOXES].Value = WBUtils.JoinUpToLimit(";", updatedFavouriteWorkBoxes, 3100);
                        profile.Commit();
                    }
                }
            }
        }
コード例 #3
0
        public static void CheckLastModifiedDatesAndTitlesOfRecentWorkBoxes(SPSite cacheSite, SPList cacheList, UserProfile profile, long ticksAtLastUpdate)
        {
            WBLogging.TimerTasks.Verbose("Looking at work boxes recently visited by: " + profile.DisplayName);

            UserProfileValueCollection workBoxesRecentlyVisited = profile[WorkBox.USER_PROFILE_PROPERTY__MY_RECENTLY_VISITED_WORK_BOXES];
            String recentlyVisitedDetails = workBoxesRecentlyVisited.Value.WBxToString();

            if (!String.IsNullOrEmpty(recentlyVisitedDetails))
            {
                string[] recentWorkBoxes = recentlyVisitedDetails.Split(';');

                if (recentWorkBoxes.Length > 0)
                {
                    WBLogging.TimerTasks.Verbose("Found recently visited work boxes: " + recentWorkBoxes.Length);

                    bool hasChangesToSave = false;

                    List <String> updatedRecentWorkBoxes = new List <String>();

                    foreach (string recentWorkBoxLinkDetails in recentWorkBoxes)
                    {
                        WBLink workBoxLink = new WBLink(recentWorkBoxLinkDetails);
                        if (!workBoxLink.IsOK)
                        {
                            continue;
                        }

                        /*
                         * string[] details = recentWorkBoxLinkDetails.Split('|');
                         * string workBoxTitle = details[0];
                         * string workBoxUrl = details[1];
                         * string workBoxUniqueID = details[2];
                         * string workBoxGUID = details[3];
                         */

                        try
                        {
                            long ticksWhenVisited = 0;
                            //if (details.Length >= 5)
                            if (workBoxLink.UsingTicksWhenVisited)
                            {
                                string ticksWhenVisitedString = workBoxLink.TicksWhenVisitedString;
                                ticksWhenVisited = Convert.ToInt64(workBoxLink.TicksWhenVisitedString);

                                // Would we have already done this recently visited work box during the last update:
                                if (ticksWhenVisited > ticksAtLastUpdate)
                                {
                                    // OK so we're going to update the details for this work box:
                                    using (WorkBox workBox = new WorkBox(workBoxLink.URL))
                                    {
                                        workBox.RecentlyVisited(cacheList, ticksWhenVisited);
                                    }
                                }
                            }

                            WBQuery query = new WBQuery();
                            query.AddEqualsFilter(WBColumn.WorkBoxGUID, workBoxLink.SPWebGUID);
                            query.AddViewColumn(WBColumn.Title);

                            SPListItemCollection items = cacheList.WBxGetItems(cacheSite, query);

                            if (items.Count > 0)
                            {
                                String cachedWBTitle = items[0].WBxGetAsString(WBColumn.Title);
                                if (cachedWBTitle != workBoxLink.Title)
                                {
                                    WBLogging.TimerTasks.Verbose("Updating work box title in recently visited list: " + workBoxLink.Title + " -> " + cachedWBTitle);
                                    workBoxLink.Title = cachedWBTitle;
                                    hasChangesToSave  = true;
                                }
                            }
                        }
                        catch (Exception exception)
                        {
                            WBLogging.Teams.Monitorable("Something went wrong when searching for a favourite work box" + exception.Message);
                        }

                        updatedRecentWorkBoxes.Add(workBoxLink.ToString());
                    }


                    if (hasChangesToSave)
                    {
                        profile[WorkBox.USER_PROFILE_PROPERTY__MY_RECENTLY_VISITED_WORK_BOXES].Value = WBUtils.JoinUpToLimit(";", updatedRecentWorkBoxes, 3100);
                        profile.Commit();
                    }
                }
            }
        }