diff --git a/PROMS/VEPROMS User Interface/frmBatchRefresh.cs b/PROMS/VEPROMS User Interface/frmBatchRefresh.cs index 1ae0f399..cc3a6eb1 100644 --- a/PROMS/VEPROMS User Interface/frmBatchRefresh.cs +++ b/PROMS/VEPROMS User Interface/frmBatchRefresh.cs @@ -239,7 +239,7 @@ namespace VEPROMS return loadedWorkingDraft; } - + private bool LoadDocVersions(FolderInfo fic, TreeNode tnc, bool noProcs) { bool rtnval = false; @@ -1755,19 +1755,77 @@ namespace VEPROMS txtResults.Clear(); txtProcess.Clear(); + this.Cursor = Cursors.WaitCursor; + + //Create checked proce and doc info lists. + List pil = new List(); + List dvil = new List(); + + // Create a list of procedures the user selected + foreach (TreeNode tn in myProcedures.Keys) + if (tn.Checked) + pil.Add(myProcedures[tn]); + + // Create a list of doc versions the user selected + foreach (TreeNode tn in myDocVersions.Keys) + if (tn.Checked) + dvil.Add(myDocVersions[tn]); + + bool cancelledOut = false; // Flag to indicate if the process should be cancelled + StringBuilder sbDocVersions = new StringBuilder(); + + foreach (DocVersionInfo dq in dvil) + { + string msg = string.Empty; + if (!MySessionInfo.CanCheckOutItem(dq.VersionID, CheckOutType.DocVersion, ref msg)) + { + string msgp = string.Empty; + foreach (ProcedureInfo pi in dq.Procedures) + { + if (!MySessionInfo.CanCheckOutItem(pi.ItemID, CheckOutType.Procedure, ref msgp)) + { + FolderInfo fi = (FolderInfo)dq.ActiveParent; + int itemID = (int)fi.FolderID; + string folderName = fi.Name; + + if (swDeleteFolder.Value) + sbDocVersions.AppendLine($"{folderName} - {msgp}"); + else + sbDocVersions.AppendLine(msgp); + + cancelledOut = true; + } + } + } + } + + if (cancelledOut) + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("The batch update process was not successful for all working drafts selected."); + sb.AppendLine("The following procedures are currently checked out..."); + sb.AppendLine(); + sb.AppendLine(sbDocVersions.ToString()); + sb.AppendLine(); + if (swDeleteFolder.Value) + sb.AppendLine("If you want to delete these folders, please contact the respective users and have them close any procedures in the working draft."); + else + sb.AppendLine("If you want to delete annotations from these working drafts, please contact the respective users and have them close any procedures in the working draft."); + sb.AppendLine(); + txtProcess.AppendText(sb.ToString()); + return; + } + + + + if (swDeleteFolder.Value) { if (FlexibleMessageBox.Show(this, "Are you sure you want to remove the selected folders and their contents?", "Confirm Folder Deletion", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { txtProcess.AppendText("Deleting Folders..."); - //Load Selected Folders with docversions - List dvil = new List(); - foreach (TreeNode tn in myDocVersions.Keys) - if (tn.Checked) - dvil.Add(myDocVersions[tn]); - - //Load Selected Folders with docversions + //Load Selected Folders List ef = new List(); foreach (TreeNode tn in myFolders.Keys) @@ -1782,18 +1840,6 @@ namespace VEPROMS // Write progress status txtProcess.AppendText("Deleting Annotations..."); - // Create a list of procedures the user selected - List pil = new List(); - foreach (TreeNode tn in myProcedures.Keys) - if (tn.Checked) - pil.Add(myProcedures[tn]); - - // Create a list of doc versions the user selected - List dvil = new List(); - foreach (TreeNode tn in myDocVersions.Keys) - if (tn.Checked) - dvil.Add(myDocVersions[tn]); - frmAnnotationsCleanup frmAnnoDel = new frmAnnotationsCleanup(this, pil, dvil); frmAnnoDel.ShowDialog(); @@ -1860,8 +1906,8 @@ namespace VEPROMS } - txtResults.AppendText($"Folder deletion process completed, {foldersDeleted} folder(s) have been deleted. "); - txtResults.AppendText(Environment.NewLine); + + //Run Repair int prgStpIdx = -1; @@ -1874,6 +1920,9 @@ namespace VEPROMS MessageBox.Show($"Folder deletion completed, {foldersDeleted} folders have been deleted.", "Delete Folders"); ClearStepProgress(); + + txtResults.AppendText($"Folder deletion process completed, {foldersDeleted} folders have been deleted."); + txtResults.AppendText(Environment.NewLine); } private bool DeleteFolderByID(int folderID)