Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Need to create Null kml file

Author  Topic 

danjapro
Starting Member

44 Posts

Posted - 2006-09-08 : 14:16:04
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;
}
   

- Advertisement -