本文整理汇总了C#中Connection.getConnInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.getConnInfo方法的具体用法?C# Connection.getConnInfo怎么用?C# Connection.getConnInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.getConnInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getKML
public XmlDocument getKML(int connID)
{
String serverPath = "http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + ":"
+ HttpContext.Current.Request.ServerVariables["SERVER_PORT"];
//create new connection a populate fields to get the connection name for KMLGenerator
Connection conn = new Connection(connID);
conn.populateFields();
string name = conn.getConnInfo().getConnectionName();
//create a new kml genereator with the connection name as the placemark name
KMLGenerator kmlGen = new KMLGenerator(name, serverPath);
string kml = "";
//generate the kml for the given connID
try
{
kml = kmlGen.generateKML(connID);
}
catch (Exception e)
{
//if there was an error generating kml, return a kml file that contains only a screen overlay that states there was an error generating kml
kml = "<ScreenOverlay> <name>KML Error</name> <Icon> <href>" + serverPath + "/graphics/kml-error.png</href> </Icon> <overlayXY x=\"0.5\" y=\"0.5\" xunits=\"fraction\" yunits=\"fraction\"/> <screenXY x=\"0.5\" y=\"0.5\" xunits=\"fraction\" yunits=\"fraction\"/> <rotationXY x=\"0\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/> <size x=\"1\" y=\"0.2\" xunits=\"fraction\" yunits=\"fraction\"/></ScreenOverlay>";
}
//add the kml to an XMLDoc and return
XmlDocument kmlDoc = new XmlDocument();
kmlDoc.LoadXml(kml);
return kmlDoc;
}
示例2: genKMLFunction
protected void genKMLFunction(object sender, EventArgs e)
{
try
{
//Generate the KML from the connection
ImageButton sendBtn = (ImageButton)sender;
String serverPath = "http://" + Request.ServerVariables["SERVER_NAME"] + ":" + Request.ServerVariables["SERVER_PORT"];
string args = sendBtn.CommandArgument.ToString();
KMLGenerator kml = new KMLGenerator(ConnInfo.getConnInfo(Convert.ToInt32(args)).getConnectionName(), serverPath);
//Generate the KML string based on the connection id
String kmlString = kml.generateKML(int.Parse(args));
Connection conn = new Connection(int.Parse(args));
conn.populateFields();
//Write the KML string to a downloadable file
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/vnd.google-earth.kml+xml kml";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + (conn.getConnInfo()).getConnectionName() + ".kml");
Response.Write(kmlString);
Response.End();
return;
}
catch (ODBC2KMLException ex)
{
ErrorHandler err = new ErrorHandler(ex.errorText, errorPanel1);
err.displayError();
return;
}
//Response.Redirect("Main.aspx", true);
}
示例3: generateKMLFromConnection
/// <summary>
/// This function takes a connection object and generates all the associated KML for that connection.
/// It works hand-in-hand with KMLGenerationLibrary, Styles, and Placemarks.
///
/// There is also a helper class used to prevent duplicate styles (HashStyleComparer).
/// </summary>
/// <param name="connection">Connection --> connection object for the connection that you wish to generate KML for</param>
/// <returns>String --> A string that is the KML</returns>
public string generateKMLFromConnection(Connection connection)
{
//if the mapping is invalid, throw an exception and don't try to continue
if (!connection.mapping.isValid(connection.connInfo))
{
throw new ODBC2KMLException("There was an exception generating KML. Mapping is invalid.");
}
//Needed to generate KML, parameter is desired file name within KML file
KMLGenerationLibrary kmlGenerator = new KMLGenerationLibrary(this.fileName);
try
{
//Get mappings fromc onnection object
Mapping map = connection.getMapping();
//Create array list to hold places
ArrayList placemarks = new ArrayList();
//Create hashset to hold unique styles, takes HashStyleComparer which is a helper class
HashSet<Style> styles = new HashSet<Style>(new HashStyleComparer());
//Create the Icon array and grabs the icons for the connection
ArrayList icons = new ArrayList();
icons = connection.getIcons();
//Create the overlay array and grab the overlays for the connection
ArrayList overlays = new ArrayList();
overlays = connection.getOverlays();
//Retrieve description string
String descString = connection.getDescription().getDesc();
//Create an array to store new description values
ArrayList descArray = new ArrayList();
//Create data table to pass to parser
DataTable remote = null;
//Create database
Database DB = new Database(connection.getConnInfo());
//Grab the tablename out of mapping
String tableName = map.getTableName();
try
{
if (connection.getConnInfo().getDatabaseType() == ConnInfo.MSSQL)
{
remote = DB.executeQueryRemote("SELECT * FROM " + tableName);
}
else if (connection.getConnInfo().getDatabaseType() == ConnInfo.MYSQL)
{
remote = DB.executeQueryRemote("SELECT * FROM " + tableName + ";");
}
else if (connection.getConnInfo().getDatabaseType() == ConnInfo.ORACLE)
{
remote = DB.executeQueryRemote("SELECT * FROM \"" + tableName + "\"");
}
}
catch
{
throw new ODBC2KMLException("There was an exception generating KML. There was a problem retreiving data from the remote server");
}
//Parsed descriptions for rows
descArray = Description.parseDesc(remote, descString, tableName);
int counter = 0;
//For each row in the table!!!
foreach (DataRow remoteRow in remote.Rows)
{
//Set placemark name
string placemarkName;
try
{
if (map.getPlacemarkFieldName() == null || map.getPlacemarkFieldName().Trim().Equals("") || map.getPlacemarkFieldName().Trim().Equals("No placemark name mapped"))
{
placemarkName = "";
}
else
{
placemarkName = (String)remoteRow[map.getPlacemarkFieldName()];
}
}
catch
{
throw new ODBC2KMLException("There was an exception generating KML. Error parsing placemark.");
}
//Foreach row set the description for each row
String rowDesc = descArray[counter].ToString();
//.........这里部分代码省略.........