private SPListItemCollection getResultsForWorkBoxCollection(string workBoxCollectionURL, WBTeam team, WBRecordsType recordsType) { WBUtils.logMessage("Getting results for WBCollection: " + workBoxCollectionURL); using (WBCollection collection = new WBCollection(workBoxCollectionURL)) { return(collection.QueryFilteredBy(team, recordsType, true)); } }
private string addWorkBoxesForRecordsClass(WBTaxonomy recordsTypes, TermCollection recordsTypesTerms) { if (recordsTypesTerms.Count == 0) { return(""); } string finalHtml = ""; bool containsWorkBoxesForMe = false; foreach (Term recordsTypeTerm in recordsTypesTerms) { WBRecordsType recordsType = new WBRecordsType(recordsTypes, recordsTypeTerm); string html = ""; string workBoxesHtml = ""; containsWorkBoxesForMe = false; html = "<tr><td colspan=\"5\" class=\"wbf-records-type\">\n" + recordsType.Name + "</td></tr>\n"; // html += "<li class=\"wbf-records-type\">" + recordsType.Name; // html += "\n"; string workBoxCollectionURL = recordsType.WorkBoxCollectionUrl; WBUtils.logMessage("The work box collection url = " + workBoxCollectionURL); if (workBoxCollectionURL != "") { bool originalAccessDeniedCatchValue = SPSecurity.CatchAccessDeniedException; SPSecurity.CatchAccessDeniedException = false; try { using (WBCollection collection = new WBCollection(workBoxCollectionURL)) { SPListItemCollection workBoxResults = collection.QueryFilteredBy(recordsType, WorkBox.WORK_BOX_STATUS__OPEN, false); if (workBoxResults != null && workBoxResults.Count > 0) { containsWorkBoxesForMe = true; workBoxesHtml = addWorkBoxResults(collection, workBoxResults); } } } catch (UnauthorizedAccessException e) { WBUtils.logMessage("UnauthorizedAccessException thrown for user trying to access: " + workBoxCollectionURL + " Exception was: " + e.Message); // Let's just hide this for the moment as the user doesn't have access to here anyway. workBoxesHtml = ""; } catch (Exception e) { workBoxesHtml = "<i>Exception occured when trying to get results from the work box collection at: " + workBoxCollectionURL + " Exception was: " + e.Message + "</i>"; } finally { SPSecurity.CatchAccessDeniedException = originalAccessDeniedCatchValue; } } if (containsWorkBoxesForMe || ShowAllRecordsTypes) { html += workBoxesHtml; //html += "</li>\n"; finalHtml += html; } } if (finalHtml != "" || ShowAllRecordsTypes) { // finalHtml = "<ul class=\"wbf-my-work-boxes-list wbf-records-types\">\n" + finalHtml + "</ul>\n"; } return(finalHtml); }
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(); } }