For Parent/Child procedures, added the Child name (ex. Unit 1) to the export filename when you export from the Approve Version

This commit is contained in:
John Jenko 2016-08-11 17:53:27 +00:00
parent df152b7b67
commit d42a05a1f4

View File

@ -377,6 +377,7 @@ namespace Volian.Controls.Library
#endregion #endregion
public partial class vlnTreeView : TreeView public partial class vlnTreeView : TreeView
{ {
private ProcedureInfo _currentPri = null; // used to get child name to append to approved export filename -AddApprovedRevisionsMultiUnit() & ImportProcedure_Click()
private SessionInfo _MySessionInfo; private SessionInfo _MySessionInfo;
public SessionInfo MySessionInfo public SessionInfo MySessionInfo
{ {
@ -1087,6 +1088,7 @@ namespace Volian.Controls.Library
private void AddApprovedRevisionsMultiUnit(Menu.MenuItemCollection menuItemCollection, ProcedureInfo pri) private void AddApprovedRevisionsMultiUnit(Menu.MenuItemCollection menuItemCollection, ProcedureInfo pri)
{ {
_currentPri = pri;
RevisionInfoList ril = RevisionInfoList.GetByItemID(pri.ItemID); RevisionInfoList ril = RevisionInfoList.GetByItemID(pri.ItemID);
if (ril.Count == 0) return; // no versions to list if (ril.Count == 0) return; // no versions to list
MenuItem mi = menuItemCollection.Add("Versions"); MenuItem mi = menuItemCollection.Add("Versions");
@ -1116,7 +1118,7 @@ namespace Volian.Controls.Library
mirs.Tag = ri; mirs.Tag = ri;
mirs.Click += new EventHandler(MultiUnitSummaryOfChanges_Click); mirs.Click += new EventHandler(MultiUnitSummaryOfChanges_Click);
} }
if (ri.LatestVersion.ApprovedXML != null) if (ri.LatestVersion.ApprovedXML != null && ri.LatestVersion.ApprovedXML != "")
{ {
MenuItem miri = mir.MenuItems.Add("Create Procedure to Import"); MenuItem miri = mir.MenuItems.Add("Create Procedure to Import");
miri.Tag = ri; miri.Tag = ri;
@ -1138,7 +1140,7 @@ namespace Volian.Controls.Library
try try
{ {
//_MyLog.WarnFormat("Context Menu 1 before GET - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 1 before GET - {0}", GC.GetTotalMemory(true));
_currentPri = pri;
using (RevisionInfoList ril = RevisionInfoList.GetByItemID(pri.ItemID)) using (RevisionInfoList ril = RevisionInfoList.GetByItemID(pri.ItemID))
{ {
//_MyLog.WarnFormat("Context Menu 1 After GET - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 1 After GET - {0}", GC.GetTotalMemory(true));
@ -1172,7 +1174,7 @@ namespace Volian.Controls.Library
mirs.Click += new EventHandler(SummaryOfChanges_Click); mirs.Click += new EventHandler(SummaryOfChanges_Click);
} }
//_MyLog.WarnFormat("Context Menu 1 b4 import - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 1 b4 import - {0}", GC.GetTotalMemory(true));
if (addImportMI && ri.LatestVersion.ApprovedXML != null) if (addImportMI && ri.LatestVersion.ApprovedXML != null && ri.LatestVersion.ApprovedXML != "")
{ {
MenuItem miri = mir.MenuItems.Add("Create Procedure to Import"); MenuItem miri = mir.MenuItems.Add("Create Procedure to Import");
miri.Tag = ri; miri.Tag = ri;
@ -1212,12 +1214,16 @@ namespace Volian.Controls.Library
void ImportProcedure_Click(object sender, EventArgs e) void ImportProcedure_Click(object sender, EventArgs e)
{ {
RevisionInfo ri = (sender as MenuItem).Tag as RevisionInfo; RevisionInfo ri = (sender as MenuItem).Tag as RevisionInfo;
RevisionConfig rc = ri.MyConfig as RevisionConfig;
// bug fix: B2016-183 - add the child's name (ex Unit 1) to the export file name for Parent/Child procedures.
int applIdx = rc.Applicability_Index;
string str = (applIdx > 0)?_currentPri.MyDocVersion.UnitNames[applIdx-1] +"_":""; // if parent/child get the defined child name to inlcude the export filename
System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); System.Xml.XmlDocument xd = new System.Xml.XmlDocument();
xd.LoadXml(ri.LatestVersion.ApprovedXML); xd.LoadXml(ri.LatestVersion.ApprovedXML);
string PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database; string PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database;
DirectoryInfo di = new DirectoryInfo(PEIPath); DirectoryInfo di = new DirectoryInfo(PEIPath);
if (!di.Exists) di.Create(); if (!di.Exists) di.Create();
string fileName = PEIPath + "\\Approved_Rev_" + ri.RevisionNumber.Replace(" ","_") + "_" + xd.SelectSingleNode("procedure/content/@number").InnerText.Replace(" ","_").Replace(@"\u8209?", "-").Replace(@"\u9586?","_")+".pxml"; string fileName = PEIPath + "\\" + str + "Approved_Rev_" + ri.RevisionNumber.Replace(" ","_") + "_"+ xd.SelectSingleNode("procedure/content/@number").InnerText.Replace(" ","_").Replace(@"\u8209?", "-").Replace(@"\u9586?","_")+".pxml";
xd.Save(fileName); xd.Save(fileName);
MessageBox.Show("Approved procedure saved to import file " + fileName,"Saving TempMod", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Approved procedure saved to import file " + fileName,"Saving TempMod", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }