Added Error Handling code
Added a new parameter to SaveSectionDocument and Error Handling Changed error handling for InvokeMember to throw an exception Added code to change the view to PrintMode when determining length
This commit is contained in:
parent
1741b0e3e0
commit
2c14e4113b
@ -79,16 +79,7 @@ namespace DataLoader
|
||||
// See if there is PSI and if so, add it to the xml.
|
||||
OleDbDataAdapter dapsi = new OleDbDataAdapter("select * from [" + dr["entry"] + "] where [STEP] is null", cn);
|
||||
int handleBefore = HandleCount;
|
||||
try
|
||||
{
|
||||
dapsi.Fill(ds);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
//Application.Exit();
|
||||
throw ex; // Exit from Data Loader
|
||||
}
|
||||
TryToLoadDataSet(ds, fname, dapsi);
|
||||
int handleAfter = HandleCount;
|
||||
if (!RunWithDB2K && handleAfter - handleBefore > 10)
|
||||
{
|
||||
@ -268,6 +259,40 @@ namespace DataLoader
|
||||
ds.Dispose();
|
||||
return itm;
|
||||
}
|
||||
|
||||
private static void TryToLoadDataSet(DataSet ds, string fname, OleDbDataAdapter dapsi)
|
||||
{
|
||||
try
|
||||
{
|
||||
dapsi.Fill(ds);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FileInfo fi;
|
||||
switch (ex.Message)
|
||||
{
|
||||
case "Index file not found.":// then delete inf file
|
||||
fi = new FileInfo(fname.ToLower().Replace(".dbf",".inf"));
|
||||
fi.Delete();
|
||||
TryToLoadDataSet(ds, fname, dapsi); // Try again
|
||||
break;
|
||||
case "External table is not in the expected format.": // then pad dbt file with 128 zeros.
|
||||
fi = new FileInfo(fname.ToLower().Replace(".dbf", ".dbt"));
|
||||
FileStream fs = fi.OpenWrite();
|
||||
fs.Position = fs.Length;
|
||||
byte[] buf = new byte[128];
|
||||
for (int i = 0; i < 128; i++) buf[i] = 0;
|
||||
fs.Write(buf, 0, 128);
|
||||
fs.Close();
|
||||
TryToLoadDataSet(ds, fname, dapsi); // Try again
|
||||
break;
|
||||
default: // Unrecognized error
|
||||
Console.WriteLine(ex.Message);
|
||||
//Application.Exit();
|
||||
throw new Exception("Error in MigrateProcedure: " + fname, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool dB2KInstalled()
|
||||
{
|
||||
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"software\dBase\dB2K");
|
||||
@ -316,7 +341,7 @@ namespace DataLoader
|
||||
catch (Exception ex)
|
||||
{
|
||||
_MyLog.ErrorFormat("MigrateProcedures - {0} - {1}\r\n\r\n{2}", pth,ex.Message, ex.InnerException);
|
||||
throw ex;
|
||||
throw new Exception("Error in MigrateProcedures: " + pth, ex);
|
||||
}
|
||||
return FirstItm;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ namespace DataLoader
|
||||
string thenum = num.ToString("d2");
|
||||
fname = string.Format("{0}\\rtffiles\\{1}.A{2}", pth, ProcFileName, thenum);
|
||||
Application.DoEvents();
|
||||
SaveSectionDocument(fname, stpseq, SecType, ref Documentid);
|
||||
SaveSectionDocument(fname, stpseq, SecType, ref Documentid, procitem.DisplayNumber + ":" + (Number == string.Empty ? Title : Number));
|
||||
if (Documentid == 0)
|
||||
{
|
||||
if (MissingDocument==null) MissingDocument = Document.MakeDocument("MISSING FILE IN CONVERSION", null, null, null);
|
||||
@ -453,6 +453,8 @@ namespace DataLoader
|
||||
}
|
||||
}
|
||||
Item secitem = AddSection(procitem, num, title, stype, dts, init, ci, step + sequence, fmt, libDocid, pth, FromItem, sectFormat);
|
||||
if (secitem == null)
|
||||
throw (new Exception("Null parameter in AddSection"));
|
||||
thesectid = secitem.ItemID;
|
||||
|
||||
// if the editsectid hasn't been set yet, set it to this section id, i.e. the first
|
||||
|
@ -42,15 +42,7 @@ namespace LBWordLibrary
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append(string.Format("{0}.{1} {2} - {3}", _MyType.Name, name, bf.ToString(), ex.GetType().Name));
|
||||
string prefix = "\r\n ";
|
||||
do
|
||||
{
|
||||
sb.Append(prefix + ex.Message);
|
||||
ex = ex.InnerException;
|
||||
} while (ex != null);
|
||||
Console.WriteLine(sb.ToString());
|
||||
throw new Exception(string.Format("LBComObject.DoInvokeMember {0}.{1}", _MyType.Name, name), ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -263,6 +263,8 @@ namespace LBWordLibrary
|
||||
{
|
||||
get
|
||||
{
|
||||
ActiveWindow.ActivePane.View.Type = LBWdViewType.wdPrintView;
|
||||
ActiveWindow.View.Type = LBWdViewType.wdPrintView;
|
||||
LBPages myPages = ActiveWindow.ActivePane.Pages;// Start with pages
|
||||
float retval = (float)myPages.Count - 1;
|
||||
LBRange myRange = Range();
|
||||
@ -485,7 +487,7 @@ namespace LBWordLibrary
|
||||
string previous = LBDocumentClass.GetRangeText(myRange);
|
||||
if (Regex.IsMatch(previous, "[A-Z]")) return true;
|
||||
if (Regex.IsMatch(previous, "[a-z]")) return false;
|
||||
start = start - 1;
|
||||
start = start - 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user