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();
        }
示例#2
0
        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());
        }
示例#3
0
        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);
            }
        }
示例#4
0
        protected void ProcessSelection(String selectedPath)
        {
            WBLogging.Debug("In ProcessSelection(): selectedPath = " + selectedPath);

            if (!String.IsNullOrEmpty(selectedPath))
            {
                if (string.IsNullOrEmpty(selectedPath))
                {
                    selectedPath = "/";
                }

                selectedPath = selectedPath.Replace("(root)", "");
                if (string.IsNullOrEmpty(selectedPath))
                {
                    selectedPath = "/";
                }

                SelectedFolderPath.Text = selectedPath;

                // Now for the bit where the path is analysed to pick out the selected functional area and the records type:

                String[] pathSteps = selectedPath.Split('/');

                // We're only interested in selections of 3rd level 'folders' that are: functional area / records type / records type  ... or below.
                if (pathSteps.Length < 3)
                {
                    return;
                }

                WBTerm functionalArea = manager.FunctionalAreasTaxonomy.GetSelectedWBTermByPath(pathSteps[0]);
                if (functionalArea == null)
                {
                    WBLogging.Debug("The functional area part of the selected path came back null: " + selectedPath);
                    return;
                }

                Term recordsTypeTerm = manager.RecordsTypesTaxonomy.GetOrCreateSelectedTermByPath(pathSteps[1] + "/" + pathSteps[2]);
                if (recordsTypeTerm == null)
                {
                    WBLogging.Debug("The records type part of the selected path came back null: " + selectedPath);
                    return;
                }
                WBRecordsType recordsType = new WBRecordsType(manager.RecordsTypesTaxonomy, recordsTypeTerm);


                process.FunctionalAreaUIControlValue = functionalArea.UIControlValue;
                process.RecordsTypeUIControlValue    = recordsType.UIControlValue;

                WBLogging.Debug("Set the new records type to be: " + process.RecordsTypeUIControlValue);


                // Finally let's see if there is a specific record being selected as well:
                if (!process.IsReplaceActionToCreateNewSeries)
                {
                    WBRecord record = manager.Libraries.GetRecordByPath(selectedPath);

                    SelectedRecordID.Text       = record.RecordID;
                    process.ToReplaceRecordID   = record.RecordID;
                    process.ToReplaceRecordPath = selectedPath;
                    process.ToReplaceShortTitle = record.Title;
                    process.ToReplaceSubjectTagsUIControlValue = record.SubjectTagsUIControlValue;
                }


                PublishingProcessJSON.Value = WBUtils.SerializeToCompressedJSONForURI(process);
            }
            else
            {
                WBLogging.Debug("In LibraryLocations_SelectedNodeChanged(): Selected path was null");
            }
        }
        private void RenderPage()
        {
            if (process == null)
            {
                WBLogging.Debug("process == null");
                return;
            }

            DocumentsBeingPublished.Text = process.GetStandardHTMLTableRows();

            SPListItem currentItem = process.CurrentItem;

            EditShortTitle.Text = process.CurrentShortTitle;
            ShortTitle.Text     = process.CurrentShortTitle;

            WBLogging.Debug("Passed title / name");

            SelectLocationButton.OnClientClick = "WorkBoxFramework_pickANewLocation(WorkBoxFramework_PublishDoc_pickedANewLocation, '" + process.FunctionalAreaUIControlValue + "', '" + process.RecordsTypeUIControlValue + "'); return false;";


            if (!String.IsNullOrEmpty(process.ToReplaceRecordID) && process.ReplaceAction != WBPublishingProcess.REPLACE_ACTION__CREATE_NEW_SERIES)
            {
                recordBeingReplaced = manager.Libraries.GetRecordByID(process.ToReplaceRecordID);
                if (recordBeingReplaced == null)
                {
                    ErrorMessageLabel.Text = "Could not find the record that is meant to be replaced. Supposedly it has RecordID = " + process.ToReplaceRecordID;
                    return;
                }
            }

            if (recordBeingReplaced == null)
            {
                if (documentFunctionalArea != null && documentRecordsType != null)
                {
                    LocationPath.Text = documentFunctionalArea.Name + " / " + documentRecordsType.FullPath.Replace("/", " / ");
                }
                else
                {
                    LocationPath.Text = "<none>";
                }
            }
            else
            {
                LocationPath.Text = process.ToReplaceRecordPath;
            }

            if (recordBeingReplaced == null || process.ReplaceAction == WBPublishingProcess.REPLACE_ACTION__CREATE_NEW_SERIES)
            {
                WBLogging.Debug("Setting buttons etc for NEW");

                NewRadioButton.Checked      = true;
                ReplaceRadioButton.Checked  = false;
                LeaveOnIzziCheckBox.Enabled = true; // Otherwise the surrounding span tag is disabled too! - we'll disable with jQuery!
                SelectLocationButton.Text   = "Choose Location";
                PublishAll.Enabled          = true;

                NewOrReplace.Text = "New";
            }
            else
            {
                WBLogging.Debug("Setting buttons etc for REPLACE");

                NewRadioButton.Checked      = false;
                ReplaceRadioButton.Checked  = true;
                LeaveOnIzziCheckBox.Enabled = true;
                if (process.ReplaceAction == WBPublishingProcess.REPLACE_ACTION__LEAVE_ON_IZZI)
                {
                    LeaveOnIzziCheckBox.Checked = true;
                }
                else
                {
                    LeaveOnIzziCheckBox.Checked = false;
                }
                SelectLocationButton.Text = "Choose Document";
                PublishAll.Enabled        = false;

                NewOrReplace.Text = "Replace";
            }

            WBLogging.Debug("Just before protective zone stage");

            TheProtectiveZone.Text = process.ProtectiveZone;

            if (showSubjectTags)
            {
                if (documentRecordsType == null || documentRecordsType.IsDocumentSubjectTagsRequired)
                {
                    SubjectTagsTitle.Text = "Subject Tags" + WBConstant.REQUIRED_ASTERISK;
                }
                else
                {
                    SubjectTagsTitle.Text = "Subject Tags (optional)";
                }

                if (documentRecordsType != null)
                {
                    SubjectTagsDescription.Text = documentRecordsType.DocumentSubjectTagsDescription;
                }

                process.SubjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTagsField, WorkBox.COLUMN_NAME__SUBJECT_TAGS, true);
                SubjectTagsField.Text = process.SubjectTagsUIControlValue;
            }

            /*
             * if (showReferenceID)
             * {
             *  if (documentRecordsType.IsDocumentReferenceIDRequired)
             *  {
             *      ReferenceIDTitle.Text = "Reference ID" + WBConstant.REQUIRED_ASTERISK;
             *  }
             *  else
             *  {
             *      ReferenceIDTitle.Text = "Reference ID (optional)";
             *  }
             *  ReferenceIDDescription.Text = documentRecordsType.DocumentReferenceIDDescription;
             *  ReferenceID.Text = sourceDocAsItem.WBxGetColumnAsString(WorkBox.COLUMN_NAME__REFERENCE_ID);
             * }
             *
             * if (showReferenceDate)
             * {
             *  if (documentRecordsType.IsDocumentReferenceDateRequired)
             *  {
             *      ReferenceDateTitle.Text = "Reference Date" + WBConstant.REQUIRED_ASTERISK;
             *  }
             *  else
             *  {
             *      ReferenceDateTitle.Text = "Reference Date (optional)";
             *  }
             *  ReferenceDateDescription.Text = documentRecordsType.DocumentReferenceDateDescription;
             *  if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__REFERENCE_DATE))
             *  {
             *      ReferenceDate.SelectedDate = (DateTime)sourceDocAsItem[WorkBox.COLUMN_NAME__REFERENCE_DATE];
             *  }
             *  else
             *  {
             *      ReferenceDate.SelectedDate = DateTime.Now;
             *  }
             * }
             *
             * if (showSeriesTag)
             * {
             *  if (documentRecordsType.IsDocumentSeriesTagRequired)
             *  {
             *      SeriesTagTitle.Text = "Series Tag" + WBConstant.REQUIRED_ASTERISK;
             *  }
             *  else
             *  {
             *      SeriesTagTitle.Text = "Series Tag (optional)";
             *  }
             *  SeriesTagDescription.Text = documentRecordsType.DocumentSeriesTagDescription;
             *
             *  SeriesTagDropDownList.DataSource = GetSeriesTagDataSource(documentRecordsType.DocumentSeriesTagParentTerm(process.SeriesTagsTaxonomy));
             *  SeriesTagDropDownList.DataTextField = "SeriesTagTermName";
             *  SeriesTagDropDownList.DataValueField = "SeriesTagTermUIControlValue";
             *  SeriesTagDropDownList.DataBind();
             *
             *  if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__SERIES_TAG))
             *  {
             *      SeriesTagDropDownList.SelectedValue = sourceDocAsItem.WBxGetSingleTermColumn<WBTerm>(process.SeriesTagsTaxonomy, WorkBox.COLUMN_NAME__SERIES_TAG).UIControlValue;
             *  }
             * }
             *
             * if (showScanDate)
             * {
             *  if (documentRecordsType.IsDocumentScanDateRequired)
             *  {
             *      ScanDateTitle.Text = "Scan Date" + WBConstant.REQUIRED_ASTERISK;
             *  }
             *  else
             *  {
             *      ScanDateTitle.Text = "Scan Date (optional)";
             *  }
             *  ScanDateDescription.Text = documentRecordsType.DocumentScanDateDescription;
             *  if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__SCAN_DATE))
             *  {
             *      ScanDate.SelectedDate = (DateTime)sourceDocAsItem[WorkBox.COLUMN_NAME__SCAN_DATE];
             *  }
             * }
             */

            WBLogging.Debug("Just owning team");

            process.TeamsTaxonomy.InitialiseTaxonomyControl(OwningTeamField, WorkBox.COLUMN_NAME__OWNING_TEAM, false);
            OwningTeamField.Text = process.OwningTeamUIControlValue;

            WBLogging.Debug("Just involved team");

            process.TeamsTaxonomy.InitialiseTaxonomyControl(InvolvedTeamsField, WorkBox.COLUMN_NAME__INVOLVED_TEAMS, true);
            InvolvedTeamsField.Text = process.InvolvedTeamsWithoutOwningTeamAsUIControlValue;

            if (process.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC)
            {
                WebPageURL.Text = process.WebPageURL;
                showWebPageURL  = true;
            }
            else
            {
                WebPageURL.Text    = "";
                process.WebPageURL = "";
                showWebPageURL     = false;
            }


            if (process.CountStillToPublish > 1)
            {
                if (process.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PROTECTED)
                {
                    showPublishAllButton = manager.AllowBulkPublishOfFileTypes(process.DifferentFileTypesStillToPublish);
                }
                else
                {
                    showPublishAllButton = manager.AllowBulkPublishToPublicOfFileTypes(process.DifferentFileTypesStillToPublish);
                }
            }
            else
            {
                showPublishAllButton = false;
            }


            WBLogging.Debug("Just before serialization");

            // Lastly we're going to capture the state of the publishing process:
            PublishingProcessJSON.Value = WBUtils.SerializeToCompressedJSONForURI(process);
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                String currentUserLoginName = SPContext.Current.Web.CurrentUser.LoginName;

                WBTaxonomy teams           = WBTaxonomy.GetTeams(SPContext.Current.Site);
                WBTaxonomy functionalAreas = WBTaxonomy.GetFunctionalAreas(teams);
                WBTeam     team            = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web);
                if (team == null)
                {
                    WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current);
                    if (workBox != null)
                    {
                        team = workBox.OwningTeam;
                    }
                }

                // Check if this user has permission - checking basic team membership:
                if (team == null || !team.IsCurrentUserTeamMember())
                {
                    AccessDeniedPanel.Visible          = true;
                    UpdateRecordsMetadataPanel.Visible = false;
                    AccessDeniedReason.Text            = "You are not a member of this team";
                    return;
                }

                RecordID.Text = Request.QueryString["RecordID"];
                WBLogging.Debug("Record ID is found to be: " + RecordID.Text);

                using (WBRecordsManager manager = new WBRecordsManager(currentUserLoginName))
                {
                    WBRecord record = manager.Libraries.GetRecordByID(RecordID.Text);

                    record.CheckMetadata();

                    Filename.Text    = record.Name;
                    RecordTitle.Text = record.Title;

                    String location = "<unknown>";
                    if (record.FunctionalArea != null && record.FunctionalArea.Count > 0)
                    {
                        WBLogging.Debug("Found functional area = " + record.FunctionalArea);
                        WBTerm functionalArea = record.FunctionalArea[0];
                        location = functionalArea.FullPath;
                        WBLogging.Debug("location = " + location);

                        WBTermCollection <WBTerm> teamsFunctionalAreas = team.FunctionalArea(functionalAreas);

                        if (!teamsFunctionalAreas.Contains(functionalArea))
                        {
                            WBLogging.Debug("Team functional areas UIControlValue: " + teamsFunctionalAreas.UIControlValue);
                            WBLogging.Debug("Record's functional area UIControlValue: " + functionalArea);

                            AccessDeniedPanel.Visible          = true;
                            UpdateRecordsMetadataPanel.Visible = false;
                            AccessDeniedReason.Text            = "The team " + team.Name + " does not have permission to edit this functional area: " + functionalArea.Name;
                            return;
                        }
                    }
                    location += "/" + record.RecordsType.FullPath;

                    String folders = record.ProtectedMasterRecord.LibraryRelativePath.Replace(record.Name, "").Replace(location, "");

                    RecordsLocation.Text = "<b>" + location + "</b> " + folders;

                    String status = record.RecordSeriesStatus;
                    RecordSeriesStatus.Text = status;

                    String explainStatus = "";
                    if (status == "Latest")
                    {
                        if (record.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC)
                        {
                            explainStatus = "(live on the public website)";
                        }
                        else if (record.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)";
                    }
                    ExplainStatus.Text = explainStatus;

                    RecordSeriesStatusChange.DataSource = new String[] { "", "Retire", "Archive" };
                    RecordSeriesStatusChange.DataBind();
                    RecordSeriesStatusChange.SelectedValue = "";

                    ProtectiveZone.DataSource = new String[] { WBRecordsType.PROTECTIVE_ZONE__PROTECTED, WBRecordsType.PROTECTIVE_ZONE__PUBLIC };
                    ProtectiveZone.DataBind();
                    ProtectiveZone.SelectedValue = record.ProtectiveZone;

                    manager.SubjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTags, WBColumn.SubjectTags.DisplayName, true);
                    SubjectTags.Text = record.SubjectTagsUIControlValue;

                    manager.TeamsTaxonomy.InitialiseTaxonomyControl(OwningTeam, WBColumn.OwningTeam.DisplayName, false);
                    OwningTeam.Text = record.OwningTeam.UIControlValue;

                    manager.TeamsTaxonomy.InitialiseTaxonomyControl(InvolvedTeams, WBColumn.InvolvedTeams.DisplayName, true);
                    InvolvedTeams.Text = record.InvolvedTeamsWithoutOwningTeamAsUIControlValue;
                }
            }
        }
示例#7
0
        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");
            }
        }