diff --git a/PROMS/Baseline/App.config b/PROMS/Baseline/App.config new file mode 100644 index 00000000..193f33c8 --- /dev/null +++ b/PROMS/Baseline/App.config @@ -0,0 +1,42 @@ + + + + +
+ + + + + + + + + + + + + + + 0, 0 + + + 700, 400 + + + Normal + + + 120 + + + 350 + + + 167 + + + + + + + \ No newline at end of file diff --git a/PROMS/Baseline/AutomatedTesting.sql b/PROMS/Baseline/AutomatedTesting.sql new file mode 100644 index 00000000..99d95971 --- /dev/null +++ b/PROMS/Baseline/AutomatedTesting.sql @@ -0,0 +1,145 @@ +/* ======================================================================== + Copyright 2018 - Volian Enterprises, Inc. All rights reserved. + Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + ------------------------------------------------------------------------ + This is a SQL script which can be used to create a CMD Batch file to + perform automated testing on all of the folders within the current + database and server. + ------------------------------- NOTE ----------------------------------- + There are no parameters in this script. The following values are + retrieved from the databse which is currently open + DB_NAME() - Gets the current Database Name + @@Servername - Gets the current SQL Servername + These are passed as parameters to PROMS along with some other paramters + which specifies how the procedure should be printed. + You can add REM before any folders that should not print + ****************************** CAUTION ********************************* + If you are comparing against code created before 8/1/2018 you will need + to specify /NW to exclude the Word output which had not previously been + included. + =======================================================================*/ +PRINT 'REM Blank Line Before Batch Commands +@ECHO OFF +ECHO Automated testing assumes the following: +ECHO C:\PDFS will be used to store the results of the Automated Print Testing +ECHO C:\PROMS will be used to store the executable for the Automated Print Testing +ECHO --- +ECHO The following Parameter Needs to be set: +set PROMSEXE=1.5.1805.910.Production +ECHO PROMSEXE [%PROMSEXE%] - Subfolder of the PROMS Executable +ECHO --- +ECHO Automated Testing will: +ECHO Delete PDFs +ECHO Update Formats From the folder promsformats under the PROMSEXE folder +set dbName=' + DB_NAME() + ' +set /p GroupComment=Specify Output[%PROMSEXE%_%dbName%]: || set GroupComment=%PROMSEXE%_%dbName% +ECHO AAA >%TEMP%\VEPROMS\NewFile.txt +for %%a in (%TEMP%\VEPROMS\NewFile.txt) do Set fdt=%%~ta +for /F "tokens=1,2,3,4,5,6 delims=/: " %%i in (''echo %fdt%'') do call:sc_FixTime %%k %%i %%j %%n %%l %%m +set fdt=%fdt::=%_%GroupComment% +set ServerName=' + @@Servername + ' +md %TEMP%\VEPROMS\%fdt% +echo %date% %time% Start ' + @@Servername + ' ' + DB_NAME() + '%GroupComment% >>%TEMP%\VEPROMS\%fdt%\Times.txt +del %TEMP%\VEPROMS\NewFile.txt +Rem Cleanup output folder before processing +del %temp%\VEPROMS\*.txt +del %temp%\VEPROMS\*.pdf +Rem Delete PDFs +sqlcmd -E -S%servername% -d%DBNAME% -b -Q "delete from pdfs" +if ERRORLEVEL 1 goto :oops +Rem Update Formats +call :sc_setformats unnecessary unnecessary ' + DB_NAME() + ' unnecessary %PROMSEXE% +Rem Perform PROMS printing for each Folder ---------------------------------------- +' + +declare @CommandLine nvarchar(255) +declare Commands cursor for +select 'Call :sc_PrintPDF %TEMP%\VEPROMS ' + + cast(VersionID as varchar(5))+ ' ' + db_name() + ' ' + + Replace(Replace(ff.name,' ','_'),'-','_') + ' %PROMSEXE%' + from docversions dv + join folders ff on dv.folderID = ff.FolderID + order by versionID +OPEN Commands +FETCH NEXT FROM Commands INTO @CommandLine +WHILE @@FETCH_STATUS = 0 +BEGIN + print @CommandLine + FETCH NEXT FROM Commands INTO @CommandLine +END +CLOSE Commands +DEALLOCATE Commands +PRINT 'Call :sc_MoveErrorLog ' + db_name() +' + +echo %date% %time% Done >>%TEMP%\VEPROMS\%fdt%\Times.txt +Move %TEMP%\VEPROMS\%fdt% C:\PDFs\%fdt% + +set GroupComment= +set fdt= +rem wait 20 +goto:eof + +:sc_setformats +echo loading formats from c:\proms\%5\promsformats +"C:\PROMS\%5\VEPROMS.exe" /UF=c:\proms\%5\promsformats /P= /DB=%ServerName%:%3 +timeout /T 10 +goto:eof + +:sc_PrintPDF +echo %date% %time% Start %2 (%4) >>%TEMP%\VEPROMS\%fdt%\Times.txt +echo Creating PDFs for DocVersion %2 (%4) in %3 +rem del %userprofile%\Documents\VEPROMS\%3*.txt +"C:\PROMS\%5\VEPROMS.exe" /P=%2 /DB=%ServerName%:%3 /NT /NC +rem ----------------------------------------------- +rem Add /NW to exclude Word Output to the Meta File +rem ----------------------------------------------- +echo %date% %time% Done %2 (%4) >>%TEMP%\VEPROMS\%fdt%\Times.txt +call :sc_AddText %3 %2 %4 %5 +C: +cd %1 +if not exist DebugP*.txt goto:sc_PrintPDFNoFiles +set fdt1=%fdt%\%3\%2_%4 +md %fdt1% +del DOC_*.pdf > nul +move *.pdf %fdt1% > nul +move *.txt %fdt1% > nul +for /F %%c in (''cd'') do echo Files Moved to %%c\%fdt1% +set fdt1= +goto:eof +:sc_PrintPDFNoFiles +for /F %%d in (''cd'') do echo No Files to Move in %%d +goto:eof + +:sc_FixTime +set fdt=%1%2%3_%5%6 +if "%5%4"=="12PM" goto:sc_FixTimeDone +if "%5%4"=="12AM" set fdt=%1%2%3_00%6 +if "%4"=="AM" goto:sc_FixTimeDone +if "%5"=="01" set fdt=%1%2%3_13%6 +if "%5"=="02" set fdt=%1%2%3_14%6 +if "%5"=="03" set fdt=%1%2%3_15%6 +if "%5"=="04" set fdt=%1%2%3_16%6 +if "%5"=="05" set fdt=%1%2%3_17%6 +if "%5"=="06" set fdt=%1%2%3_18%6 +if "%5"=="07" set fdt=%1%2%3_19%6 +if "%5"=="08" set fdt=%1%2%3_20%6 +if "%5"=="09" set fdt=%1%2%3_21%6 +if "%5"=="10" set fdt=%1%2%3_22%6 +if "%5"=="11" set fdt=%1%2%3_23%6 +:sc_FixTimeDone +echo %2/%3/%1 %5:%6 %4 %fdt% +goto:eof + +:sc_MoveErrorLog +move %userprofile%\Documents\VEPROMS\%1*.txt %fdt%\%1 > nul +goto:eof + +:sc_AddText +for %%a in ("%userprofile%\Documents\VEPROMS\%1 *.txt") do Set fil=%%a +echo "=========== %4 Printing Complete %2 %3 ===========" >>"%fil%" +set fil= +goto :eof + +oops: +TIMEOUT /T 60 +' \ No newline at end of file diff --git a/PROMS/Baseline/Baseline.csproj b/PROMS/Baseline/Baseline.csproj new file mode 100644 index 00000000..e867120c --- /dev/null +++ b/PROMS/Baseline/Baseline.csproj @@ -0,0 +1,107 @@ + + + + + Debug + AnyCPU + {8B29E0DE-B6C9-4041-8817-319FDE3123C4} + WinExe + Properties + Baseline + Baseline + v4.5 + 512 + SAK + SAK + SAK + SAK + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + frmBaseline.cs + + + Form + + + frmSettings.cs + + + + + frmBaseline.cs + + + frmSettings.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + PreserveNewest + + + + + \ No newline at end of file diff --git a/PROMS/Baseline/Baseline.csproj.vspscc b/PROMS/Baseline/Baseline.csproj.vspscc new file mode 100644 index 00000000..b6d32892 --- /dev/null +++ b/PROMS/Baseline/Baseline.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/PROMS/Baseline/Program.cs b/PROMS/Baseline/Program.cs new file mode 100644 index 00000000..e245b9d6 --- /dev/null +++ b/PROMS/Baseline/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Baseline +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmBaseline()); + } + } +} diff --git a/PROMS/Baseline/Properties/AssemblyInfo.cs b/PROMS/Baseline/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..3f47a66c --- /dev/null +++ b/PROMS/Baseline/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Baseline")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Baseline")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2ebd4d89-21f4-41db-b8fe-9ea40be0f23a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/PROMS/Baseline/Properties/DataSources/IgnoreLines.datasource b/PROMS/Baseline/Properties/DataSources/IgnoreLines.datasource new file mode 100644 index 00000000..48761b91 --- /dev/null +++ b/PROMS/Baseline/Properties/DataSources/IgnoreLines.datasource @@ -0,0 +1,21 @@ + + + + Baseline.IgnoreLines, Baseline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + + + + \ No newline at end of file diff --git a/PROMS/Baseline/Properties/Resources.Designer.cs b/PROMS/Baseline/Properties/Resources.Designer.cs new file mode 100644 index 00000000..1f9cf194 --- /dev/null +++ b/PROMS/Baseline/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Baseline.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Baseline.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/PROMS/Baseline/Properties/Resources.resx b/PROMS/Baseline/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/PROMS/Baseline/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PROMS/Baseline/Properties/Settings.Designer.cs b/PROMS/Baseline/Properties/Settings.Designer.cs new file mode 100644 index 00000000..ddd0a043 --- /dev/null +++ b/PROMS/Baseline/Properties/Settings.Designer.cs @@ -0,0 +1,156 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Baseline.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string Compare1 { + get { + return ((string)(this["Compare1"])); + } + set { + this["Compare1"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string Compare2 { + get { + return ((string)(this["Compare2"])); + } + set { + this["Compare2"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0, 0")] + public global::System.Drawing.Point Location { + get { + return ((global::System.Drawing.Point)(this["Location"])); + } + set { + this["Location"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("700, 400")] + public global::System.Drawing.Size Size { + get { + return ((global::System.Drawing.Size)(this["Size"])); + } + set { + this["Size"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Normal")] + public global::System.Windows.Forms.FormWindowState WidnowState { + get { + return ((global::System.Windows.Forms.FormWindowState)(this["WidnowState"])); + } + set { + this["WidnowState"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("120")] + public int Split1 { + get { + return ((int)(this["Split1"])); + } + set { + this["Split1"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("350")] + public int Split2 { + get { + return ((int)(this["Split2"])); + } + set { + this["Split2"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("167")] + public int Split3 { + get { + return ((int)(this["Split3"])); + } + set { + this["Split3"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Collections.Specialized.StringCollection MRU1 { + get { + return ((global::System.Collections.Specialized.StringCollection)(this["MRU1"])); + } + set { + this["MRU1"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + public global::System.Collections.Specialized.StringCollection MRU2 { + get { + return ((global::System.Collections.Specialized.StringCollection)(this["MRU2"])); + } + set { + this["MRU2"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string Ignore { + get { + return ((string)(this["Ignore"])); + } + set { + this["Ignore"] = value; + } + } + } +} diff --git a/PROMS/Baseline/Properties/Settings.settings b/PROMS/Baseline/Properties/Settings.settings new file mode 100644 index 00000000..b201444e --- /dev/null +++ b/PROMS/Baseline/Properties/Settings.settings @@ -0,0 +1,39 @@ + + + + + + + + + + + + 0, 0 + + + 700, 400 + + + Normal + + + 120 + + + 350 + + + 167 + + + + + + + + + + + + \ No newline at end of file diff --git a/PROMS/Baseline/frmBaseline.Designer.cs b/PROMS/Baseline/frmBaseline.Designer.cs new file mode 100644 index 00000000..88f69955 --- /dev/null +++ b/PROMS/Baseline/frmBaseline.Designer.cs @@ -0,0 +1,388 @@ +namespace Baseline +{ + partial class frmBaseline + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.panel1 = new System.Windows.Forms.Panel(); + this.btnUC = new System.Windows.Forms.Button(); + this.cbCaseSensitive = new System.Windows.Forms.CheckBox(); + this.cbFile2 = new System.Windows.Forms.ComboBox(); + this.cbFile1 = new System.Windows.Forms.ComboBox(); + this.tbSearch = new System.Windows.Forms.TextBox(); + this.btnSearch = new System.Windows.Forms.Button(); + this.btnSettings = new System.Windows.Forms.Button(); + this.btnBaseline = new System.Windows.Forms.Button(); + this.btnPagination = new System.Windows.Forms.Button(); + this.btnBrowse2 = new System.Windows.Forms.Button(); + this.btnBrowse1 = new System.Windows.Forms.Button(); + this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.splitContainer3 = new System.Windows.Forms.SplitContainer(); + this.lbDifferent = new System.Windows.Forms.ListBox(); + this.lbProcedures = new System.Windows.Forms.ListBox(); + this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.lbResults1 = new System.Windows.Forms.ListBox(); + this.lbResults2 = new System.Windows.Forms.ListBox(); + this.fbd = new System.Windows.Forms.FolderBrowserDialog(); + this.StatusBar = new System.Windows.Forms.StatusStrip(); + this.tsslStatus = new System.Windows.Forms.ToolStripStatusLabel(); + this.tt = new System.Windows.Forms.ToolTip(this.components); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); + this.splitContainer1.Panel1.SuspendLayout(); + this.splitContainer1.Panel2.SuspendLayout(); + this.splitContainer1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit(); + this.splitContainer3.Panel1.SuspendLayout(); + this.splitContainer3.Panel2.SuspendLayout(); + this.splitContainer3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); + this.splitContainer2.Panel1.SuspendLayout(); + this.splitContainer2.Panel2.SuspendLayout(); + this.splitContainer2.SuspendLayout(); + this.StatusBar.SuspendLayout(); + this.SuspendLayout(); + // + // panel1 + // + this.panel1.Controls.Add(this.btnUC); + this.panel1.Controls.Add(this.cbCaseSensitive); + this.panel1.Controls.Add(this.cbFile2); + this.panel1.Controls.Add(this.cbFile1); + this.panel1.Controls.Add(this.tbSearch); + this.panel1.Controls.Add(this.btnSearch); + this.panel1.Controls.Add(this.btnSettings); + this.panel1.Controls.Add(this.btnBaseline); + this.panel1.Controls.Add(this.btnPagination); + this.panel1.Controls.Add(this.btnBrowse2); + this.panel1.Controls.Add(this.btnBrowse1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Top; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(707, 80); + this.panel1.TabIndex = 0; + // + // btnUC + // + this.btnUC.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnUC.Enabled = false; + this.btnUC.Location = new System.Drawing.Point(586, 50); + this.btnUC.Name = "btnUC"; + this.btnUC.Size = new System.Drawing.Size(49, 23); + this.btnUC.TabIndex = 12; + this.btnUC.Text = "UC"; + this.tt.SetToolTip(this.btnUC, "Run Ultra Compare on Selected Pagination Information"); + this.btnUC.UseVisualStyleBackColor = true; + this.btnUC.Click += new System.EventHandler(this.btnUC_Click); + // + // cbCaseSensitive + // + this.cbCaseSensitive.AutoSize = true; + this.cbCaseSensitive.Location = new System.Drawing.Point(356, 56); + this.cbCaseSensitive.Name = "cbCaseSensitive"; + this.cbCaseSensitive.Size = new System.Drawing.Size(96, 17); + this.cbCaseSensitive.TabIndex = 11; + this.cbCaseSensitive.Text = "Case Sensitive"; + this.tt.SetToolTip(this.cbCaseSensitive, "Set the Search to be Case Sensitive\r\nUppercase and Lowercase will not match"); + this.cbCaseSensitive.UseVisualStyleBackColor = true; + // + // cbFile2 + // + this.cbFile2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cbFile2.FormattingEnabled = true; + this.cbFile2.Location = new System.Drawing.Point(12, 25); + this.cbFile2.Name = "cbFile2"; + this.cbFile2.Size = new System.Drawing.Size(623, 21); + this.cbFile2.TabIndex = 10; + this.tt.SetToolTip(this.cbFile2, "New PDF Folder\r\nAll Subfolders will be compared"); + // + // cbFile1 + // + this.cbFile1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cbFile1.FormattingEnabled = true; + this.cbFile1.Location = new System.Drawing.Point(12, 3); + this.cbFile1.Name = "cbFile1"; + this.cbFile1.Size = new System.Drawing.Size(623, 21); + this.cbFile1.TabIndex = 9; + this.tt.SetToolTip(this.cbFile1, "Baseline PDF Folder\r\nAll subfolders will be compared\r\n"); + // + // tbSearch + // + this.tbSearch.Location = new System.Drawing.Point(221, 54); + this.tbSearch.Name = "tbSearch"; + this.tbSearch.Size = new System.Drawing.Size(129, 20); + this.tbSearch.TabIndex = 8; + this.tt.SetToolTip(this.tbSearch, "String to search for in all data"); + // + // btnSearch + // + this.btnSearch.Location = new System.Drawing.Point(152, 52); + this.btnSearch.Name = "btnSearch"; + this.btnSearch.Size = new System.Drawing.Size(61, 23); + this.btnSearch.TabIndex = 7; + this.btnSearch.Text = "Search"; + this.tt.SetToolTip(this.btnSearch, "Perform Search on Baseline Data"); + this.btnSearch.UseVisualStyleBackColor = true; + this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click); + // + // btnSettings + // + this.btnSettings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnSettings.Location = new System.Drawing.Point(641, 50); + this.btnSettings.Name = "btnSettings"; + this.btnSettings.Size = new System.Drawing.Size(61, 26); + this.btnSettings.TabIndex = 6; + this.btnSettings.Text = "Settings"; + this.btnSettings.UseVisualStyleBackColor = true; + this.btnSettings.Click += new System.EventHandler(this.btnSettings_Click); + // + // btnBaseline + // + this.btnBaseline.Location = new System.Drawing.Point(79, 52); + this.btnBaseline.Name = "btnBaseline"; + this.btnBaseline.Size = new System.Drawing.Size(67, 23); + this.btnBaseline.TabIndex = 5; + this.btnBaseline.Text = "Baseline"; + this.tt.SetToolTip(this.btnBaseline, "Find Baseline Differences"); + this.btnBaseline.UseVisualStyleBackColor = true; + this.btnBaseline.Click += new System.EventHandler(this.btnBaseline_Click); + // + // btnPagination + // + this.btnPagination.Location = new System.Drawing.Point(3, 52); + this.btnPagination.Name = "btnPagination"; + this.btnPagination.Size = new System.Drawing.Size(70, 23); + this.btnPagination.TabIndex = 4; + this.btnPagination.Text = "Pagination"; + this.tt.SetToolTip(this.btnPagination, "Find Pagination Differences"); + this.btnPagination.UseVisualStyleBackColor = true; + this.btnPagination.Click += new System.EventHandler(this.btnPagination_Click); + // + // btnBrowse2 + // + this.btnBrowse2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnBrowse2.Location = new System.Drawing.Point(641, 25); + this.btnBrowse2.Name = "btnBrowse2"; + this.btnBrowse2.Size = new System.Drawing.Size(61, 20); + this.btnBrowse2.TabIndex = 3; + this.btnBrowse2.Text = "Browse..."; + this.tt.SetToolTip(this.btnBrowse2, "Browse for new PDFs"); + this.btnBrowse2.UseVisualStyleBackColor = true; + this.btnBrowse2.Click += new System.EventHandler(this.btnBrowse2_Click); + // + // btnBrowse1 + // + this.btnBrowse1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnBrowse1.Location = new System.Drawing.Point(641, 2); + this.btnBrowse1.Name = "btnBrowse1"; + this.btnBrowse1.Size = new System.Drawing.Size(61, 20); + this.btnBrowse1.TabIndex = 1; + this.btnBrowse1.Text = "Browse..."; + this.tt.SetToolTip(this.btnBrowse1, "Browse for Baseline PDFs\r\n"); + this.btnBrowse1.UseVisualStyleBackColor = true; + this.btnBrowse1.Click += new System.EventHandler(this.btnBrowse1_Click); + // + // splitContainer1 + // + this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer1.Location = new System.Drawing.Point(0, 80); + this.splitContainer1.Name = "splitContainer1"; + this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + this.splitContainer1.Panel1.Controls.Add(this.splitContainer3); + // + // splitContainer1.Panel2 + // + this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); + this.splitContainer1.Size = new System.Drawing.Size(707, 397); + this.splitContainer1.SplitterDistance = 196; + this.splitContainer1.TabIndex = 1; + // + // splitContainer3 + // + this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer3.Location = new System.Drawing.Point(0, 0); + this.splitContainer3.Name = "splitContainer3"; + this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // splitContainer3.Panel1 + // + this.splitContainer3.Panel1.Controls.Add(this.lbDifferent); + // + // splitContainer3.Panel2 + // + this.splitContainer3.Panel2.Controls.Add(this.lbProcedures); + this.splitContainer3.Panel2Collapsed = true; + this.splitContainer3.Size = new System.Drawing.Size(707, 196); + this.splitContainer3.SplitterDistance = 167; + this.splitContainer3.TabIndex = 0; + // + // lbDifferent + // + this.lbDifferent.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbDifferent.FormattingEnabled = true; + this.lbDifferent.Location = new System.Drawing.Point(0, 0); + this.lbDifferent.Name = "lbDifferent"; + this.lbDifferent.Size = new System.Drawing.Size(707, 196); + this.lbDifferent.TabIndex = 1; + this.tt.SetToolTip(this.lbDifferent, "Differences by Procedure Sets"); + this.lbDifferent.SelectedIndexChanged += new System.EventHandler(this.lbDifferent_SelectedIndexChanged); + // + // lbProcedures + // + this.lbProcedures.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbProcedures.FormattingEnabled = true; + this.lbProcedures.Location = new System.Drawing.Point(0, 0); + this.lbProcedures.Name = "lbProcedures"; + this.lbProcedures.Size = new System.Drawing.Size(707, 25); + this.lbProcedures.TabIndex = 1; + this.tt.SetToolTip(this.lbProcedures, "Procedures withDifferences or Search Text"); + this.lbProcedures.SelectedIndexChanged += new System.EventHandler(this.lbProcedures_SelectedIndexChanged); + // + // splitContainer2 + // + this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer2.Location = new System.Drawing.Point(0, 0); + this.splitContainer2.Name = "splitContainer2"; + // + // splitContainer2.Panel1 + // + this.splitContainer2.Panel1.Controls.Add(this.lbResults1); + // + // splitContainer2.Panel2 + // + this.splitContainer2.Panel2.Controls.Add(this.lbResults2); + this.splitContainer2.Size = new System.Drawing.Size(707, 197); + this.splitContainer2.SplitterDistance = 350; + this.splitContainer2.TabIndex = 0; + // + // lbResults1 + // + this.lbResults1.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbResults1.FormattingEnabled = true; + this.lbResults1.Location = new System.Drawing.Point(0, 0); + this.lbResults1.Name = "lbResults1"; + this.lbResults1.Size = new System.Drawing.Size(350, 197); + this.lbResults1.TabIndex = 0; + this.tt.SetToolTip(this.lbResults1, "Results from Baseline PDFs"); + this.lbResults1.SelectedIndexChanged += new System.EventHandler(this.lbResults1_SelectedIndexChanged); + // + // lbResults2 + // + this.lbResults2.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbResults2.FormattingEnabled = true; + this.lbResults2.Location = new System.Drawing.Point(0, 0); + this.lbResults2.Name = "lbResults2"; + this.lbResults2.Size = new System.Drawing.Size(353, 197); + this.lbResults2.TabIndex = 0; + this.tt.SetToolTip(this.lbResults2, "Results from New PDFs"); + this.lbResults2.SelectedIndexChanged += new System.EventHandler(this.lbResults2_SelectedIndexChanged); + // + // fbd + // + this.fbd.SelectedPath = "fbd"; + // + // StatusBar + // + this.StatusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tsslStatus}); + this.StatusBar.Location = new System.Drawing.Point(0, 477); + this.StatusBar.Name = "StatusBar"; + this.StatusBar.Size = new System.Drawing.Size(707, 22); + this.StatusBar.TabIndex = 2; + this.StatusBar.Text = "statusStrip1"; + // + // tsslStatus + // + this.tsslStatus.Name = "tsslStatus"; + this.tsslStatus.Size = new System.Drawing.Size(118, 17); + this.tsslStatus.Text = "toolStripStatusLabel1"; + // + // frmBaseline + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(707, 499); + this.Controls.Add(this.splitContainer1); + this.Controls.Add(this.StatusBar); + this.Controls.Add(this.panel1); + this.Name = "frmBaseline"; + this.Text = "Baseline"; + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.splitContainer1.Panel1.ResumeLayout(false); + this.splitContainer1.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); + this.splitContainer1.ResumeLayout(false); + this.splitContainer3.Panel1.ResumeLayout(false); + this.splitContainer3.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit(); + this.splitContainer3.ResumeLayout(false); + this.splitContainer2.Panel1.ResumeLayout(false); + this.splitContainer2.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); + this.splitContainer2.ResumeLayout(false); + this.StatusBar.ResumeLayout(false); + this.StatusBar.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button btnSettings; + private System.Windows.Forms.Button btnBaseline; + private System.Windows.Forms.Button btnPagination; + private System.Windows.Forms.Button btnBrowse2; + private System.Windows.Forms.Button btnBrowse1; + private System.Windows.Forms.SplitContainer splitContainer1; + private System.Windows.Forms.SplitContainer splitContainer2; + private System.Windows.Forms.ListBox lbResults1; + private System.Windows.Forms.ListBox lbResults2; + private System.Windows.Forms.FolderBrowserDialog fbd; + private System.Windows.Forms.StatusStrip StatusBar; + private System.Windows.Forms.ToolStripStatusLabel tsslStatus; + private System.Windows.Forms.TextBox tbSearch; + private System.Windows.Forms.Button btnSearch; + private System.Windows.Forms.SplitContainer splitContainer3; + private System.Windows.Forms.ListBox lbDifferent; + private System.Windows.Forms.ListBox lbProcedures; + private System.Windows.Forms.ComboBox cbFile2; + private System.Windows.Forms.ComboBox cbFile1; + private System.Windows.Forms.CheckBox cbCaseSensitive; + private System.Windows.Forms.Button btnUC; + private System.Windows.Forms.ToolTip tt; + } +} + diff --git a/PROMS/Baseline/frmBaseline.cs b/PROMS/Baseline/frmBaseline.cs new file mode 100644 index 00000000..3146997c --- /dev/null +++ b/PROMS/Baseline/frmBaseline.cs @@ -0,0 +1,1337 @@ +/* ======================================================================== + * Copyright 2018 - Volian Enterprises, Inc. All rights reserved. + * Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE + * ------------------------------------------------------------------------ + * This program is to automate the Comparison of PDF output using the debug + * files created during automated testing. The SQL script is used to create + * the debug files; DebugPagination.txt and DebugMeta.txt. This comparison + * code then compares these files run with two versions of the PROMS code + * and finds pages that have been impacted by the changes to the PROMS code. + * + * By Identifying Procedures and Pages that have been changed the amount of + * time required to perform comparisons is greatly reduced. + * + * The Pagination Comparison simply looks for things that have impacted page + * breaks. This is a quick summary of the page breaks for all of the + * procedures in a folder. Thus, the folders are listed which contain + * differences. When a folder is selected, the pagination information is + * compared for all of the procedures in each folder. If no changes exits, + * then the folder is not contained in the list. after selecting a folder, + * a comparison is shown of the pagination lines that are different. + * Pressing the UC button allows you to see ultracompare with the two + * pagination files. If you select a line that is different, two pdf + * windows are opened to the relative pages. + * + * The Meta Comparison looks at more detail including text and formatting + * differences. This information is organized by procedure and page. It + * uses the procedure/page/line classes. The structure of this file is + * described in + * V:\Proms Versions\Automated Testing\Baseline Metafile Key.docx + * By Clicking on a folder a list of impacted procedures is provided. + * By clicking on a Procedure a list of pages and lines are provided. + * By clicking on a line the PDF is displayed. + * + * The Search feature performs a text search on the Meta File. Looking + * for RCP will tell you where RCP can be found in the PDFs. This may be + * of use if you want to see where certain text is contained within all of + * the PDFs. Looking for [[ will find all of the special characters which + * have not yet been handled in the PROMS meta code. See FixText in + * DisplayText.cs in the PROMS code. + * ======================================================================*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Collections.Specialized; +using System.IO; +using System.Text.RegularExpressions; +using System.Xml.Serialization; +using System.Xml.Schema; +using System.Xml; +using System.Runtime.InteropServices; + +namespace Baseline +{ + enum LastWas + { + Pagination, + Baseline, + Search + }; + public enum Relation + { + Contains, + StartsWith, + EndsWith, + Regex + } + public partial class frmBaseline : Form + { + private IgnoreLines _MyIgnore = new IgnoreLines(); + public IgnoreLines MyIgnore + { + get { return _MyIgnore; } + set { _MyIgnore = value; } + } + private LastWas myLast = LastWas.Search; + private Settings MySettings; + public string MyStatus + { + get { return tsslStatus.Text; } + set + { + tsslStatus.Text = value; + Application.DoEvents(); + } + } + public frmBaseline() + { + InitializeComponent(); + LoadSettings(); + SetupEventHandlers(); + MyStatus = "Ready"; + } + #region Settings + /// + /// Setup event handlers for changes to Settings + /// + private void SetupEventHandlers() + { + this.Resize += frmBaseline_Resize; + this.Move += frmBaseline_Move; + this.splitContainer1.SplitterMoved += splitContainer1_SplitterMoved; + this.splitContainer2.SplitterMoved += splitContainer2_SplitterMoved; + this.splitContainer3.SplitterMoved += splitContainer3_SplitterMoved; + cbFile1.TextChanged += cbFile1_TextChanged; + cbFile2.TextChanged += cbFile2_TextChanged; + } + // Remember the location of splitters + void splitContainer3_SplitterMoved(object sender, SplitterEventArgs e) + { + Properties.Settings.Default.Split3 = splitContainer3.SplitterDistance; + Properties.Settings.Default.Save(); + } + void splitContainer2_SplitterMoved(object sender, SplitterEventArgs e) + { + Properties.Settings.Default.Split2 = splitContainer2.SplitterDistance; + Properties.Settings.Default.Save(); + } + void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e) + { + Properties.Settings.Default.Split1 = splitContainer1.SplitterDistance; + Properties.Settings.Default.Save(); + } + // Remember Form Location + void frmBaseline_Move(object sender, EventArgs e) + { + Properties.Settings.Default.Location = this.Location; + Properties.Settings.Default.Save(); + } + // Remember Form Size + void frmBaseline_Resize(object sender, EventArgs e) + { + if (this.WindowState == FormWindowState.Normal) + { + Properties.Settings.Default.Size = this.Size; + } + Properties.Settings.Default.WidnowState = this.WindowState; + Properties.Settings.Default.Save(); + } + // Load Settings + private void LoadSettings() + { + this.Location = Properties.Settings.Default.Location; + this.Size = Properties.Settings.Default.Size; + this.WindowState = Properties.Settings.Default.WidnowState; + if(Properties.Settings.Default.Ignore != null && Properties.Settings.Default.Ignore != "") + MyIgnore = IgnoreLines.Get(Properties.Settings.Default.Ignore); + MySettings= new Settings(); + MySettings.IgnoreLines = new BindingList(); + splitContainer1.SplitterDistance = Properties.Settings.Default.Split1; + splitContainer2.SplitterDistance = Properties.Settings.Default.Split2; + splitContainer3.SplitterDistance = Properties.Settings.Default.Split3; + if (Properties.Settings.Default.MRU1 != null && Properties.Settings.Default.MRU1.Count > 0) + { + cbFile1.Items.Clear(); + foreach (string str in Properties.Settings.Default.MRU1) + cbFile1.Items.Add(str); + cbFile1.SelectedIndex = 0; + } + if (Properties.Settings.Default.MRU2 != null && Properties.Settings.Default.MRU2.Count > 0) + { + cbFile2.Items.Clear(); + foreach (string str in Properties.Settings.Default.MRU2) + cbFile2.Items.Add(str); + cbFile2.SelectedIndex = 0; + } + } + #endregion + /// + /// Use FolderBrowserDialog to find folder + /// + /// + /// + private void btnBrowse1_Click(object sender, EventArgs e) + { + fbd.SelectedPath = cbFile1.Text; + if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) + cbFile1.Text = fbd.SelectedPath; + } + private void btnBrowse2_Click(object sender, EventArgs e) + { + fbd.SelectedPath = cbFile2.Text; + if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) + cbFile2.Text = fbd.SelectedPath; + } + /// + /// Open frmSettings to edit ignore list + /// + /// + /// + private void btnSettings_Click(object sender, EventArgs e) + { + string saveOriginal = MyIgnore.ToString(); + frmSettings mySettings = new frmSettings(MyIgnore); + if (mySettings.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + Properties.Settings.Default.Ignore = MyIgnore.ToString(); + Properties.Settings.Default.Save(); + } + else + { + MyIgnore = IgnoreLines.Get(saveOriginal); + } + } + /// + /// Process DebugPagination.txt in all sub-folders + /// + /// + /// + private void btnPagination_Click(object sender, EventArgs e) + { + myLast = LastWas.Pagination; + // Initialize lbDifferent DocVersion comparison list + lbDifferent.DataSource = null; + lbDifferent.Items.Clear(); + // Initialize line differences for DebugPagination + lbResults1.Items.Clear(); + lbResults2.Items.Clear(); + MyStatus = "Searching..."; + // Perform DebugPagination Comparison + FindFiles fnd = new FindFiles(cbFile1.Text, cbFile2.Text, "DebugPagination.txt",MyIgnore); + lbDifferent.DataSource = fnd; + lbDifferent.DisplayMember = "File1"; + MyStatus = string.Format("{0} Differences Found", fnd.Count); + } + /// + /// Fill Appropriate List Boxes when an entry is selected in lbDifferent + /// + /// + /// + private void lbDifferent_SelectedIndexChanged(object sender, EventArgs e) + { + //Initialize ListBoxes + lbProcedures.Items.Clear(); + lbResults1.Items.Clear(); + lbResults2.Items.Clear(); + FindFile ff = lbDifferent.SelectedItem as FindFile; + if (ff != null) + { + // Fill Procedure or Result ListBoxes + switch (myLast) + { + case LastWas.Pagination: + CompareContent(ff.File1, ff.File2);// Compare DebugPagination + break; + case LastWas.Baseline: + CompareContent3(ff.File1, ff.File2);// Compare DebugMeta + break; + case LastWas.Search: + ShowSearchResults(ff.File1, ff.File2);// Perform search on DebugMeta + break; + default: + CompareContent(ff.File1, ff.File2);//Default DebugPagination + break; + } + //CompareOneFile(ff.File1, ff.File2); + } + } + Procedures MyProcs1; + Procedures MyProcs2; + /// + /// Use LINQ to find a search string in the DebugMeta Files + /// + /// + /// + private void ShowSearchResults(string file1, string file2) + { + IEnumerable lines1 = File.ReadLines(file1);// LINQ Read Lines + IEnumerable lines2 = File.ReadLines(file2);// LINQ Read Lines + lines1 = AddItemIDs(lines1);// LINQ Add ItemIDs to each line to make them unique + lines2 = AddItemIDs(lines2);// LINQ Add ItemIDs to each line to make them unique + // LINQ Lambda Expression - Only includes lines that contain the search text + // Each line x such that local function Contains(tbsearch.Text, x) is true + lines1 = lines1.Where(x => Contains(tbSearch.Text, x));// LINQ Search + lines2 = lines2.Where(x => Contains(tbSearch.Text, x));// LINQ Search + // Initialize Results + lbResults1.Items.Clear(); + lbResults2.Items.Clear(); + // Initialize Procedure List + lbProcedures.Items.Clear(); + // TODO: Are the following lines necessary + string line1 = lines1.ElementAt(0); + string line2 = lines2.ElementAt(0); + // Load a List of Procedures + MyProcs1 = FillProcedures(lines1); + MyProcs2 = FillProcedures(lines2); + // Populate the Procedure ListBox + foreach (Procedure proc in MyProcs1) + { + // TODO: Is the following local variable necessary + int i = lbProcedures.Items.Add(proc); + } + MyStatus = string.Format("{0} Procedures contain {1}",MyProcs1.Count(),tbSearch.Text); + } + /// + /// Fill the Procedure ListBox + /// + /// + /// + private Procedures FillProcedures(IEnumerable lines) + { + Procedures myProcs = new Procedures(); + string lastProc = null; + int pageNumber = 0; + foreach (string line in lines) + { + if (line.StartsWith("!!")) // !! Lines contain Procedure Info + { + lastProc = line; + //Remember last Procedure line + pageNumber = 1; + } + else if (line.StartsWith("Page Change from ")) // These lines contain Page Number + { + pageNumber = int.Parse(line.Substring(line.LastIndexOf(' '))); + // Remember last page number + } + else + { + // use remembered procedure and page number to save line of text + myProcs.Add(lastProc, pageNumber, line);// Otherwise add Procedure, Page or Line + } + } + return myProcs; + } + /// + /// LINQ add ItemID Prefix to each line + /// + /// + /// + private static IEnumerable AddItemIDs(IEnumerable lines1) + { + List list1 = new List(); + string prefix = ""; + foreach (string line in lines1) + { + if (line.StartsWith("TX ")) //Get the ItemID + { + if (line.Contains("ItmID=")) + { + prefix = line.Substring(line.IndexOf("ItmID=") + 6); + } + else + prefix = ""; + list1.Add(line); + } + else if (line.Contains(" Atrbs: "))// Add the prefix to make the line unique + list1.Add(prefix + line); + else + { + prefix = ""; + list1.Add(line); + } + } + lines1 = list1.AsEnumerable();// Convert back to Enumerable to work with LINQ + return lines1; + } + private string GetProcNum(string line) + { + string retval = line.Substring(3, line.IndexOf(" | ") - 3); + if (retval.Contains("_")) + retval = retval.Substring(0, retval.IndexOf("_") - 1); + return retval; + } + /// + /// Include lines for Procedure or Page or Search is true + /// Account for Case Insensitive CheckBox + /// + /// + /// + /// + private bool Contains(string searchText, string x) + { + bool result; + if (cbCaseSensitive.Checked) + { + result = x.Contains(searchText) || x.StartsWith("Page Change from ") || Regex.IsMatch(x, @"^!![^|]+\|[^|]+?$", RegexOptions.Compiled); + } + else + { + result = x.ToUpper().Contains(searchText.ToUpper()) || x.StartsWith("Page Change from ") || Regex.IsMatch(x, @"^!![^|]+\|[^|]+?$", RegexOptions.Compiled); + } + return result; + } + private void CompareContent(string file1, string file2) + { + // Enable the UltraCompare button + // Collapse the Procedure Panel + btnUC.Enabled = splitContainer3.Panel2Collapsed = true; + IEnumerable lines1 = FindFiles.ReadFilteredLines(file1, true, MyIgnore); + IEnumerable lines2 = FindFiles.ReadFilteredLines(file2, true, MyIgnore); + IEnumerable missing1 = lines1.Except(lines2); + IEnumerable missing2 = lines2.Except(lines1); + lbResults1.Items.Clear(); + lbResults1.Items.AddRange(missing1.ToArray()); + lbResults2.Items.Clear(); + lbResults2.Items.AddRange(missing2.ToArray()); + } + /// + /// LINQ Perform DebugMeta Comparison + /// + /// + /// + private void CompareContent3(string file1, string file2) + { + // Disble the UltraCompare button + // Expand the Procedure Panel + btnUC.Enabled = splitContainer3.Panel2Collapsed = false; + IEnumerable lines1 = FindFiles.ReadFilteredLines(file1, true,MyIgnore);// LINQ Read lines excluding lines to be ignored + IEnumerable lines2 = FindFiles.ReadFilteredLines(file2, true, MyIgnore);// LINQ Read lines excluding lines to be ignored + lines1 = AddItemIDs(lines1);// LINQ Add ItemID prefix to make lines unique + lines2 = AddItemIDs(lines2);// LINQ Add ItemID prefix to make lines unique + // The following lines create a list of lines without Page Numbers or procedures + // They are removed from this list so that they will not be impacted by the intersect below + IEnumerable noPageNumbers1 = lines1.Where(x => x.StartsWith("Page Change from ") == false);// LINQ get lines without Page Numbers + IEnumerable noPageNumbers2 = lines2.Where(x => x.StartsWith("Page Change from ") == false);// LINQ get lines without Page Numbers + noPageNumbers1 = noPageNumbers1.Where(x => x.StartsWith("!! ") == false);//LINQ remove lines with !! + noPageNumbers2 = noPageNumbers2.Where(x => x.StartsWith("!! ") == false);//LINQ remove lines with !! + IEnumerable intersect = noPageNumbers1.Intersect(noPageNumbers2);//LINQ find Matchhing lines + List lIntersect = intersect.ToList();//LINQ Create a list of matching lines + HashSet hs = new HashSet(intersect);// LINQ Create a HashSet of matching lines + IEnumerable missing1 = lines1.Where(x => !hs.Contains(x));// LINQ Remove matching lines + IEnumerable missing2 = lines2.Where(x => !hs.Contains(x));// LINQ Remove matching lines + MyProcs1 = FillProcedures(missing1);// Fill Procedures from the lines that don't match (including Procedure and Page Number lines) + MyProcs2 = FillProcedures(missing2);// Fill Procedures from the lines that don't match (including Procedure and Page Number lines) + if (MyProcs1 != null && MyProcs1.Count > 0)// Fill Procedure ListBox with MyProcs1 + { + foreach (Procedure proc in MyProcs1) + lbProcedures.Items.Add(proc); + MyStatus = string.Format("{0} Procedures found with differences", MyProcs1.Count()); + } + else if (MyProcs2 != null && MyProcs2.Count > 0)// Fill Procedure ListBox with MyProcs1 + { + foreach (Procedure proc in MyProcs2) + lbProcedures.Items.Add(proc); + MyStatus = string.Format("{0} Procedures found with differences", MyProcs2.Count()); + } + } + /// + /// Open One or more PDF's + /// + /// + /// + private void lbResults1_SelectedIndexChanged(object sender, EventArgs e) + { + string line=null; + if (lbResults1.SelectedItem is string) + line = (string)lbResults1.SelectedItem; + Line myLine = lbResults1.SelectedItem as Line; + switch (myLast) + { + case LastWas.Pagination: + line = OpenPDF(line); + break; + case LastWas.Baseline: // TODO: Need to add code here to open matching file + OpenOnePDF(myLine,1); + break; + case LastWas.Search: // TODO: Need to add code here to open matching file + OpenOnePDF(myLine,1); + break; + default: + break; + } + } + private void lbResults2_SelectedIndexChanged(object sender, EventArgs e) + { + + string line=null; + if(lbResults2.SelectedItem is string) + line = (string)lbResults2.SelectedItem; + Line myLine = lbResults2.SelectedItem as Line; + + switch (myLast) + { + case LastWas.Pagination: + line = OpenPDF(line); + break; + case LastWas.Baseline: // TODO: Need to add code here to open matching file + OpenOnePDF(myLine,2); + break; + case LastWas.Search: // TODO: Need to add code here to open matching file + OpenOnePDF(myLine,2); + break; + default: + break; + } + } + string exePath; + private string OpenPDF(string line) + { + int page = int.Parse(line.Substring(0, 6)); + line = line.Substring(8, line.IndexOf(".S") - 8); + FindFile ff = lbDifferent.SelectedItem as FindFile; + FileInfo fi1 = new FileInfo(ff.File1); + FileInfo fi2 = new FileInfo(ff.File2); + // 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 + } + // 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.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 "); + 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; + } + /// + /// Try to get the location of the PDF Reader executable + /// + /// Process of PDF Reader + /// + private string TryToGetPath(System.Diagnostics.Process p) + { + p.WaitForInputIdle(); + while (p.MainModule == null) + { + Console.WriteLine("{0} - {1}", p.MainWindowTitle,p.ProcessName); + p.WaitForInputIdle(); + Application.DoEvents(); + } + return p.MainModule.FileName; + } + /// + /// Start UltraCompare of two files + /// + /// + /// + private void CompareOneFile(string compareFile, string baseFile) + { + //Console.WriteLine("Compare {0} and {1}", compareFile, baseFile); + string progname = string.Empty; + if (System.IO.File.Exists(@"C:\Program Files\IDM Computer Solutions\UltraCompare\UC.exe")) + progname = @"C:\Program Files\IDM Computer Solutions\UltraCompare\UC.exe"; + if (System.IO.File.Exists(@"C:\Program Files (x86)\IDM Computer Solutions\UltraCompare\UC.exe")) + progname = @"C:\Program Files (x86)\IDM Computer Solutions\UltraCompare\UC.exe"; + System.Diagnostics.ProcessStartInfo psi = + new System.Diagnostics.ProcessStartInfo(progname, string.Format(@" -t ""{0}"" ""{1}""", compareFile, baseFile)); + System.Diagnostics.Process prc = System.Diagnostics.Process.Start(psi); + } + + private ProcessLocationQueue myQueue= new ProcessLocationQueue(); + private Timer queueTimer = null; + /// + /// Move a Process to a specific screen location - This is done with a timer so + /// that it waits until windows are finished being initialized. + /// + /// + /// + /// + private void MoveProcess(System.Diagnostics.Process proc, int x, int y) + { + if (queueTimer == null) + { + queueTimer = new Timer(); + queueTimer.Enabled = false; + queueTimer.Tick += queueTimer_Tick; + queueTimer.Interval = 1000; + } + myQueue.Add(proc, x, y); + if (!queueTimer.Enabled) + queueTimer.Enabled = true; + } + /// + /// timer tick for moving a process window + /// + /// + /// + void queueTimer_Tick(object sender, EventArgs e) + { + while (myQueue.Count > 0) + myQueue.ProcessNext(); + queueTimer.Enabled = false; + } + /// + /// Open PDF associated with the selected line + /// + /// + /// + private void OpenOnePDF(Line myLine, int list) + { + string proc = myLine.MyProc.Number; + 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(); + } + 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); + } + else + { + 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); + } + } + /// + /// Perform Debug Meta file comparison for all of the folders within the automated testing folders + /// + /// + /// + private void btnBaseline_Click(object sender, EventArgs e) + { + myLast = LastWas.Baseline; + lbDifferent.DataSource = null; + // Initialize Differnce and Results ListBoxes + lbDifferent.Items.Clear(); + lbResults1.Items.Clear(); + lbResults2.Items.Clear(); + MyStatus = "Searching..."; + // Perform code to find DebugMeta files with diffences + FindFiles fnd = new FindFiles(cbFile1.Text, cbFile2.Text, "DebugMeta.txt",MyIgnore); + lbDifferent.DataSource = fnd; + lbDifferent.DisplayMember = "File1"; + MyStatus = string.Format("{0} Differences Found", fnd.Count); + } + /// + /// Perform search of all the DocVersions Debug.Meta Files + /// + /// + /// + private void btnSearch_Click(object sender, EventArgs e) + { + // Disble the UltraCompare button + // Expand the Procedure Panel + btnUC.Enabled= splitContainer3.Panel2Collapsed = false; + myLast = LastWas.Search; + // Initialize ListBoxes + lbDifferent.DataSource = null; + lbDifferent.Items.Clear(); + lbResults1.Items.Clear(); + lbResults2.Items.Clear(); + MyStatus = "Searching..."; + //Perform Search + FindFiles fnd = new FindFiles(cbFile1.Text, cbFile2.Text, "DebugMeta.txt", tbSearch.Text, SearchType.Contains, cbCaseSensitive.Checked); + lbDifferent.DataSource = fnd; + lbDifferent.DisplayMember = "File1"; + MyStatus = string.Format("{0} Differences Found", fnd.Count); + } + bool InHandler1 = false; + // Track changes to the File Path 1 including Most Recent Used + private void cbFile1_TextChanged(object sender, EventArgs e) + { + if (InHandler1) return; + InHandler1 = true; + string str = cbFile1.Text; + while (cbFile1.Items.Contains(str)) + cbFile1.Items.Remove(str); + cbFile1.Items.Insert(0, str); + cbFile1.SelectedIndex = 0; + Properties.Settings.Default.MRU1 = new System.Collections.Specialized.StringCollection(); + foreach (string str1 in cbFile1.Items) + Properties.Settings.Default.MRU1.Add(str1); + Properties.Settings.Default.Save(); + InHandler1 = false; + } + bool InHandler2 = false; + // Track changes to the File Path 2 including Most Recent Used + private void cbFile2_TextChanged(object sender, EventArgs e) + { + if (InHandler2) return; + InHandler2 = true; + string str = cbFile2.Text; + while (cbFile2.Items.Contains(str)) + cbFile2.Items.Remove(str); + cbFile2.Items.Insert(0, str); + cbFile2.SelectedIndex = 0; + Properties.Settings.Default.MRU2 = new System.Collections.Specialized.StringCollection(); + foreach (string str2 in cbFile2.Items) + Properties.Settings.Default.MRU2.Add(str2); + Properties.Settings.Default.Save(); + InHandler2 = false; + } + private void lbProcedures_SelectedIndexChanged(object sender, EventArgs e) + { + //Initialize Results List Box + lbResults1.Items.Clear(); + Procedure myProc = lbProcedures.SelectedItem as Procedure; + //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 + if (myProc1 != null) + { + foreach (Page myPage in myProc1.MyPages) + { + lbResults1.Items.Add(myPage); + foreach (Line myLine in myPage.MyLines) + lbResults1.Items.Add(myLine); + } + } + lbResults2.Items.Clear(); + // Build the results ListBox for the right window + Procedure myProc2 = MyProcs2.Find(x => x.Number == myProc.Number && x.Title == myProc.Title); + if (myProc2 != null) + { + foreach (Page myPage in myProc2.MyPages) + { + lbResults2.Items.Add(myPage); + foreach (Line myLine in myPage.MyLines) + lbResults2.Items.Add(myLine); + } + } + } + /// + /// Open Ultra Compare for the currently selected DocVersion + /// + /// + /// + private void btnUC_Click(object sender, EventArgs e) + { + if (myLast == LastWas.Pagination) + { + FindFile ff = lbDifferent.SelectedItem as FindFile; + CompareOneFile(ff.File1, ff.File2); + } + } + } + public enum SearchType + { + Contains, + StartsWith, + EndsWith + }; + public class Settings + { + private BindingList _IgnoreLines; + public BindingList IgnoreLines + { + get { return _IgnoreLines; } + set { _IgnoreLines = value; } + } + } + public partial class FindFile + { + private string _File1; + public string File1 + { + get { return _File1; } + set { _File1 = value; } + } + private string _File2; + public string File2 + { + get { return _File2; } + set { _File2 = value; } + } + public FindFile(string file1, string file2) + { + File1 = file1; + File2 = file2; + } + } + public partial class FindFiles : List + { + private string _FileName; + public string FileName + { + get { return _FileName; } + } + /// + /// Build list of DocVersion Folders with differences + /// + /// Base path + /// Compare path + /// filename + /// Ignore list + public FindFiles(string path1, string path2, string fileName,IgnoreLines myIgnore) + { + DirectoryInfo di1 = new DirectoryInfo(path1); + DirectoryInfo di2 = new DirectoryInfo(path2); + _FileName = fileName; + FillByCompare(di1, di2, fileName, myIgnore); + } + /// + /// Fill for a search + /// + /// + /// + /// + /// + /// + /// + public FindFiles(string path1, string path2, string fileName, string searchText, SearchType searchType, bool caseSensitive) + { + DirectoryInfo di1 = new DirectoryInfo(path1); + DirectoryInfo di2 = new DirectoryInfo(path2); + _FileName = fileName; + FillByCompare(di1, di2, fileName,searchText,searchType, caseSensitive); + } + /// + /// Fill results by search + /// + /// + /// + /// + /// + /// + /// + private void FillByCompare(DirectoryInfo di1, DirectoryInfo di2, string fileName, string searchText, SearchType searchType, bool caseSensitive) + { + foreach (DirectoryInfo diChild1 in di1.GetDirectories()) + { + DirectoryInfo diChild2 = new DirectoryInfo(di2.FullName + "\\" + diChild1.Name); + if (diChild2.Exists) + FillByCompare(diChild1, diChild2, fileName,searchText,searchType,caseSensitive); + } + foreach (FileInfo fiChild1 in di1.GetFiles(fileName)) + { + FileInfo fiChild2 = new FileInfo(di2.FullName + "\\" + fiChild1.Name); + if (fiChild2.Exists) + { + if (CompareFile(fiChild1, fiChild2,searchText,searchType, caseSensitive)) + Add(new FindFile(fiChild1.FullName, fiChild2.FullName)); + } + } + } + /// + /// LINQ Peform Searc on DebugMeta files in all DocVersion folders + /// + /// + /// + /// + /// + /// + /// + private bool CompareFile(FileInfo fiChild1, FileInfo fiChild2, string searchText, SearchType searchType,bool caseSensitive) + { + IEnumerable lines1=null; + IEnumerable lines2=null; + switch (searchType) + { + case SearchType.Contains: + if (caseSensitive) + { + lines1 = File.ReadLines(fiChild1.FullName).Where(x => x.Contains(searchText)); + lines2 = File.ReadLines(fiChild2.FullName).Where(x => x.Contains(searchText)); + } + else + { + lines1 = File.ReadLines(fiChild1.FullName).Where(x => x.ToUpper().Contains(searchText.ToUpper())); + lines2 = File.ReadLines(fiChild2.FullName).Where(x => x.ToUpper().Contains(searchText.ToUpper())); + } + break; + case SearchType.StartsWith: + if (caseSensitive) + { + lines1 = File.ReadLines(fiChild1.FullName).Where(x => x.StartsWith(searchText)); + lines2 = File.ReadLines(fiChild2.FullName).Where(x => x.StartsWith(searchText)); + } + else + { + lines1 = File.ReadLines(fiChild1.FullName).Where(x => x.ToUpper().StartsWith(searchText.ToUpper())); + lines2 = File.ReadLines(fiChild2.FullName).Where(x => x.ToUpper().StartsWith(searchText.ToUpper())); + } + break; + case SearchType.EndsWith: + if (caseSensitive) + { + lines1 = File.ReadLines(fiChild1.FullName).Where(x => x.EndsWith(searchText)); + lines2 = File.ReadLines(fiChild2.FullName).Where(x => x.EndsWith(searchText)); + } + else + { + lines1 = File.ReadLines(fiChild1.FullName).Where(x => x.ToUpper().EndsWith(searchText.ToUpper())); + lines2 = File.ReadLines(fiChild2.FullName).Where(x => x.ToUpper().EndsWith(searchText.ToUpper())); + } + break; + } + if (lines1 != null && lines2 != null) + { + if ((lines1.Count() > 0) || (lines2.Count() > 0)) + { + return true; + } + return false; + } + return false; + } + private void FillByCompare(DirectoryInfo di1, DirectoryInfo di2, string fileName, IgnoreLines myIgnore) + { + foreach (DirectoryInfo diChild1 in di1.GetDirectories()) + { + DirectoryInfo diChild2 = new DirectoryInfo(di2.FullName + "\\" + diChild1.Name); + if (diChild2.Exists) + FillByCompare(diChild1, diChild2, fileName,myIgnore);// Recursively work on Sub-Folders + } + foreach (FileInfo fiChild1 in di1.GetFiles(fileName)) + { + FileInfo fiChild2 = new FileInfo(di2.FullName + "\\" + fiChild1.Name); + if (fiChild2.Exists) + { + if (CompareFile(fiChild1, fiChild2,myIgnore)) + Add(new FindFile(fiChild1.FullName, fiChild2.FullName));// Process Each File + } + } + } + private bool CompareFile(FileInfo fiChild1, FileInfo fiChild2,IgnoreLines myIgnore) + { + if (fiChild1.Name == "DebugMeta.txt") + { + IEnumerable lines1 = ReadFilteredLines(fiChild1.FullName, false, myIgnore);//LINQ Read lines without ignored lines + IEnumerable lines2 = ReadFilteredLines(fiChild2.FullName, false, myIgnore);//LINQ Read lines without ignored lines + if (lines1.Except(lines2).Count() == 0 && + lines2.Except(lines1).Count() == 0) //Look for lines in one file that are not in the other + return false; + return true; + } + else + { + string file1Contents = ReadContents(fiChild1);// This is just a simple text comparison + string file2Contents = ReadContents(fiChild2); + return !file1Contents.Equals(file2Contents); + } + } + /// + /// LINQ - Readlines and remove items based upon the ignore list + /// + /// + /// + /// + /// + public static IEnumerable ReadFilteredLines(string child1, bool includeProcedures, IgnoreLines myIgnore) + { + IEnumerable lines = File.ReadLines(child1); + lines = lines.Where(x => FindProcedure(x,includeProcedures)); + foreach (IgnoreLine ignore in myIgnore) + { + if (ignore.Active) + { + switch (ignore.SearchType) + { + case Relation.Contains: + lines = lines.Where(x => x.Contains(ignore.Text) == false); + break; + case Relation.StartsWith: + lines = lines.Where(x => x.StartsWith(ignore.Text) == false); + break; + case Relation.EndsWith: + lines = lines.Where(x => x.EndsWith(ignore.Text) == false); + break; + case Relation.Regex: + Regex myreg = new Regex(ignore.Text, RegexOptions.Compiled); + lines = lines.Where(x => myreg.IsMatch(x) == false); + break; + default: + break; + } + } + } + return lines; + } + /// + /// Find a procedure line in a meta file + /// + /// + /// + /// + private static bool FindProcedure(string x, bool includeProcedures) + { + bool result = x.StartsWith("!!") == false; + if(includeProcedures) result |= Regex.IsMatch(x, @"^!![^|]+\|[^|]+?$", RegexOptions.Compiled); + return result; + } + /// + /// basic text read + /// + /// + /// + private string ReadContents(FileInfo fiChild1) + { + StreamReader sr = fiChild1.OpenText(); + string buff = sr.ReadToEnd(); + return buff; + } + } + // Classes for structured data storage used for meta file comparisons + // + // Procedure contains: + // Number - Procedure Number + // Title - Procedure Title + // MyPages - The Page objects associated with this procedure + // + // Page contains: + // Number - PageNumber + // MyLines - The Line Objects associated with this Page + // + // Line contains: + // MyProc - The containing procedure + // MyPage - the containing page + // Text - the line of text + public partial class Procedure + { + private string _Number; + public string Number + { + get { return _Number; } + set { _Number = value; } + } + private string _Title; + public string Title + { + get { return _Title; } + set { _Title = value; } + } + private Pages _MyPages = new Pages(); + public Pages MyPages + { + get { return _MyPages; } + set { _MyPages = value; } + } + public Procedure(string number, string title) + { + _Number = number; + _Title = title; + } + public override string ToString() + { + return string.Format("{0} - {1}", Number, Title); + } + } + public partial class Procedures : List + { + // Sample data for a Procedure Number line + // !! E-0 | Reactor Trip Or Safety Injection + // The First Group is the Procedure Number + // The Second Group is the Procedure Title + public Regex parseLine = new Regex("^!! (.*) \\| (.*)$", RegexOptions.Compiled); + /// + /// This adds a procedure, page and line class as needed, If the procedure + /// already exists it is used. If the page already exists it is used. + /// + /// Procedure Line matches Regular Expression above + /// Page Number + /// Text from the meta File + public void Add(string lastProc, int pageNumber, string text) + { + if (lastProc == null) return; + Match m = parseLine.Match(lastProc); + if (m.Success) + { + Procedure myProc = this.Find(x => x.Number.Equals(m.Groups[1].ToString()) && x.Title.Equals(m.Groups[2].ToString())); + if (myProc == null) this.Add(myProc = new Procedure(m.Groups[1].ToString(), m.Groups[2].ToString())); + Page myPage = myProc.MyPages.Find(x => x.Number == pageNumber); + if (myPage == null) myProc.MyPages.Add(myPage = new Page(pageNumber)); + myPage.MyLines.Add(new Line(text, myProc, myPage)); + } + } + } + public partial class Page + { + private int _Number; + public int Number + { + get { return _Number; } + set { _Number = value; } + } + private Lines _MyLines = new Lines(); + + public Lines MyLines + { + get { return _MyLines; } + set { _MyLines = value; } + } + public Page(int number) + { + _Number = number; + } + public override string ToString() + { + return string.Format("Page {0}", Number); + } + } + public partial class Pages : List + { + public void Add(int number) + { + Add(new Page(number)); + } + } + public partial class Line + { + private Procedure _MyProc; + public Procedure MyProc + { + get { return _MyProc; } + set { _MyProc = value; } + } + private Page _MyPage; + public Page MyPage + { + get { return _MyPage; } + set { _MyPage = value; } + } + private string _Text; + public string Text + { + get { return _Text; } + set { _Text = value; } + } + public Line(string text) + { + _Text = text; + } + public Line(string text, Procedure myProc, Page myPage) + { + _Text = text; + _MyProc = myProc; + _MyPage = myPage; + } + public override string ToString() + { + return Text; + } + } + public partial class Lines : List + { + public void Add(string text) + { + Add(new Line(text)); + } + } + [Serializable] + public partial class IgnoreLine + { + private bool _Active = true; + public bool Active + { + get { return _Active; } + set { _Active = value; } + } + private Relation _SearchType = Relation.Contains; + public Relation SearchType + { + get { return _SearchType; } + set { _SearchType = value; } + } + private string _Text; + public string Text + { + get { return _Text; } + set { _Text = value; } + } + public IgnoreLine(string text, Relation searchType, bool active) + { + Text = text; + SearchType = searchType; + Active = active; + } + public IgnoreLine() + { + } + } + [Serializable] + public partial class IgnoreLines : BindingList + { + public IgnoreLines() + { + } + public void Add(string text, Relation searchType, bool active) + { + Add(new IgnoreLine(text, searchType, active)); + } + // Convert IgnoreLines to string (XML) + public override string ToString() + { + return GenericSerializer.StringSerialize(this); + } + // Convert string to IgnoreLines + public static IgnoreLines Get(string xml) + { + return GenericSerializer.StringDeserialize(xml); + } + } + /// + /// This is a simple serializer that takes a class and converts it to and from string (XML) + /// + /// + public static class GenericSerializer where T : class + { + public static string StringSerialize(T t) + { + string strOutput = string.Empty; + XmlSerializer xs = new XmlSerializer(typeof(T)); + using (MemoryStream ms = new MemoryStream()) + { + xs.Serialize(new NonXsiTextWriter(ms, Encoding.Unicode), t); + //xs.Serialize(ms, t); + ms.Position = 0; + StreamReader sr = new StreamReader(ms); + strOutput = sr.ReadToEnd(); + ms.Close(); + } + return strOutput; + } + public static T StringDeserialize(string s) + { + T t; + string ss = s.Replace("encoding=\"utf-16\"", ""); + XmlSerializer xs = new XmlSerializer(typeof(T)); + UTF8Encoding enc = new UTF8Encoding(); + Byte[] arrBytData = enc.GetBytes(ss); + using (MemoryStream ms = new MemoryStream(arrBytData)) + { + t = (T)xs.Deserialize(ms); + } + return t; + } + } + /// + /// This XML Writer makes the XML more simple by excluding the XSI attributes from the serializer + /// + public class NonXsiTextWriter : XmlTextWriter + { + public NonXsiTextWriter(TextWriter w) : base(w) { } + public NonXsiTextWriter(Stream w, Encoding encoding) + : base(w, encoding) + { + this.Formatting = Formatting.Indented; + } + public NonXsiTextWriter(string filename, Encoding encoding) : base(filename, encoding) { } + bool _skip = false; + public override void WriteStartAttribute(string prefix, string localName, string ns) + { + if ((prefix == "xmlns" && (localName == "xsd" || localName == "xsi")) || // Omits XSD and XSI declarations. + ns == XmlSchema.InstanceNamespace) // Omits all XSI attributes. + { + _skip = true; + return; + } + if (localName == "xlink_href") + base.WriteStartAttribute(prefix, "xlink:href", ns); + else + base.WriteStartAttribute(prefix, localName, ns); + } + public override void WriteString(string text) + { + if (_skip) return; + base.WriteString(text); + } + public override void WriteEndAttribute() + { + if (_skip) + { // Reset the flag, so we keep writing. + _skip = false; + return; + } + base.WriteEndAttribute(); + } + } + /// + /// Class to support moving a process window + /// + public class ProcessLocation + { + [DllImport("user32.dll", EntryPoint = "SetWindowPos")] + public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags); + public const short SWP_NOMOVE = 0X2; + public const short SWP_NOSIZE = 1; + public const short SWP_NOZORDER = 0X4; + public const int SWP_SHOWWINDOW = 0x0040; + + private System.Diagnostics.Process _Process; + + public System.Diagnostics.Process Process + { + get { return _Process; } + set { _Process = value; } + } + private int _X; + public int X + { + get { return _X; } + set { _X = value; } + } + private int _Y; + public int Y + { + get { return _Y; } + set { _Y = value; } + } + public ProcessLocation(System.Diagnostics.Process process, int x, int y) + { + Process = process; + X = x; + Y = y; + } + public void MoveIt() + { + SetWindowPos(Process.MainWindowHandle, 0, X, Y, 200, 400, SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOZORDER); + } + } + public class ProcessLocationQueue: Queue + { + public void Add(System.Diagnostics.Process process, int x, int y) + { + Enqueue(new ProcessLocation(process,x,y)); + } + public void ProcessNext() + { + ProcessLocation pl = Dequeue(); + pl.MoveIt(); + } + } +} diff --git a/PROMS/Baseline/frmBaseline.resx b/PROMS/Baseline/frmBaseline.resx new file mode 100644 index 00000000..2f985086 --- /dev/null +++ b/PROMS/Baseline/frmBaseline.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 306, 17 + + + 306, 17 + + + 17, 17 + + + 203, 17 + + \ No newline at end of file diff --git a/PROMS/Baseline/frmSettings.Designer.cs b/PROMS/Baseline/frmSettings.Designer.cs new file mode 100644 index 00000000..ba116e47 --- /dev/null +++ b/PROMS/Baseline/frmSettings.Designer.cs @@ -0,0 +1,150 @@ +namespace Baseline +{ + partial class frmSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.dgv = new System.Windows.Forms.DataGridView(); + this.panel1 = new System.Windows.Forms.Panel(); + this.btnOK = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.dgvcSearchType = new System.Windows.Forms.DataGridViewComboBoxColumn(); + this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ignoreLinesBindingSource = new System.Windows.Forms.BindingSource(this.components); + ((System.ComponentModel.ISupportInitialize)(this.dgv)).BeginInit(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.ignoreLinesBindingSource)).BeginInit(); + this.SuspendLayout(); + // + // dgv + // + this.dgv.AutoGenerateColumns = false; + this.dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgv.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.dataGridViewCheckBoxColumn1, + this.dgvcSearchType, + this.dataGridViewTextBoxColumn3}); + this.dgv.DataSource = this.ignoreLinesBindingSource; + this.dgv.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgv.Location = new System.Drawing.Point(0, 0); + this.dgv.Name = "dgv"; + this.dgv.Size = new System.Drawing.Size(515, 219); + this.dgv.TabIndex = 1; + this.dgv.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.dgv_DataError); + // + // panel1 + // + this.panel1.Controls.Add(this.btnCancel); + this.panel1.Controls.Add(this.btnOK); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 219); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(515, 77); + this.panel1.TabIndex = 2; + // + // btnOK + // + this.btnOK.Location = new System.Drawing.Point(347, 51); + this.btnOK.Name = "btnOK"; + this.btnOK.Size = new System.Drawing.Size(75, 23); + this.btnOK.TabIndex = 0; + this.btnOK.Text = "OK"; + this.btnOK.UseVisualStyleBackColor = true; + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(428, 51); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 1; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // dataGridViewCheckBoxColumn1 + // + this.dataGridViewCheckBoxColumn1.DataPropertyName = "Active"; + this.dataGridViewCheckBoxColumn1.FillWeight = 50F; + this.dataGridViewCheckBoxColumn1.HeaderText = "Active"; + this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1"; + this.dataGridViewCheckBoxColumn1.Resizable = System.Windows.Forms.DataGridViewTriState.True; + // + // dgvcSearchType + // + this.dgvcSearchType.DataPropertyName = "SearchType"; + this.dgvcSearchType.HeaderText = "SearchType"; + this.dgvcSearchType.Name = "dgvcSearchType"; + this.dgvcSearchType.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.dgvcSearchType.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + // + // dataGridViewTextBoxColumn3 + // + this.dataGridViewTextBoxColumn3.DataPropertyName = "Text"; + this.dataGridViewTextBoxColumn3.HeaderText = "Text"; + this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3"; + this.dataGridViewTextBoxColumn3.Width = 200; + // + // ignoreLinesBindingSource + // + this.ignoreLinesBindingSource.DataSource = typeof(Baseline.IgnoreLine); + // + // frmSettings + // + this.AcceptButton = this.btnOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(515, 296); + this.Controls.Add(this.dgv); + this.Controls.Add(this.panel1); + this.Name = "frmSettings"; + this.Text = "frmSettings"; + this.Load += new System.EventHandler(this.frmSettings_Load); + ((System.ComponentModel.ISupportInitialize)(this.dgv)).EndInit(); + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.ignoreLinesBindingSource)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.BindingSource ignoreLinesBindingSource; + private System.Windows.Forms.DataGridView dgv; + private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1; + private System.Windows.Forms.DataGridViewComboBoxColumn dgvcSearchType; + private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnOK; + + } +} \ No newline at end of file diff --git a/PROMS/Baseline/frmSettings.cs b/PROMS/Baseline/frmSettings.cs new file mode 100644 index 00000000..361fe543 --- /dev/null +++ b/PROMS/Baseline/frmSettings.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Baseline +{ + public partial class frmSettings : Form + { + private IgnoreLines _MyIgnore; + public IgnoreLines MyIgnore + { + get { return _MyIgnore; } + set { + _MyIgnore = value; + dgv.DataSource=null; + //dgvcSearchType.ValueType = typeof(Relation); + //dgvcSearchType.ValueMember = "Value"; + //dgvcSearchType.DisplayMember = "Display"; + //dgvcSearchType.DataSource = new Relation[] { Relation.Contains, Relation.StartsWith, Relation.EndsWith, Relation.Regex } + //.Select(x => new { Display = x.ToString(), Value = x }) + //.ToList(); + dgv.DataSource=value; + //dgvcSearchType.DataSource = + //new List((Relation[]) Enum.GetValues(typeof(Relation))) + //.Select(x => new { Display=x.ToString(), Value=(int)x }) + //.ToList();; + } + } + public frmSettings(IgnoreLines myIgnore) + { + InitializeComponent(); + _MyIgnore=myIgnore; + } + private void frmSettings_Load(object sender, EventArgs e) + { + dgv.DataSource=MyIgnore; + DataGridViewComboBoxColumn col = dgvcSearchType; + col.Name = "My Enum Column"; + col.DataSource = Enum.GetValues(typeof(Relation)); + col.ValueType = typeof(Relation); + } + + private void dgv_DataError(object sender, DataGridViewDataErrorEventArgs e) + { + Console.WriteLine("Here"); + } + private void btnOK_Click(object sender, EventArgs e) + { + this.DialogResult = System.Windows.Forms.DialogResult.OK; + this.Close(); + } + private void btnCancel_Click(object sender, EventArgs e) + { + this.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.Close(); + } + } +} diff --git a/PROMS/Baseline/frmSettings.resx b/PROMS/Baseline/frmSettings.resx new file mode 100644 index 00000000..bcc83e9b --- /dev/null +++ b/PROMS/Baseline/frmSettings.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 17, 17 + + \ No newline at end of file