protected void RenderRecordsToKeep() { if (String.IsNullOrEmpty(selectedRecordsString)) { RecordsBeingKept.Text = "<tr><td><i>No records were selected!</i></td></tr>"; return; } String html = @" <tr> <td class=""wbf-field-name-panel""> <div class=""wbf-field-name"">Records to Keep</div> </td> <td class=""wbf-field-value-panel""> "; String[] recordDetailsPairs = selectedRecordsString.Split('_'); List <String> allRecordIDsToKeep = new List <String>(); List <String> allRecordFilenamesToKeep = new List <String>(); foreach (String recordDetailsPair in recordDetailsPairs) { String[] recordDetails = recordDetailsPair.Split('x'); String recordSeriesID = recordDetails[0]; String recordID = recordDetails[1]; WBRecord versionRecord = manager.Libraries.GetRecordByID(recordID); String filename = versionRecord.Name; html += @" <div> <img src='/_layouts/images/WorkBoxFramework/list-item-16.png' alt='Record to be kept'/> <img src='" + WBUtils.DocumentIcon16(filename) + "' alt='Icon for file " + filename + "'/> " + filename + @" </div> "; allRecordIDsToKeep.Add(versionRecord.RecordID); allRecordFilenamesToKeep.Add(versionRecord.Name); } html += @" </td> </tr> "; RecordsBeingKept.Text = html; AllRecordIDsToKeep.Value = String.Join(",", allRecordIDsToKeep.ToArray()); AllRecordFilenamesToKeep.Value = String.Join(",", allRecordFilenamesToKeep.ToArray()); }
public String GetHTMLForOneRecordVersion(SPListItemCollection items) { String html = ""; foreach (SPListItem item in items) { String filename = item.Name; html += @" <div> <img src='/_layouts/images/WorkBoxFramework/list-item-16.png' alt='Record to be archived'/> <img src='" + WBUtils.DocumentIcon16(filename) + "' alt='Icon for file " + filename + "'/> " + filename + @" </div> "; } return(html); }
protected void Page_Load(object sender, EventArgs e) { SPGroup publishersGroup = WorkBox.OwningTeam.PublishersGroup(SPContext.Current.Site); if (publishersGroup != null) { if (publishersGroup.ContainsCurrentUser) { userCanPublishToPublic = true; } } if (!IsPostBack) { if (Request.QueryString["selectedItemsIDsString"] != null && Request.QueryString["selectedListGUID"] != null) { manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName); string selectedListGUID = Request.QueryString["selectedListGUID"]; string[] selectedItemsIDs = Request.QueryString["selectedItemsIDsString"].ToString().Split('|'); WBLogging.Debug("Before creating the WBProcessObject"); process = new WBPublishingProcess(WorkBox, selectedListGUID, selectedItemsIDs); WBLogging.Debug("Created the WBProcessObject"); PublishingProcessJSON.Value = WBUtils.SerializeToCompressedJSONForURI(process); String html = ""; WBLogging.Debug("Created the WBProcessObject and serialised " + PublishingProcessJSON.Value); if (process.ItemIDs.Count == 0) { WBLogging.Debug("process.ItemIDs.Count == 0"); html += "<i>No documents selected!</i>"; } else { html += "<table cellpadding='0px' cellspacing='5px'>"; foreach (String itemID in process.ItemIDs) { String filename = process.MappedFilenames[itemID]; WBLogging.Debug("list through item with name: " + filename); html += "<tr><td align='center'><img src='" + WBUtils.DocumentIcon16(filename) + "' alt='Icon for file " + filename + "'/></td><td align='left'>" + filename + "</td></tr>\n"; String fileType = WBUtils.GetExtension(filename); if (!fileTypes.Contains(fileType)) { fileTypes.Add(fileType); } } html += "</table>"; List <string> disallowedFileTypes = manager.GetFileTypesDisallowedFromBeingPublishedToPublic(fileTypes); if (String.IsNullOrEmpty(WorkBox.OwningTeam.InformationAssetOwnerLogin)) { PublicWebSiteButton.Enabled = false; PublicNotAllowedMessage.Text = "You cannot publish to the public website because the owning team of this work box does not have an assigned Information Asset Owner(IAO)"; PublicExtranetButton.Enabled = false; PublicExtranetNotAllowedMessage.Text = "You cannot publish to the public website because the owning team of this work box does not have an assigned Information Asset Owner(IAO)"; } else if (!WorkBox.OwningTeam.IsCurrentUserTeamMember()) { PublicWebSiteButton.Enabled = false; PublicNotAllowedMessage.Text = "You cannot publish to the public website from here because you are not a member of this work box's owning team"; PublicExtranetButton.Enabled = false; PublicExtranetNotAllowedMessage.Text = "You cannot publish to the public website from here because you are not a member of this work box's owning team"; } else if (disallowedFileTypes.Count > 0) { PublicWebSiteButton.Enabled = false; PublicNotAllowedMessage.Text = "The following file types have not been approved for publishing to a public website: " + String.Join(", ", disallowedFileTypes.ToArray()); PublicExtranetButton.Enabled = false; PublicExtranetNotAllowedMessage.Text = "The following file types have not been approved for publishing to a public website: " + String.Join(", ", disallowedFileTypes.ToArray()); } } DocumentsBeingPublished.Text = html; } else { ErrorMessageLabel.Text = "There was an error with the passed through values"; } } else { process = WBUtils.DeserializeFromCompressedJSONInURI <WBPublishingProcess>(PublishingProcessJSON.Value); process.WorkBox = WorkBox; } }
public String GetStandardHTMLTableRows() { SPListItem currentItem = this.CurrentItem; String html = ""; if (this.ItemIDs.Count == 0) { WBLogging.Debug("process.ItemIDs.Count == 0"); html += "<i>No documents selected!</i>"; } else { int numberOfDocuments = this.ItemIDs.Count; int itemIndex = -1; int currentItemIndex = -1; bool before = true; foreach (String itemID in this.ItemIDs) { itemIndex++; String filename = this.MappedFilenames[itemID]; WBLogging.Debug("list through item with name: " + filename); if (itemID == this.CurrentItemID) { currentItemIndex = itemIndex; if (itemIndex != 0) { // OK so we've got to close the table row of the already published documents: html += @" </td> </tr>"; } before = false; if (this.PublishMode != PUBLISH_MODE__ALL_TOGETHER) { String originalFilename = ""; if (currentItem != null) { originalFilename = currentItem.WBxGetColumnAsString(WorkBox.COLUMN_NAME__ORIGINAL_FILENAME); } html += @" <tr> <td class=""wbf-field-name-panel""> <div class=""wbf-field-name"">Publishing Document</div> </td> <td class=""wbf-field-value-panel""> <div class=""wbf-field-read-only-title""> <table border=""0"" cellpadding=""0"" cellspacing=""2px""> <tr> <td rowspan=""2"" style=""padding-right: 10px; ""> <img src='" + WBUtils.DocumentIcon32(filename) + "' alt='Icon for file " + filename + @"'/> </td> <td>" + filename + @"</td> </tr> <tr> <td>" + originalFilename + @"</td> </tr> </table> </div> </td> </tr> "; } else { // So if we're here then we are publishing all together - so let's slightly change the layout: html += @" <tr> <td class=""wbf-field-name-panel""> <div class=""wbf-field-name"">Publishing Documents</div> </td> <td class=""wbf-field-value-panel""> <div> <img src='/_layouts/images/WorkBoxFramework/list-item-16.png' alt='Unpublished document'/> <img src='" + WBUtils.DocumentIcon16(filename) + "' alt='Icon for file " + filename + "'/> " + filename + @" </div> "; } } else { if (before) { String statusIcon = "/_layouts/images/WorkBoxFramework/green-tick-16.png"; String statusAltText = "Successfully published"; if (this.ItemStatus[itemID] == WBPublishingProcess.DOCUMENT_STATUS__ERROR) { statusIcon = "/_layouts/images/WorkBoxFramework/red-cross-16.png"; statusAltText = "Failed to publish"; } if (itemIndex == 0) { // OK so let's start the table row of the documents that have already been published: html += @" <tr> <td class=""wbf-field-name-panel""> <div class=""wbf-field-name""></div> </td> <td class=""wbf-field-name-panel""> "; } html += @" <div> <img src='" + statusIcon + "' alt='" + statusAltText + @"'/> <img src='" + WBUtils.DocumentIcon16(filename) + "' alt='Icon for file " + filename + "'/> " + filename + @" </div> "; } else { if (itemIndex == currentItemIndex + 1 && this.PublishMode != PUBLISH_MODE__ALL_TOGETHER) { html += @" <tr> <td class=""wbf-field-name-panel""> <div class=""wbf-field-name""></div> </td> <td class=""wbf-field-name-panel""> "; } html += @" <div> <img src='/_layouts/images/WorkBoxFramework/list-item-16.png' alt='Unpublished document'/> <img src='" + WBUtils.DocumentIcon16(filename) + "' alt='Icon for file " + filename + "'/> " + filename + @" </div> "; if (itemIndex == numberOfDocuments - 1) { html += @" </td> </tr>"; } } } } } return(html); }
protected void Page_Load(object sender, EventArgs e) { webPart = this.Parent as PickedDocumentsGroup; 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[5]; detailsToSave[0] = WBUtils.ReplaceDelimiterCharacters(webPart.Title); detailsToSave[1] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupDescription); detailsToSave[2] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupSubjectTags); detailsToSave[3] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupCoverage); detailsToSave[4] = WBUtils.ReplaceDelimiterCharacters(webPart.PickedDocumentsDetails.WBxTrim()); String currentDetails = String.Join(",", detailsToSave); WBLogging.Debug("Current details: " + currentDetails); if (IsPostBack) { if (NeedToSave.Value == "true") { WBLogging.Debug("Trying to save value: " + NewDocumentsGroupDetails.Value); string[] newDetails = NewDocumentsGroupDetails.Value.WBxTrim().Split(','); if (newDetails.Length != 5) { WBLogging.Debug("The details sent to this page have the wrong structure: " + NewDocumentsGroupDetails.Value); Description.Text = "(the web part has not yet been edited)."; return; } webPart.Title = WBUtils.PutBackDelimiterCharacters(newDetails[0]); webPart.DocumentsGroupDescription = WBUtils.PutBackDelimiterCharacters(newDetails[1]); webPart.DocumentsGroupSubjectTags = WBUtils.PutBackDelimiterCharacters(newDetails[2]); webPart.DocumentsGroupCoverage = WBUtils.PutBackDelimiterCharacters(newDetails[3]); webPart.PickedDocumentsDetails = WBUtils.PutBackDelimiterCharacters(newDetails[4]); webPartManager.SaveChanges(WebPartGuid); SPContext.Current.File.Update(); SPContext.Current.Web.Update(); currentDetails = NewDocumentsGroupDetails.Value.WBxTrim(); WBLogging.Debug("New current details: " + currentDetails); } } if (!String.IsNullOrEmpty(currentDetails) && !currentDetails.Contains(",")) { WBLogging.Generic.Unexpected("The PickRelatedDocuments web part had an odd value: " + currentDetails); currentDetails = ""; } if ((SPContext.Current.FormContext.FormMode == SPControlMode.Edit) || (webPartManager.DisplayMode == WebPartManager.EditDisplayMode)) { EditPanel.Visible = true; InEditMode = true; EditDocumentsGroupButton.OnClientClick = "WorkBoxFramework_editDocumentsGroup(WBF_EditDialogCallback" + WebPartUniqueID + ", \"" + currentDetails + "\"); return false;"; } else { EditPanel.Visible = false; EditDocumentsGroupButton.OnClientClick = ""; } WBLogging.Debug("PickedDocumentsGroup currentDetails: " + currentDetails); Title.Text = webPart.Title; Description.Text = WBUtils.MaybeAddParagraphTags(webPart.DocumentsGroupDescription); WBTermCollection <WBTerm> allSubjects = new WBTermCollection <WBTerm>(null, webPart.DocumentsGroupSubjectTags); SubjectTags.Text = allSubjects.Names(); Coverage.Text = webPart.DocumentsGroupCoverage; if (String.IsNullOrEmpty(webPart.PickedDocumentsDetails)) { DocumentsList.Text = "<ul><li>(No documents picked)</li></ul>"; DocumentsToView = false; return; } String extranetRecordsLibraryURL = WBFWebPartsUtils.GetExtranetLibraryURL(SPContext.Current.Site); SPSite extranetRecordsSite = null; SPWeb extranetRecordsWeb = null; SPList extranetRecordsLibrary = null; try { string[] documentsDetailsArray = webPart.PickedDocumentsDetails.Split(';'); String publicRecordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site); using (SPSite publicRecordsSite = new SPSite(publicRecordsLibraryURL)) using (SPWeb publicRecordsWeb = publicRecordsSite.OpenWeb()) { SPList publicRecordsLibrary = publicRecordsWeb.GetList(publicRecordsLibraryURL); 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 = null; if (zone == "Public Extranet") { if (extranetRecordsLibrary == null) { extranetRecordsSite = new SPSite(extranetRecordsLibraryURL); extranetRecordsWeb = extranetRecordsSite.OpenWeb(); extranetRecordsLibrary = extranetRecordsWeb.GetList(extranetRecordsLibraryURL); } item = WBFWebPartsUtils.GetRecord(extranetRecordsSite, extranetRecordsWeb, extranetRecordsLibrary, zone, recordID); } else { item = WBFWebPartsUtils.GetRecord(publicRecordsSite, publicRecordsWeb, publicRecordsLibrary, 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 = ""; long fileLength = (item.File.Length / 1024); additionalText = ", " + fileLength + "KB"; if (item.WBxHasValue(WBColumn.ReferenceDate)) { DateTime referenceDate = (DateTime)item.WBxGet(WBColumn.ReferenceDate); string referenceDateString = string.Format("{0}-{1}-{2}", referenceDate.Year.ToString("D4"), referenceDate.Month.ToString("D2"), referenceDate.Day.ToString("D2")); additionalText += ", " + referenceDateString; } html += String.Format("<li><img src=\"{0}\" alt=\"{1}\"/><a target=\"_blank\" href=\"{2}\">{1}</a> <span>({3})</span></li>", WBUtils.DocumentIcon16(item.WBxGetAsString(WBColumn.Name)), title, item.WBxGetAsString(WBColumn.EncodedAbsoluteURL), extension + additionalText); } } html += "</ul>\n"; DocumentsList.Text = html; } } catch (Exception exception) { if (InEditMode) { DocumentsList.Text = "An error occurred: " + exception.Message; } else { DocumentsToView = false; } } finally { if (extranetRecordsWeb != null) { extranetRecordsWeb.Dispose(); } if (extranetRecordsSite != null) { extranetRecordsSite.Dispose(); } } }
public String RenderClipboardItems(SPSite site) { UserProfile profile = GetUserProfile(site); Dictionary <String, List <int> > clipboardItems = new Dictionary <String, List <int> >(); String clipboardAction = GetClipboard(profile, clipboardItems); if (clipboardItems.Count == 0) { return("<div class='wbf-clipboard-items'><p>Clipboard is empty</p></div>"); } String html = "<div class='wbf-clipboard-items'>"; String actionImageSrc = ""; if (clipboardAction == CLIPBOARD_ACTION__CUT) { actionImageSrc = "/_layouts/images/cuths.png"; } else { actionImageSrc = "/_layouts/images/copy16.gif"; } foreach (String workBoxURL in clipboardItems.Keys) { List <int> ids = clipboardItems[workBoxURL]; using (WorkBox clipboardWorkBox = new WorkBox(workBoxURL)) { html += "<div class='wbf-clipboard-from-work-box'><b>From:</b> <img src=\"/_layouts/images/WorkBoxFramework/work-box-16.png\"/> <b>" + clipboardWorkBox.Title + "</b> "; SPDocumentLibrary documents = clipboardWorkBox.DocumentLibrary; if (ids.Count > 0) { Dictionary <String, String> htmlFragmentsToOrder = new Dictionary <string, string>(); foreach (int id in ids) { String htmlFragment = "<div class='wbf-clipboard-item'><i>(could not find an item)</i></div>"; try { SPListItem item = documents.GetItemById(id); SPFolder fromFolder = null; String itemImageSrc = ""; if (item.Folder == null) { fromFolder = item.File.ParentFolder; itemImageSrc = WBUtils.DocumentIcon16(item.Name); } else { fromFolder = item.Folder.ParentFolder; itemImageSrc = "/_layouts/images/folder.gif"; } htmlFragment = "<div class='wbf-clipboard-item'>"; htmlFragment += "<img src=\"" + actionImageSrc + "\"/> /" + fromFolder.Url + " <img src=\"" + itemImageSrc + "\"/> <b>" + item.Name + "</b>"; htmlFragment += "</div>\n"; htmlFragmentsToOrder.Add(fromFolder.Url + "/" + item.Name, htmlFragment); } catch (Exception itemException) { // Trying to add this to the end of the list of items found: htmlFragmentsToOrder.Add("zzzzzzz", htmlFragment); WBUtils.SendErrorReport(clipboardWorkBox.Web, "Error in RenderClipboardItems", "Exception : " + itemException + " \n\n " + itemException.StackTrace); } } List <String> ordering = new List <String>(htmlFragmentsToOrder.Keys); ordering.Sort(); foreach (String key in ordering) { html += htmlFragmentsToOrder[key]; } } else { html += "<p>Nothing from this work box</p>"; } html += "</div>\n"; } } html += "</div>\n"; return(html); }
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); }
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 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; } } }