public bool ImportDesiredVariables(DbConnection conn, IDataClient client, string filename, string tablename)
{
if ((string.IsNullOrEmpty(filename)) || (!File.Exists(filename)))
{
_log.DebugFormat("ImportDesiredVariables failed: provided filename was empty or did not exist \"{0}\" ", filename);
return false;
}
try
{
//empty/create our temporary table
DataTable dt = SetupTable(conn, client, tablename);
//get a list of the columns they wanted
dt = ReadVariablesFile(filename, dt);
//check all our error scenarios
TableChecker[] fnList = new TableChecker[] {
CheckForMaxColumns,
CheckForMinColumns,
CheckForDuplicates,
CheckForMOEDuplicates,
CheckForReserved
};
bool noErrors = true;
foreach (var errCheckFn in fnList)
{
string msg = errCheckFn(dt);
if (!string.IsNullOrEmpty(msg))
{
noErrors = false;
_log.Error(msg);
}
}
if (!noErrors)
{
return false;
}
SaveTable(conn, client, dt);
return true;
}
catch (Exception ex)
{
_log.Error("Variable Import Failed", ex);
RemoveTemporaryTable(conn, client);
}
return false;
}