diff --git a/PROMS/DataLoader/OutsideTransition.cs b/PROMS/DataLoader/OutsideTransition.cs index df069c28..19ddf62f 100644 --- a/PROMS/DataLoader/OutsideTransition.cs +++ b/PROMS/DataLoader/OutsideTransition.cs @@ -57,45 +57,67 @@ namespace DataLoader string xtproccmd = "SELECT * FROM [xtprocid] WHERE [SETID]='" + setid + "' AND [PROCID]='" + procid + "'"; using (OleDbDataAdapter da = new OleDbDataAdapter(xtproccmd, _DbConnect)) { - DataSet ds = new DataSet(); - da.Fill(ds); - DataTable dt = ds.Tables[0]; - dt.CaseSensitive = true; - DataRow dr = dt.Rows[0]; // there should be only one entry! - retval = dr["Procnum"].ToString(); // this should be the procedure number! - ds.Dispose(); + try + { + DataSet ds = new DataSet(); + da.Fill(ds); + DataTable dt = ds.Tables[0]; + dt.CaseSensitive = true; + DataRow dr = dt.Rows[0]; // there should be only one entry! + retval = dr["Procnum"].ToString(); // this should be the procedure number! + ds.Dispose(); + } + catch (Exception ex) + { + return "";//ex.GetType().Name + " " + ex.Message; + } } return retval; } private string GetPath(string setid) { - string xtsetcmd = "SELECT * FROM [xtsetid] WHERE [SETID]='" + setid + "'"; - OleDbDataAdapter da = new OleDbDataAdapter(xtsetcmd, _DbConnect); - DataSet ds = new DataSet(); - da.Fill(ds); - DataTable dt = ds.Tables[0]; - dt.CaseSensitive = true; - DataRow dr = dt.Rows[0]; // there should be only one entry! - string retval = dr["Path"].ToString(); - da.Dispose(); - ds.Dispose(); - return retval; // dr["Path"].ToString(); // this should be the path to the proc set! + try + { + string xtsetcmd = "SELECT * FROM [xtsetid] WHERE [SETID]='" + setid + "'"; + OleDbDataAdapter da = new OleDbDataAdapter(xtsetcmd, _DbConnect); + DataSet ds = new DataSet(); + da.Fill(ds); + DataTable dt = ds.Tables[0]; + dt.CaseSensitive = true; + DataRow dr = dt.Rows[0]; // there should be only one entry! + string retval = dr["Path"].ToString(); + da.Dispose(); + ds.Dispose(); + return retval; // dr["Path"].ToString(); // this should be the path to the proc set! + } + catch (Exception ex) + { + return "";//ex.GetType().Name + " " + ex.Message; + } } private string GetTitle(string setid, string procid) { - string xtproccmd = "SELECT * FROM [xtprocid] WHERE [SETID]='" + setid + "' AND [PROCID]='" + procid + "'"; - OleDbDataAdapter da = new OleDbDataAdapter(xtproccmd, _DbConnect); - DataSet ds = new DataSet(); - da.Fill(ds); - DataTable dt = ds.Tables[0]; - dt.CaseSensitive = true; - DataRow dr = dt.Rows[0]; // there should be only one entry! - string retval = dr["Proctitle"].ToString(); - da.Dispose(); - ds.Dispose(); - return retval; // dr["Proctitle"].ToString(); // this should be the procedure number! + try + { + + string xtproccmd = "SELECT * FROM [xtprocid] WHERE [SETID]='" + setid + "' AND [PROCID]='" + procid + "'"; + OleDbDataAdapter da = new OleDbDataAdapter(xtproccmd, _DbConnect); + DataSet ds = new DataSet(); + da.Fill(ds); + DataTable dt = ds.Tables[0]; + dt.CaseSensitive = true; + DataRow dr = dt.Rows[0]; // there should be only one entry! + string retval = dr["Proctitle"].ToString(); + da.Dispose(); + ds.Dispose(); + return retval; // dr["Proctitle"].ToString(); // this should be the procedure number! + } + catch (Exception ex) + { + return "";//ex.GetType().Name + " " + ex.Message; + } } public string GetDescription(string key) @@ -222,18 +244,27 @@ namespace DataLoader private static DocVersionInfo PartialMatch(string path) { string partial = GetPartial(path); - foreach (DocVersionInfo dvi in _DocVersions) + if (partial != null) { - if (dvi.MyFolder.Title.ToUpper().EndsWith(partial.ToUpper())) - return dvi; + foreach (DocVersionInfo dvi in _DocVersions) + { + if (dvi.MyFolder.Title.ToUpper().EndsWith(partial.ToUpper())) + return dvi; + } } return null; } private static string GetPartial(string path) { - string[] parts = path.Split("\\".ToCharArray()); - return "\\" + parts[parts.Length - 2] + "\\" + parts[parts.Length - 1]; + Console.WriteLine(string.Format("GetPartial path = {0}",path)); + if (path.Contains("\\")) + { + string[] parts = path.Split("\\".ToCharArray()); + return "\\" + parts[parts.Length - 2] + "\\" + parts[parts.Length - 1]; + } + else + return null; } private static DocVersionInfo ExactMatch(string path)