当前位置: 首页>>代码示例>>C#>>正文


C# Connection.populateFields方法代码示例

本文整理汇总了C#中Connection.populateFields方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.populateFields方法的具体用法?C# Connection.populateFields怎么用?C# Connection.populateFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.populateFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: generateKML

        /// <summary>
        /// This function takes a connection ID and generates all the associated KML for that connection.
        /// It works hand-in-hand with KMLGenerationLibrary, Styles, and Placemarks.
        /// It also calls generateKMLFromConnection.
        /// 
        /// There is also a helper class used to prevent duplicate styles (HashStyleComparer).
        /// </summary>
        /// <param name="connID">int --> connection ID for the connection that you wish to generate KML for</param>
        /// <returns>String --> A string that is the KML</returns>
        public string generateKML(int connID)
        {
            Connection connection = new Connection(connID);
            connection.populateFields();

            return generateKMLFromConnection(connection);
        }
开发者ID:sweenr,项目名称:odbc2kml,代码行数:16,代码来源:KMLGenerator.cs

示例2: 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;
        }
开发者ID:sweenr,项目名称:odbc2kml,代码行数:29,代码来源:KMLGenWebSVC.asmx.cs

示例3: updateConnection

        protected void updateConnection(object sender, CommandEventArgs e)
        {
            Button sendBtn = (Button)sender;
            String args = sendBtn.CommandArgument.ToString();

            ConnInfo tempConnInfo = new ConnInfo();

            tempConnInfo.setConnectionName(editConnName.Text);
            tempConnInfo.setDatabaseName(editConnDBName.Text);
            tempConnInfo.setServerAddress(editConnDBAddr.Text);
            tempConnInfo.setPortNumber(editConnDBPort.Text);
            tempConnInfo.setUserName(editConnUser.Text);
            tempConnInfo.setPassword(editConnPass.Text);
            tempConnInfo.setDatabaseType((editConnDBType.SelectedIndex));
            tempConnInfo.setOracleProtocol(editOracleProtocol.Text);
            tempConnInfo.setOracleServiceName(editOracleService.Text);
            tempConnInfo.setOracleSID(editOracleSID.Text);

            //If the connection information is bad, report the error and cancel the function. This does NOT run against the database.
            try
            {
                if (!tempConnInfo.isValid(Convert.ToInt32(args)))
                {
                    throw new ODBC2KMLException("");  // Throw any error. The catch is generic.
                }
            }
            catch
            {
                String error = "The entered connection information is invalid. Please make sure all fields are filled and that they are in proper format.";

                if (tempConnInfo.getDatabaseType() == ConnInfo.ORACLE)
                {
                    error = "The entered connection information is invalid. Please verify that all fields have a value and the value is of proper type."
                        + " Also, make sure that Oracle SID or Oracle Service Name and Oracle Protocol have been entered.";
                }

                ErrorHandler eh = new ErrorHandler(error, errorPanel1);
                this.editConnModalPopUp.Hide();
                eh.displayError();
                return;
            }

            //Create database and test it
            Database db = new Database(tempConnInfo);

            //See if you can reach the database. If not, error out and don't save.
            try
            {
                if (tempConnInfo.getDatabaseType() == ConnInfo.MSSQL)
                {
                    String query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA != 'information_schema' AND TABLE_NAME != 'sysdiagrams'";
                    db.executeQueryRemote(query);
                }

                else if (tempConnInfo.getDatabaseType() == ConnInfo.MYSQL)
                {
                    String query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA != 'information_schema' && TABLE_SCHEMA != 'mysql'";
                    db.executeQueryRemote(query);
                }

                else if (tempConnInfo.getDatabaseType() == ConnInfo.ORACLE)
                {
                    String query = "select TABLE_NAME from user_tables";
                    db.executeQueryRemote(query);
                }
            }
            catch
            {
                ErrorHandler eh = new ErrorHandler("The database entered could not be connected to. Please verify the information is correct.", errorPanel1);
                this.editConnModalPopUp.Hide();
                eh.displayError();
                return;
            }

            db.executeQueryLocal("UPDATE Connection SET name='" + tempConnInfo.getConnectionName()
                + "', dbName='" + tempConnInfo.getDatabaseName() + "', userName='" + tempConnInfo.getUserName()
                + "', password='" + tempConnInfo.getPassword() + "', port='" + tempConnInfo.getPortNumber()
                + "', address='" + tempConnInfo.getServerAddress() + "', type='" + tempConnInfo.getDatabaseType()
                + "', protocol='" + tempConnInfo.getOracleProtocol() + "', serviceName='" + tempConnInfo.getOracleServiceName()
                + "', SID='" + tempConnInfo.getOracleSID() + "' WHERE (ID='" + args + "')");

            Connection conn = new Connection(Convert.ToInt16(args));

            try
            {
                conn.populateFields();
                //Force the connection into a safe state, if it is not
                if (!conn.safeStateConnection())
                {
                    String error = "Invalid connection information. Please verify all of your fields are filled in correctly."
                    + "If you are using an oracle connection, please make sure you filled out the oracle specific information.";
                    ErrorHandler eh = new ErrorHandler(error, errorPanel1);
                    this.editConnModalPopUp.Hide();
                    eh.displayError();
                    return;
                }
            }
            catch (ODBC2KMLException err)
            {
                ErrorHandler eh = new ErrorHandler(err.errorText, errorPanel1);
//.........这里部分代码省略.........
开发者ID:sweenr,项目名称:odbc2kml,代码行数:101,代码来源:Main.aspx.cs

示例4: 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);
        }
开发者ID:sweenr,项目名称:odbc2kml,代码行数:33,代码来源:Main.aspx.cs


注:本文中的Connection.populateFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。