protected void Page_Load(object sender, EventArgs e)
        {
            webPart = this.Parent as ViewSeriesPages;

            string additionalPath = Request.QueryString["AdditionalPath"];

            if (additionalPath == null)
            {
                additionalPath = "";
            }

            if (webPart.ParentSeriesTag == null || webPart.ParentSeriesTag == "")
            {
                PageSeriesTagName.Text = "<i>(Web part not yet configured)</i>";
                return;
            }

            string fullPath = webPart.ParentSeriesTag + additionalPath;

            WBTaxonomy seriesTags = WBTaxonomy.GetSeriesTags(SPContext.Current.Site);

            WBTerm pageSeriesTag = null;

            Term pageSeriesTagTerm = seriesTags.GetSelectedTermByPath(fullPath);

            if (pageSeriesTagTerm != null)
            {
                pageSeriesTag = new WBTerm(seriesTags, pageSeriesTagTerm);
            }

            if (pageSeriesTag == null)
            {
                PageSeriesTagName.Text = "<i>(Could not find the series tag with path: " + fullPath + ")</i>";
                return;
            }


            PageSeriesTagName.Text        = pageSeriesTag.Name;
            PageSeriesTagDescription.Text = pageSeriesTag.Description;

            string html = "<table cellspacing=\"10\" cellpadding=\"10\" class=\"seriesTags\">";

            foreach (Term child in pageSeriesTag.Term.Terms)
            {
                if (child.Terms.Count > 0)
                {
                    html = html + createTableRowForChildSeriesTag(seriesTags, additionalPath, child);
                }
                else
                {
                    html = html + createTableRowForDocument(seriesTags, child);
                }
            }

            html += "</table>";

            TableOfChildTerms.Text = html;
        }
Beispiel #2
0
        /// <summary>
        /// Updates and existing subject tag
        /// </summary>
        void UpdateTag()
        {
            // It appears that a TaxonomySession will always run as the current user, even if elevated.
            // See: http://scle.me/1skLGCY

            var currentSiteGuid = SPContext.Current.Site.ID;
            var oldContext      = HttpContext.Current;

            HttpContext.Current = null;

            SPSecurity.RunWithElevatedPrivileges(() =>
            {
                using (SPSite elevatedSite = new SPSite(currentSiteGuid))
                {
                    WBTaxonomy wbTax = WBTaxonomy.GetSubjectTags(elevatedSite);

                    Term rootSubjectTagTerm = wbTax.GetSelectedTermByPath(_path);
                    WBSubjectTag subjectTag = null;

                    if (rootSubjectTagTerm != null)
                    {
                        subjectTag = new WBSubjectTag(wbTax, rootSubjectTagTerm);
                        if (subjectTag == null)
                        {
                            return;
                        }
                    }

                    // Page content
                    subjectTag.PageContent = htmlDescription.Html;

                    // Internal Contact
                    SPUser pickedUser = ppInternalContact.WBxGetSingleResolvedUser(elevatedSite.RootWeb);
                    if (pickedUser != null)
                    {
                        subjectTag.InternalContactLoginName = pickedUser.LoginName;
                    }
                    else
                    {
                        subjectTag.InternalContactLoginName = string.Empty;
                    }

                    // External Contact
                    subjectTag.ExternalContact = htmlExternalContact.Html;

                    // Tag Name
                    subjectTag.Name = txtEdit_CurrentTagName.Text;
                    subjectTag.Update();
                }
            });

            HttpContext.Current = oldContext;
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            // Save permission group changes - its the only thing editable at the moment.
            var selectedSubjectTag = _subjectTags.GetSelectedTermByPath(tvAllSubjectTags.SelectedNode.ValuePath);

            if (selectedSubjectTag != null)
            {
                WBSubjectTag subjectTag = null;

                subjectTag = new WBSubjectTag(_subjectTags, selectedSubjectTag);
                if (subjectTag == null)
                {
                    return; // something better!
                }
                subjectTag.TeamsWithPermissionToEditUIControlValue = taxTeams.Text;

                subjectTag.Update();

                lblPageMessage.Text = "Saved";
            }
        }
Beispiel #4
0
        protected override void CreateChildControls()
        {
            WBTaxonomy teams = WBTaxonomy.GetTeams(SPContext.Current.Site);

            String selectedUserLoginName = Page.Request.QueryString["LoginName"];

            if (!String.IsNullOrEmpty(selectedUserLoginName))
            {
                selectedUser = SPContext.Current.Web.WBxEnsureUserOrNull(selectedUserLoginName);
            }

            TermCollection terms = teams.TermSet.Terms;

            if (ParentTeamsTerm != null && ParentTeamsTerm != "")
            {
                Term parentTerm = teams.GetSelectedTermByPath(ParentTeamsTerm);

                terms = parentTerm.Terms;
            }

            SPTreeView treeView = new SPTreeView();

            TreeNodeStyle nodeStyle = new TreeNodeStyle();

            treeView.NodeStyle.HorizontalPadding = new Unit(3);
            treeView.NodeStyle.CssClass          = "wbf-team-tree-node";

            this.Controls.Clear();
            this.Controls.Add(treeView);

            if (UseTreeView)
            {
                treeView.ShowLines = true;

                treeView.Nodes.Clear();

                PopulateTreeView(treeView.Nodes, teams, terms);
            }
            else
            {
                PopulateListView(teams, terms);
            }

            if (!displayingAnyTeams)
            {
                Literal noTeamsLiteral = new Literal();
                noTeamsLiteral.Text = "<i>(You are not a member of such a team site yet. Contact the SharePoint champion in your area for more information)</i>";
                this.Controls.Add(noTeamsLiteral);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Initialise the form
        /// </summary>
        void BindForm()
        {
            if (String.IsNullOrEmpty(_path))
            {
                return;
            }

            SPSecurity.RunWithElevatedPrivileges(() =>
            {
                using (SPSite elevatedSite = new SPSite(SPContext.Current.Site.ID))
                {
                    WBTaxonomy subjectTags = WBTaxonomy.GetSubjectTags(elevatedSite);

                    Term rootSubjectTagTerm = subjectTags.GetSelectedTermByPath(_path);
                    WBSubjectTag subjectTag = null;

                    if (rootSubjectTagTerm != null)
                    {
                        subjectTag = new WBSubjectTag(subjectTags, rootSubjectTagTerm);
                        if (subjectTag == null)
                        {
                            return;
                        }
                    }

                    // DOes the current user have permission?
                    WBTaxonomy teamsTax = WBTaxonomy.GetTeams(elevatedSite);
                    if (!subjectTag.TeamsWithPermissionToEdit(teamsTax).WBxContainsCurrentUserAsTeamMember())
                    {
                        Response.Redirect("AccessDenied.html");
                    }

                    if (!CreateNew) // Edit Mode
                    {
                        txtTagName.Text     = subjectTag.Name;
                        txtTagName.ReadOnly = true;

                        // To support existing terms where content is stored in the description, first attempt to read from the the multi-property array Page Content,
                        // then fall back to the description. Changes will be saved to the multi-property array.
                        if (String.IsNullOrEmpty(subjectTag.PageContent))
                        {
                            htmlDescription.Field.Html = subjectTag.Description;
                        }
                        else
                        {
                            htmlDescription.Field.Html = subjectTag.PageContent;
                        }

                        ppInternalContact.WBxInitialise(subjectTag.InternalContact(SPContext.Current.Web)); // It's an option to use the RootWeb of the elevated site here, I have used SPContext for consistency
                        htmlExternalContact.Field.Html = subjectTag.ExternalContact;

                        // Added this due to issue with the Html editor in IE in a modal dialog!  If the value is null, you cannot click in to start editing.
                        if (String.IsNullOrEmpty(htmlExternalContact.Field.Html))
                        {
                            htmlExternalContact.Field.Html = " ";
                        }
                        if (String.IsNullOrEmpty(htmlDescription.Field.Html))
                        {
                            htmlDescription.Field.Html = " ";
                        }
                    }
                    else
                    {
                        // Nothing to do if creating a new child term
                    }
                }
            });
        }
Beispiel #6
0
        /// <summary>
        /// Creates a new Subject Tag
        /// </summary>
        void CreateNewTag()
        {
            // It appears that a TaxonomySession will always run as the current user, even if elevated.
            // See: http://scle.me/1skLGCY

            var currentSiteGuid = SPContext.Current.Site.ID;
            var oldContext      = HttpContext.Current;

            HttpContext.Current = null;

            SPSecurity.RunWithElevatedPrivileges(() =>
            {
                using (SPSite elevatedSite = new SPSite(currentSiteGuid))
                {
                    WBTaxonomy wbTax = WBTaxonomy.GetSubjectTags(elevatedSite);

                    _path = String.Concat(_path, "/", txtTagName.Text);

                    Term rootSubjectTagTerm = wbTax.GetSelectedTermByPath(_path); // Try and get the tag, but don't auto create
                    WBSubjectTag subjectTag = null;

                    if (rootSubjectTagTerm != null)
                    {
                        lblValidationMessage.Text = "The term you are trying to create already exists";
                    }
                    else
                    {
                        rootSubjectTagTerm = wbTax.GetSelectedTermByPath(_path, true); // Now create
                    }

                    if (rootSubjectTagTerm != null)
                    {
                        subjectTag = new WBSubjectTag(wbTax, rootSubjectTagTerm);

                        if (subjectTag == null)
                        {
                            return;
                        }

                        subjectTag.PageContent = htmlDescription.Html;
                        if (htmlExternalContact.Html.ToLower() != "<div>&#160;</div>")
                        {
                            subjectTag.ExternalContact = htmlExternalContact.Html;
                        }

                        SPUser pickedUser = ppInternalContact.WBxGetSingleResolvedUser(elevatedSite.RootWeb);
                        if (pickedUser != null)
                        {
                            subjectTag.InternalContactLoginName = pickedUser.LoginName;
                        }

                        /*if (ppInternalContact.Entities != null && ppInternalContact.Entities.Count > 0)
                         * {
                         *  PickerEntity pe = (PickerEntity)ppInternalContact.Entities[0];
                         *  subjectTag.InternalContactLoginName = pe.DisplayText;
                         * }*/
                        wbTax.CommitAll();
                    }
                    else
                    {
                        lblValidationMessage.Text = "Your new tag could not be created, please contact support";
                    }
                }
            });
            HttpContext.Current = oldContext;
        }
        protected override void Render(HtmlTextWriter writer)
        {
            //WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);
            WBTaxonomy seriesTags = WBTaxonomy.GetSeriesTags(SPContext.Current.Site);

            WBTerm seriesTag = null;

            if (SeriesTag != null && SeriesTag != "")
            {
                Term seriesTagTerm = seriesTags.GetSelectedTermByPath(SeriesTag);
                if (seriesTagTerm != null)
                {
                    seriesTag = new WBTerm(seriesTags, seriesTagTerm);
                }
            }

            WBQuery query = new WBQuery();

            //query.AddEqualsFilter(WBColumn.RecordsType, workBox.RecordsType);

            if (seriesTag != null)
            {
                query.AddEqualsFilter(WBColumn.SeriesTag, seriesTag);
            }

            if (ReferenceID != null && ReferenceID != "")
            {
                query.AddEqualsFilter(WBColumn.ReferenceID, ReferenceID);
            }

            //            if (FilterByOwningTeam)
            //            query.AddEqualsFilter(WBColumn.OwningTeam, workBox.OwningTeam);


            if (sortColumn != null)
            {
                WBLogging.Debug("Sorting in Render with sortColumn: " + sortColumn.DisplayName);
            }
            else
            {
                WBLogging.Debug("SortColumn was null - so sorting by declared record date.");

                sortColumn = WBColumn.DeclaredRecord;
                ascending  = false;
            }

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

            query.AddViewColumn(WBColumn.Name);
            query.AddViewColumn(WBColumn.FileTypeIcon);
            query.AddViewColumn(WBColumn.EncodedAbsoluteURL);
            query.AddViewColumn(WBColumn.ReferenceDate);
            query.AddViewColumn(WBColumn.ProtectiveZone);
            query.AddViewColumn(WBColumn.DeclaredRecord);

            WBFarm farm = WBFarm.Local;

            using (SPSite site = new SPSite(farm.ProtectedRecordsLibraryUrl))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPList recordsLibrary = web.GetList(farm.ProtectedRecordsLibraryUrl);

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

                    gridView.DataSource = dataTable;

                    gridView.Columns.Clear();
                    gridView.Columns.Add(WBUtils.DynamicIconTemplateField(WBColumn.FileTypeIcon, WBColumn.EncodedAbsoluteURL));
                    gridView.Columns.Add(WBUtils.HyperLinkField(WBColumn.Name, WBColumn.EncodedAbsoluteURL, sortColumn, ascending));
                    gridView.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, sortColumn, ascending));
                    gridView.Columns.Add(WBUtils.BoundField(WBColumn.ProtectiveZone, sortColumn, ascending));
                    gridView.Columns.Add(WBUtils.BoundField(WBColumn.DeclaredRecord, sortColumn, ascending));

                    gridView.DataBind();
                }
            }

            base.Render(writer);
        }
Beispiel #8
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");
            }
        }
Beispiel #9
0
        private void BuildListOfAllowedTerms()
        {
            WBFarm farm = WBFarm.Local;

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

                Term   pageSeriesTagTerm   = subjectTagsTaxonomy.GetSelectedTermByPath(FullSubjectTagPath);
                WBTerm localPageSubjectTag = null;
                if (pageSeriesTagTerm != null)
                {
                    localPageSubjectTag = new WBTerm(subjectTagsTaxonomy, 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 = true;
                        //query.AddClause(subjectTagClause);

                        if (webPart.OnlyLiveRecords)
                        {
                            WBQueryClause isLiveClause = new WBQueryClause(WBColumn.LiveOrArchived, WBQueryClause.Comparators.Equals, WBColumn.LIVE_OR_ARCHIVED__LIVE);
                            query.AddClause(isLiveClause);
                        }

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

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


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

                        query.AddViewColumn(WBColumn.Name);
                        query.AddViewColumn(WBColumn.SubjectTags);

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

                        SPListItemCollection documents = recordsLibrary.WBxGetItems(site, query);

                        WBLogging.Debug("Got documents back");

                        WBLogging.Debug("Documents contains " + documents.Count + " items");

                        foreach (SPListItem document in documents)
                        {
                            WBTermCollection <WBTerm> subjectTags = document.WBxGetMultiTermColumn <WBTerm>(subjectTagsTaxonomy, WBColumn.SubjectTags.DisplayName);
                            foreach (WBTerm subjectTag in subjectTags)
                            {
                                string fullPath = subjectTag.FullPath;
                                if (allUsedTerms.Contains(fullPath))
                                {
                                    WBLogging.Debug("Already has term: " + fullPath + "  so not adding");
                                }
                                else
                                {
                                    WBLogging.Debug("Adding to list of allowed terms: " + fullPath);
                                    this.allUsedTerms.Add(fullPath);
                                    while (fullPath.Contains("/"))
                                    {
                                        int lastIndex = fullPath.LastIndexOf('/');
                                        fullPath = fullPath.Substring(0, lastIndex);
                                        if (allUsedTerms.Contains(fullPath))
                                        {
                                            WBLogging.Debug("Already has term: " + fullPath + "  so not adding");
                                            fullPath = "";
                                        }
                                        else
                                        {
                                            allUsedTerms.Add(fullPath);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    WBUtils.logMessage("pageSubjectTag was null");
                }
            }
        }
Beispiel #10
0
        private Dictionary <String, String> FindRecordsTypesToList()
        {
            WBFarm farm = WBFarm.Local;

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

            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);
                         * }
                         * }
                         */

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

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

                        query.AddViewColumn(WBColumn.Name);
                        query.AddViewColumn(WBColumn.Title);
                        query.AddViewColumn(WBColumn.RecordsType);

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

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

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

                        SPListItemCollection listOfFoundDocuments = recordsLibrary.WBxGetItems(site, query);

                        foreach (SPListItem item in listOfFoundDocuments)
                        {
                            WBRecordsType recordsType     = item.WBxGetSingleTermColumn <WBRecordsType>(recordsTypesTaxonomy, WBColumn.RecordsType);
                            String        justRecordsType = GetJustRecordsTypeName(recordsType.Name);

                            if (!typesToList.ContainsKey(justRecordsType))
                            {
                                typesToList.Add(justRecordsType, recordsType.FullPath);
                            }
                        }
                    }
                }
                else
                {
                    WBLogging.Debug("pageSubjectTag was null");
                }
            }

            return(typesToList);
        }
Beispiel #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            webPart = this.Parent as ViewSubjectPages;

            DocumentsForSubject.AllowSorting = true;
            DocumentsForSubject.Sorting     += new GridViewSortEventHandler(DocumentsForSubject_Sorting);

            DocumentsForSubject.AllowPaging                   = true;
            DocumentsForSubject.PageIndexChanging            += new GridViewPageEventHandler(DocumentsForSubject_PageIndexChanging);
            DocumentsForSubject.PagerSettings.Mode            = PagerButtons.Numeric;
            DocumentsForSubject.PagerSettings.Position        = PagerPosition.Bottom;
            DocumentsForSubject.PagerSettings.PageButtonCount = 20;
            DocumentsForSubject.PagerSettings.Visible         = true;
            DocumentsForSubject.PageSize = 20;

            // this odd statement is required in order to get the pagination to work with an SPGridView!
            DocumentsForSubject.PagerTemplate = null;


            showAtoZ    = webPart.ShowAToZ;
            showFilters = false;

            string additionalPath = "";

            if (String.IsNullOrEmpty(webPart.RootSubjectTag))
            {
                PageName.Text = "<i>(Web part not yet configured)</i>";
                return;
            }

            // Let's capture the information about what we should be looking at:
            pickedLetter = Request.QueryString["Letter"];
            if (!String.IsNullOrEmpty(pickedLetter))
            {
                viewingALetter = true;
            }

            additionalPath = Request.QueryString["AdditionalPath"];
            if (additionalPath == null)
            {
                additionalPath = "";
            }

            recordsTypeFullPath = Request.QueryString["RecordsType"];
            if (String.IsNullOrEmpty(recordsTypeFullPath))
            {
                recordsTypeFullPath = NO_RECORDS_TYPE_SELECTED;
            }

            if (webPart.ShowRecordTypes)
            {
                WBLogging.Debug("ViewSubjectPages: Using records types. Currently set as: " + recordsTypeFullPath);
            }
            else
            {
                WBLogging.Debug("ViewSubjectPages: Not using records types");
            }

            FullSubjectTagPath = webPart.RootSubjectTag + additionalPath;
            WBLogging.Debug("FullSubjectTagPath = " + FullSubjectTagPath);

            WBTaxonomy subjectTags = WBTaxonomy.GetSubjectTags(SPContext.Current.Site);

            Term   rootSubjectTagTerm = subjectTags.GetSelectedTermByPath(webPart.RootSubjectTag);
            WBTerm rootSubjectTag     = null;

            if (rootSubjectTagTerm != null)
            {
                rootSubjectTag = new WBTerm(subjectTags, rootSubjectTagTerm);
            }

            if (rootSubjectTag == null)
            {
                PageName.Text = "<i>(Could not find the root subject tag with path: " + webPart.RootSubjectTag + ")</i>";
                return;
            }


            Term pageSubjectTagTerm = subjectTags.GetSelectedTermByPath(FullSubjectTagPath);
            //SC: WBTerm pageSubjectTag = null;
            WBSubjectTag pageSubjectTag = null;

            if (pageSubjectTagTerm != null)
            {
                //SC: pageSubjectTag = new WBTerm(subjectTags, pageSubjectTagTerm);
                pageSubjectTag = new WBSubjectTag(subjectTags, pageSubjectTagTerm);
            }

            if (pageSubjectTag == null)
            {
                PageName.Text = "<i>(Could not find the page subject tag with path: " + FullSubjectTagPath + ")</i>";
                return;
            }

            string html = "";

            string recordsTypeParameter = "";

            if (webPart.ShowRecordTypes)
            {
                recordsTypeParameter = "&RecordsType=" + recordsTypeFullPath;
            }

            //webPart.OnlyTermsWithDocuments = false;

            if (webPart.OnlyTermsWithDocuments)
            {
                BuildListOfAllowedTerms();
            }

            if (viewingALetter)
            {
                PageName.Text = "<a href='?'>" + webPart.RootSubjectTag + "</a> - " + pickedLetter;
                PageSubjectTagDescription.Text = "You are viewing a list of all of the subjects with the letter '" + pickedLetter + "'.";

                Dictionary <String, String> allTermPaths = new Dictionary <string, string>();
                AddAllTermsThatMatch(pickedLetter, "", rootSubjectTagTerm, allTermPaths);

                if (allTermPaths.Count > 0)
                {
                    List <String> terms = new List <String>(allTermPaths.Keys);
                    terms.Sort();

                    List <String> termsWithLetterFirst = new List <String>();
                    List <String> remainingTerms       = new List <String>();

                    foreach (String term in terms)
                    {
                        if (term.IndexOf(pickedLetter) == 0)
                        {
                            termsWithLetterFirst.Add(term);
                        }
                        else
                        {
                            remainingTerms.Add(term);
                        }
                    }

                    foreach (String term in termsWithLetterFirst)
                    {
                        html += "<div class='lbi-a-to-z-child-subject'><a href='?AdditionalPath=" + allTermPaths[term] + recordsTypeParameter + "'>" + term + "</a></div>\n";
                    }

                    if (remainingTerms.Count > 0)
                    {
                        html += "<div>&nbsp;</div>\n";
                        foreach (String term in remainingTerms)
                        {
                            html += "<div class='lbi-a-to-z-child-subject'><a href='?AdditionalPath=" + allTermPaths[term] + recordsTypeParameter + "'>" + term + "</a></div>\n";
                        }
                    }
                }
                else
                {
                    html += "<p>There were no terms found for the letter '" + pickedLetter + "'.</p>";
                }
            }
            else
            {
                List <String> names = new List <String>(FullSubjectTagPath.Split('/'));
                List <String> path  = new List <String>(names);
                path.RemoveAt(0);


                String justRecordsType = "";
                if (!String.IsNullOrEmpty(recordsTypeFullPath) && recordsTypeFullPath != NO_RECORDS_TYPE_SELECTED)
                {
                    justRecordsType = GetJustRecordsTypeName(recordsTypeFullPath);
                }

                PageName.Text = BuildPageNamePath(names, path, justRecordsType);

                //SC: PageSubjectTagDescription.Text = pageSubjectTag.Description;
                if (String.IsNullOrEmpty(pageSubjectTag.PageContent))
                {
                    PageSubjectTagDescription.Text = pageSubjectTag.Description;
                }
                else
                {
                    PageSubjectTagDescription.Text = pageSubjectTag.PageContent;
                }

                // Contacts
                if (!String.IsNullOrEmpty(pageSubjectTag.InternalContactLoginName))
                {
                    panInternalContact.Visible = true;
                    var user = pageSubjectTag.InternalContact(SPContext.Current.Web);
                    if (user != null)
                    {
                        // Bind user to control for presentation
                        ((WBFUser)wbfInternalContact).User = user;
                    }
                }
                else
                {
                    panInternalContact.Visible = false;
                }
                if (!pageSubjectTag.ExternalContact.WBxIsHtmlFieldEmpty())
                {
                    panExternalContact.Visible = true;
                    litExternalContact.Text    = pageSubjectTag.ExternalContact;
                }
                else
                {
                    panExternalContact.Visible = false;
                }


                foundChildSubjectTags = false;

                onRootOfAtoZ = (webPart.ShowAToZ && pageSubjectTag.Name == webPart.RootSubjectTag);

                bool showDocuments = true;

                if (!onRootOfAtoZ)
                {
                    // OK so now we need to find the sub terms and put them in order.
                    List <String> termLabels = new List <String>();
                    foreach (Term child in pageSubjectTag.Term.Terms)
                    {
                        if (child.IsAvailableForTagging && CheckTermIsAllowed(child))
                        {
                            termLabels.Add(child.Name);
                            foundChildSubjectTags = true;
                        }
                    }

                    if (termLabels.Count > 0)
                    {
                        if (webPart.OnlyShowDocumentsOnLeafPages)
                        {
                            showDocuments = false;
                        }

                        termLabels.Sort();

                        foreach (String label in termLabels)
                        {
                            html += "<div class='lbi-a-to-z-child-subject'><a href='?AdditionalPath=" + additionalPath + "/" + label + recordsTypeParameter + "'>" + label + "</a></div>\n";
                        }
                    }
                    else
                    {
                        // OK so there are no further subject tags, but should we be presenting records types:
                        if (webPart.ShowRecordTypes)
                        {
                            if (recordsTypeFullPath == NO_RECORDS_TYPE_SELECTED)
                            {
                                Dictionary <String, String> recordsTypesToList = FindRecordsTypesToList();
                                if (recordsTypesToList.Count > 0)
                                {
                                    if (webPart.OnlyShowDocumentsOnLeafPages)
                                    {
                                        showDocuments = false;
                                    }

                                    List <String> justRecordsTypes = new List <String>(recordsTypesToList.Keys);
                                    justRecordsTypes.Sort();

                                    foreach (String recordsType in justRecordsTypes)
                                    {
                                        String recordsTypePath = recordsTypesToList[recordsType];

                                        html += "<div class='lbi-a-to-z-child-subject'><a href='?AdditionalPath=" + additionalPath + "&RecordsType=" + recordsTypePath + "'>" + recordsType + "</a></div>\n";
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (webPart.ShowDocumentsOnAtoZRootPage)
                    {
                        showDocuments = true;
                    }
                    else
                    {
                        showDocuments = false;
                    }
                }

                if (showDocuments)
                {
                    RefreshBoundDocumentsList();
                }
            }

            if (!String.IsNullOrEmpty(html))
            {
                //TableOfChildSubjects.Text = String.Concat("<h3 class='wbf-subject-tag-section-head'>Child Subject Tags</h3>", html);
                TableOfChildSubjects.Text = html;
            }

            // Added by Steve Clements
            SetupAddEditButtons(pageSubjectTag);
        }
Beispiel #12
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");
            }
        }
Beispiel #13
0
        /*
         * private string createTableRowForChildSubjectTag(WBTaxonomy seriesTags, String additionalPath, Term child)
         * {
         *  string currentURL = Request.Url.ToString();
         *  int startIndex = currentURL.IndexOf("?");
         *  if (startIndex > 0)
         *  {
         *      currentURL = currentURL.Substring(0, startIndex);
         *  }
         *
         *  string childURL = currentURL + "?AdditionalPath=" + additionalPath + "/" + child.Name;
         *
         *  if (!webPart.OnlyLiveRecords)
         *  {
         *      childURL += "&LiveOrArchived=" + SelectedLiveOrArchivedStatusFilter;
         *  }
         *
         *
         *  string html = "<tr class=\"subjectTags\"><td class=\"subjectTags\"><a href=\"" + childURL + "\">" + child.Name + "</a></td></tr>";
         *
         *  return html;
         * }
         */


        private int CountArchivedDocsOfThisSelection()
        {
            WBFarm farm = WBFarm.Local;

            int foundDocuments = 0;

            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);

                        WBQueryClause isArchivedClause = new WBQueryClause(WBColumn.LiveOrArchived, WBQueryClause.Comparators.Equals, WBColumn.LIVE_OR_ARCHIVED__ARCHIVED);
                        query.AddClause(isArchivedClause);


                        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);
                            }
                        }

                        query.AddViewColumn(WBColumn.Name);
                        query.AddViewColumn(WBColumn.Title);
                        query.AddViewColumn(WBColumn.RecordID);


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

                        SPListItemCollection foundArchivedItems = recordsLibrary.WBxGetItems(site, query);

                        foundDocuments = foundArchivedItems.Count;
                    }
                }
                else
                {
                    WBUtils.logMessage("pageSubjectTag was null");
                }
            }

            return(foundDocuments);
        }
Beispiel #14
0
        /*
         * protected void ViewSelector_OnSelectedIndexChanged(object sender, EventArgs e)
         * {
         *  SelectedViewTitle.Text = "Browse " + webPart.RecordsLibraryView; // ViewSelector.SelectedValue;
         *  // SelectedView = ViewSelector.SelectedValue;
         *
         *  SelectedNodePath = "";
         *
         *  RefreshBrowsableTreeView();
         *  RefreshBoundData();
         *
         * }
         *
         * protected void FilterByProtectiveZone_OnSelectedIndexChanged(object sender, EventArgs e)
         * {
         *  ProtectiveZoneFilter = FilterByProtectiveZone.SelectedValue;
         *
         *  RefreshBoundData();
         * }
         */



        private void RefreshBoundData()
        {
            if (SelectedNodePath != "")
            {
                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;
                }


                default: return;
                }

                String recordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site);

                using (SPSite site = new SPSite(recordsLibraryURL))
                {
                    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)
                            {
                                query.FilterByFolderPath = WBUtils.PrepareFilenameForPublicWeb(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, WorkBox.WORK_BOX_RECORD_CONTENT_TYPE));

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

                            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.FileSize);
                        query.AddViewColumn(WBColumn.FileTypeIcon);
                        query.AddViewColumn(WBColumn.FileType);
                        query.AddViewColumn(WBColumn.TitleOrName);
                        query.AddViewColumn(WBColumn.DisplayFileSize);
                        query.AddViewColumn(WBColumn.EncodedAbsoluteURL);
                        //query.AddViewColumn(WBColumn.FunctionalArea);
                        //query.AddViewColumn(WBColumn.OwningTeam);
                        query.AddViewColumn(WBColumn.ReferenceDate);
                        query.AddViewColumn(WBColumn.DeclaredRecord);
                        //query.AddViewColumn(WBColumn.ReferenceID);
                        //query.AddViewColumn(WBColumn.SeriesTag);
                        //query.AddViewColumn(WBColumn.ProtectiveZone);

                        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(recordsLibraryURL); //"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.HyperLinkField(WBColumn.Name, WBColumn.EncodedAbsoluteURL, sortColumn, ascending));
                        //ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending));
                        //ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, 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.ReferenceDate, sortColumn, ascending));
                        //ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.DeclaredRecord, 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.ProtectiveZone, 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));
                         * }
                         */


                        ShowResults.DataBind();
                    }
                }
            }
            else
            {
                WBUtils.logMessage("SelectedNodePath was empty");
            }
        }
        private void RefreshBoundData()
        {
            if (SelectedNodePath != "")
            {
                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)
                    {
                        return;
                    }

                    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.Debug("Did not find subject with path: " + SelectedNodePath);
                        return;
                    }
                    break;
                }


                default: return;
                }


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

                String recordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site);

                if (Request.QueryString["Library"] == "Extranet")
                {
                    recordsLibraryURL = WBFWebPartsUtils.GetExtranetLibraryURL(SPContext.Current.Site);
                }

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

                        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);
                        }

                        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);
                        }

                        //                        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.FileSize);
                        query.AddViewColumn(WBColumn.FileTypeIcon);
                        query.AddViewColumn(WBColumn.FileType);
                        query.AddViewColumn(WBColumn.TitleOrName);
                        query.AddViewColumn(WBColumn.DisplayFileSize);
                        query.AddViewColumn(WBColumn.RecordID);
                        query.AddViewColumn(WBColumn.EncodedAbsoluteURL);
                        query.AddViewColumn(WBColumn.ReferenceDate);
                        query.AddViewColumn(WBColumn.ReferenceID);
                        query.AddViewColumn(WBColumn.ProtectiveZone);
                        query.AddViewColumn(WBColumn.DeclaredRecord);

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

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

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

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

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

                        ShowResults.DataSource = dataTable;

                        ShowResults.Columns.Clear();

                        ButtonField buttonField = new ButtonField();
                        buttonField.Text        = "Select";
                        buttonField.CommandName = "Select Document";
                        ShowResults.Columns.Add(buttonField);

                        ShowResults.Columns.Add(WBUtils.DynamicIconTemplateField(WBColumn.FileTypeIcon, WBColumn.EncodedAbsoluteURL));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.Title, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.Name, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.DeclaredRecord, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.ProtectiveZone, sortColumn, ascending));
                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.RecordID, sortColumn, ascending));

//                        BoundField test = WBUtils.BoundField(WBColumn.ServerURL, sortColumn, ascending);
//                      test.Hid

//                        ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending));
                        //ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, 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));

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



                        ShowResults.DataBind();
                    }
                }
            }

            else
            {
                WBUtils.logMessage("SelectedNodePath was empty");
            }
        }