コード例 #1
0
        private void RefreshBoundData()
        {
            if (SelectedNodePath != "")
            {
                SPGroup rmManagersGroup = SPContext.Current.Web.WBxGetGroupOrNull(WBFarm.Local.RecordsManagersGroupName);

                if (rmManagersGroup != null)
                {
                    if (rmManagersGroup.ContainsCurrentUser)
                    {
                        currentUserIsRecordsManager = true;
                        WBLogging.Debug("Set the current user as being a records manager.");
                    }
                    else
                    {
                        WBLogging.Debug("The current user is not a part of the RM Managers group called: " + WBFarm.Local.RecordsManagersGroupName);
                    }
                }
                else
                {
                    WBLogging.Debug("Could not find the RM Managers group called: " + WBFarm.Local.RecordsManagersGroupName);
                }

                SelectedRecordsType.Text = SelectedNodePath.Replace("Records Types/", "").Replace("/", " / ");

                WBRecordsType recordsType    = null;
                WBTerm        functionalArea = null;
                WBTerm        subjectTag     = null;

                switch (SelectedView)
                {
                case VIEW_BY_RECORDS_TYPE:
                {
                    recordsType = recordsTypesTaxonomy.GetSelectedRecordsType(SelectedNodePath);
                    SelectedRecordsTypeDescription.Text = recordsType.Description;
                    break;
                }

                case VIEW_BY_FUNCTION_THEN_TYPE:
                {
                    string[] parts = SelectedNodePath.Split('/');
                    if (parts.Length < 3)
                    {
                        break;
                    }

                    string        functionPath = parts[0];
                    List <String> partsList    = new List <String>(parts);
                    partsList.RemoveAt(0);
                    string recordsTypePath = String.Join("/", partsList.ToArray());

                    Term functionalAreaTerm = functionalAreaTaxonomy.GetSelectedTermByPath(functionPath);
                    if (functionalAreaTerm != null)
                    {
                        functionalArea = new WBTerm(functionalAreaTaxonomy, functionalAreaTerm);
                    }

                    recordsType = recordsTypesTaxonomy.GetSelectedRecordsType(recordsTypePath);
                    SelectedRecordsTypeDescription.Text = recordsType.Description;
                    break;
                }

                case VIEW_BY_SUBJECT:
                {
                    Term subjectTagsTerm = subjectTagsTaxonomy.GetSelectedTermByPath(SelectedNodePath);
                    if (subjectTagsTerm != null)
                    {
                        subjectTag = new WBTerm(subjectTagsTaxonomy, subjectTagsTerm);
                        SelectedRecordsTypeDescription.Text = subjectTag.Description;
                    }

                    if (subjectTag == null)
                    {
                        WBLogging.Generic.Verbose("Did not find subject with path: " + SelectedNodePath);
                        return;
                    }
                    break;
                }

                case VIEW_BY_FOLDER_PATH:
                {
                    string[] parts = SelectedNodePath.Split('/');
                    if (parts.Length < 3)
                    {
                        break;
                    }

                    string        functionPath         = parts[0];
                    List <String> recordsTypePartsList = new List <String>();
                    recordsTypePartsList.Add(parts[1]);
                    recordsTypePartsList.Add(parts[2]);
                    string recordsTypePath = String.Join("/", recordsTypePartsList.ToArray());

                    Term functionalAreaTerm = functionalAreaTaxonomy.GetSelectedTermByPath(functionPath);
                    if (functionalAreaTerm != null)
                    {
                        functionalArea = new WBTerm(functionalAreaTaxonomy, functionalAreaTerm);
                    }

                    recordsType = recordsTypesTaxonomy.GetSelectedRecordsType(recordsTypePath);
                    SelectedRecordsTypeDescription.Text = recordsType.Description;
                    break;
                }

                default: return;
                }


                WBTeam team = WBTeam.GetFromTeamSite(teamsTaxonomy, SPContext.Current.Web);

                WBFarm farm = WBFarm.Local;

                using (SPSite site = new SPSite(farm.ProtectedRecordsLibraryUrl))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        WBQuery query = new WBQuery();

                        if (recordsType == null && functionalArea == null)
                        {
                            query.LogicallyCannotHaveResults = true;
                        }
                        else
                        {
                            if (SelectedView == VIEW_BY_FUNCTION_THEN_TYPE || SelectedView == VIEW_BY_FOLDER_PATH)
                            {
                                WBLogging.Generic.Unexpected("Setting FilterByFolderPath = " + SelectedNodePath);
                                query.FilterByFolderPath = SelectedNodePath;
                            }
                            else
                            {
                                if (recordsType != null)
                                {
                                    WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType);
                                    recordsTypeClause.UseDescendants = true;
                                    query.AddClause(recordsTypeClause);
                                }

                                if (functionalArea != null)
                                {
                                    WBQueryClause functionalAreaClause = new WBQueryClause(WBColumn.FunctionalArea, WBQueryClause.Comparators.Equals, functionalArea);
                                    functionalAreaClause.UseDescendants = true;
                                    query.AddClause(functionalAreaClause);
                                }
                            }

                            query.AddClause(new WBQueryClause(WBColumn.ContentType, WBQueryClause.Comparators.Equals, farm.WorkBoxRecordContentTypeName));

                            if (subjectTag != null)
                            {
                                WBQueryClause subjectTagClause = new WBQueryClause(WBColumn.SubjectTags, WBQueryClause.Comparators.Equals, subjectTag);
                                subjectTagClause.UseDescendants = false;
                                query.AddClause(subjectTagClause);
                            }

                            if (team != null)
                            {
                                query.AddEqualsFilter(WBColumn.InvolvedTeams, team);
                            }

                            if (!String.IsNullOrEmpty(webPart.FilterByProtectiveZone))
                            {
                                query.AddEqualsFilter(WBColumn.ProtectiveZone, webPart.FilterByProtectiveZone);
                            }
                        }

                        showFilters = true;

                        string statusFilter = SelectedLiveOrArchivedStatusFilter;
                        if (statusFilter == null || statusFilter == "")
                        {
                            statusFilter = "All";                                             // WBColumn.LIVE_OR_ARCHIVED__LIVE;
                        }
                        if (statusFilter != "All")
                        {
                            query.AddEqualsFilter(WBColumn.LiveOrArchived, statusFilter);
                        }

                        FilterLiveStatus.CssClass     = "wbf-unselected-filter";
                        FilterArchivedStatus.CssClass = "wbf-unselected-filter";
                        FilterAllStatus.CssClass      = "wbf-unselected-filter";

                        if (statusFilter == WBColumn.LIVE_OR_ARCHIVED__LIVE)
                        {
                            FilterLiveStatus.CssClass = "wbf-selected-filter";
                        }
                        if (statusFilter == WBColumn.LIVE_OR_ARCHIVED__ARCHIVED)
                        {
                            FilterArchivedStatus.CssClass = "wbf-selected-filter";
                        }
                        if (statusFilter == "All")
                        {
                            FilterAllStatus.CssClass = "wbf-selected-filter";
                        }


                        query.AddViewColumn(WBColumn.Name);
                        query.AddViewColumn(WBColumn.Title);
                        query.AddViewColumn(WBColumn.TitleOrName);
                        query.AddViewColumn(WBColumn.FileSize);
                        query.AddViewColumn(WBColumn.FileTypeIcon);
                        query.AddViewColumn(WBColumn.FileType);
                        query.AddViewColumn(WBColumn.DisplayFileSize);
                        query.AddViewColumn(WBColumn.EncodedAbsoluteURL);
                        query.AddViewColumn(WBColumn.FunctionalArea);
                        query.AddViewColumn(WBColumn.OwningTeam);
                        query.AddViewColumn(WBColumn.ReferenceDate);
                        query.AddViewColumn(WBColumn.ReferenceID);
                        query.AddViewColumn(WBColumn.SeriesTag);
                        query.AddViewColumn(WBColumn.ProtectiveZone);
                        query.AddViewColumn(WBColumn.RecordID);
                        query.AddViewColumn(WBColumn.LiveOrArchived);



                        if (SelectedView != VIEW_BY_SUBJECT)
                        {
                            query.AddViewColumn(WBColumn.SubjectTags);
                        }
                        else
                        {
                            query.AddViewColumn(WBColumn.RecordsType);
                        }

                        if (sortColumn != null)
                        {
                            query.OrderBy(sortColumn, ascending);
                        }



                        SPList recordsLibrary = web.GetList(farm.ProtectedRecordsLibraryUrl); //"Documents"]; //farm.RecordsCenterRecordsLibraryName];

                        DataTable dataTable = recordsLibrary.WBxGetDataTable(site, query);

                        ShowResults.DataSource = dataTable;

                        ShowResults.Columns.Clear();
                        ShowResults.Columns.Add(WBUtils.DynamicIconTemplateField(WBColumn.FileTypeIcon, WBColumn.EncodedAbsoluteURL));
                        ShowResults.Columns.Add(WBUtils.HyperLinkField(WBColumn.TitleOrName, WBColumn.EncodedAbsoluteURL, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FileType, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.DisplayFileSize, sortColumn, ascending));
//                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, sortColumn, ascending));
                        //                      ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending));
                        //ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.ProtectiveZone, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.LiveOrArchived, sortColumn, ascending));


                        if (SelectedView != VIEW_BY_SUBJECT)
                        {
                            ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.SubjectTags, sortColumn, ascending));
                        }
                        else
                        {
                            ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, sortColumn, ascending));
                        }

                        if (this.currentUserIsRecordsManager)
                        {
                            List <WBColumn> valueColumns = new List <WBColumn>();
                            valueColumns.Add(WBColumn.RecordID);

                            String formatString = SPContext.Current.Web.Url + "/_layouts/WorkBoxFramework/UpdateRecordsMetadata.aspx?RecordID={0}";

                            formatString = "<a href=\"javascript: WorkBoxFramework_commandAction('" + formatString + "', 800, 600); \">(edit metadata)</a>";

                            ShowResults.Columns.Add(WBUtils.FormatStringTemplateField(formatString, valueColumns));
                            WBLogging.Debug("Added the (edit metadata) show column.");
                        }
                        else
                        {
                            WBLogging.Debug("Did not add the (edit metadata) show column.");
                        }


                        ShowResults.DataBind();
                    }
                }
            }
            else
            {
                WBUtils.logMessage("SelectedNodePath was empty");
            }
        }
コード例 #2
0
        private void RefreshBoundDocumentsList()
        {
            WBFarm farm = WBFarm.Local;

            // SC
            if (String.IsNullOrEmpty(farm.ProtectedRecordsLibraryUrl))
            {
                return;
            }

            bool foundDocuments = false;

            using (SPSite site = new SPSite(farm.ProtectedRecordsLibraryUrl))
            {
                WBTaxonomy subjectTags          = WBTaxonomy.GetSubjectTags(site);
                WBTaxonomy teamsTaxonomy        = WBTaxonomy.GetTeams(subjectTags);
                WBTaxonomy recordsTypesTaxonomy = WBTaxonomy.GetRecordsTypes(teamsTaxonomy);

                Term   pageSeriesTagTerm   = subjectTags.GetSelectedTermByPath(FullSubjectTagPath);
                WBTerm localPageSubjectTag = null;
                if (pageSeriesTagTerm != null)
                {
                    localPageSubjectTag = new WBTerm(subjectTags, pageSeriesTagTerm);
                }

                if (localPageSubjectTag != null)
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        WBQuery query = new WBQuery();

                        WBQueryClause subjectTagClause = new WBQueryClause(WBColumn.SubjectTags, WBQueryClause.Comparators.Equals, localPageSubjectTag);
                        subjectTagClause.UseDescendants = false;
                        query.AddClause(subjectTagClause);

                        if (webPart.OnlyLiveRecords)
                        {
                            WBQueryClause isLiveClause = new WBQueryClause(WBColumn.LiveOrArchived, WBQueryClause.Comparators.Equals, WBColumn.LIVE_OR_ARCHIVED__LIVE);
                            query.AddClause(isLiveClause);
                        }
                        else
                        {
                            string statusFilter = SelectedLiveOrArchivedStatusFilter;
                            if (statusFilter == null || statusFilter == "")
                            {
                                statusFilter = WBColumn.LIVE_OR_ARCHIVED__LIVE;
                            }
                            if (statusFilter != "All")
                            {
                                query.AddEqualsFilter(WBColumn.LiveOrArchived, statusFilter);
                            }

                            FilterLiveStatus.CssClass     = "wbf-unselected-filter";
                            FilterArchivedStatus.CssClass = "wbf-unselected-filter";
                            FilterAllStatus.CssClass      = "wbf-unselected-filter";

                            if (statusFilter == WBColumn.LIVE_OR_ARCHIVED__LIVE)
                            {
                                FilterLiveStatus.CssClass = "wbf-selected-filter";
                            }
                            if (statusFilter == WBColumn.LIVE_OR_ARCHIVED__ARCHIVED)
                            {
                                FilterArchivedStatus.CssClass = "wbf-selected-filter";
                            }
                            if (statusFilter == "All")
                            {
                                FilterAllStatus.CssClass = "wbf-selected-filter";
                            }
                        }

                        WBTeam team = null;
                        if (!String.IsNullOrEmpty(webPart.FilterByOwningTeam))
                        {
                            team = teamsTaxonomy.GetSelectedTeam(webPart.FilterByOwningTeam);

                            if (team != null)
                            {
                                query.AddEqualsFilter(WBColumn.OwningTeam, team);
                            }
                        }


                        if (webPart.ShowRecordTypes && !String.IsNullOrEmpty(recordsTypeFullPath) && recordsTypeFullPath != NO_RECORDS_TYPE_SELECTED)
                        {
                            WBRecordsType recordsTypeToFilterBy = recordsTypesTaxonomy.GetSelectedRecordsType(recordsTypeFullPath);

                            if (recordsTypeToFilterBy != null)
                            {
                                query.AddEqualsFilter(WBColumn.RecordsType, recordsTypeToFilterBy);
                            }
                        }

                        /*
                         * string protectiveZoneFilter = "Public"; // Request.QueryString["ProtectiveZone"];
                         * if (protectiveZoneFilter != null && protectiveZoneFilter != "")
                         * {
                         *  query.AddEqualsFilter(WBColumn.ProtectiveZone, protectiveZoneFilter);
                         * }
                         * */

                        query.AddViewColumn(WBColumn.Name);
                        query.AddViewColumn(WBColumn.Title);
                        query.AddViewColumn(WBColumn.TitleOrName);
                        query.AddViewColumn(WBColumn.FileSize);
                        query.AddViewColumn(WBColumn.FileTypeIcon);
                        query.AddViewColumn(WBColumn.FileType);
                        query.AddViewColumn(WBColumn.DisplayFileSize);
                        query.AddViewColumn(WBColumn.EncodedAbsoluteURL);
                        query.AddViewColumn(WBColumn.LiveOrArchived);
                        query.AddViewColumn(WBColumn.RecordID);

//                        query.AddViewColumn(WBColumn.OwningTeam);
                        query.AddViewColumn(WBColumn.ReferenceDate);
                        //                     query.AddViewColumn(WBColumn.ReferenceID);
                        //                      query.AddViewColumn(WBColumn.SeriesTag);
//                        query.AddViewColumn(WBColumn.ProtectiveZone);
                        //query.AddViewColumn(WBColumn.DeclaredRecord);
                        //                    query.AddViewColumn(WBColumn.SubjectTags);

                        if (sortColumn == null)
                        {
                            sortColumn = WBColumn.ReferenceDate;
                            ascending  = false;
                        }

                        if (sortColumn != null)
                        {
                            query.OrderBy(sortColumn, ascending);
                        }

                        SPList recordsLibrary = web.GetList(farm.ProtectedRecordsLibraryUrl); //"Documents"]; //farm.RecordsCenterRecordsLibraryName];

                        DataTable dataTable = recordsLibrary.WBxGetDataTable(site, query);

                        if (dataTable.Rows.Count > 0)
                        {
                            foundDocuments = true;
                        }

                        DocumentsForSubject.DataSource = dataTable;

                        DocumentsForSubject.Columns.Clear();
                        DocumentsForSubject.Columns.Add(WBUtils.DynamicIconTemplateField(WBColumn.FileTypeIcon, WBColumn.EncodedAbsoluteURL));
                        DocumentsForSubject.Columns.Add(WBUtils.HyperLinkField(WBColumn.TitleOrName, WBColumn.EncodedAbsoluteURL, sortColumn, ascending));
                        DocumentsForSubject.Columns.Add(WBUtils.BoundField(WBColumn.FileType, sortColumn, ascending));
                        DocumentsForSubject.Columns.Add(WBUtils.BoundField(WBColumn.DisplayFileSize, sortColumn, ascending));
                        if (!webPart.OnlyLiveRecords)
                        {
                            DocumentsForSubject.Columns.Add(WBUtils.BoundField(WBColumn.LiveOrArchived, sortColumn, ascending));
                        }
                        DocumentsForSubject.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, sortColumn, ascending));


                        SPGroup rmManagersGroup = SPContext.Current.Web.WBxGetGroupOrNull(WBFarm.Local.RecordsManagersGroupName);

                        if (rmManagersGroup != null)
                        {
                            if (rmManagersGroup.ContainsCurrentUser)
                            {
                                List <WBColumn> valueColumns = new List <WBColumn>();
                                valueColumns.Add(WBColumn.RecordID);

                                String formatString = SPContext.Current.Web.Url + "/_layouts/WorkBoxFramework/UpdateRecordsMetadata.aspx?RecordID={0}";

                                formatString = "<a href=\"javascript: WorkBoxFramework_commandAction('" + formatString + "', 800, 600); \">(edit metadata)</a>";

                                DocumentsForSubject.Columns.Add(WBUtils.FormatStringTemplateField(formatString, valueColumns));
                            }
                        }


                        DocumentsForSubject.DataBind();
                    }
                }
                else
                {
                    WBUtils.logMessage("pageSubjectTag was null");
                }
            }


            if (foundDocuments && !webPart.OnlyLiveRecords)
            {
                showFilters = true;
            }

            if (!foundDocuments && !foundChildSubjectTags && !(onRootOfAtoZ))
            {
                int archivedDocs = 0;

                if (!webPart.OnlyLiveRecords)
                {
                    if (SelectedLiveOrArchivedStatusFilter == WBColumn.LIVE_OR_ARCHIVED__LIVE)
                    {
                        archivedDocs = this.CountArchivedDocsOfThisSelection();
                    }

                    showFilters = true;
                }

                if (archivedDocs > 0)
                {
                    DynamicNoDocumentsMessage.Text = "(No live documents have been found. There are " + archivedDocs + " archived documents of this type.)";
                }
                else
                {
                    DynamicNoDocumentsMessage.Text = "(No documents have been found)";
                }
            }
            else
            {
                DynamicNoDocumentsMessage.Text = "";
            }

            // Show Related docs header if docs or message being displayed
            if (DocumentsForSubject.Rows.Count > 0 || !String.IsNullOrEmpty(DynamicNoDocumentsMessage.Text))
            {
                h3RelatedDocs.Style.Add(HtmlTextWriterStyle.Display, "block");
            }
        }