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(); } }