protected void updateButton_OnClick(object sender, EventArgs e) { bool digestOK = SPContext.Current.Web.ValidateFormDigest(); String callingUserLogin = SPContext.Current.Web.CurrentUser.LoginName; if (digestOK) { SPSecurity.RunWithElevatedPrivileges(delegate() { using (WBRecordsManager manager = new WBRecordsManager(callingUserLogin)) { WBRecord record = manager.Libraries.GetRecordByID(RecordID.Text); record.LiveOrArchived = LiveOrArchived.SelectedValue; record.ProtectiveZone = ProtectiveZone.SelectedValue; record.SubjectTagsUIControlValue = SubjectTags.Text; record.Update(callingUserLogin, ReasonForChange.Text); } }); CloseDialogAndRefresh(); } else { returnFromDialogError("The security digest for the request was not OK"); } libraryWeb.Dispose(); librarySite.Dispose(); }
protected void KeepNextDocument(object sender, EventArgs e) { WBLogging.Debug("Attempting to keep the next document with index: " + indexOfNextRecordToKeep + " and filename: " + mappedFilenames[indexOfNextRecordToKeep.ToString()]); String callingUserLogin = SPContext.Current.Web.CurrentUser.LoginName; WBTaskFeedback feedback = new WBTaskFeedback(indexOfNextRecordToKeep.ToString()); try { SPSecurity.RunWithElevatedPrivileges(delegate() { using (WBRecordsManager elevatedManager = new WBRecordsManager(callingUserLogin)) { WBRecord record = elevatedManager.Libraries.GetRecordByID(recordIDs[indexOfNextRecordToKeep]); record[WBColumn.ReviewDate] = DateTime.Now.AddYears(2); record.Update(callingUserLogin, ReasonToKeepRecords.Value); feedback.Success("Kept successfully"); } }); } catch (Exception exception) { feedback.Failed("Keeping failed", exception); } WBLogging.Debug("Kept the document"); RecordKeepingProgress.WBxUpdateTask(feedback); indexOfNextRecordToKeep++; NextRecordToKeep.Text = "" + indexOfNextRecordToKeep; if (indexOfNextRecordToKeep < recordIDs.Length) { Image image = (Image)RecordKeepingProgress.WBxFindNestedControlByID(RecordKeepingProgress.WBxMakeControlID(indexOfNextRecordToKeep.ToString(), "image")); image.ImageUrl = "/_layouts/images/WorkBoxFramework/processing-task-32.gif"; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "TriggerNextStepFunction", "WorkBoxFramework_triggerKeepNextDocument();", true); } else { WBLogging.Debug("Trying to set button text to done"); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ChangeDoneButtonTextFunction", "WorkBoxFramework_finishedProcessing('Done');", true); } }
protected void updateButton_OnClick(object sender, EventArgs e) { /* Something here appears to be causing an authentication error * if (team == null || !team.IsCurrentUserTeamMember()) * { * return; * } * WBTermCollection<WBTerm> teamsFunctionalAreas = team.FunctionalArea(teams); */ String callingUserLogin = SPContext.Current.Web.CurrentUser.LoginName; if (true) { SPSecurity.RunWithElevatedPrivileges(delegate() { using (WBRecordsManager elevatedManager = new WBRecordsManager(callingUserLogin)) { WBRecord record = elevatedManager.Libraries.GetRecordByID(RecordID.Text); // Just making sure that any old records have any missing metadata filled in before the update is applied: record.CheckMetadata(); /* Something here appears to be causing an authentication error * // Let's just double check the permissions to edit: * WBTermCollection<WBTerm> recordsFunctionalAreas = record.FunctionalArea; * if (recordsFunctionalAreas != null && recordsFunctionalAreas.Count > 0) * { * WBTerm functionalArea = record.FunctionalArea[0]; * if (!teamsFunctionalAreas.Contains(functionalArea)) * { * throw new Exception("You are trying to edit a record (" + record.RecordID + ") which has a functional area (" + functionalArea.Name + ") that your team (" + team.Name + ") doesn't have permission to edit!"); * } * } */ if (RecordSeriesStatusChange.SelectedValue == "Retire") { if (record.RecordSeriesStatus == "Latest") { record.RecordSeriesStatus = "Retired"; } } if (RecordSeriesStatusChange.SelectedValue == "Archive") { record.RecordSeriesStatus = "Archived"; record.LiveOrArchived = "Archived"; } record.Title = RecordTitle.Text; record.ProtectiveZone = ProtectiveZone.SelectedValue; record.SubjectTagsUIControlValue = SubjectTags.Text; record.OwningTeamUIControlValue = OwningTeam.Text; record.InvolvedTeamsWithoutOwningTeamAsUIControlValue = InvolvedTeams.Text; if (record.ProtectiveZone != WBRecordsType.PROTECTIVE_ZONE__PROTECTED && record.Metadata.IsNullOrEmpty(WBColumn.ReviewDate)) { record[WBColumn.ReviewDate] = DateTime.Now.AddYears(2); } WBLogging.Debug("About to udpate with callingUser = "******"The security digest for the request was not OK"); } }