This commit is contained in:
parent
29e9fa6b74
commit
0ee3442b0d
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
@ -1,80 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{97C3A741-3C26-453D-9F2F-F083CB62B45C}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PromsGetDoc</RootNamespace>
|
||||
<AssemblyName>PromsGetDoc</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@ -1,22 +0,0 @@
|
||||
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user