|
|
|
|
@@ -456,7 +456,7 @@ namespace Baseline
|
|
|
|
|
switch (myLast)
|
|
|
|
|
{
|
|
|
|
|
case LastWas.Pagination:
|
|
|
|
|
line = OpenPDF(line);
|
|
|
|
|
OpenPDF(line);
|
|
|
|
|
break;
|
|
|
|
|
case LastWas.Baseline: // TODO: Need to add code here to open matching file
|
|
|
|
|
OpenOnePDF(myLine,1);
|
|
|
|
|
@@ -479,7 +479,7 @@ namespace Baseline
|
|
|
|
|
switch (myLast)
|
|
|
|
|
{
|
|
|
|
|
case LastWas.Pagination:
|
|
|
|
|
line = OpenPDF(line);
|
|
|
|
|
OpenPDF(line);
|
|
|
|
|
break;
|
|
|
|
|
case LastWas.Baseline: // TODO: Need to add code here to open matching file
|
|
|
|
|
OpenOnePDF(myLine,2);
|
|
|
|
|
@@ -491,34 +491,99 @@ namespace Baseline
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string exePath;
|
|
|
|
|
private string OpenPDF(string line)
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This will return the full path to the PDF file
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fi"></param>
|
|
|
|
|
/// <param name="patern"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string GetPFDFileAndPath(FileInfo fi, string patern)
|
|
|
|
|
{
|
|
|
|
|
int page = int.Parse(line.Substring(0, 6));
|
|
|
|
|
string[] fileList = Directory.GetFiles(fi.DirectoryName, patern);
|
|
|
|
|
// sort the list of file list
|
|
|
|
|
Array.Sort((string[])fileList);
|
|
|
|
|
return fileList.First(); // the PDF file that we what should be top of the list then.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This will parse out the procedure number for the PROMS ShortPath representation of a procedure section or step part
|
|
|
|
|
/// In the PROMS ShortPath, ".S" is used to delimit the procedure number, section then uses "..S" for the step parts
|
|
|
|
|
/// This method was written to handle cases where ".S" is used as part of the procedure number
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="txt"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string ParseOutProcedureNumberFromLine(string txt)
|
|
|
|
|
{
|
|
|
|
|
// old logic was looking for the first occurence of ".S" in the txt string as the ending point of the procedure nuumber
|
|
|
|
|
// Beaver Valley has a procedure number "1.SBGEN" in which the old logic would not work
|
|
|
|
|
// 1.SBGEN.SC. ==> short path of attachment section "C"
|
|
|
|
|
// 1.SBGEN.SC..S1. ==> short path of Step 1 in attachment section "C"
|
|
|
|
|
string rtnstr = null;
|
|
|
|
|
int lidx = -1;
|
|
|
|
|
// if the item is to a high levels step or sub-step the short path as "..S" for each part of the step
|
|
|
|
|
// so look for the last occurence of ".." which will be the end of the section information
|
|
|
|
|
lidx = txt.LastIndexOf("..");
|
|
|
|
|
if (lidx > 0)
|
|
|
|
|
{
|
|
|
|
|
lidx = txt.LastIndexOf(".S", lidx); // this will position us to the end of the procedure number
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lidx = txt.LastIndexOf(".S"); // this will position us to the end of the procedure number if there was no step information
|
|
|
|
|
}
|
|
|
|
|
// B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file.
|
|
|
|
|
line = line.Substring(8, line.IndexOf(".S") - 8).Replace("/", "_").Replace("\\", "_");
|
|
|
|
|
rtnstr = txt.Substring(8, lidx - 8).Replace("/", "_").Replace("\\", "_");
|
|
|
|
|
return rtnstr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string exePath;
|
|
|
|
|
private void OpenPDF(string line)
|
|
|
|
|
{
|
|
|
|
|
int pageNum = int.Parse(line.Substring(0, 6));
|
|
|
|
|
// B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file.
|
|
|
|
|
string ProcNum = ParseOutProcedureNumberFromLine(line);
|
|
|
|
|
string procPatern = string.Format("*{0}*.pdf", string.IsNullOrEmpty(line) ? "noProcNumber" : ProcNum);
|
|
|
|
|
|
|
|
|
|
FindFile ff = lbDifferent.SelectedItem as FindFile;
|
|
|
|
|
FileInfo fi1 = new FileInfo(ff.File1);
|
|
|
|
|
FileInfo fi2 = new FileInfo(ff.File2);
|
|
|
|
|
string PDFfileName1 = GetPFDFileAndPath(fi1,procPatern);
|
|
|
|
|
string PDFfileName2 = GetPFDFileAndPath(fi2,procPatern);
|
|
|
|
|
if (string.IsNullOrEmpty(PDFfileName1) || string.IsNullOrEmpty(PDFfileName2)) return;
|
|
|
|
|
|
|
|
|
|
// If you don't know where the Reader executable is for PDFs Open a PDF and Check to see where the path points
|
|
|
|
|
if (exePath == null)
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process p = System.Diagnostics.Process.Start(fi1.DirectoryName + "\\" + line + ".pdf");
|
|
|
|
|
exePath = TryToGetPath(p);
|
|
|
|
|
p.Kill(); // No need to keep it open
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process p = System.Diagnostics.Process.Start(PDFfileName1);
|
|
|
|
|
exePath = TryToGetPath(p);
|
|
|
|
|
p.Kill(); // No need to keep it open
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
string msg = string.Format("{0} - {1}", ex.GetType().Name, ex.Message);
|
|
|
|
|
Console.WriteLine(msg);
|
|
|
|
|
MessageBox.Show(msg, "Error opening default PDF Viewer");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Open the first PDF on a Specific Page
|
|
|
|
|
System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A page={0} ", page) + fi1.DirectoryName + "\\" + line + ".pdf ");
|
|
|
|
|
System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format(" /A \"page={0}\" \"{1}\" ", pageNum,PDFfileName1));
|
|
|
|
|
System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi1);
|
|
|
|
|
// Move the PDF Reader window to 0,0
|
|
|
|
|
MoveProcess(p1, 0, 0);
|
|
|
|
|
// Open the first PDF on a Specific Page
|
|
|
|
|
System.Diagnostics.ProcessStartInfo psi2 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A page={0} ", page) + fi2.DirectoryName + "\\" + line + ".pdf ");
|
|
|
|
|
|
|
|
|
|
// Open the second PDF on a Specific Page
|
|
|
|
|
System.Diagnostics.ProcessStartInfo psi2 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format(" /A \"page={0}\" \"{1}\" ", pageNum, PDFfileName2));
|
|
|
|
|
System.Diagnostics.Process p2 = System.Diagnostics.Process.Start(psi2);
|
|
|
|
|
// Move the PDF Reader window to 960,0
|
|
|
|
|
// TODO: This Offset could be a Setting
|
|
|
|
|
MoveProcess(p2, 960, 0);
|
|
|
|
|
return line;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Try to get the location of the PDF Reader executable
|
|
|
|
|
@@ -530,7 +595,7 @@ namespace Baseline
|
|
|
|
|
p.WaitForInputIdle();
|
|
|
|
|
while (p.MainModule == null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("{0} - {1}", p.MainWindowTitle,p.ProcessName);
|
|
|
|
|
Console.WriteLine("{0} - {1}", p.MainWindowTitle, p.ProcessName);
|
|
|
|
|
p.WaitForInputIdle();
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
}
|
|
|
|
|
@@ -594,40 +659,52 @@ namespace Baseline
|
|
|
|
|
/// <param name="list"></param>
|
|
|
|
|
private void OpenOnePDF(Line myLine, int list)
|
|
|
|
|
{
|
|
|
|
|
if (myLine == null) return; // no PDF to open
|
|
|
|
|
// B2018-113 - Replace slashes and backslashes with underscores just as PROMS does when creating a PDF file.
|
|
|
|
|
string proc = myLine.MyProc.Number.Replace("/","_").Replace("\\","_");
|
|
|
|
|
|
|
|
|
|
// if no procedure number, PROMS creates pdf filename "NoProcNumber.pdf"
|
|
|
|
|
// create pattern to use to get the PDF from the directory
|
|
|
|
|
// add wildcards (*) to file the file if any prefix or suffix was added to the filename
|
|
|
|
|
string procPatern = string.Format("*{0}*.pdf", proc == string.Empty ? "noProcNumber" : proc);
|
|
|
|
|
int pagenum = myLine.MyPage.Number;
|
|
|
|
|
FindFile ff = lbDifferent.SelectedItem as FindFile;
|
|
|
|
|
FileInfo fi1 = new FileInfo(ff.File1);
|
|
|
|
|
FileInfo fi2 = new FileInfo(ff.File2);
|
|
|
|
|
if (exePath == null)
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process p = System.Diagnostics.Process.Start(fi1.DirectoryName + "\\" + proc + ".pdf");
|
|
|
|
|
while (exePath == null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
exePath = p.MainModule.FileName;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
Console.WriteLine("{0} - {1}", ex.GetType().Name, ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
p.Kill();
|
|
|
|
|
}
|
|
|
|
|
string PDFfileName = null;
|
|
|
|
|
if (list == 1)
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A page={0} ", pagenum) + fi1.DirectoryName + "\\" + proc + ".pdf ");
|
|
|
|
|
System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi1);
|
|
|
|
|
FileInfo fi1 = new FileInfo(ff.File1);
|
|
|
|
|
PDFfileName = GetPFDFileAndPath(fi1, procPatern);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
else // list == 2
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.ProcessStartInfo psi2 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A page={0} ", pagenum) + fi2.DirectoryName + "\\" + proc + ".pdf ");
|
|
|
|
|
System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi2);
|
|
|
|
|
FileInfo fi2 = new FileInfo(ff.File2);
|
|
|
|
|
PDFfileName = GetPFDFileAndPath(fi2, procPatern);
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(PDFfileName)) return; // no PDF to open
|
|
|
|
|
|
|
|
|
|
// if exePath is null, then open the found PDF with the default PDF viewer and
|
|
|
|
|
// capture/save the entire name and path of the default PDF viewer
|
|
|
|
|
if (exePath == null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
System.Diagnostics.Process tp = System.Diagnostics.Process.Start(PDFfileName);
|
|
|
|
|
exePath = TryToGetPath(tp);
|
|
|
|
|
tp.Kill();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Application.DoEvents();
|
|
|
|
|
string msg = string.Format("{0} - {1}", ex.GetType().Name, ex.Message);
|
|
|
|
|
Console.WriteLine(msg);
|
|
|
|
|
MessageBox.Show(msg, "Error opening default PDF Viewer");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// open the PDF and jump to the page number
|
|
|
|
|
System.Diagnostics.ProcessStartInfo psi1 = new System.Diagnostics.ProcessStartInfo(exePath, string.Format("/A \"page={0}\" \"{1}\" ", pagenum,PDFfileName));
|
|
|
|
|
psi1.UseShellExecute = false;
|
|
|
|
|
System.Diagnostics.Process p1 = System.Diagnostics.Process.Start(psi1);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Perform Debug Meta file comparison for all of the folders within the automated testing folders
|
|
|
|
|
@@ -709,11 +786,12 @@ namespace Baseline
|
|
|
|
|
private void lbProcedures_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//Initialize Results List Box
|
|
|
|
|
lbResults1.Items.Clear();
|
|
|
|
|
Procedure myProc = lbProcedures.SelectedItem as Procedure;
|
|
|
|
|
if (myProc == null) return; // clicked on the white space (blank line) in the list of different procedures
|
|
|
|
|
//TODO: May need to consider if there are duplicate procedure numers and titles
|
|
|
|
|
Procedure myProc1 = MyProcs1.Find(x => x.Number == myProc.Number && x.Title == myProc.Title);
|
|
|
|
|
// Build the results ListBox for the left window
|
|
|
|
|
lbResults1.Items.Clear();
|
|
|
|
|
if (myProc1 != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (Page myPage in myProc1.MyPages)
|
|
|
|
|
|