protected void Page_Load(object sender, EventArgs e) { webPart = this.Parent as RelatedMeetings; if (webPart.MeetingsWorkBoxCollectionURL == null || webPart.MeetingsWorkBoxCollectionURL == "") { CreateNewMeetingLink.Text = "(Web part not configured yet)"; return; } using (WorkBox workBox = new WorkBox(SPContext.Current)) { if (workBox.LinkedWorkBoxesList == null) { CreateNewMeetingLink.Text = "(Work Box doesn't have a related items list)"; return; } DataTable dataTable = createDataTable(); addRelatedWorkBoxesToDataTable(workBox.LinkedWorkBoxesList, dataTable); RelatedMeetings.DataSource = dataTable; RelatedMeetings.DataBind(); using (WBCollection collection = new WBCollection(webPart.MeetingsWorkBoxCollectionURL)) { string createNewURL = collection.GetUrlForNewDialog(workBox, WorkBox.RELATION_TYPE__CHILD); string createNewText = "Create New Meeting"; // collection.CreateNewWorkBoxText; CreateNewMeetingLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 600, 500);\">" + createNewText + "</a>"; } } }
private void RefreshBoundData() { if (!String.IsNullOrEmpty(SelectedRecordsTypeGUID)) { WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); WBTaxonomy teams = WBTaxonomy.GetTeams(recordsTypes); WBRecordsType recordsType = recordsTypes.GetRecordsType(new Guid(SelectedRecordsTypeGUID)); String recordsTypePath = recordsType.FullPath; //recordsTypePath = recordsTypePath.Substring(1, recordsTypePath.Length - 1); recordsTypePath = recordsTypePath.Replace("/", " / "); SelectionTitle.Text = recordsTypePath; SelectionDescription.Text = recordsType.Description; WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web); WBFarm farm = WBFarm.Local; using (WBCollection collection = new WBCollection(recordsType.WorkBoxCollectionUrl)) { // using (SPWeb web = site.OpenWeb()) // { WBQuery query = new WBQuery(); WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType); recordsTypeClause.UseDescendants = false; query.AddClause(recordsTypeClause); if (team != null) { query.AddEqualsFilter(WBColumn.InvolvedTeams, team); } string statusFilter = SelectedWorkBoxStatusFilter; if (statusFilter == null || statusFilter == "") statusFilter = "Open"; if (statusFilter != "All") { query.AddEqualsFilter(WBColumn.WorkBoxStatus, statusFilter); } FilterOpenStatus.CssClass = "wbf-unselected-filter"; FilterClosedStatus.CssClass = "wbf-unselected-filter"; FilterAllStatus.CssClass = "wbf-unselected-filter"; if (statusFilter == "Open") FilterOpenStatus.CssClass = "wbf-selected-filter"; if (statusFilter == "Closed") FilterClosedStatus.CssClass = "wbf-selected-filter"; if (statusFilter == "All") FilterAllStatus.CssClass = "wbf-selected-filter"; query.AddViewColumn(WBColumn.Title); query.AddViewColumn(WBColumn.WorkBoxURL); //query.AddViewColumn(WBColumn.OwningTeam); // query.AddViewColumn(WBColumn.FunctionalArea); query.AddViewColumn(WBColumn.ReferenceDate); //query.AddViewColumn(WBColumn.ReferenceID); //query.AddViewColumn(WBColumn.SeriesTag); // query.AddViewColumn(WBColumn.InvolvedTeams); query.AddViewColumn(WBColumn.WorkBoxStatus); if (sortColumn != null) query.OrderBy(sortColumn, ascending); DataTable dataTable = collection.Query(query); SelectedWorkBoxes.DataSource = dataTable; SelectedWorkBoxes.Columns.Clear(); SelectedWorkBoxes.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL)); SelectedWorkBoxes.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending)); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.InvolvedTeams, sortColumn, ascending)); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, sortColumn, ascending)); SelectedWorkBoxes.DataBind(); if (recordsType.CanCurrentUserCreateWorkBoxForTeam(collection, team)) { string createNewURL = collection.GetUrlForNewDialog(recordsType, team); string createNewText = recordsType.CreateNewWorkBoxText; CreateNewWorkBoxLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 730, 800);\">" + createNewText + "</a>"; } else { CreateNewWorkBoxLink.Text = ""; } // } } } else { WBUtils.logMessage("SelectedRecordsTypeGUID was empty"); } }
protected void Page_Load(object sender, EventArgs e) { // Get the selected parameters: string recordsTypeGUID = Request.Params["recordsTypeGUID"]; string selectedWorkBoxCollectionURL = Request.Params["workBoxCollectionURL"]; string includeDocumentsFlag = Request.Params["includeDocuments"]; WBTaxonomy teams = WBTaxonomy.GetTeams(SPContext.Current.Site); WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(teams); WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current); if (recordsTypeGUID == null || recordsTypeGUID == "" || selectedWorkBoxCollectionURL == null || selectedWorkBoxCollectionURL == "" || team == null ) { InformationText.Text = "<span>Make a selection from the left to see work boxes of that type.</span>"; } else { Guid teamsTermGuid = team.Id; string teamsGUID = team.Id.ToString(); // Process the parameters: bool includeDocumentRecords = false; if (includeDocumentsFlag != null && includeDocumentsFlag != "") { includeDocumentRecords = includeDocumentsFlag.Equals(true.ToString()); } WBRecordsType recordsType = null; Guid selectedRecordsTypeTermGUID = new Guid(recordsTypeGUID); recordsType = recordsTypes.GetRecordsType(selectedRecordsTypeTermGUID); string infoText = "<div class='wbf-view-selected-records-type'>You have selected to view: <span 'wbf-records-type-name'>" + recordsType.Name + "</span></div>\n"; if (recordsType.Description != "") { infoText += "<div class='wbf-records-type-description'>" + recordsType.Description + "</div>"; } InformationText.Text = infoText; WBUtils.logMessage("Found the records type info: " + recordsType.Name); DataTable combinedData = createCombinedDataTable(); if (includeDocumentRecords) { WBUtils.logMessage("Records Library IS being included in search"); WBFarm farm = WBFarm.Local; // SPListItemCollection docResults = getResultsForList(farm.RecordsCenterUrl, farm.RecordsCenterRecordsLibraryName, team, recordsType); // addDocResultsToCombinedData(farm.RecordsCenterUrl, docResults, combinedData); } else { WBUtils.logMessage("Records Library is not being included in search"); } if (selectedWorkBoxCollectionURL != "") { using (WBCollection collection = new WBCollection(selectedWorkBoxCollectionURL)) { WBUtils.logMessage("A work box colleciton IS being included in search: " + selectedWorkBoxCollectionURL); SPListItemCollection workBoxResults = collection.QueryFilteredBy(team, recordsType, true); WBUtils.logMessage("Got back from query this num of results: " + workBoxResults.Count); addWorkBoxResultsToCombinedData(collection, workBoxResults, combinedData); if (recordsType.CanCurrentUserCreateWorkBoxForTeam(collection, team)) { string createNewURL = collection.GetUrlForNewDialog(recordsType, team); string createNewText = recordsType.CreateNewWorkBoxText; CreateNewWorkBoxLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 730, 800);\">" + createNewText + "</a>"; } } } else { WBUtils.logMessage("No work box colleciton is being included in search"); } ShowCombinedResults.DataSource = combinedData; ShowCombinedResults.DataBind(); } }
private void RefreshBoundData() { if (SelectedWorkBoxView == VIEW__SELECTED_RECORDS_TYPE) { FilterOpenStatus.Enabled = true; FilterClosedStatus.Enabled = true; FilterAllStatus.Enabled = true; } else { FilterOpenStatus.Enabled = false; FilterClosedStatus.Enabled = false; FilterAllStatus.Enabled = false; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ClearHighlightedRecordsTypes", "$('a.ms-navitem').css('font-weight', 'normal');", true); } WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); WBTaxonomy teams = WBTaxonomy.GetTeams(recordsTypes); WBQuery query = new WBQuery(); query.AddViewColumn(WBColumn.Title); query.AddViewColumn(WBColumn.WorkBoxURL); //query.AddViewColumn(WBColumn.OwningTeam); // query.AddViewColumn(WBColumn.FunctionalArea); //query.AddViewColumn(WBColumn.ReferenceDate); //query.AddViewColumn(WBColumn.ReferenceID); //query.AddViewColumn(WBColumn.SeriesTag); // query.AddViewColumn(WBColumn.InvolvedTeams); query.AddViewColumn(WBColumn.WorkBoxStatus); checkSortState(); if (sortColumn != null) { query.OrderBy(sortColumn, ascending); } SelectedWorkBoxes.Columns.Clear(); SelectedWorkBoxes.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL)); SelectedWorkBoxes.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending, "")); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.InvolvedTeams, sortColumn, ascending)); switch (SelectedWorkBoxView) { case VIEW__RECENTLY_CREATED: { query.AddViewColumn(WBColumn.WorkBoxDateCreated); //query.AddViewColumn(WBColumn.RecordsType); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateCreated, HorizontalAlign.Center, sortColumn, ascending)); //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending)); break; } case VIEW__RECENTLY_MODIFIED: { query.AddViewColumn(WBColumn.WorkBoxDateLastModified); //query.AddViewColumn(WBColumn.RecordsType); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateLastModified, HorizontalAlign.Center, sortColumn, ascending)); //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending)); break; } case VIEW__RECENTLY_VISITED: { query.AddViewColumn(WBColumn.WorkBoxDateLastVisited); //query.AddViewColumn(WBColumn.RecordsType); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateLastVisited, HorizontalAlign.Center, sortColumn, ascending)); //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending)); break; } case VIEW__SELECTED_RECORDS_TYPE: { query.AddViewColumn(WBColumn.ReferenceDate); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending)); break; } } SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, HorizontalAlign.Center, sortColumn, ascending)); WBRecordsType recordsType = null; WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web); if (team != null) { switch (SelectedInvolvementFilter) { case FILTER_INVOLVEMENT__OWNS: { WBLogging.Debug("Adding a filter for OwningTeam"); query.AddEqualsFilter(WBColumn.OwningTeam, team); break; } case FILTER_INVOLVEMENT__INVOLVED: { WBLogging.Debug("Adding a filter for InvolvedTeams"); query.AddEqualsFilter(WBColumn.InvolvedTeams, team); break; } case FILTER_INVOLVEMENT__VISITING: { WBLogging.Debug("Adding a filter for VisitingTeams"); query.AddEqualsFilter(WBColumn.VisitingTeams, team); break; } } } if (SelectedWorkBoxView == VIEW__SELECTED_RECORDS_TYPE) { if (SelectedRecordsTypeGUID != "") { recordsType = recordsTypes.GetRecordsType(new Guid(SelectedRecordsTypeGUID)); } else if (!IsPostBack && !String.IsNullOrEmpty(webPart.InitialRecordsType)) { string initialRecordsTypePath = webPart.InitialRecordsType.Replace(" / ", "/").Trim(); recordsType = recordsTypes.GetSelectedRecordsType(initialRecordsTypePath); } if (recordsType != null) { String recordsTypePath = recordsType.FullPath; //recordsTypePath = recordsTypePath.Substring(1, recordsTypePath.Length - 1); recordsTypePath = recordsTypePath.Replace("/", " / "); SelectionTitle.Text = recordsTypePath; SelectionDescription.Text = recordsType.Description; WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType); recordsTypeClause.UseDescendants = false; query.AddClause(recordsTypeClause); string statusFilter = SelectedWorkBoxStatusFilter; if (statusFilter != "All") { query.AddEqualsFilter(WBColumn.WorkBoxStatus, statusFilter); } try { using (WBCollection collection = new WBCollection(recordsType.WorkBoxCollectionUrl)) { DataTable dataTable = collection.Query(query); SelectedWorkBoxes.DataSource = dataTable; SelectedWorkBoxes.DataBind(); if (recordsType.CanCurrentUserCreateWorkBoxForTeam(collection, team)) { string createNewURL = collection.GetUrlForNewDialog(recordsType, team); string createNewText = recordsType.CreateNewWorkBoxText; CreateNewWorkBoxLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 730, 800);\">" + createNewText + "</a>"; } else { CreateNewWorkBoxLink.Text = ""; } } } catch (Exception exception) { SelectedWorkBoxes.DataSource = null; SelectedWorkBoxes.DataBind(); SelectionDescription.Text = SelectionDescription.Text + "<p><em>(An exception occured when trying to query the work boxes for this records type!)</em></p>"; CreateNewWorkBoxLink.Text = ""; WBLogging.RecordsTypes.Unexpected("Exception occurred on a team site when trying to query the work boxes of records type: " + recordsTypePath, exception); } } else { WBUtils.logMessage("SelectedRecordsTypeGUID was empty"); } } else { String cachedDetailsListUrl = WBFarm.Local.OpenWorkBoxesCachedDetailsListUrl; // OK so this is a general 'recent' query using (SPWeb cacheWeb = SPContext.Current.Site.OpenWeb(cachedDetailsListUrl)) { SPList cacheList = cacheWeb.GetList(cachedDetailsListUrl); DataTable dataTable = cacheList.WBxGetDataTable(SPContext.Current.Site, query); SelectedWorkBoxes.DataSource = dataTable; SelectedWorkBoxes.DataBind(); CreateNewWorkBoxLink.Text = ""; SelectionTitle.Text = SelectedWorkBoxView + " Work Boxes"; SelectionDescription.Text = "Select a category from left hand tree navigation to list work boxes of that type."; } } // OK so now to check that the right filters are highlighted: ViewRecentlyCreated.CssClass = ""; ViewRecentlyModified.CssClass = ""; ViewRecentlyVisited.CssClass = ""; if (SelectedWorkBoxView == VIEW__RECENTLY_CREATED) { ViewRecentlyCreated.CssClass = "wbf-filter-selected"; } if (SelectedWorkBoxView == VIEW__RECENTLY_MODIFIED) { ViewRecentlyModified.CssClass = "wbf-filter-selected"; } if (SelectedWorkBoxView == VIEW__RECENTLY_VISITED) { ViewRecentlyVisited.CssClass = "wbf-filter-selected"; } FilterByOwns.CssClass = ""; FilterByInvolved.CssClass = ""; FilterByVisiting.CssClass = ""; if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__OWNS) { FilterByOwns.CssClass = "wbf-filter-selected"; } if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__INVOLVED) { FilterByInvolved.CssClass = "wbf-filter-selected"; } if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__VISITING) { FilterByVisiting.CssClass = "wbf-filter-selected"; } FilterOpenStatus.CssClass = ""; FilterClosedStatus.CssClass = ""; FilterAllStatus.CssClass = ""; if (SelectedWorkBoxStatusFilter == "Open") { FilterOpenStatus.CssClass = "wbf-filter-selected"; } if (SelectedWorkBoxStatusFilter == "Closed") { FilterClosedStatus.CssClass = "wbf-filter-selected"; } if (SelectedWorkBoxStatusFilter == "All") { FilterAllStatus.CssClass = "wbf-filter-selected"; } }