private void RefreshBrowsableTreeView() { String recordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site); using (SPSite site = new SPSite(recordsLibraryURL)) { using (SPWeb web = site.OpenWeb()) { SPList recordsLibrary = web.GetList(recordsLibraryURL); //"Documents"]; //farm.RecordsCenterRecordsLibraryName]; Dictionary <String, TreeNode> newNodes = new Dictionary <String, TreeNode>(); foreach (SPFolder functionFolder in recordsLibrary.RootFolder.SubFolders) { //Term foundTerm = functionalAreaTaxonomy.GetSelectedTermByPath(functionFolder.Name); //if (foundTerm != null && foundTerm.IsAvailableForTagging) if (functionFolder.Name != "Forms") { TreeNode newNode = AddFunctionFolderBranch(functionFolder); newNodes.Add(newNode.Text, newNode); } } List <String> allNames = new List <String>(newNodes.Keys); allNames.Sort(); foreach (String name in allNames) { BrowsableTreeView.Nodes.Add(newNodes[name]); } } } }
private void CreateTable() { List <String> documentsDetailsList = new List <String>(); List <String> refreshedDocumentsDetailsList = new List <String>(); string currentDetails = DocumentsDetails.Value.WBxTrim(); WBLogging.Debug("Building the table with current details: " + currentDetails); if (!String.IsNullOrEmpty(currentDetails)) { documentsDetailsList = new List <String>(currentDetails.Split(';')); } numOfDocs = documentsDetailsList.Count; Table table = new Table(); table.Width = Unit.Percentage(100); TableRow headers = new TableRow(); headers.WBxAddTableHeaderCell("Title"); headers.WBxAddTableHeaderCell("Filename"); headers.WBxAddTableHeaderCell("File Type"); // headers.WBxAddTableHeaderCell("Else"); table.Rows.Add(headers); String recordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site); using (SPSite site = new SPSite(recordsLibraryURL)) using (SPWeb web = site.OpenWeb()) { SPList library = web.GetList(recordsLibraryURL); int index = 0; foreach (String details in documentsDetailsList) { TableRow row = CreateEditableTableRow(site, web, library, index, details, refreshedDocumentsDetailsList); allRows.Add(row); table.Rows.Add(row); index++; } } EditRelatedDocumentsTable.Controls.Add(table); DocumentsDetails.Value = String.Join(";", refreshedDocumentsDetailsList.ToArray()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WBFarm farm = WBFarm.Local; SPSite site = SPContext.Current.Site; RecordsLibraryToUse.DataSource = WBFWebPartsUtils.GetRecordsLibraryOptions(); RecordsLibraryToUse.DataBind(); RecordsLibraryToUse.WBxSafeSetSelectedValue(WBFWebPartsUtils.GetRecordsLibraryToUse(site)); LocalPublicLibraryURL.Text = WBFWebPartsUtils.GetLocalPublicLibraryURL(site); UseExtranetLibrary.Checked = WBFWebPartsUtils.UseExtranetLibrary(site); LocalExtranetLibraryURL.Text = WBFWebPartsUtils.GetLocalExtranetLibraryURL(site); ShowFileIcons.Checked = WBFWebPartsUtils.ShowFileIcons(site); ShowKBFileSize.Checked = WBFWebPartsUtils.ShowKBFileSize(site); ShowDescription.Checked = WBFWebPartsUtils.ShowDescription(site); } }
public TableRow CreateEditableTableRow(SPSite site, SPWeb web, SPList library, int index, String details) { TableRow row = new TableRow(); row.ID = MakeControlID(index, "row"); row.CssClass = "wbf-edit-action-row"; string[] parts = details.Split('|'); string zone = parts[0]; string recordID = parts[1]; SPListItem recordItem = null; if (zone == "Public Extranet") { if (extranetRecordsLibrary == null) { string extranetRecordsLibraryURL = WBFWebPartsUtils.GetExtranetLibraryURL(SPContext.Current.Site); extranetRecordsSite = new SPSite(extranetRecordsLibraryURL); extranetRecordsWeb = extranetRecordsSite.OpenWeb(); extranetRecordsLibrary = extranetRecordsWeb.GetList(extranetRecordsLibraryURL); } recordItem = WBFWebPartsUtils.GetRecord(extranetRecordsSite, extranetRecordsWeb, extranetRecordsLibrary, zone, recordID); } else { recordItem = WBFWebPartsUtils.GetRecord(site, web, library, zone, recordID); } if (recordItem == null) { return(row); } String displayName = recordItem.WBxGetAsString(WBColumn.Title); if (String.IsNullOrEmpty(displayName)) { displayName = recordItem.WBxGetAsString(WBColumn.Name); } string extension = Path.GetExtension(recordItem.Name).Replace(".", "").ToUpper(); Image image = new Image(); image.ImageUrl = WBUtils.DocumentIcon16(recordItem.Name); image.Width = Unit.Pixel(16); image.Height = Unit.Pixel(16); row.WBxAddInTableCell(image); Label label = new Label(); label.Text = recordItem.WBxGetAsString(WBColumn.Title); row.WBxAddInTableCell(label); label = new Label(); label.Text = recordItem.WBxGetAsString(WBColumn.Name); row.WBxAddInTableCell(label); Label extensionLabel = new Label(); extensionLabel.Text = extension; row.WBxAddInTableCell(extensionLabel); Button upButton = (Button)row.WBxAddWithIDInTableCell(new Button(), MakeControlID(index, "UpButton")); upButton.Text = "/\\"; upButton.CommandName = "Up"; upButton.CommandArgument = index.ToString(); upButton.Command += new CommandEventHandler(upButton_OnClick); Button downButton = (Button)row.WBxAddWithIDInTableCell(new Button(), MakeControlID(index, "DownButton")); downButton.Text = "\\/"; downButton.CommandName = "Down"; downButton.CommandArgument = index.ToString(); downButton.Command += new CommandEventHandler(downButton_OnClick); Button replaceButton = (Button)row.WBxAddWithIDInTableCell(new Button(), MakeControlID(index, "ReplaceButton")); replaceButton.Text = "Replace"; replaceButton.OnClientClick = "WorkBoxFramework_pickADocument(" + index + "); return false;"; Button removeButton = (Button)row.WBxAddWithIDInTableCell(new Button(), MakeControlID(index, "RemoveButton")); removeButton.Text = "Remove"; removeButton.OnClientClick = "WBF_DeleteRow(" + index + ",\"" + recordItem.Name + "\"); return false;"; HiddenField documentDetails = (HiddenField)row.WBxAddWithIDInTableCell(new HiddenField(), MakeControlID(index, "DocumentDetails")); if (!IsPostBack) { documentDetails.Value = details; } return(row); }
private void RenderPage() { WBTaxonomy subjectTagsTaxonomy = WBTaxonomy.GetSubjectTags(SPContext.Current.Site); subjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTagsField, WorkBox.COLUMN_NAME__SUBJECT_TAGS, true); if (!String.IsNullOrEmpty(newSubjectTagsUIControlValue)) { SubjectTagsField.Text = newSubjectTagsUIControlValue; } EditDocumentsTable.Controls.Clear(); List <String> documentsDetailsList = new List <String>(); string currentDetails = DocumentsDetails.Value.WBxTrim(); WBLogging.Debug("Building the table with current details: " + currentDetails); if (!String.IsNullOrEmpty(currentDetails)) { documentsDetailsList = new List <String>(currentDetails.Split(';')); } numOfDocs = documentsDetailsList.Count; Table table = new Table(); table.Width = Unit.Percentage(100); TableRow headers = new TableRow(); headers.WBxAddTableHeaderCell("Title"); headers.WBxAddTableHeaderCell("Filename"); headers.WBxAddTableHeaderCell("File Type"); // headers.WBxAddTableHeaderCell("Else"); table.Rows.Add(headers); String recordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site); using (SPSite site = new SPSite(recordsLibraryURL)) using (SPWeb web = site.OpenWeb()) { SPList library = web.GetList(recordsLibraryURL); int index = 0; foreach (String details in documentsDetailsList) { TableRow row = CreateEditableTableRow(site, web, library, index, details); allRows.Add(row); table.Rows.Add(row); index++; } if (extranetRecordsWeb != null) { extranetRecordsWeb.Dispose(); } if (extranetRecordsSite != null) { extranetRecordsSite.Dispose(); } } EditDocumentsTable.Controls.Add(table); }
protected void Page_Load(object sender, EventArgs e) { showNewUI = WBFWebPartsUtils.ShowDescription(SPContext.Current.Site); if (!IsPostBack) { String allDetails = Request.QueryString["CurrentDetails"]; string[] details = allDetails.Split(','); if (details.Length != 3) { WBLogging.Debug("The details sent to this page have the wrong structure: " + allDetails); ErrorMessage.Text = "There was a problem with the data sent to this page."; return; } EditTitle.Text = WBUtils.PutBackDelimiterCharacters(details[0]); EditDescription.Text = WBUtils.PutBackDelimiterCharacters(details[1]); DocumentsDetails.Value = addBackIgnoreParts(WBUtils.PutBackDelimiterCharacters(details[2])); } List <String> documentsDetailsList = new List <String>(); string currentDetails = DocumentsDetails.Value.WBxTrim(); if (!String.IsNullOrEmpty(currentDetails)) { documentsDetailsList = new List <String>(currentDetails.Split(';')); } if (IsPostBack) { if (!String.IsNullOrEmpty(ReplaceRowIndex.Value)) { int rowIndex = Convert.ToInt32(ReplaceRowIndex.Value); ReplaceRowIndex.Value = ""; if (rowIndex == -1) { documentsDetailsList.Add(ReplacementDetails.Value); } else { documentsDetailsList.RemoveAt(rowIndex); documentsDetailsList.Insert(rowIndex, ReplacementDetails.Value); } DocumentsDetails.Value = String.Join(";", documentsDetailsList.ToArray()); } if (!String.IsNullOrEmpty(DeleteRowIndex.Value)) { int rowIndex = Convert.ToInt32(DeleteRowIndex.Value); DeleteRowIndex.Value = ""; documentsDetailsList.RemoveAt(rowIndex); DocumentsDetails.Value = String.Join(";", documentsDetailsList.ToArray()); } } CreateTable(); }
public TableRow CreateEditableTableRow(SPSite site, SPWeb web, SPList library, int index, String details, List <String> refreshedDocumentsDetailsList) { TableRow row = new TableRow(); row.ID = MakeControlID(index, "row"); row.CssClass = "wbf-edit-action-row"; //WBLogging.Debug("Just starting with details: " + details); string[] parts = details.Split('|'); string zone = parts[0]; string recordID = parts[1]; //WBLogging.Debug("Here"); SPListItem recordItem = WBFWebPartsUtils.GetRecord(site, web, library, zone, recordID); if (recordItem == null) { return(row); } // OK so we're actually going to refresh the details with the values from the record: details = String.Format("{0}|{1}|{2}|{3}", zone, recordID, "Ignore", recordItem.Name.WBxTrim().Replace(";", "-").Replace("|", "-") ); refreshedDocumentsDetailsList.Add(details); String displayName = recordItem.WBxGetAsString(WBColumn.Title); if (String.IsNullOrEmpty(displayName)) { displayName = recordItem.WBxGetAsString(WBColumn.Name); } string extension = Path.GetExtension(recordItem.Name).Replace(".", "").ToUpper(); //WBLogging.Debug("And Here"); Image image = new Image(); image.ImageUrl = WBUtils.DocumentIcon16(recordItem.Name); image.Width = Unit.Pixel(16); image.Height = Unit.Pixel(16); row.WBxAddInTableCell(image); Label label = new Label(); label.Text = recordItem.WBxGetAsString(WBColumn.Title); row.WBxAddInTableCell(label); label = new Label(); label.Text = recordItem.WBxGetAsString(WBColumn.Name); row.WBxAddInTableCell(label); Label extensionLabel = new Label(); extensionLabel.Text = extension; row.WBxAddInTableCell(extensionLabel); //WBLogging.Debug("As far as Here"); Button upButton = (Button)row.WBxAddWithIDInTableCell(new Button(), MakeControlID(index, "UpButton")); upButton.Text = "/\\"; upButton.CommandName = "Up"; upButton.CommandArgument = index.ToString(); upButton.Command += new CommandEventHandler(upButton_OnClick); Button downButton = (Button)row.WBxAddWithIDInTableCell(new Button(), MakeControlID(index, "DownButton")); downButton.Text = "\\/"; downButton.CommandName = "Down"; downButton.CommandArgument = index.ToString(); downButton.Command += new CommandEventHandler(downButton_OnClick); Button replaceButton = (Button)row.WBxAddWithIDInTableCell(new Button(), MakeControlID(index, "ReplaceButton")); replaceButton.Text = "Replace"; replaceButton.OnClientClick = "WorkBoxFramework_pickADocument(" + index + "); return false;"; Button removeButton = (Button)row.WBxAddWithIDInTableCell(new Button(), MakeControlID(index, "RemoveButton")); removeButton.Text = "Remove"; removeButton.OnClientClick = "WBF_DeleteRow(" + index + ",\"" + recordItem.Name + "\"); return false;"; HiddenField documentDetails = (HiddenField)row.WBxAddWithIDInTableCell(new HiddenField(), MakeControlID(index, "DocumentDetails")); //WBLogging.Debug("Really Here"); if (!IsPostBack) { documentDetails.Value = details; } return(row); }
/* * 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"); } }
protected void Page_Load(object sender, EventArgs e) { webPart = this.Parent as PickRelatedDocuments; SPWebPartManager webPartManager = (SPWebPartManager)WebPartManager.GetCurrentWebPartManager(this.Page); Guid WebPartGuid = webPartManager.GetStorageKey(webPart); WebPartUniqueID = WebPartGuid.ToString().Replace("-", String.Empty);; //EditRelatedDocumentsButton.OnClientClick = "WorkBoxFramework_editRelatedDocuments(WBF_EditDialogCallback" + WebPartUniqueID + ", \"" + webPart.PickedDocumentsDetails + "\"); return false;"; String[] detailsToSave = new String[3]; detailsToSave[0] = WBUtils.ReplaceDelimiterCharacters(webPart.Title); detailsToSave[1] = WBUtils.ReplaceDelimiterCharacters(webPart.RelatedDocumentsDescription); detailsToSave[2] = WBUtils.ReplaceDelimiterCharacters(webPart.PickedDocumentsDetails.WBxTrim()); String currentDetails = String.Join(",", detailsToSave); String pickedDocumentsDetails = webPart.PickedDocumentsDetails.WBxTrim(); if (IsPostBack) { if (NeedToSave.Value == "true") { string[] newDetails = NewRelatedDocumentsDetails.Value.WBxTrim().Split(','); if (newDetails.Length != 3) { WBLogging.Debug("The details sent to this page have the wrong structure: " + NewRelatedDocumentsDetails.Value); Description.Text = "(the web part has not yet been edited)."; return; } if (WBFWebPartsUtils.ShowDescription(SPContext.Current.Site)) { webPart.Title = WBUtils.PutBackDelimiterCharacters(newDetails[0]); webPart.RelatedDocumentsDescription = WBUtils.PutBackDelimiterCharacters(newDetails[1]); } webPart.PickedDocumentsDetails = WBUtils.PutBackDelimiterCharacters(newDetails[2]); webPartManager.SaveChanges(WebPartGuid); SPContext.Current.File.Update(); SPContext.Current.Web.Update(); currentDetails = NewRelatedDocumentsDetails.Value.WBxTrim(); pickedDocumentsDetails = webPart.PickedDocumentsDetails; } } if (!String.IsNullOrEmpty(currentDetails) && !currentDetails.Contains(",")) { WBLogging.Generic.Unexpected("The PickRelatedDocuments web part had an odd value: " + currentDetails); currentDetails = ""; } Description.Text = WBUtils.MaybeAddParagraphTags(webPart.RelatedDocumentsDescription); if (!String.IsNullOrEmpty(Description.Text) && WBFWebPartsUtils.ShowDescription(SPContext.Current.Site)) { showDescription = true; } if ((SPContext.Current.FormContext.FormMode == SPControlMode.Edit) || (webPartManager.DisplayMode == WebPartManager.EditDisplayMode)) { EditPanel.Visible = true; InEditMode = true; EditRelatedDocumentsButton.OnClientClick = "WorkBoxFramework_editRelatedDocuments(WBF_EditDialogCallback" + WebPartUniqueID + ", \"" + stripDownDetailsForEditing(currentDetails) + "\"); return false;"; } else { EditPanel.Visible = false; EditRelatedDocumentsButton.OnClientClick = ""; } WBLogging.Debug("PickRelatedDocuments currentDetails: " + currentDetails); if (String.IsNullOrEmpty(pickedDocumentsDetails)) { DocumentList.Text = "<ul><li>(No documents picked)</li></ul>"; DocumentsToView = false; return; } try { string[] documentsDetailsArray = pickedDocumentsDetails.Split(';'); String recordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site); using (SPSite site = new SPSite(recordsLibraryURL)) using (SPWeb web = site.OpenWeb()) { SPList library = web.GetList(recordsLibraryURL); String html = "<ul>\n"; foreach (string documentDetails in documentsDetailsArray) { string[] documentDetailsArray = documentDetails.Split('|'); if (documentDetailsArray.Length != 4) { WBLogging.Generic.Unexpected("Badly formatted document details in PickRelatedDocuments web part: " + currentDetails + " - Ignoring these details"); continue; } string zone = documentDetailsArray[0]; string recordID = documentDetailsArray[1]; string sourceID = documentDetailsArray[2]; string filename = documentDetailsArray[3]; SPListItem item = WBFWebPartsUtils.GetRecord(site, web, library, zone, recordID); if (item == null) { if (InEditMode) { html += "<li><i>(Could not find document)</i></li>"; } } else { DocumentsToView = true; string title = item.WBxGetAsString(WBColumn.Title); if (String.IsNullOrEmpty(title)) { title = Path.GetFileNameWithoutExtension(item.Name); } string extension = Path.GetExtension(item.Name).Replace(".", "").ToUpper(); string additionalText = ""; if (WBFWebPartsUtils.ShowKBFileSize(SPContext.Current.Site)) { long fileLength = (item.File.Length / 1024); additionalText = ", " + fileLength + "KB"; } if (WBFWebPartsUtils.ShowFileIcons(SPContext.Current.Site)) { title = String.Format("<img src=\"{0}\" alt=\"{1}\" class=\"wbf-picked-doc-image\"/> {1}", WBUtils.DocumentIcon16(item.Name), title); } html += "<li><a target=\"_blank\" href=\"" + item.WBxGetAsString(WBColumn.EncodedAbsoluteURL) + "\">" + title + "</a> <span>(" + extension + additionalText + ")</span></li>"; } } html += "</ul>\n"; DocumentList.Text = html; } } catch (Exception exception) { if (InEditMode) { DocumentList.Text = "An error occurred: " + exception.Message; } else { DocumentsToView = false; } } }