private void lvDatabase_SelectedIndexChanged(object sender, EventArgs e) { string selecteIndex = lvDatabase.FocusedItem.SubItems[0].Text; System.Console.WriteLine("Selected index ====================================" + selecteIndex); try { int tmp = Convert.ToInt16(selecteIndex); DataRow[] returnedRow; returnedRow = ds1.Tables["service"].Select("id='" + tmp + "'"); DataRow dr1; dr1 = returnedRow[0]; string title = "Work Order"; WBDocument document = new WBDocument(wBDisplay, title); document.setDataRow(dr1); // data from database documentToPrint = document.create(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Press ok"); } finally { } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (WBRecordsManager manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName)) { AllRecordIDsToArchive.Value = Request.QueryString["AllRecordIDsToArchive"]; ReasonToArchiveRecords.Value = Request.QueryString["ReasonToArchiveRecords"]; recordIDs = AllRecordIDsToArchive.Value.Split(','); foreach (String recordID in recordIDs) { WBDocument record = manager.Libraries.ProtectedMasterLibrary.GetDocumentByID(recordID); allFilenamesToArchive.Add(record.Name); } AllRecordFilenamesToArchive.Value = String.Join(",", allFilenamesToArchive.ToArray()); WBLogging.Debug("AllRecordIDsToArchive.Value = " + AllRecordIDsToArchive.Value); WBLogging.Debug("AllRecordFilenamesToArchive.Value = " + AllRecordFilenamesToArchive.Value); indexOfNextRecordToArchive = 0; NextRecordToArchive.Text = "" + indexOfNextRecordToArchive; } } else { indexOfNextRecordToArchive = NextRecordToArchive.Text.WBxToInt(); recordIDs = AllRecordIDsToArchive.Value.Split(','); } WBLogging.Debug("recordIDs.Length = " + recordIDs.Length); if (indexOfNextRecordToArchive < recordIDs.Length) { String[] filenames = AllRecordFilenamesToArchive.Value.Split(','); WBLogging.Debug("filenames.Length = " + filenames.Length); for (int i = 0; i < recordIDs.Length && i < filenames.Length; i++) { mappedFilenames.Add(i.ToString(), filenames[i]); } RecordArchivingProgress.WBxCreateTasksTable(mappedFilenames.Keys, mappedFilenames); Image image = (Image)RecordArchivingProgress.WBxFindNestedControlByID(RecordArchivingProgress.WBxMakeControlID(indexOfNextRecordToArchive.ToString(), "image")); if (image != null) { image.ImageUrl = "/_layouts/images/WorkBoxFramework/processing-task-32.gif"; } WBLogging.Debug("Finished"); } }
private void RenderFoundRecords(SPListItemCollection items) { if (items == null) { FoundRecords.Text = "<i>items was null!</i>"; return; } if (items.Count == 0) { FoundRecords.Text = "<i>No records found</i>"; return; } String html = "<table class='wbf-record-series-details'>\n"; html += "<tr>" + "<th class='wbf-record-series-odd'></th>" + "<th class='wbf-record-series-odd'>" + RenderColumnTitle("Title", WBColumn.Title) + "</th>" + "<th class='wbf-record-series-even'>" + RenderColumnTitle("Filename", WBColumn.Name) + "</th>" + "<th class='wbf-record-series-odd'>Version</th>" + "<th class='wbf-record-series-even'>" + RenderColumnTitle("Protective Zone", WBColumn.ProtectiveZone) + "</th>" + "<th class='wbf-record-series-odd'>" + RenderColumnTitle("Published Date", WBColumn.DatePublished) + "</th>" + "<th class='wbf-record-series-even'>" + RenderColumnTitle("Published By", WBColumn.PublishedBy) + "</th>" + "<th class='wbf-record-series-even'></th>" + "</tr>\n"; int countViewableItems = 0; foreach (SPListItem item in items) { if (ItemCanBePicked(item)) { countViewableItems++; WBDocument document = new WBDocument(manager.Libraries.ProtectedMasterLibrary, item); document.CheckAndFixMetadataForRecord(); String publishedDateString = ""; if (document.Item.WBxHasValue(WBColumn.DatePublished)) { publishedDateString = String.Format("{0:dd/MM/yyyy}", document[WBColumn.DatePublished]); } if (publishedDateString == "" && document.Item.WBxHasValue(WBColumn.Modified)) { publishedDateString = String.Format("{0:dd/MM/yyyy}", document[WBColumn.Modified]); } String publishedByString = "<unknown>"; SPUser publishedBy = document.GetSingleUserColumn(WBColumn.PublishedBy); if (publishedBy != null) { publishedByString = publishedBy.Name; } else { // If the published by column isn't set then we'll use the author column as a backup value: publishedBy = document.GetSingleUserColumn(WBColumn.Author); if (publishedBy != null) { publishedByString = publishedBy.Name; } } long fileLength = (document.Item.File.Length / 1024); if (fileLength == 0) { fileLength = 1; } String fileLengthString = "" + fileLength + " KB"; String version = document.RecordSeriesIssue.WBxTrim(); if (String.IsNullOrEmpty(version)) { version = "1"; } if (masterLibraryHasVersions) { version += "." + (item.Versions.Count - 1).ToString(); } html += "<tr>" + "<td class='wbf-record-series-summary-detail'><input type='checkbox' class='wbf-our-records-check-boxes' data-record-id='" + document.RecordSeriesID + "x" + document.RecordID + "' onclick=\"WBF_checkbox_changed(event);\"/></td>" + "<td class='wbf-record-series-summary-detail'>" + document.Title + "</td>" + "<td class='wbf-record-series-summary-detail'>" + document.Filename + "</td>" + "<td class='wbf-record-series-summary-detail wbf-centre'>" + version + "</td>" + "<td class='wbf-record-series-summary-detail'>" + document.ProtectiveZone + "</td>" + "<td class='wbf-record-series-summary-detail wbf-centre'>" + publishedDateString + "</td>" + "<td class='wbf-record-series-summary-detail'>" + publishedByString + "</td>" + "<td class='wbf-record-series-summary-detail'><a href='#' onclick='WorkBoxFramework_viewRecordSeriesDetails(\"" + document.RecordSeriesID + "\", \"" + document.RecordID + "\");'>view details</a></td>" + "</tr>"; } } if (countViewableItems == 0) { FoundRecords.Text = "<i>No suitable records found</i><!-- number of unsuitable records = " + items.Count + " -->"; return; } html += "\n</table>"; FoundRecords.Text = html; // This should attach the right function to the checkboxes //ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "AttachChangeListeners", "$(function () { WBF_add_checkbox_change_function(); });", true); }
protected void publishButton_OnClick(object sender, EventArgs e) { WBLogging.Debug("In publishButton_OnClick()"); Hashtable metadataProblems = checkMetadataState(); string protectiveZone = ""; if (metadataProblems.Count > 0) { RecordsTypeFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__RECORDS_TYPE].WBxToString(); FunctionalAreaFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__FUNCTIONAL_AREA].WBxToString(); ProtectiveZoneMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__PROTECTIVE_ZONE].WBxToString(); // SubjectTagsMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__SUBJECT_TAGS].WBxToString(); ReferenceIDMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__REFERENCE_ID].WBxToString();; ReferenceDateMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__REFERENCE_DATE].WBxToString();; SeriesTagFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__SERIES_TAG].WBxToString(); ScanDateMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__SCAN_DATE].WBxToString(); OwningTeamFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__OWNING_TEAM].WBxToString(); InvolvedTeamsFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__INVOLVED_TEAMS].WBxToString(); pageRenderingRequired = true; } else { pageRenderingRequired = false; } if (pageRenderingRequired) { WBLogging.Debug("In publishButton_OnClick(): Page render required - not publishing at this point"); renderPage(); } else { WBLogging.Debug("In publishButton_OnClick(): No page render required - so moving to publish"); // The event should only be processed if there is no other need to render the page again // First let's update the item with the new metadata values submitted: SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)SPContext.Current.Web.Lists[new Guid(ListGUID.Value)]; SPListItem sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value)); WBDocument document = CaptureAsDocument(sourceDocAsItem, documentRecordsType); document.Update(); /* * * OK So now we actually publish out the document: * */ SPFile sourceFile = sourceDocAsItem.File; string errorMessage = ""; string successMessage = "<h3>Successfully Published Out</h3> <table cellpadding='5'>"; if (TheDestinationType.Value.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__WORK_BOX)) { using (WorkBox workBox = new WorkBox(DestinationURL.Value)) { string selectedFolderPath = Request.QueryString["SelectedFolderPath"]; if (string.IsNullOrEmpty(selectedFolderPath)) { selectedFolderPath = "/"; } string destinationRootFolderUrl = DestinationURL.Value + "/" + workBox.DocumentLibrary.RootFolder.Url + selectedFolderPath; errorMessage = sourceFile.WBxCopyTo(destinationRootFolderUrl, new List <String>()); if (errorMessage == "") { successMessage += "<tr><td>Filename</td><td><b>" + sourceFile.Name + "</b></td></tr><tr><td>Published out to:</td><td><a href=\"" + destinationRootFolderUrl + "\"><b>" + destinationRootFolderUrl + "</b></a></td></tr>"; } } } else { // WBRecordsType recordsType = new WBRecordsType(recordsTypeTaxonomy, document[WBColumn.RecordsType].WBxToString()); using (WBRecordsManager manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName)) { try { WBLogging.Debug("In publishButton_OnClick(): About to try to publish"); manager.PublishDocument(WorkBox, document); WBLogging.Debug("In publishButton_OnClick(): Should have finished the publishing"); //recordsType.PublishDocument(document, sourceFile.OpenBinaryStream()); string fullClassPath = "Just a test"; // WBUtils.NormalisePath(document.FunctionalArea.Names() + "/" + recordsType.FullPath); successMessage += "<tr><td>Published out to location:</td><td>" + fullClassPath + "</td></tr>\n"; if (document.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC) { successMessage += "<tr><td>To public records library</td><td><a href=\"http://stagingweb/publicrecords\">Our public library</a></td></tr>\n"; } if (document.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET) { successMessage += "<tr><td>To public extranet records library</td><td><a href=\"http://stagingextranets/records\">Our public extranet library</a></td></tr>\n"; } successMessage += "<tr><td>To internal records library</td><td><a href=\"http://sp.izzi/library/Pages/ViewByFunctionThenType.aspx\">Our internal library</a></td></tr>\n"; } catch (Exception exception) { errorMessage = "An error occurred when trying to publish: " + exception.Message; WBLogging.Generic.Unexpected(exception); } } } /* * WBFarm farm = WBFarm.Local; * string destinationRootFolderUrl = farm.ProtectedRecordsLibraryUrl; * List<String> filingPath = null; * * * filingPath = documentRecordsType.FilingPathForItem(sourceDocAsItem); * * string filingPathString = string.Join("/", filingPath.ToArray()); * * WBLogging.Generic.Verbose("The file is: " + sourceFile.Url); * WBLogging.Generic.Verbose("The destination is: " + destinationRootFolderUrl); * WBLogging.Generic.Verbose("The destination filing path is: " + filingPathString); * * * string errorMessage = sourceFile.WBxCopyTo(destinationRootFolderUrl, filingPath); * * if (errorMessage == "") * { * successMessage += "<tr><td>Filename</td><td><b>" + sourceFile.Name + "</b></td></tr><tr><td>Published out to:</td><td><a href=\"" + destinationRootFolderUrl + "\"><b>" + destinationRootFolderUrl + "</b></a></td></tr><tr><td>Filing path:</td><td><a href=\"" + destinationRootFolderUrl + "/" + filingPathString + "\"><b>" + filingPathString + "</b></td></tr>"; * } * * WBLogging.Generic.Verbose("Protective zone was set to be: " + protectiveZone); * * * if (!TheDestinationType.Value.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__WORK_BOX) * && protectiveZone.Equals(WBRecordsType.PROTECTIVE_ZONE__PUBLIC)) * { * // OK so we're going to copy this to the public library as well: * WBLogging.Generic.Verbose("The file is: " + sourceFile.Url); * WBLogging.Generic.Verbose("The destination is: " + farm.PublicRecordsLibraryUrl); * WBLogging.Generic.Verbose("The destination filing path is: " + filingPathString); * * string errorMessagePublic = sourceFile.WBxCopyTo(farm.PublicRecordsLibraryUrl, filingPath); * * if (errorMessagePublic == "") * { * successMessage += "<tr><td colspan='2'><b>And also published to the public library.</b></td></tr>"; * } * } * * if (!TheDestinationType.Value.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__WORK_BOX) * && protectiveZone.Equals(WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET)) * { * // OK so we're going to copy this to the public extranet library as well: * WBLogging.Generic.Verbose("The file is: " + sourceFile.Url); * WBLogging.Generic.Verbose("The destination is: " + farm.PublicExtranetRecordsLibraryUrl); * WBLogging.Generic.Verbose("The destination filing path is: " + filingPathString); * * string errorMessagePublicExtranet = sourceFile.WBxCopyTo(farm.PublicExtranetRecordsLibraryUrl, filingPath); * * if (errorMessagePublicExtranet == "") * { * successMessage += "<tr><td colspan='2'><b>And also published to the public extranet library.</b></td></tr>"; * } * } */ successMessage += "</table>"; if (errorMessage == "") { //returnFromDialogOKAndRefresh(); GoToGenericOKPage("Publishing Out Success", successMessage); } else { GoToGenericOKPage("Publishing Out Error", errorMessage); //returnFromDialogOK("An error occurred during publishing: " + errorMessage); } } }
protected void Page_Load(object sender, EventArgs e) { WBLogging.Generic.Verbose("In Page_Load for the public doc metadata dialog"); // Creating the taxonomy objects for later use: recordsTypeTaxonomy = WBTaxonomy.GetRecordsTypes(WorkBox.Site); teamsTaxonomy = WBTaxonomy.GetTeams(recordsTypeTaxonomy); seriesTagsTaxonomy = WBTaxonomy.GetSeriesTags(recordsTypeTaxonomy); subjectTagsTaxonomy = WBTaxonomy.GetSubjectTags(recordsTypeTaxonomy); functionalAreasTaxonomy = WBTaxonomy.GetFunctionalAreas(recordsTypeTaxonomy); // If this is the initial call to the page then we need to load the basic details of the document we're publishing out: if (!IsPostBack) { ListGUID.Value = Request.QueryString["ListGUID"]; ItemID.Value = Request.QueryString["ItemID"]; // The following variable has its name due to a strange compliation error with the name 'DestinationType' TheDestinationType.Value = Request.QueryString["DestinationType"]; DestinationURL.Value = Request.QueryString["DestinationURL"]; DestinationTitle.Text = Request.QueryString["DestinationTitle"] + " (" + Request.QueryString["DestinationType"] + ")"; WBLogging.Generic.Verbose("DestinationType = " + TheDestinationType.Value); WBLogging.Generic.Verbose("DestinationURL = " + DestinationURL.Value); } // Now do a check that we do at this stage have the basic details of the document: if (ListGUID.Value == null || ListGUID.Value == "") { errorMessage += "ListGUID hasn't been set. "; } if (ItemID.Value == null || ItemID.Value == "") { errorMessage += "ItemID hasn't been set. "; } if (TheDestinationType.Value == null || TheDestinationType.Value == "") { errorMessage += "DestinationType hasn't been set. "; } if (errorMessage.Length > 0) { ErrorMessageLabel.Text = errorMessage; return; } // Let's clear out all of the error messages text fields: ErrorMessageLabel.Text = ""; RecordsTypeFieldMessage.Text = ""; FunctionalAreaFieldMessage.Text = ""; ProtectiveZoneMessage.Text = ""; ReferenceIDMessage.Text = ""; ReferenceDateMessage.Text = ""; SeriesTagFieldMessage.Text = ""; ScanDateMessage.Text = ""; OwningTeamFieldMessage.Text = ""; InvolvedTeamsFieldMessage.Text = ""; //OK so we have the basic identity information for the document being published out so let's get the document item: Guid sourceListGuid = new Guid(ListGUID.Value); SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)WorkBox.Web.Lists[sourceListGuid]; sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value)); sourceFile = sourceDocAsItem.File; generatingFilename = WorkBox.RecordsType.GeneratePublishOutFilenames; // Now, if this is the first time we might need to load up the default metadata values for the document: if (!IsPostBack) { WorkBox.Web.AllowUnsafeUpdates = true; WorkBox.ApplyPublishOutDefaults(sourceDocAsItem); WorkBox.Web.AllowUnsafeUpdates = false; // Let's now re-load the item as it's name may have changed: sourceDocAsItem = null; sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value)); sourceFile = sourceDocAsItem.File; pageRenderingRequired = true; } else { WBLogging.Debug("Setting the subject tags: " + SubjectTagsField.Text); sourceDocAsItem.WBxSetMultiTermColumn(WorkBox.COLUMN_NAME__SUBJECT_TAGS, SubjectTagsField.Text); // If this is a post back - then let's check if the records type has been modified: if (NewRecordsTypeUIControlValue.Value != "") { WBLogging.Generic.Unexpected("The returned value was: " + NewRecordsTypeUIControlValue.Value); WBRecordsType oldRecordsType = sourceDocAsItem.WBxGetSingleTermColumn <WBRecordsType>(recordsTypeTaxonomy, WorkBox.COLUMN_NAME__RECORDS_TYPE); WBRecordsType newRecordsType = new WBRecordsType(recordsTypeTaxonomy, NewRecordsTypeUIControlValue.Value); RecordsTypeUIControlValue.Value = NewRecordsTypeUIControlValue.Value; RecordsType.Text = newRecordsType.Name; pageRenderingRequired = true; // These are now being done in CaptureAsDocument() // sourceDocAsItem.WBxSetSingleTermColumn(WorkBox.COLUMN_NAME__RECORDS_TYPE, NewRecordsTypeUIControlValue.Value); // sourceDocAsItem.WBxSet(WBColumn.Title, this.TitleField.Text); // This is now being done in CaptureAsDocument() // WorkBox.GenerateFilename(newRecordsType, sourceDocAsItem); // If either the old or new records type have an uneditable functional area, then we'll update it to the new default area. if (!oldRecordsType.IsFunctionalAreaEditable || !newRecordsType.IsFunctionalAreaEditable) { WBLogging.Debug("Setting the functional area as it's not editable: " + newRecordsType.DefaultFunctionalAreaUIControlValue); this.FunctionalAreaField.Text = newRecordsType.DefaultFunctionalAreaUIControlValue; sourceDocAsItem.WBxSetMultiTermColumn(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, newRecordsType.DefaultFunctionalAreaUIControlValue); } /* This is now being done in CaptureAsDocument() * else * { * WBLogging.Debug("Saving the current functional area selection: " + this.FunctionalAreaField.Text); * sourceDocAsItem.WBxSetMultiTermColumn(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, this.FunctionalAreaField.Text); * } */ WBDocument document = CaptureAsDocument(sourceDocAsItem, newRecordsType); document.Update(); // Let's now re-load the item as it's name may have changed: sourceDocAsItem = null; sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value)); sourceFile = sourceDocAsItem.File; } else { // Otherwise we are in a normal post back call. pageRenderingRequired = false; } } // Now load up some of the basic details: documentRecordsType = sourceDocAsItem.WBxGetSingleTermColumn <WBRecordsType>(recordsTypeTaxonomy, WorkBox.COLUMN_NAME__RECORDS_TYPE); destinationType = TheDestinationType.Value; // Which of the metadata fields are being used in the form (or will need to be processed in any postback) : showReferenceID = documentRecordsType.DocumentReferenceIDRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; showReferenceDate = documentRecordsType.DocumentReferenceDateRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; showSubjectTags = true; // documentRecordsType.DocumentSubjectTagsRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; showSeriesTag = documentRecordsType.DocumentSeriesTagRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; showScanDate = documentRecordsType.DocumentScanDateRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; if (pageRenderingRequired) { renderPage(); } }
protected WBDocument CaptureAsDocument(SPListItem sourceDocAsItem, WBRecordsType documentRecordsType) { WBDocument document = new WBDocument(WorkBox, sourceDocAsItem); // Which of the metadata fields are being used by the active records type? showReferenceID = documentRecordsType.DocumentReferenceIDRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; showReferenceDate = documentRecordsType.DocumentReferenceDateRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; showSubjectTags = true; // documentRecordsType.DocumentSubjectTagsRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; showSeriesTag = documentRecordsType.DocumentSeriesTagRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; showScanDate = documentRecordsType.DocumentScanDateRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; //document.Name = // if (!generatingFilename) // { // sourceDocAsItem["Name"] = NameField.Text; // } document.Title = TitleField.Text; //sourceDocAsItem["Title"] = TitleField.Text; if (documentRecordsType.IsFunctionalAreaEditable) { document[WBColumn.FunctionalArea] = FunctionalAreaField.Text; sourceDocAsItem.WBxSetMultiTermColumn(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, FunctionalAreaField.Text); } //document.FunctionalArea = sourceDocAsItem.WBxGetMultiTermColumn<WBTerm>(functionalAreasTaxonomy, WBColumn.FunctionalArea.DisplayName); String protectiveZone = ProtectiveZone.SelectedValue; document.ProtectiveZone = protectiveZone; //sourceDocAsItem.WBxSetColumnAsString(WorkBox.COLUMN_NAME__PROTECTIVE_ZONE, protectiveZone); // Now to save the current value of the Records Type field: document[WBColumn.RecordsType] = RecordsTypeUIControlValue.Value; //sourceDocAsItem.WBxSetSingleTermColumn(WorkBox.COLUMN_NAME__RECORDS_TYPE, RecordsTypeUIControlValue.Value); if (showSubjectTags) { WBLogging.Debug("Setting subject tags to be: " + SubjectTagsField.Text); document[WBColumn.SubjectTags] = SubjectTagsField.Text; } else { WBLogging.Debug("NOT !!! Setting subject tags to be: " + SubjectTagsField.Text); } if (showReferenceID) { document.ReferenceID = ReferenceID.Text; //sourceDocAsItem.WBxSetColumnAsString(WorkBox.COLUMN_NAME__REFERENCE_ID, ReferenceID.Text); } if (showReferenceDate) { document.ReferenceDate = ReferenceDate.SelectedDate; // sourceDocAsItem[WorkBox.COLUMN_NAME__REFERENCE_DATE] = ReferenceDate.SelectedDate; } if (showSeriesTag) { document[WBColumn.SeriesTag] = SeriesTagDropDownList.SelectedValue; //sourceDocAsItem.WBxSetSingleTermColumn(WorkBox.COLUMN_NAME__SERIES_TAG, SeriesTagDropDownList.SelectedValue); } if (showScanDate) { document.ScanDate = ScanDate.SelectedDate; //sourceDocAsItem[WorkBox.COLUMN_NAME__SCAN_DATE] = ScanDate.SelectedDate; } //sourceDocAsItem.WBxSetSingleTermColumn(WorkBox.COLUMN_NAME__OWNING_TEAM, OwningTeamField.Text); //sourceDocAsItem.WBxSetMultiTermColumn(WorkBox.COLUMN_NAME__INVOLVED_TEAMS, InvolvedTeamsField.Text); document[WBColumn.OwningTeam] = OwningTeamField.Text; document[WBColumn.InvolvedTeams] = InvolvedTeamsField.Text; document.CheckOwningTeamIsAlsoInvolved(); if (String.IsNullOrEmpty(document.OriginalFilename)) { document.OriginalFilename = sourceDocAsItem.Name; } WorkBox.GenerateFilename(documentRecordsType, sourceDocAsItem); /* * if (WorkBox.RecordsType.GeneratePublishOutFilenames) * { * WorkBox.GenerateFilename(documentRecordsType, sourceDocAsItem); * } * * sourceDocAsItem.Update(); */ return(document); }
protected void Page_Load(object sender, EventArgs e) { WBLogging.Generic.Verbose("In Page_Load for the self approval dialog"); manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName); // If this is the initial call to the page then we need to load the basic details of the document we're publishing out: if (!IsPostBack) { process = WBUtils.DeserializeFromCompressedJSONInURI <WBPublishingProcess>(Request.QueryString["PublishingProcessJSON"]); process.WorkBox = WorkBox; // WBLogging.Debug("Created the WBProcessObject"); PublishingProcessJSON.Value = WBUtils.SerializeToCompressedJSONForURI(process); // WBLogging.Debug("Serialized the WBProcessObject to hidden field"); } else { process = WBUtils.DeserializeFromCompressedJSONInURI <WBPublishingProcess>(PublishingProcessJSON.Value); process.WorkBox = WorkBox; } // Let's clear out all of the error messages text fields: ErrorMessageLabel.Text = ""; //OK so we have the basic identity information for the document being published out so let's get the document item: Guid sourceListGuid = new Guid(process.ListGUID); SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)WorkBox.Web.Lists[sourceListGuid]; sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(process.CurrentItemID)); sourceFile = sourceDocAsItem.File; WBDocument sourceDocument = new WBDocument(WorkBox, sourceDocAsItem); fileTypeInfo = manager.GetFileTypeInfo(sourceDocument.FileType); if (fileTypeInfo != null) { Dictionary <String, String> checkBoxDetails = manager.GetCheckBoxDetailsForDocumentType(fileTypeInfo.WBxGetAsString(WBColumn.DocumentType)); foreach (String checkBoxCode in checkBoxDetails.Keys) { CheckBoxes.Controls.Add(CreateCheckBoxDiv(checkBoxCode, checkBoxDetails[checkBoxCode])); } CheckBoxesCodes.Value = String.Join(";", checkBoxDetails.Keys.ToArray <string>()); } if (!IsPostBack) { DocumentsBeingPublished.Text = process.GetStandardHTMLTableRows(); String typeText = null; if (fileTypeInfo != null) { typeText = fileTypeInfo.WBxGetAsString(WBColumn.DocumentType) + " (" + fileTypeInfo.WBxGetAsString(WBColumn.FileTypePrettyName) + ")"; } if (String.IsNullOrEmpty(typeText)) { typeText = sourceDocument.FileType + " " + sourceDocument.Name; } DocumentType.Text = typeText; WBLogging.Debug("The file type of the record is: " + typeText); IAO.Text = "<none found>"; if (!String.IsNullOrEmpty(process.OwningTeamsIAOAtTimeOfPublishing)) { SPUser owningTeamIAO = SPContext.Current.Web.WBxEnsureUserOrNull(process.OwningTeamsIAOAtTimeOfPublishing); if (owningTeamIAO != null) { IAO.Text = owningTeamIAO.Name; } } } }
protected void Page_Load(object sender, EventArgs e) { // First we're going to check membership of the records management group: String rmGroupName = WBFarm.Local.RecordsManagersGroupName; SPGroup rmGroup = null; if (!String.IsNullOrEmpty(rmGroupName)) { try { rmGroup = SPContext.Current.Web.SiteGroups[rmGroupName]; } catch (Exception exception) { // Probably the group hasn't been created or setup here yet } } if (rmGroup == null || !rmGroup.ContainsCurrentUser) { AccessDeniedPanel.Visible = true; UpdateRecordsMetadataPanel.Visible = false; return; } currentUserLoginName = SPContext.Current.Web.CurrentUser.LoginName; String listIDString = ""; String itemIDString = ""; String recordIDString = ""; recordsTypesTaxonomy = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); subjectTagsTaxonomy = WBTaxonomy.GetSubjectTags(recordsTypesTaxonomy); librarySite = new SPSite(WBFarm.Local.ProtectedRecordsLibraryUrl); libraryWeb = librarySite.OpenWeb(); libraryList = libraryWeb.GetList(WBFarm.Local.ProtectedRecordsLibraryUrl); if (!IsPostBack) { recordIDString = Request.QueryString["RecordID"]; if (String.IsNullOrEmpty(recordIDString)) { listIDString = Request.QueryString["ListID"]; itemIDString = Request.QueryString["ItemID"]; } else { listIDString = libraryList.ID.ToString(); } ListID.Value = listIDString; ItemID.Value = itemIDString; } else { recordIDString = RecordID.Text; listIDString = ListID.Value; itemIDString = ItemID.Value; } if (!String.IsNullOrEmpty(itemIDString)) { int itemID = Convert.ToInt32(itemIDString); recordItem = libraryList.GetItemById(itemID); } else { recordItem = WBUtils.FindItemByColumn(SPContext.Current.Site, libraryList, WBColumn.RecordID, recordIDString); if (recordItem != null) { itemIDString = recordItem.ID.ToString(); ItemID.Value = itemIDString; } } if (recordItem != null) { record = new WBDocument(recordItem); FunctionalArea.Text = record.FunctionalArea.Names(); WBRecordsType recordsType = record.RecordsType; recordsType.Taxonomy = recordsTypesTaxonomy; RecordsType.Text = recordsType.FullPath.Replace("/", " / "); if (!IsPostBack) { Filename.Text = recordItem.Name; Title.Text = recordItem.Title; RecordID.Text = record[WBColumn.RecordID].WBxToString(); LiveOrArchived.DataSource = new String[] { "Live", "Archived" }; LiveOrArchived.DataBind(); LiveOrArchived.SelectedValue = record[WBColumn.LiveOrArchived].WBxToString(); ProtectiveZone.DataSource = WBRecordsType.getProtectiveZones(); ProtectiveZone.DataBind(); ProtectiveZone.SelectedValue = record.ProtectiveZone; subjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTags, WBColumn.SubjectTags.DisplayName, true); SubjectTags.Text = record.SubjectTags.UIControlValue; } } if (!IsPostBack) { libraryWeb.Dispose(); librarySite.Dispose(); LiveOrArchived.Focus(); } }
internal String RenderHTMLForOneDocumentVersion(Dictionary <String, String> checklistTextMap, WBDocument document, String majorVersion, String minorVersion, int minorVersionIndex) { String html = ""; String versionNumber = majorVersion; if (!String.IsNullOrEmpty(minorVersion)) { versionNumber += "." + minorVersion; } String versionAsToggleID = versionNumber.Replace(".", "-"); String publishedDateString = ""; if (document.HasValue(WBColumn.DatePublished)) { publishedDateString = String.Format("{0:dd/MM/yyyy}", document[WBColumn.DatePublished]); } if (publishedDateString == "" && document.HasValue(WBColumn.Modified)) { publishedDateString = String.Format("{0:dd/MM/yyyy}", document[WBColumn.Modified]); } String publishedByString = "<unknown>"; SPUser publishedBy = document.GetSingleUserColumn(WBColumn.PublishedBy); if (publishedBy != null) { publishedByString = publishedBy.Name; } else { // If the published by column isn't set then we'll use the author column as a backup value: publishedBy = document.GetSingleUserColumn(WBColumn.Author); if (publishedBy != null) { publishedByString = publishedBy.Name; } } String modifiedByString = ""; String modifiedOnString = ""; if (document.IsSPListItemVersion) { SPFieldUserValue versionCreated = document.ItemVersion.CreatedBy; SPUser modifiedBy = versionCreated.User; if (modifiedBy != null) { WBLogging.Debug("Version created by lookup ID: " + versionCreated.LookupId); WBLogging.Debug("Version created by lookup Value: " + versionCreated.LookupValue); WBLogging.Debug("Version created by as string: " + versionCreated.ToString()); WBLogging.Debug("Version created by SPUser.Login: "******"Version created by SPUser.Name: " + modifiedBy.Name); modifiedByString = modifiedBy.Name; } modifiedOnString = String.Format("{0:dd/MM/yyyy}", document.ItemVersion.Created); } else { SPUser modifiedBy = document.GetSingleUserColumn(WBColumn.ModifiedBy); if (modifiedBy != null) { modifiedByString = modifiedBy.Name; } if (document.HasValue(WBColumn.Modified)) { modifiedOnString = String.Format("{0:dd/MM/yyyy}", document[WBColumn.Modified]); } } String approvedByString = document.GetMultiUserColumn(WBColumn.PublishingApprovedBy).WBxToPrettyString(); String iaoString = document.GetSingleUserColumn(WBColumn.IAOAtTimeOfPublishing).WBxToPrettyString(); long fileLength = (document.Item.File.Length / 1024); if (fileLength == 0) { fileLength = 1; } String fileLengthString = "" + fileLength + " KB"; String status = document[WBColumn.RecordSeriesStatus].WBxToString(); String extraStatusCSS = ""; if (String.IsNullOrEmpty(status)) { status = "Latest"; } if (minorVersionIndex > 0) { status = "(old metadata)"; extraStatusCSS = " wbf-old-metadata"; } String explainStatus = ""; if (status == "Latest") { if (document.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC) { explainStatus = "(live on the public website)"; } else if (document.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET) { explainStatus = "(live on a public extranet website)"; } else { explainStatus = "(live on izzi intranet)"; } } else if (status == "Retired") { explainStatus = "(visible on izzi intranet searches)"; } else if (status == "Archived") { explainStatus = "(archived in the protected, master records library)"; } String reviewDateString = ""; if (document.HasValue(WBColumn.ReviewDate)) { reviewDateString = String.Format("{0:dd/MM/yyyy}", document[WBColumn.ReviewDate]); } String checkInComments = ""; if (document.IsSPListItemVersion) { int fileVersionsCount = document.Item.File.Versions.Count; WBLogging.Debug("File versions count: " + fileVersionsCount); WBLogging.Debug("minorVersionIndex = " + minorVersionIndex); int minorFileVersionIndex = fileVersionsCount - minorVersionIndex; WBLogging.Debug("minorFileVersionIndex = " + minorFileVersionIndex); if (minorFileVersionIndex >= 0 && minorFileVersionIndex < fileVersionsCount) { SPFileVersion fileVersion = document.Item.File.Versions[minorFileVersionIndex]; checkInComments = fileVersion.CheckInComment; } else { checkInComments = document.Item.File.CheckInComment; } } else { checkInComments = document.Item.File.CheckInComment; } String checklistCount = "0"; String checklistDiv = ""; String checklistCodes = document[WBColumn.PublishingApprovalChecklist].WBxToString(); if (!String.IsNullOrEmpty(checklistCodes)) { String[] codes = checklistCodes.Split(';'); checklistDiv = "<div id='wbf-checklist-" + versionAsToggleID + "' style='display: none;'>"; foreach (String code in codes) { if (checklistTextMap.ContainsKey(code)) { checklistDiv += "<input type='checkbox' enabled='false' checked disabled/>" + checklistTextMap[code] + "<br/>"; } else { checklistDiv += "<input type='checkbox' enabled='false' checked disabled/>" + code + " (couldn't decode this checklist item)<br/>"; } } checklistDiv += "</div>"; checklistCount = codes.Length.ToString(); } String issueOddOrEven = "odd"; if (majorVersion.WBxToInt() % 2 == 0) { issueOddOrEven = "even"; } html += "<tr>" + "<td class='wbf-record-series-summary-issue-" + issueOddOrEven + "'>" + versionNumber + "</td>" + "<td class='wbf-record-series-summary-detail wbf-record-series-detail-left'>" + document.Name + "</td>" + "<td class='wbf-record-series-summary-detail'>" + publishedDateString + "</td>" + "<td class='wbf-record-series-summary-detail'>" + publishedByString + "</td>" + "<td class='wbf-record-series-summary-detail'>" + modifiedOnString + "</td>" + "<td class='wbf-record-series-summary-detail " + extraStatusCSS + "'>" + status + "</td>" + "<td class='wbf-record-series-summary-detail wbf-record-series-detail-right'>" + fileLengthString + "</td>" + "<td class='wbf-record-series-summary-detail'><a href='#' class='wbf-more-or-less' id='wbf-more-or-less-" + versionAsToggleID + "' onclick='WBF_toggleByID(\"" + versionAsToggleID + "\");'><nobr>more ></nobr></a></td>" + "</tr>\n"; html += "<tr class='wbf-record-details' id='wbf-record-details-" + versionAsToggleID + "' style=' display: none;' ><td></td><td colspan='6' class='wbf-record-series-details-panel-cell'><table class='wbf-record-series-details-panel' width='100%'>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>Title</td><td class='wbf-record-series-detail-odd'>" + document.Title + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Filename</td><td class='wbf-record-series-detail-even wbf-record-series-detail-left'>" + document.Filename + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>Location</td><td class='wbf-record-series-detail-odd'>" + document.LibraryLocation + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Subject Tags</td><td class='wbf-record-series-detail-even'>" + document.SubjectTags.Names() + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>Owning Team</td><td class='wbf-record-series-detail-odd'>" + document.OwningTeam.Name + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Involved Teams</td><td class='wbf-record-series-detail-even'>" + document.InvolvedTeamsWithoutOwningTeam.Names() + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>Protective Zone</td><td class='wbf-record-series-detail-odd'>" + document.ProtectiveZone + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Status</td><td class='wbf-record-series-detail-even'>" + status + " " + explainStatus + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>Approved By</td><td class='wbf-record-series-detail-odd'>" + approvedByString + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Approval Checklist</td><td class='wbf-record-series-detail-even'><a href='#' onclick='WBF_toggleChecklist(\"" + versionAsToggleID + "\");'>" + checklistCount + " checklist items were ticked</a>" + checklistDiv + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>IAO When Published</td><td class='wbf-record-series-detail-odd'>" + iaoString + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Intended Web Page URL</td><td class='wbf-record-series-detail-even'>" + document[WBColumn.IntendedWebPageURL].WBxToString() + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>Review Date</td><td class='wbf-record-series-detail-odd'>" + reviewDateString + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Modified By</td><td class='wbf-record-series-detail-even'>" + modifiedByString + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>Modified On</td><td class='wbf-record-series-detail-odd'>" + modifiedOnString + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Reason for Change</td><td class='wbf-record-series-detail-even'>" + checkInComments + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-odd'>Record Series ID</td><td class='wbf-record-series-detail-odd'>" + document.RecordSeriesID + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-title wbf-record-series-detail-even'>Record ID</td><td class='wbf-record-series-detail-even'>" + document.RecordID + "</td></tr>"; html += "<tr><td class='wbf-record-series-detail-even' colspan='2' align='center'><input type='button' value='View Document' onclick='window.open(\"" + document.AbsoluteURL + "\", \"_blank\");' />"; if (minorVersionIndex <= 0 && status != "Archived") { html += " <input type='button' value='Edit Metadata' onclick='WBF_edit_records_metadata(\"" + document.RecordID + "\");'/>"; } html += "</td></tr>"; html += "</table>\n"; return(html); }
protected void Page_Load(object sender, EventArgs e) { String html = "<table class='wbf-record-series-details'>\n"; html += "<tr>" + "<th class='wbf-record-series-odd'>Version</th>" + "<th class='wbf-record-series-even'>Filename</th>" + "<th class='wbf-record-series-odd'>Published</th>" + "<th class='wbf-record-series-even'>Published By</th>" + "<th class='wbf-record-series-odd'>Modified</th>" + "<th class='wbf-record-series-even'>Status</th>" + "<th class='wbf-record-series-odd'>File Size</th>" + "<th class='wbf-record-series-odd'></th>" + "</tr>\n"; String recordSeriesID = Request.QueryString["RecordSeriesID"]; String recordID = Request.QueryString["RecordID"]; using (WBRecordsManager manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName)) { WBRecordsLibrary masterLibrary = manager.Libraries.ProtectedMasterLibrary; SPList masterLibraryList = masterLibrary.List; WBQuery query = new WBQuery(); if (String.IsNullOrEmpty(recordSeriesID) || recordSeriesID == recordID) { query.AddEqualsFilter(WBColumn.RecordID, recordID); } else { query.AddEqualsFilter(WBColumn.RecordSeriesID, recordSeriesID); query.OrderBy(WBColumn.RecordSeriesIssue, false); } SPListItemCollection items = masterLibraryList.WBxGetItems(SPContext.Current.Site, query); /* * List<WBDocument> versions = new List<WBDocument>(); * foreach (SPListItem item in items) * { * * bool notInserted = true; * for (int i = 0; i < versions.Count && notInserted; i++) * { * * * if (document.RecordSeriesIssue.WBxToInt() > versions[i].RecordSeriesIssue.WBxToInt()) * } * * } * */ Dictionary <String, String> checklistTextMap = manager.GetChecklistTextMap(); if (masterLibrary.List.EnableVersioning) { foreach (SPListItem item in items) { SPListItemVersionCollection versionCollection = item.Versions; int versionCount = item.Versions.Count; WBLogging.Debug("Item versions count | File versions count: " + versionCount + " | " + item.File.Versions.Count); for (int i = 0; i < versionCount; i++) { SPListItemVersion version = versionCollection[i]; WBDocument document = new WBDocument(masterLibrary, version); // We're going to render the minor version numbers counting up - even though lower index values are for more recent versions: html += RenderHTMLForOneDocumentVersion(checklistTextMap, document, document.RecordSeriesIssue, (versionCount - 1 - i).ToString(), i); } } } else { foreach (SPListItem item in items) { WBDocument document = new WBDocument(masterLibrary, item); html += RenderHTMLForOneDocumentVersion(checklistTextMap, document, document.RecordSeriesIssue, null, -1); } } } html += "</table>"; ViewRecordSeriesTable.Text = html; }