C2017-003: Support SQL Server for storing of Referenced Object data
This commit is contained in:
@@ -30,7 +30,10 @@ using System.IO;
|
||||
using System.Data;
|
||||
using RODBInterface;
|
||||
using VlnStatus;
|
||||
|
||||
using System.Data.SqlClient;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using System.Xml.Schema;
|
||||
|
||||
// CmpRpt reads data for the RO database and puts the data into the
|
||||
// temporary file, 'print.tmp'. After this, it is sorted and printed.
|
||||
@@ -137,12 +140,27 @@ namespace CmpRpt
|
||||
// for the Access database.
|
||||
string roIdArg = BuildROList(args);
|
||||
string[] roIDList = roIdArg.Split(',');
|
||||
if (args.Length == 2)
|
||||
if (args.Length == 2 || args.Length == 3)
|
||||
{
|
||||
string path = args[0];
|
||||
Directory.SetCurrentDirectory(path);
|
||||
}
|
||||
myrodb = new RODB(Directory.GetCurrentDirectory());
|
||||
if (SqlConnectionStr != null)
|
||||
myrodb = new SqlRODB(Directory.GetCurrentDirectory(), SqlConnectionStr, false);
|
||||
else
|
||||
{
|
||||
myrodb = new AccessRODB(Directory.GetCurrentDirectory());
|
||||
// if using access, be sure that the data has not been converted. When converted a record will be inserted w/ type = 8 and the info
|
||||
// will contain the connection string.
|
||||
string constring = myrodb.RODB_HasBeenConverted();
|
||||
if (constring != null)
|
||||
{
|
||||
MessageBox.Show("This Referenced Object Database has been converted to sql. Attempting to use the sql version of the database. If this does not work, contact your Database Administrator", "RO access problem");
|
||||
SqlConnectionStr = constring;
|
||||
myrodb.dbProviderType = (int)RODB.DB_PROVIDER.SQL_SERVER;
|
||||
myrodb = new SqlRODB(Directory.GetCurrentDirectory(), SqlConnectionStr, true);
|
||||
}
|
||||
}
|
||||
VlnXmlElement rptele = null;
|
||||
|
||||
// Add the root to the tree
|
||||
@@ -258,22 +276,50 @@ namespace CmpRpt
|
||||
if (showStatBar != null)
|
||||
showStatBar.Dispose();
|
||||
}
|
||||
|
||||
private static string BuildROList(string[] args)
|
||||
// C2017-003: use sql
|
||||
static public string SqlConnectionStr = null;
|
||||
static public SqlConnection ROAPP_SqlConnection
|
||||
{
|
||||
string parm2 = args[args.Length - 1];
|
||||
string roIdArg = null;
|
||||
if (parm2.StartsWith("/f="))
|
||||
get
|
||||
{
|
||||
FileInfo fi = new FileInfo(parm2.Substring(3));
|
||||
using (StreamReader sr = fi.OpenText())
|
||||
// Attempt to make a connection
|
||||
SqlConnection cn = new SqlConnection(SqlConnectionStr);
|
||||
try
|
||||
{
|
||||
roIdArg = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
cn.Open();
|
||||
return cn;
|
||||
}
|
||||
catch (SqlException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Could Not Make Connection To Database");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
roIdArg = parm2;
|
||||
}
|
||||
private static string BuildROList(string[] args)
|
||||
{
|
||||
// when ro's in sql was added, an /sql parameter was introduced to allow the definition of the connection string. So
|
||||
// go through list of args to find the one w/ /f= to find filename that has the ro list in it.
|
||||
string roIdArg = null;
|
||||
for (int i = 1; i<=args.Length-1; i++)
|
||||
{
|
||||
string parm2 = args[i];
|
||||
if (parm2.StartsWith("/f="))
|
||||
{
|
||||
FileInfo fi = new FileInfo(parm2.Substring(3));
|
||||
using (StreamReader sr = fi.OpenText())
|
||||
{
|
||||
roIdArg = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
}
|
||||
}
|
||||
else if (parm2.StartsWith("/sql="))
|
||||
{
|
||||
SqlConnectionStr = parm2.Substring(5);
|
||||
}
|
||||
else
|
||||
roIdArg = parm2;
|
||||
}
|
||||
return roIdArg;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user