Beispiel #1
0
        internal WBQuery GetQueryForNewlyPublishedPublicDocsThatNeedEmailAlert()
        {
            WBQuery query = new WBQuery();

            query.AddEqualsFilter(WBColumn.LiveOrArchived, WBColumn.LIVE_OR_ARCHIVED__LIVE);
            query.AddEqualsFilter(WBColumn.ProtectiveZone, WBRecordsType.PROTECTIVE_ZONE__PUBLIC);
            query.AddEqualsFilter(WBColumn.RecordSeriesStatus, WBColumn.RECORD_SERIES_STATUS__LATEST);
            query.AddIsNullFilter(WBColumn.SentNewlyPublishedAlert);
            query.AddFilter(WBColumn.DatePublished, WBQueryClause.Comparators.GreaterThan, DateTime.Now.AddDays(-_daysToIncludeNewlyPublishedPublicDocsInEmailAlerts));
            query.RecursiveAll = true;

            return(query);
        }
Beispiel #2
0
        public SPListItemCollection GetLiveVersionsUpTo(String recordSeriesID, String recordID)
        {
            WBQuery query = new WBQuery();

            if (String.IsNullOrEmpty(recordSeriesID) || recordSeriesID == recordID)
            {
                query.AddFilter(WBColumn.LiveOrArchived, WBQueryClause.Comparators.Equals, WBColumn.LIVE_OR_ARCHIVED__LIVE);
                query.AddFilter(WBColumn.RecordID, WBQueryClause.Comparators.Equals, recordID);
            }
            else
            {
                query.AddFilter(WBColumn.RecordSeriesID, WBQueryClause.Comparators.Equals, recordSeriesID);
                query.AddFilter(WBColumn.LiveOrArchived, WBQueryClause.Comparators.Equals, WBColumn.LIVE_OR_ARCHIVED__LIVE);
                query.AddFilter(WBColumn.RecordID, WBQueryClause.Comparators.LessThanEquals, recordID);
            }

            query.OrderByDescending(WBColumn.RecordID);

            return(List.WBxGetItems(Site, query));
        }
Beispiel #3
0
        internal Dictionary <String, String> GetCheckBoxDetailsForDocumentType(String documentType)
        {
            WBQuery query = new WBQuery();

            query.AddEqualsFilter(WBColumn.DocumentType, documentType);
            query.AddEqualsFilter(WBColumn.UseCheckBox, true);
            query.OrderByAscending(WBColumn.Order);

            SPList checkBoxDetailsList = Libraries.ProtectedMasterLibrary.Web.Lists.TryGetList(CHECK_BOXES_LIST_TITLE);
            SPListItemCollection items = checkBoxDetailsList.WBxGetItems(Libraries.ProtectedMasterLibrary.Site, query);

            Dictionary <String, String> checkBoxDetails = new Dictionary <String, String>();

            foreach (SPListItem item in items)
            {
                checkBoxDetails.Add(item.WBxGetAsString(WBColumn.CheckBoxCode), item.WBxGetAsString(WBColumn.CheckBoxText));
            }

            return(checkBoxDetails);
        }
Beispiel #4
0
        private WBTermCollection <WBSubjectTag> AddAdditionalSubjectTags(SPSite controlSite, WBTermCollection <WBSubjectTag> subjectTags, String sourceID)
        {
            WBLogging.Migration.Verbose("Adding additional subject tags for item with Source ID = " + sourceID);
            WBQuery query = new WBQuery();

            query.AddFilter(WBColumn.SourceID, WBQueryClause.Comparators.Equals, sourceID);

            SPListItemCollection items = MigrationSubjectsList.WBxGetItems(controlSite, query);

            if (items.Count > 0)
            {
                WBTaxonomy subjectTagsTaxonomy = subjectTags.Taxonomy;

                subjectTags = new WBTermCollection <WBSubjectTag>(subjectTags);

                foreach (SPListItem item in items)
                {
                    String paths = WBUtils.NormalisePaths(item.WBxGetAsString(WBColumn.SubjectTagsPaths));

                    string[] pathsArray = paths.Split(';');
                    foreach (String path in pathsArray)
                    {
                        Term subjectTerm = subjectTagsTaxonomy.GetOrCreateSelectedTermByPath(path);
                        if (subjectTerm != null)
                        {
                            WBLogging.Migration.Verbose("Adding additional subject: " + path);

                            subjectTags.Add(new WBSubjectTag(subjectTagsTaxonomy, subjectTerm));
                        }
                        else
                        {
                            WBLogging.Migration.Unexpected("Could not find or create subject: " + path);
                        }
                    }
                }
            }

//            WBLogging.Migration.Verbose("At this point the subjectTags = " + subjectTags);

            return(subjectTags);
        }
Beispiel #5
0
        internal WBQuery GetQueryForTeamsPublicRecordsToArchiveInFutureWeek(WBTeam team, int weekInFuture, bool limitToJustOneWeek)
        {
            WBQuery query = new WBQuery();

            if (team != null)
            {
                query.AddEqualsFilter(WBColumn.OwningTeam, team);
            }
            query.AddEqualsFilter(WBColumn.LiveOrArchived, WBColumn.LIVE_OR_ARCHIVED__LIVE);
            query.AddEqualsFilter(WBColumn.ProtectiveZone, WBRecordsType.PROTECTIVE_ZONE__PUBLIC);
            query.AddEqualsFilter(WBColumn.RecordSeriesStatus, WBColumn.RECORD_SERIES_STATUS__LATEST);

            query.OrderByAscending(WBColumn.ReviewDate);

            if (limitToJustOneWeek && weekInFuture > 1)
            {
                query.AddFilter(WBColumn.ReviewDate, WBQueryClause.Comparators.GreaterThanEquals, DateTime.Now.AddDays((-_weeksBetweenReviewDateAndAutoArchival + weekInFuture - 1) * 7));
            }

            query.AddFilter(WBColumn.ReviewDate, WBQueryClause.Comparators.LessThan, DateTime.Now.AddDays((-_weeksBetweenReviewDateAndAutoArchival + weekInFuture) * 7));
            query.RecursiveAll = true;

            return(query);
        }
Beispiel #6
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();
                    }
                }
            }
        }
Beispiel #7
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();
                    }
                }
            }
        }