Example #1
0
        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");
            }
        }
Example #2
0
        protected void ArchiveNextDocument(object sender, EventArgs e)
        {
            WBLogging.Debug("Attempting to archive the next document with index: " + indexOfNextRecordToArchive + " and filename: " + mappedFilenames[indexOfNextRecordToArchive.ToString()]);
            String         callingUserLogin = SPContext.Current.Web.CurrentUser.LoginName;
            WBTaskFeedback feedback         = new WBTaskFeedback(indexOfNextRecordToArchive.ToString());

            try
            {
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    using (WBRecordsManager elevatedManager = new WBRecordsManager(callingUserLogin))
                    {
                        WBRecord record       = elevatedManager.Libraries.GetRecordByID(recordIDs[indexOfNextRecordToArchive]);
                        record.LiveOrArchived = WBColumn.LIVE_OR_ARCHIVED__ARCHIVED;
                        record.Update(callingUserLogin, ReasonToArchiveRecords.Value);

                        feedback.Success("Archived successfully");
                    }
                });
            }
            catch (Exception exception)
            {
                feedback.Failed("Archiving failed", exception);
            }

            WBLogging.Debug("Archived the document");

            RecordArchivingProgress.WBxUpdateTask(feedback);

            indexOfNextRecordToArchive++;

            NextRecordToArchive.Text = "" + indexOfNextRecordToArchive;

            if (indexOfNextRecordToArchive < recordIDs.Length)
            {
                Image image = (Image)RecordArchivingProgress.WBxFindNestedControlByID(RecordArchivingProgress.WBxMakeControlID(indexOfNextRecordToArchive.ToString(), "image"));
                image.ImageUrl = "/_layouts/images/WorkBoxFramework/processing-task-32.gif";

                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "TriggerNextStepFunction", "WorkBoxFramework_triggerArchiveNextDocument();", true);
            }
            else
            {
                WBLogging.Debug("Trying to set button text to done");
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ChangeDoneButtonTextFunction", "WorkBoxFramework_finishedProcessing('Done');", true);
            }
        }