diff --git a/PROMS/PromsGetDoc/App.config b/PROMS/PromsGetDoc/App.config
new file mode 100644
index 00000000..8e156463
--- /dev/null
+++ b/PROMS/PromsGetDoc/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PROMS/PromsGetDoc/PROMSGETDOC/App.config b/PROMS/PromsGetDoc/PROMSGETDOC/App.config
new file mode 100644
index 00000000..8e156463
--- /dev/null
+++ b/PROMS/PromsGetDoc/PROMSGETDOC/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PROMS/PromsGetDoc/PROMSGETDOC/Program.cs b/PROMS/PromsGetDoc/PROMSGETDOC/Program.cs
new file mode 100644
index 00000000..39dfeee4
--- /dev/null
+++ b/PROMS/PromsGetDoc/PROMSGETDOC/Program.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Data;
+using System.Data.Sql;
+using System.Data.SqlClient;
+using System.IO;
+
+namespace PromsGetDoc
+{
+ class Program
+ {
+ // arguments are:
+ // docId
+ // filename/pathname for resulting word doc
+ // sql server name
+ // database name
+
+ // Can be run from command line or from macro in microsoft office tools as shown here:
+ // Sub Macro1()
+ // Call Shell("""Path_To_Exe\PromsGetDoc.exe"" 5 C:\temp\sample3.doc .\sqlexpress veproms_app", vbNormalFocus)
+ // End Sub
+ static void Main(string[] args)
+ {
+ if (args.Length != 4)
+ {
+ Console.WriteLine("Need 4 arguments: DocId, Output File/Path, Server Name, Database Name");
+ return;
+ }
+ byte[] doc = null;
+ int _docId = int.Parse(args[0]);
+ string connectionStr = string.Format(@"Data Source={0};Initial Catalog={1};Integrated Security=True", args[2], args[3]);
+ try
+ {
+ using (SqlConnection cn = new SqlConnection(connectionStr))
+ {
+ cn.Open(); // do I need this?
+ using (SqlCommand cm = cn.CreateCommand())
+ {
+ cm.CommandType = CommandType.StoredProcedure;
+ cm.CommandText = "getDocument";
+ cm.Parameters.AddWithValue("@DocID", _docId);
+ cm.CommandTimeout = 100;
+ using (SqlDataReader dr = cm.ExecuteReader())
+ {
+ if (!dr.Read())
+ {
+ Console.WriteLine("ERROR: No Record Found");
+ return;
+ }
+ doc = (byte[])dr.GetValue(2);
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("ERROR: Could not access/read data. Check server and database name. " + ex.Message);
+ return;
+ }
+ if (doc != null)
+ {
+ try
+ {
+ FileInfo fi = new FileInfo(args[1]);
+ FileStream fs = fi.Create();
+ fs.Write(doc, 0, doc.Length);
+ fs.Close();
+ }
+ catch (Exception ex1)
+ {
+ Console.WriteLine("ERROR: Could not write Word file. " + ex1.Message);
+ return;
+ }
+ }
+ }
+ }
+}
diff --git a/PROMS/PromsGetDoc/PROMSGETDOC/PromsGetDoc.csproj b/PROMS/PromsGetDoc/PROMSGETDOC/PromsGetDoc.csproj
new file mode 100644
index 00000000..6d87707d
--- /dev/null
+++ b/PROMS/PromsGetDoc/PROMSGETDOC/PromsGetDoc.csproj
@@ -0,0 +1,58 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}
+ Exe
+ Properties
+ PromsGetDoc
+ PromsGetDoc
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PROMS/PromsGetDoc/PROMSGETDOC/PromsGetDoc.sln b/PROMS/PromsGetDoc/PROMSGETDOC/PromsGetDoc.sln
new file mode 100644
index 00000000..d387d948
--- /dev/null
+++ b/PROMS/PromsGetDoc/PROMSGETDOC/PromsGetDoc.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30723.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PromsGetDoc", "PromsGetDoc.csproj", "{97C3A741-3C26-453D-9F2F-F083CB62B45C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/PROMS/PromsGetDoc/Program.cs b/PROMS/PromsGetDoc/Program.cs
new file mode 100644
index 00000000..39dfeee4
--- /dev/null
+++ b/PROMS/PromsGetDoc/Program.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Data;
+using System.Data.Sql;
+using System.Data.SqlClient;
+using System.IO;
+
+namespace PromsGetDoc
+{
+ class Program
+ {
+ // arguments are:
+ // docId
+ // filename/pathname for resulting word doc
+ // sql server name
+ // database name
+
+ // Can be run from command line or from macro in microsoft office tools as shown here:
+ // Sub Macro1()
+ // Call Shell("""Path_To_Exe\PromsGetDoc.exe"" 5 C:\temp\sample3.doc .\sqlexpress veproms_app", vbNormalFocus)
+ // End Sub
+ static void Main(string[] args)
+ {
+ if (args.Length != 4)
+ {
+ Console.WriteLine("Need 4 arguments: DocId, Output File/Path, Server Name, Database Name");
+ return;
+ }
+ byte[] doc = null;
+ int _docId = int.Parse(args[0]);
+ string connectionStr = string.Format(@"Data Source={0};Initial Catalog={1};Integrated Security=True", args[2], args[3]);
+ try
+ {
+ using (SqlConnection cn = new SqlConnection(connectionStr))
+ {
+ cn.Open(); // do I need this?
+ using (SqlCommand cm = cn.CreateCommand())
+ {
+ cm.CommandType = CommandType.StoredProcedure;
+ cm.CommandText = "getDocument";
+ cm.Parameters.AddWithValue("@DocID", _docId);
+ cm.CommandTimeout = 100;
+ using (SqlDataReader dr = cm.ExecuteReader())
+ {
+ if (!dr.Read())
+ {
+ Console.WriteLine("ERROR: No Record Found");
+ return;
+ }
+ doc = (byte[])dr.GetValue(2);
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine("ERROR: Could not access/read data. Check server and database name. " + ex.Message);
+ return;
+ }
+ if (doc != null)
+ {
+ try
+ {
+ FileInfo fi = new FileInfo(args[1]);
+ FileStream fs = fi.Create();
+ fs.Write(doc, 0, doc.Length);
+ fs.Close();
+ }
+ catch (Exception ex1)
+ {
+ Console.WriteLine("ERROR: Could not write Word file. " + ex1.Message);
+ return;
+ }
+ }
+ }
+ }
+}
diff --git a/PROMS/PromsGetDoc/PromsGetDoc.csproj b/PROMS/PromsGetDoc/PromsGetDoc.csproj
new file mode 100644
index 00000000..6d87707d
--- /dev/null
+++ b/PROMS/PromsGetDoc/PromsGetDoc.csproj
@@ -0,0 +1,58 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}
+ Exe
+ Properties
+ PromsGetDoc
+ PromsGetDoc
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PROMS/PromsGetDoc/PromsGetDoc.sln b/PROMS/PromsGetDoc/PromsGetDoc.sln
new file mode 100644
index 00000000..d387d948
--- /dev/null
+++ b/PROMS/PromsGetDoc/PromsGetDoc.sln
@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.30723.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PromsGetDoc", "PromsGetDoc.csproj", "{97C3A741-3C26-453D-9F2F-F083CB62B45C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {97C3A741-3C26-453D-9F2F-F083CB62B45C}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal