I need to write additonal catch code that if there is not any or a new Asettype that it creates a error.kml file or it continues not matter what. How it is now it fails if there is a new asset type and it is not in the styles.txt file.
CODE::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: public void GenerateKmlFilesFromLatestOrbitImport( )
{
string connString = GetRegValue("FemaDbConn", "").ToString();
string styles = GetStyles();
string kml="";
string mastermap="";
int orbitImportId = GetOrbitImportId( connString );
DataSet assetTypes = GetAssetTypes(connString);
if( assetTypes.Tables.Count > 0 && assetTypes.Tables[0].Rows.Count > 0)
{
foreach( DataRow assetType in assetTypes.Tables[0].Rows )
{
kml=" <Folder> \n <name>"+ assetType["ShortDesc"] +"</name> \n";
DataSet kmlInfos = GetAssetKmlOfType((int)assetType["AssetTypeId"], orbitImportId, connString);
if( kmlInfos.Tables.Count > 0 && kmlInfos.Tables[0].Rows.Count > 0)
{
foreach( DataRow kmlInfo in kmlInfos.Tables[0].Rows )
{
kml+=" <Placemark>\n";
kml+=" <name>" + kmlInfo["EsnNumber"] + "</name>\n";
kml+=" <styleUrl>#" + assetType["ShortDesc"] + "</styleUrl>\n";
kml+=" <description>\n";
kml+=" <![CDATA[\n";
kml+=" Description: " + kmlInfo["Description"] + "<br>\n" ;
kml+=" Asset BC: " + kmlInfo["Barcode"] +"<br>\n";
kml+=" Description Detail: "+ kmlInfo["Description"] + "<br>\n";
kml+=" SKU: " + kmlInfo["Sku"]+"<br>\n";
kml+=" Inventory W/H: " + kmlInfo["WarehouseDescription"]+"<br>\n";
kml+=" Last Ping: " + kmlInfo["TraceTime"].ToString()+"<br>\n";
kml+=" Distance from Landmark: " + kmlInfo["DistanceMiles"].ToString()+"<br>\n";
kml+=" Landmark: " + kmlInfo["Landmark"]+"<br>\n";
kml+=" Has Moved: " + kmlInfo["HasMoved"].ToString()+"<br>\n" ;
kml+=" ]]>\n";
kml+=" </description>\n";
kml+=" <visibility>0</visibility>\n";
kml+=" <LookAt>\n";
kml+=" <heading>-0.00895499</heading>\n";
kml+=" <title>39.4365</title>\n";
kml+=" <range>214.17</range>\n";
kml+=" <latitude>" + kmlInfo["Latitude"] + "</latitude>\n";
kml+=" <longitude>"+ kmlInfo["Longitude"] + "</longitude>\n";
kml+=" </LookAt>\n";
kml+=" <Point>\n";
kml+=" <coordinates>"+ kmlInfo["Longitude"] +","+ kmlInfo["Latitude"] +",500</coordinates>\n";
kml+=" </Point>\n";
kml+=" </Placemark>\n\n";
}
kml+=" </Folder>\n";
mastermap+=kml;
try
{
CreateKeyHoleFile(assetType["ShortDesc"].ToString(), kml, styles);
}
catch (Exception cfile){}
}
}
CreateKeyHoleFile("mastermap", mastermap, styles);
}
}
private string GetStyles()
{
string styles = "";
StreamReader re = File.OpenText("c:\\FEMA\\styles.txt");
string input = null;
while ((input = re.ReadLine()) != null)
{
styles += input + "\n";
}
re.Close();
return styles;
}

Help fixing my catch mehod
mxapacbell
manuel0081
catch (Exception) // We will ignore whatever it is
{
... do specialized processing ...
}
Hence you have handled all possiblities and the code can commence. But I get the feeling there is more to your issue...