checking in latest panaceantech into git
This commit is contained in:
@@ -33,14 +33,15 @@ namespace quickftp
|
||||
string user = gQuery.Properties.Settings.Default.AdvantageUser;
|
||||
string pass = gQuery.Properties.Settings.Default.AdvantagePass;
|
||||
string fpath = AssemblyW.SpecializedAssemblyInfo.GetAssemblyPath(AssemblyW.AssemblyST.Executing);
|
||||
string fname = DateTime.Now.ToShortDateString().Replace('/', '_');
|
||||
//string fname = DateTime.Now.ToShortDateString().Replace('/', '_');
|
||||
|
||||
if (String.IsNullOrEmpty(path) || String.IsNullOrEmpty(user) || String.IsNullOrEmpty(pass))
|
||||
{
|
||||
// If no db configuration found (* RUN WIZARD * TO DO )
|
||||
Console.WriteLine("Advantage settings blank or null");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
AdvantageCredential cred = new AdvantageCredential(path, user, pass, AdvantageCredential.ServerType.REMOTE_LOCAL);
|
||||
if(!cred.IsValid)
|
||||
{
|
||||
@@ -48,22 +49,40 @@ namespace quickftp
|
||||
return;
|
||||
}
|
||||
|
||||
string query1 = ReadQuery("query1.txt");
|
||||
// Find Queries
|
||||
string[] queries = Directory.GetFiles(fpath, "query*.*");
|
||||
if(queries == null || queries.Length < 1)
|
||||
{
|
||||
Console.WriteLine("No queries found");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string q in queries)
|
||||
{
|
||||
ExecuteForEveryFileFound(q, cred, fpath, q.ToLower().Replace("query","result"));
|
||||
}
|
||||
|
||||
Process.GetCurrentProcess().Close();
|
||||
}
|
||||
|
||||
public static void ExecuteForEveryFileFound(string filename, AdvantageCredential cred, string fpath, string outfile)
|
||||
{
|
||||
string query1 = ReadQuery(filename);
|
||||
if (String.IsNullOrEmpty(query1))
|
||||
return;
|
||||
|
||||
DB db = DB.Create(cred);
|
||||
DBRetVal retVal = db.FillDataTable(query1);
|
||||
if(!retVal.IsValid)
|
||||
if (!retVal.IsValid)
|
||||
{
|
||||
Console.WriteLine(retVal.ErrorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
DataTable dt = retVal.GetDataTableRetVal();
|
||||
|
||||
|
||||
StringBuilder sbColumns = new StringBuilder();
|
||||
foreach (DataColumn c in dt.Columns)
|
||||
{
|
||||
@@ -73,28 +92,25 @@ namespace quickftp
|
||||
String columnHeader = sbColumns.ToString().Substring(0, sbColumns.Length - 1);
|
||||
String[] columns = columnHeader.Split(',');
|
||||
|
||||
FileWriter fw = new FileWriter(fname, "csv", fpath);
|
||||
FileWriter fw = new FileWriter(outfile, "csv", fpath);
|
||||
fw.WriteLineA(columnHeader);
|
||||
|
||||
|
||||
foreach (DataRow r in dt.Rows)
|
||||
{
|
||||
StringBuilder sbRow = new StringBuilder();
|
||||
for (int i = 0; i < columns.Length; ++i)
|
||||
{
|
||||
sbRow.Append(DataRet_Retrieve(r[columns[i]]));
|
||||
sbRow.Append(',');
|
||||
sbRow.Append(',');
|
||||
}
|
||||
String rowValues = sbRow.ToString().Substring(0, sbRow.Length - 1);
|
||||
fw.WriteLineA(rowValues);
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
|
||||
|
||||
Process.GetCurrentProcess().Close();
|
||||
}
|
||||
|
||||
public static string ReadQuery(string filename)
|
||||
|
||||
Reference in New Issue
Block a user