예제 #1
0
        public static void Main(string[] args)
        {
            int mainToLaunch = 6;

            if (mainToLaunch == 1)
            {
                AceQLTest.TheMain(args);
            }
            else if (mainToLaunch == 2)
            {
                AceQLTestColumnAsKeyName.TheMain(args);
            }
            else if (mainToLaunch == 3)
            {
                JsonTest.TheMain(args);
            }
            else if (mainToLaunch == 4)
            {
                MySqlStoredProcedureTest.TheMain(args);
            }
            else if (mainToLaunch == 5)
            {
                SqlServerStoredProcedureTest.TheMain(args);
            }
            else if (mainToLaunch == 6)
            {
                AceQLTest.TheMain(args);
                AceQLTestMetadata.TheMain();
            }
            else if (mainToLaunch == 7)
            {
                AceQLTestSessionId.TheMain();
                AceQLTestMetadata.TheMain();
            }
        }
        static async Task DoIt()
        {
            string serverUrlLocalhost = "http://localhost:9090/aceql";
            string server             = serverUrlLocalhost;
            string database           = "sampledb";
            string username           = "******";
            string sessionId          = "4pdh8p2t14nd6j7dxt1owyjxef";

            string connectionString = $"Server={server}; Database={database}";

            Boolean doItWithCredential = true;

            if (!doItWithCredential)
            {
                connectionString += $"; Username={username}; SessionId={sessionId}";
                AceQLConsole.WriteLine("Using connectionString with SessionId: " + connectionString);

                // Make sure connection is always closed to close and release server connection into the pool
                using (AceQLConnection connection = new AceQLConnection(connectionString))
                {
                    await connection.OpenAsync();

                    await AceQLTest.ExecuteExample(connection).ConfigureAwait(false);

                    await connection.CloseAsync();
                }
            }
            else
            {
                AceQLConsole.WriteLine("Using AceQLCredential with SessionId: " + sessionId);
                AceQLCredential credential = new AceQLCredential(username, sessionId);

                // Make sure connection is always closed to close and release server connection into the pool
                using (AceQLConnection connection = new AceQLConnection(connectionString))
                {
                    connection.Credential = credential;
                    await connection.OpenAsync();

                    await AceQLTest.ExecuteExample(connection).ConfigureAwait(false);

                    await connection.CloseAsync();
                }
            }
        }