Upped revision number to 1.8
C2020-033: 2021 UPGRADE Handling of incoming transitions on delete or review
This commit is contained in:
@@ -31,6 +31,28 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region Properties
|
||||
// C2020-033: SearchIncTransII represents the item that the transitions go to. It can be either the item the user
|
||||
// tried to delete or that the user selected to get Incoming Transitions from tree view or ribbon.
|
||||
private ItemInfo _SearchIncTransII = null;
|
||||
public ItemInfo SearchIncTransII
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SearchIncTransII;
|
||||
}
|
||||
set
|
||||
{
|
||||
_SearchIncTransII = value;
|
||||
if (_SearchIncTransII != null) lblSrchIncTran.Text = _SearchIncTransII.Path;
|
||||
else lblSrchIncTran.Text = "";
|
||||
}
|
||||
}
|
||||
private static UserInfo _MyUserInfo = null;
|
||||
public static UserInfo MyUserInfo
|
||||
{
|
||||
get { return _MyUserInfo; }
|
||||
set { _MyUserInfo = value; }
|
||||
}
|
||||
private string _strSrchText = "";
|
||||
private List<DocVersionInfo> lstCheckedDocVersions = new List<DocVersionInfo>();
|
||||
private List<int> lstCheckedStepTypes = new List<int>();
|
||||
@@ -61,6 +83,7 @@ namespace Volian.Controls.Library
|
||||
void _SearchResults_ListChanged(object sender, ListChangedEventArgs e)
|
||||
{
|
||||
lbSrchResults.SelectedIndex = -1; // Don't select an item from the new list
|
||||
lbSrchResultsIncTrans.SelectedIndex = -1;
|
||||
}
|
||||
|
||||
private string _DisplayMember = "SearchPath";
|
||||
@@ -167,7 +190,20 @@ namespace Volian.Controls.Library
|
||||
if(wordSectionTreeNode != null) //B2020-070 NULL reference check
|
||||
wordSectionTreeNode.Enabled = true;
|
||||
btnSearch.Enabled = true;
|
||||
if (e.NewTab == tabROSearch)
|
||||
xpSetToSearch.Enabled = true;
|
||||
xpStepTypes.Enabled = true;
|
||||
lbSrchResults.Visible = true;
|
||||
lbSrchResultsIncTrans.Visible = false;
|
||||
if (e.NewTab == tabIncTrans) // C2020-033: Incoming transitions
|
||||
{
|
||||
xpSetToSearch.Enabled = false;
|
||||
xpStepTypes.Enabled = false;
|
||||
lbSrchResults.Visible = false;
|
||||
lbSrchResultsIncTrans.Visible = true;
|
||||
lbSrchResultsIncTrans.CheckBoxesVisible = true;
|
||||
lbSrchResultsIncTrans.AutoScroll = true;
|
||||
}
|
||||
else if (e.NewTab == tabROSearch)
|
||||
{
|
||||
LoadROComboTree();
|
||||
}
|
||||
@@ -175,7 +211,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (wordSectionTreeNode != null) //B2020-070 NULL reference check
|
||||
{
|
||||
wordSectionTreeNode.Enabled = false; // C2020-010: Disable Word Section choice for Transition search
|
||||
wordSectionTreeNode.Enabled = false; // C2020-010: Disable Word Section choice for Transition search
|
||||
wordSectionTreeNode.Checked = false;
|
||||
}
|
||||
btnSearch.Enabled = (cbxTranCategory.Items.Count > 0); // B2017-038 disable search button if no format selected
|
||||
@@ -187,7 +223,7 @@ namespace Volian.Controls.Library
|
||||
foreach (DevComponents.AdvTree.Node n in dicExpandedFolderNodes.Keys)
|
||||
{
|
||||
DocVersionInfo dvi = (DocVersionInfo)n.Tag;
|
||||
if(cbxTranVersion.Tag.ToString().Contains(dvi.VersionID.ToString()))
|
||||
if (cbxTranVersion.Tag.ToString().Contains(dvi.VersionID.ToString()))
|
||||
n.Enabled = true;
|
||||
else
|
||||
n.Enabled = false;
|
||||
@@ -1036,18 +1072,27 @@ namespace Volian.Controls.Library
|
||||
private void DisplayResults()
|
||||
{
|
||||
_LoadingList = true;
|
||||
lbSrchResults.DisplayMember = _DisplayMember;
|
||||
// C2020-033: Incoming Transition tab. Note that this tab uses a different control for the search
|
||||
// results, it uses the dotnetbar list that has check boxes. Because of this, various places throughout
|
||||
// the code will check for what tab is displayed and will work eith the associated list box, either
|
||||
// lbSrchResults or lbSrchResultsIncTrans
|
||||
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4]) lbSrchResults.DisplayMember = _DisplayMember;
|
||||
else lbSrchResultsIncTrans.DisplayMember = _DisplayMember;
|
||||
if (_SearchResults != null)
|
||||
{
|
||||
if (cbSorted.Checked)
|
||||
{
|
||||
Csla.SortedBindingList<ItemInfo> sortedResults = new Csla.SortedBindingList<ItemInfo>(_SearchResults);
|
||||
sortedResults.ApplySort(_DisplayMember, ListSortDirection.Ascending);
|
||||
lbSrchResults.DataSource = sortedResults;
|
||||
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4]) lbSrchResults.DataSource = sortedResults;
|
||||
else lbSrchResultsIncTrans.DataSource = sortedResults;
|
||||
}
|
||||
else
|
||||
{
|
||||
//PopulatelbSrcResults(_SearchResults);
|
||||
lbSrchResults.DataSource = _SearchResults;
|
||||
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4]) lbSrchResults.DataSource = _SearchResults;
|
||||
else lbSrchResultsIncTrans.DataSource = _SearchResults;
|
||||
}
|
||||
grpPanSearchResults.Text = string.Format("Search Results Found: {0}", _SearchResults.Count);
|
||||
grpPanSearchResults.Style.BackColor = Color.LightGreen;// Color.YellowGreen; Color.DarkSeaGreen;
|
||||
}
|
||||
@@ -1057,7 +1102,7 @@ namespace Volian.Controls.Library
|
||||
grpPanSearchResults.Style.BackColor = saveGrpPanSearchResults;
|
||||
}
|
||||
// Turn Print and Results display style on/off based on whether there are search results
|
||||
if (lbSrchResults.Items.Count > 0)
|
||||
if (_SearchResults != null && _SearchResults.Count > 0)
|
||||
{
|
||||
btnPrnSrchRslts.Enabled = true;
|
||||
btnClearSearchResults.Enabled = true;
|
||||
@@ -1075,6 +1120,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
|
||||
lbSrchResults.SelectedIndex = -1;
|
||||
lbSrchResultsIncTrans.SelectedIndex = -1;
|
||||
LastResultsMouseOverIndex = -1;
|
||||
_LoadingList = false;
|
||||
|
||||
@@ -1125,24 +1171,56 @@ namespace Volian.Controls.Library
|
||||
LastResultsMouseOverIndex = ResultsMouseOverIndex;
|
||||
}
|
||||
}
|
||||
// C2020-033: lbSrchResultsIncTrans_ItemClicked is used to check permissions of a selection before allowing an
|
||||
// item to be clicked and to turn on/off the btnTranCvtSelToTxt button for converting selected to test.
|
||||
// Two variables are used to keep track if items are checked in the list box:
|
||||
// JustDidSelection - selecting an item event goes into both SelectedValueChanged & ItemClicked
|
||||
// but need to keep track of itemclicked which is event for checking/unchecking of Incoming Transition
|
||||
// items in lbSrchResultsIncTrans
|
||||
// IncTransSelectedCount is used to keep track if any items are checked
|
||||
private int IncTransSelectedCount = 0;
|
||||
bool JustDidSelection = false;
|
||||
private void lbSrchResultsIncTrans_ItemClicked(object sender, EventArgs e)
|
||||
{
|
||||
ListBoxItem lbi = sender as ListBoxItem;
|
||||
ItemBindingData ibd = lbi.Tag as ItemBindingData;
|
||||
ItemInfo ii = ibd.DataItem as ItemInfo;
|
||||
bool allowNonAdmin = IncTranCvtPerm();
|
||||
if (lbi.CheckState == CheckState.Checked && ii != null)
|
||||
{
|
||||
if (!allowNonAdmin && !UserInfo.CanEdit(MyUserInfo, ii.MyDocVersion))
|
||||
{
|
||||
FlexibleMessageBox.Show("You do not have permission to edit the procedure, section, or step.",
|
||||
"Convert Transition to Text", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
lbi.CheckState = CheckState.Unchecked;
|
||||
}
|
||||
else
|
||||
if (!JustDidSelection) IncTransSelectedCount++;
|
||||
}
|
||||
else
|
||||
if (!JustDidSelection && IncTransSelectedCount > 0) IncTransSelectedCount--; // user unchecked an item
|
||||
if (!JustDidSelection) btnTranCvtSelToTxt.Enabled = IncTransSelectedCount > 0;
|
||||
JustDidSelection = false;
|
||||
}
|
||||
private bool _ProcessingSelectedValueChanged = false;
|
||||
private void lbSrchResults_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_LoadingList) return;
|
||||
if (_ProcessingSelectedValueChanged) return;
|
||||
_ProcessingSelectedValueChanged = true;
|
||||
JustDidSelection = true;
|
||||
// If the list is being refreshed, then set the selection index to -1 (no selection)
|
||||
if (_SearchResults.RefreshingList && lbSrchResults.SelectedIndex != -1)
|
||||
lbSrchResults.SelectedIndex = -1;
|
||||
lbSrchResultsIncTrans.SelectedIndex = lbSrchResults.SelectedIndex = -1;
|
||||
else
|
||||
{
|
||||
_ItemInfo = lbSrchResults.SelectedValue as ItemInfo;
|
||||
_ItemInfo = (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4])? lbSrchResultsIncTrans.SelectedValue as ItemInfo : lbSrchResults.SelectedValue as ItemInfo;
|
||||
if ((tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[1]) && (_ItemInfo != null))
|
||||
{
|
||||
// B2020-019: Don't set the CurrentAnnotation to an annotation in a procedure that cannot be opened.
|
||||
AnnotationInfo tmpca = AnnotationInfo.Get(_ItemInfo.SearchAnnotationID);
|
||||
DisplayTabItem dti = null;
|
||||
if (tmpca != null) dti = _TabControl.OpenItem(tmpca.MyItem); // open the corresponding procedure text
|
||||
if (tmpca != null) dti = _TabControl.OpenItem(tmpca.MyItem); // open the corresponding procedure text
|
||||
if (dti != null)
|
||||
{
|
||||
_AnnotationDetails.CurrentAnnotation = tmpca;
|
||||
@@ -1359,6 +1437,7 @@ namespace Volian.Controls.Library
|
||||
|
||||
private void btnSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
IncTransSelectedCount = 0;
|
||||
_fromLoad = false;
|
||||
DateTime start = DateTime.Now;
|
||||
Cursor savcursor = Cursor;
|
||||
@@ -1368,9 +1447,18 @@ namespace Volian.Controls.Library
|
||||
try
|
||||
{
|
||||
LastSearchWasAnnotations = false; // B2019-119 only refresh annotation search results if an annotation search was done
|
||||
lbSrchResults.DataSource = null;
|
||||
lbSrchResults.Items.Clear();
|
||||
toolTip1.SetToolTip(lbSrchResults, null);
|
||||
if (tabSearchTypes.SelectedTab != tabSearchTypes.Tabs[4])
|
||||
{
|
||||
lbSrchResults.DataSource = null;
|
||||
lbSrchResults.Items.Clear();
|
||||
toolTip1.SetToolTip(lbSrchResults, null);
|
||||
}
|
||||
else // C2020-033: Incoming Transiiotns
|
||||
{
|
||||
lbSrchResultsIncTrans.DataSource = null;
|
||||
lbSrchResultsIncTrans.Items.Clear();
|
||||
toolTip1.SetToolTip(lbSrchResultsIncTrans, null);
|
||||
}
|
||||
Cursor = Cursors.WaitCursor;
|
||||
SearchResults = null;
|
||||
bool includeRTFformat = false;
|
||||
@@ -1407,7 +1495,7 @@ namespace Volian.Controls.Library
|
||||
ReportTitle = "Step Element Report"; //"Proms - Search by Type: " + typstr;
|
||||
TypesSelected = "Filtered By: " + typstr;
|
||||
SearchString = null;
|
||||
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, "", cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Value, includeRTFformat, includeSpecialChars, unitPrefix,"","");
|
||||
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, "", cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Value, includeRTFformat, includeSpecialChars, unitPrefix, "", "");
|
||||
cmbResultsStyleIndex = 1; //display step locations in results
|
||||
}
|
||||
}
|
||||
@@ -1433,19 +1521,19 @@ namespace Volian.Controls.Library
|
||||
// does not allow the preceding/following text to have a number, '.', letter or other rtf
|
||||
// commands. If the search string starts/ends with a letter, then use an expression that does not
|
||||
// find the preceding/following text that is text, i.e. a letter.
|
||||
if (Regex.IsMatch(TextSearchString, @"^[\d\.]")) // starts with a number or '.' decimal pt
|
||||
if (Regex.IsMatch(TextSearchString, @"^[\d\.]")) // starts with a number or '.' decimal pt
|
||||
{
|
||||
byWordPrefix = @"[^0-9a-zA-Z.vbpi:\\-]";
|
||||
}
|
||||
else if (Regex.IsMatch(TextSearchString, @"^[a-zA-Z]")) // starts with a letter
|
||||
else if (Regex.IsMatch(TextSearchString, @"^[a-zA-Z]")) // starts with a letter
|
||||
{
|
||||
byWordPrefix = @"[^a-zA-Z]";
|
||||
}
|
||||
if (Regex.IsMatch(TextSearchString, @"[\d\.]$")) // ends with a number or decimal
|
||||
if (Regex.IsMatch(TextSearchString, @"[\d\.]$")) // ends with a number or decimal
|
||||
{
|
||||
byWordSuffix = @"[^0-9a-zA-Z.vbpi:\\-]";
|
||||
}
|
||||
else if (Regex.IsMatch(TextSearchString, @"[a-zA-Z]$")) // ends with a letter
|
||||
else if (Regex.IsMatch(TextSearchString, @"[a-zA-Z]$")) // ends with a letter
|
||||
{
|
||||
byWordSuffix = @"[^a-zA-Z]";
|
||||
}
|
||||
@@ -1465,7 +1553,7 @@ namespace Volian.Controls.Library
|
||||
//ReportTitle = string.Format("Proms - Annotation Search for '{0}'", cbxTextSearchAnnotation.Text);
|
||||
if (cbxTextSearchAnnotation.Text == null || cbxTextSearchAnnotation.Text == "")
|
||||
{
|
||||
ReportTitle = string.Format("Find {0}{1}", cbxAnnoTypes.Text, (cbxAnnoTypes.SelectedIndex > 0)?" Annotations" : "" );
|
||||
ReportTitle = string.Format("Find {0}{1}", cbxAnnoTypes.Text, (cbxAnnoTypes.SelectedIndex > 0) ? " Annotations" : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1477,7 +1565,7 @@ namespace Volian.Controls.Library
|
||||
|
||||
//SearchResults = ItemInfoList.GetListFromAnnotationSearch(dviSearchList, typeSearchList, textSearchString, srchStr, cbxCaseSensitiveAnnoText.Checked);
|
||||
|
||||
SearchResults = ItemInfoList.GetListFromAnnotationSearch(DVISearchList, TypeSearchList, AnnotationSearchType, cbxTextSearchAnnotation.Text, cbxCaseSensitiveAnnoText.Checked,unitPrefix);
|
||||
SearchResults = ItemInfoList.GetListFromAnnotationSearch(DVISearchList, TypeSearchList, AnnotationSearchType, cbxTextSearchAnnotation.Text, cbxCaseSensitiveAnnoText.Checked, unitPrefix);
|
||||
//UpdateAnnotationSearchResults();
|
||||
cmbResultsStyleIndex = 2; // display annotation text in results
|
||||
}
|
||||
@@ -1498,7 +1586,7 @@ namespace Volian.Controls.Library
|
||||
cmbResultsStyleIndex = 3; // display step text in results
|
||||
}
|
||||
}
|
||||
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[3]) //Transition Search
|
||||
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[3]) //Transition Search
|
||||
{
|
||||
ReportTitle = string.Format("Search For Transitions: Transition Type: {0}, Transition Category: {1}", cbxTranFormat.SelectedItem, cbxTranCategory.SelectedItem);
|
||||
string docVersionList = string.Empty;
|
||||
@@ -1520,6 +1608,44 @@ namespace Volian.Controls.Library
|
||||
SearchResults = ItemInfoList.GetListFromTransitionSearch(docVersionList, cbxTranFormat.SelectedIndex - 1, cbxTranCategory.SelectedItem.ToString() == "All" ? "" : cbxTranCategory.SelectedItem.ToString(), TypeSearchList);
|
||||
cmbResultsStyleIndex = 3; // display step text in results
|
||||
}
|
||||
else if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4])
|
||||
{
|
||||
// C2020-033: Incoming Transitions: Make an iteminfolist from the list returned from
|
||||
// GetExternalTransitionsToChildren (also gets transitions to the item itself)
|
||||
ItemInfo trII = SearchIncTransII;
|
||||
if (trII != null)
|
||||
{
|
||||
ReportTitle = string.Format("Search For Incoming Transitions to {0}: ", trII.Path);
|
||||
TypesSelected = "Filtered By: " + typstr;
|
||||
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(trII.ItemID))
|
||||
{
|
||||
ItemInfoList iil = null;
|
||||
bool first = true;
|
||||
foreach (TransitionInfo ti in exTrans)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
ContentInfo ci = ContentInfo.Get(ti.FromID);
|
||||
ItemInfo tmp = ci.ContentItems[0];
|
||||
iil = new ItemInfoList(tmp);
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentInfo ci = ContentInfo.Get(ti.FromID);
|
||||
ItemInfo tmp = ci.ContentItems[0];
|
||||
iil.AddItem(tmp);
|
||||
}
|
||||
}
|
||||
SearchResults = iil;
|
||||
if (SearchResults == null || SearchResults.Count == 0)
|
||||
{
|
||||
FlexibleMessageBox.Show("No Matches Found.", "Search");
|
||||
}
|
||||
cmbResultsStyleIndex = 1; //display step locations in results
|
||||
}
|
||||
}
|
||||
}
|
||||
if (SearchResults != null)
|
||||
{
|
||||
AddMessageForEmptyAnnotations();
|
||||
@@ -1531,6 +1657,7 @@ namespace Volian.Controls.Library
|
||||
FlexibleMessageBox.Show("No Matches Found.", "Search");
|
||||
}
|
||||
}
|
||||
btnTranCvtAllToTxt.Enabled = IncTransCvtAllToTextPerm(); // C2020-033: does user have access to at least one item
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1556,7 +1683,7 @@ namespace Volian.Controls.Library
|
||||
bool hasAnnot = false;
|
||||
foreach (ItemInfo ii in SearchResults)
|
||||
{
|
||||
if (ii.ItemAnnotationCount > 0)
|
||||
if (ii.ItemAnnotations != null && ii.ItemAnnotationCount > 0)
|
||||
{
|
||||
// RHM - can an iteminfo have an itemannotationcount>0 and not have searchannotationtext.
|
||||
if (ii.SearchAnnotationText == null) ii.SearchAnnotationText = AnnotationInfo.Get(ii.ItemAnnotations[0].AnnotationID).SearchText;
|
||||
@@ -2153,9 +2280,16 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void btnClearSearchResults_Click(object sender, EventArgs e)
|
||||
{
|
||||
lbSrchResults.DataSource = null;
|
||||
if (tabSearchTypes.SelectedTab == tabIncTrans) // C2020-033: Clear the Incoming Transitions list box
|
||||
{
|
||||
lbSrchResultsIncTrans.DataSource = null;
|
||||
lbSrchResultsIncTrans.Items.Clear();
|
||||
}
|
||||
else
|
||||
lbSrchResults.DataSource = null;
|
||||
_SearchResults = null;
|
||||
DisplayResults();
|
||||
btnTranCvtAllToTxt.Enabled = false;
|
||||
}
|
||||
|
||||
// A timer updated the step type tree but if it was loaded from xml the timer update overwrite what
|
||||
@@ -2163,6 +2297,7 @@ namespace Volian.Controls.Library
|
||||
private bool _fromLoad = false;
|
||||
private void btnLoadSearchResults_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
IncTransSelectedCount = 0;
|
||||
_fromLoad = true;
|
||||
_LoadingList = true;
|
||||
ofdSearchResults.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS";
|
||||
@@ -2290,7 +2425,27 @@ namespace Volian.Controls.Library
|
||||
break;
|
||||
}
|
||||
case 2: //referenced object
|
||||
case 3: // transitions
|
||||
{
|
||||
FlexibleMessageBox.Show(this, "Loading Referenced Objects and Transitions searches is under construction.", "Under Construction", MessageBoxButtons.OK);
|
||||
break;
|
||||
}
|
||||
case 4: // Incoming transitions
|
||||
{
|
||||
tabSearchTypes.SelectedTab = tabIncTrans;
|
||||
cmbResultsStyle.Text = xd.SelectSingleNode("search/results/@style").InnerText;
|
||||
string tmpi = xd.SelectSingleNode("search/results/@toid").InnerText;
|
||||
SearchIncTransII = ItemInfo.Get(Convert.ToInt32(tmpi));
|
||||
System.Xml.XmlNodeList nl = xd.SelectNodes("search/results/item");
|
||||
foreach (System.Xml.XmlNode nd in nl)
|
||||
{
|
||||
int itemID = int.Parse(nd.Attributes.GetNamedItem("id").InnerText);
|
||||
ItemInfo ii = ItemInfo.Get(itemID);
|
||||
if (ii.SearchAnnotationText == null && ii.ItemAnnotations != null) ii.SearchAnnotationText = AnnotationInfo.Get(ii.ItemAnnotations[0].AnnotationID).SearchText;
|
||||
SearchResults.AddItemInfo(ii);
|
||||
}
|
||||
lbSrchResultsIncTrans.DataSource = SearchResults;
|
||||
DisplayResults();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2311,12 +2466,14 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
Cursor = Cursors.Default;
|
||||
}
|
||||
btnTranCvtAllToTxt.Enabled = IncTransCvtAllToTextPerm(); // C2020-033: does user have access to at least one item
|
||||
_LoadingList = false;
|
||||
}
|
||||
|
||||
private void btnSaveSearchResults_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
ICollection<ItemInfo> myList = lbSrchResults.DataSource as ICollection<ItemInfo>;
|
||||
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4]) myList = lbSrchResultsIncTrans.DataSource as ICollection<ItemInfo>; // C2020-033: use Incoming transition list
|
||||
if (tabSearchTypes.SelectedTabIndex == 2 || tabSearchTypes.SelectedTabIndex == 3) // ROs & Transitions are not coded yet
|
||||
{
|
||||
FlexibleMessageBox.Show(this, "Saving Referenced Objects and Transitions searches is under construction.", "Under Construction", MessageBoxButtons.OK);
|
||||
@@ -2342,32 +2499,34 @@ namespace Volian.Controls.Library
|
||||
// B2020-107: save procedures sets & step types
|
||||
// do procsets selected
|
||||
System.Xml.XmlElement xp = null;
|
||||
if (lstCheckedDocVersions != null && lstCheckedDocVersions.Count > 0)
|
||||
{
|
||||
xp = xd.CreateElement("procsets");
|
||||
foreach (DocVersionInfo dvi in lstCheckedDocVersions)
|
||||
{
|
||||
System.Xml.XmlElement xee = xd.CreateElement("set");
|
||||
xa = xd.CreateAttribute("fid");
|
||||
xa.InnerText = dvi.MyFolder.FolderID.ToString();
|
||||
xee.Attributes.SetNamedItem(xa);
|
||||
xp.AppendChild(xee);
|
||||
}
|
||||
}
|
||||
System.Xml.XmlElement xst = null;
|
||||
if (lstCheckedStepTypesStr != null && lstCheckedStepTypesStr.Count > 0)
|
||||
if (sti != 4) // C2020-033: no procsets or step types for Incoming transitions
|
||||
{
|
||||
xst = xd.CreateElement("StepType");
|
||||
foreach (string str in lstCheckedStepTypesStr) // Limited by step types
|
||||
if (lstCheckedDocVersions != null && lstCheckedDocVersions.Count > 0)
|
||||
{
|
||||
System.Xml.XmlElement xee = xd.CreateElement("type");
|
||||
xa = xd.CreateAttribute("str");
|
||||
xa.InnerText = str;
|
||||
xee.Attributes.SetNamedItem(xa);
|
||||
xst.AppendChild(xee);
|
||||
xp = xd.CreateElement("procsets");
|
||||
foreach (DocVersionInfo dvi in lstCheckedDocVersions)
|
||||
{
|
||||
System.Xml.XmlElement xee = xd.CreateElement("set");
|
||||
xa = xd.CreateAttribute("fid");
|
||||
xa.InnerText = dvi.MyFolder.FolderID.ToString();
|
||||
xee.Attributes.SetNamedItem(xa);
|
||||
xp.AppendChild(xee);
|
||||
}
|
||||
}
|
||||
if (lstCheckedStepTypesStr != null && lstCheckedStepTypesStr.Count > 0)
|
||||
{
|
||||
xst = xd.CreateElement("StepType");
|
||||
foreach (string str in lstCheckedStepTypesStr) // Limited by step types
|
||||
{
|
||||
System.Xml.XmlElement xee = xd.CreateElement("type");
|
||||
xa = xd.CreateAttribute("str");
|
||||
xa.InnerText = str;
|
||||
xee.Attributes.SetNamedItem(xa);
|
||||
xst.AppendChild(xee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (sti)
|
||||
{
|
||||
case 0: //text
|
||||
@@ -2439,6 +2598,34 @@ namespace Volian.Controls.Library
|
||||
xd.Save(sfdSearchResults.FileName);
|
||||
break;
|
||||
}
|
||||
case 2: // ro
|
||||
case 3: // transitions
|
||||
{
|
||||
FlexibleMessageBox.Show(this, "Saving Search Results for this search type is under construction.", "Under Construction", MessageBoxButtons.OK);
|
||||
break;
|
||||
}
|
||||
case 4: // C2020-033: Incoming Transitions
|
||||
{
|
||||
// do results
|
||||
xe = xd.CreateElement("results");
|
||||
xa = xd.CreateAttribute("style");
|
||||
xa.InnerText = cmbResultsStyle.Text;
|
||||
xe.Attributes.SetNamedItem(xa);
|
||||
xa = xd.CreateAttribute("toid");
|
||||
xa.InnerText = SearchIncTransII.ItemID.ToString();
|
||||
xe.Attributes.SetNamedItem(xa);
|
||||
foreach (ItemInfo ii in myList)
|
||||
{
|
||||
System.Xml.XmlElement xee = xd.CreateElement("item");
|
||||
xa = xd.CreateAttribute("id");
|
||||
xa.InnerText = ii.ItemID.ToString();
|
||||
xee.Attributes.SetNamedItem(xa);
|
||||
xe.AppendChild(xee);
|
||||
}
|
||||
xd.DocumentElement.AppendChild(xe);
|
||||
xd.Save(sfdSearchResults.FileName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2470,6 +2657,7 @@ namespace Volian.Controls.Library
|
||||
private void btnCopySearchResults_Click(object sender, EventArgs e)
|
||||
{
|
||||
ICollection<ItemInfo> myList = lbSrchResults.DataSource as ICollection<ItemInfo>;
|
||||
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4]) myList = lbSrchResultsIncTrans.DataSource as ICollection<ItemInfo>;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("\"Location\"\t\"Type\"\t\"Text\"\t\"High-Level\"\t\"Annotations\"");
|
||||
List<int> ItemsProcessed = new List<int>();
|
||||
@@ -2513,18 +2701,188 @@ namespace Volian.Controls.Library
|
||||
string sortedBy = "";
|
||||
if (cbSorted.Checked)
|
||||
sortedBy = string.Format("Sorted By: {0}", cmbResultsStyle.Text); //C2019-013 pass in sorted by information
|
||||
OnPrintRequest(new DisplaySearchEventArgs(ReportTitle, TypesSelected, SearchString, lbSrchResults.DataSource as ICollection<ItemInfo>,sortedBy));
|
||||
ICollection<ItemInfo> srchres = lbSrchResults.DataSource as ICollection<ItemInfo>;
|
||||
// C2020-033: If on the Incoming Transitions tab, use that list.
|
||||
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[4]) srchres = lbSrchResultsIncTrans.DataSource as ICollection<ItemInfo>;
|
||||
OnPrintRequest(new DisplaySearchEventArgs(ReportTitle, TypesSelected, SearchString, srchres,sortedBy));
|
||||
}
|
||||
private void panSearchButtons_Resize(object sender, EventArgs e)
|
||||
{
|
||||
cmbResultsStyle.Left = labelX1.Right + 3;
|
||||
cmbResultsStyle.Width = btnClearSearchResults.Left - cmbResultsStyle.Left - 3;
|
||||
}
|
||||
// C2020-033: Convert All (that have permissions) Incoming Transitions to text
|
||||
private void btnTranCvtAllToTxt_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<int> itmsEditable = TranCvtCheckPermission(true); // Get list based on permissions
|
||||
if (itmsEditable == null || itmsEditable.Count == 0) return;
|
||||
TranCvtToTxt(itmsEditable);
|
||||
}
|
||||
// C22020-033: Use IncTransCvtAllToTextPerm to see if user has at least edit permissions to 1 in list. This
|
||||
// is used to see if Convert All button is enabled.
|
||||
private bool IncTransCvtAllToTextPerm()
|
||||
{
|
||||
if (_SearchResults == null) return false;
|
||||
int cnt = 0;
|
||||
bool allowNonAdmin = IncTranCvtPerm();
|
||||
foreach (ItemInfo ii in _SearchResults)
|
||||
{
|
||||
if (allowNonAdmin || UserInfo.CanEdit(MyUserInfo, ii.MyDocVersion)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// C2020-033: Update the search panel for Incoming transitions. This gets called from the tree view & the ribbon
|
||||
public void UpdateSearchIncTransResults()
|
||||
{
|
||||
IncTransSelectedCount = 0;
|
||||
tabSearchTypes.SelectedTab = tabSearchTypes.Tabs[4];
|
||||
|
||||
lbSrchResultsIncTrans.DataSource = null;
|
||||
lbSrchResultsIncTrans.Items.Clear();
|
||||
// Get item to do search for, either from tree or from editor
|
||||
ItemInfo trII = SearchIncTransII;
|
||||
if (trII != null)
|
||||
{
|
||||
ReportTitle = string.Format("Search For Incoming Transitions to {0}: ", trII.Path);
|
||||
|
||||
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(trII.ItemID))
|
||||
{
|
||||
ItemInfoList iil = null;
|
||||
bool first = true;
|
||||
foreach (TransitionInfo ti in exTrans)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
ContentInfo ci = ContentInfo.Get(ti.FromID);
|
||||
ItemInfo tmp = ci.ContentItems[0];
|
||||
iil = new ItemInfoList(tmp);
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentInfo ci = ContentInfo.Get(ti.FromID);
|
||||
ItemInfo tmp = ci.ContentItems[0];
|
||||
iil.AddItem(tmp);
|
||||
}
|
||||
}
|
||||
SearchResults = iil;
|
||||
}
|
||||
}
|
||||
if (SearchResults != null && SearchResults.Count > 0)
|
||||
{
|
||||
AddMessageForEmptyAnnotations();
|
||||
cmbResultsStyle.SelectedIndex = 1; //display step locations in results
|
||||
DisplayResults();
|
||||
}
|
||||
else
|
||||
{
|
||||
btnPrnSrchRslts.Enabled = false;
|
||||
btnClearSearchResults.Enabled = false;
|
||||
btnCopySearchResults.Enabled = false;
|
||||
btnSaveSearchResults.Enabled = false;
|
||||
cmbResultsStyle.Enabled = false;
|
||||
FlexibleMessageBox.Show("No Matches Found.", "Search");
|
||||
}
|
||||
btnTranCvtAllToTxt.Enabled = IncTransCvtAllToTextPerm();
|
||||
btnTranCvtSelToTxt.Enabled = false;
|
||||
}
|
||||
public bool IncTranCvtPerm()
|
||||
{
|
||||
FolderInfo topFolder = FolderInfo.Get(1);
|
||||
FolderConfig fc = topFolder.MyConfig as FolderConfig;
|
||||
return fc.General_IncTranCvtPerm;
|
||||
}
|
||||
// C2020-033: Before allowing conversion of Incoming Transitions to text, get list of results that the user has permission edit.
|
||||
private List<int> TranCvtCheckPermission(bool all)
|
||||
{
|
||||
// check if a non-reader can convert transitions to text even if a reader - this is set by an administrator on the top
|
||||
// folder properties dialog
|
||||
bool allowNonAdmin = IncTranCvtPerm();
|
||||
List<int> itmsEditable = new List<int>(); // return this list
|
||||
int listCount = 0;
|
||||
if (all) // Check all in list
|
||||
{
|
||||
listCount = _SearchResults.Count;
|
||||
foreach (ItemInfo ii in _SearchResults)
|
||||
{
|
||||
if (allowNonAdmin || UserInfo.CanEdit(MyUserInfo, ii.MyDocVersion)) itmsEditable.Add(ii.ContentID);
|
||||
}
|
||||
}
|
||||
else // check only the items selected
|
||||
{
|
||||
listCount = lbSrchResultsIncTrans.CheckedItems.Count;
|
||||
List<ListBoxItem> lbis = lbSrchResultsIncTrans.CheckedItems;
|
||||
foreach (ListBoxItem lbi in lbis)
|
||||
{
|
||||
ItemBindingData tmpii = lbi.Tag as ItemBindingData;
|
||||
ItemInfo ii = tmpii.DataItem as ItemInfo;
|
||||
if (allowNonAdmin || UserInfo.CanEdit(MyUserInfo, ii.MyDocVersion)) itmsEditable.Add(ii.ContentID);
|
||||
}
|
||||
}
|
||||
// Prompt user if convert to text should continue. If some items cannot be edited, also state that
|
||||
// not all can be converted to text. If count of itmsEditable & lbis are different some cannot be edited.
|
||||
if (itmsEditable.Count == 0)
|
||||
{
|
||||
FlexibleMessageBox.Show("You do not have permission to edit any of the procedures, sections, and/or steps" + (all ? "." : " that are selected."),
|
||||
"Convert Transition to Text", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return null;
|
||||
}
|
||||
else if (itmsEditable.Count != listCount)
|
||||
{
|
||||
DialogResult ans = FlexibleMessageBox.Show("You only have permission to edit some of the procedures, sections, and/or steps that are selected.procedures, sections, and/or steps" + (all ? "." : " that are selected.") +
|
||||
"\r\n\r\n Should the conversion of the transitions to text continue?",
|
||||
"Convert Transition to Text", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (ans == DialogResult.No) return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogResult ans = FlexibleMessageBox.Show("Are you sure you want to convert the transitions to text?",
|
||||
"Convert Transition to Text", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (ans == DialogResult.No) return null;
|
||||
}
|
||||
return itmsEditable;
|
||||
}
|
||||
// C2020-033: convert selected transitions to text
|
||||
private void btnTranCvtSelToTxt_Click(object sender, EventArgs e)
|
||||
{
|
||||
// First see if all selected can be converted, i.e. user has permission to edit
|
||||
List<ListBoxItem> lbis = lbSrchResultsIncTrans.CheckedItems;
|
||||
List<int> itmsEditable = TranCvtCheckPermission(false);
|
||||
if (itmsEditable == null || itmsEditable.Count == 0) return;
|
||||
TranCvtToTxt(itmsEditable);
|
||||
}
|
||||
// C2020-033: For items in list, do the actual conversion of the Incoming Transition to text
|
||||
private void TranCvtToTxt(List<int> itmsEditable)
|
||||
{
|
||||
ItemInfo trII = SearchIncTransII;
|
||||
if (trII != null)
|
||||
{
|
||||
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(trII.ItemID))
|
||||
{
|
||||
foreach (TransitionInfo ti in exTrans)
|
||||
{
|
||||
// See if the 'item to' id is to be converted and if so do it. To figure this out,
|
||||
// see if it is in the list itmsEditable.
|
||||
if (itmsEditable.Contains(ti.FromID))
|
||||
{
|
||||
ContentInfo ci = ContentInfo.Get(ti.FromID);
|
||||
ItemInfo tmp = ci.ContentItems[0];
|
||||
using (Content content = Content.Get(tmp.ContentID))
|
||||
{
|
||||
content.FixTransitionText(ti, true);
|
||||
content.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#region Annoation Search Type Class
|
||||
// this class is used to generate the list of annotations to search.
|
||||
// this also allow us to add a dummy type which is used to search for all annotations
|
||||
public class AnnotationTypeSearch
|
||||
#region Annoation Search Type Class
|
||||
// this class is used to generate the list of annotations to search.
|
||||
// this also allow us to add a dummy type which is used to search for all annotations
|
||||
public class AnnotationTypeSearch
|
||||
{
|
||||
private string _Name;
|
||||
public string Name
|
||||
|
Reference in New Issue
Block a user