コード例 #1
0
        static void Main(String[] args)
        {
            // If you are using a remote instance, update IP and password here
            String user     = "******";
            String password = "******";
            String IP       = "localhost";
            int    port     = 51773;

            try
            {
                // Connect to database using EventPersister, which is based on IRISDataSource
                // For more details on EventPersister, visit
                // https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=BNETXEP_xep
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(IP, port, "User", user, password);

                Console.WriteLine("Connected to InterSystems IRIS");
                xepPersister.DeleteExtent("Demo.Airport");     // Remove old test data
                xepPersister.ImportSchemaFull("Demo.Airport"); // Import flat schema
                // Create XEP Event for object access
                Event xepEvent = xepPersister.GetEvent("Demo.Airport");
                // Create IRIS Native object
                IRISADOConnection connection = (IRISADOConnection)xepPersister.GetAdoNetConnection();
                IRIS irisNative = IRIS.CreateIRIS(connection);

                Console.WriteLine("Generating airport table...");

                // Populate 5 airport objects and save to the database using XEP
                populateAirports(xepEvent);

                // Get all airports using ADO.NET
                getAirports(connection);

                // Store natively - Uncomment the following line for task 3
                // StoreAirfare(irisNative);
                Console.ReadLine();
                // Close everything
                xepEvent.Close();
                xepPersister.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error creating airport listing: " + e);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            String ip = "localhost";
            int port = 51773;
            String username = "******";
            String password = "******";
            String Namespace = "USER";
            String className = "myApp.StockInfo";
            
            try {
                // Connect to database using EventPersister
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(ip, port, Namespace, username, password);
                Console.WriteLine("Connected to InterSystems IRIS.");
                xepPersister.DeleteExtent(className);   // remove old test data
                xepPersister.ImportSchema(className);   // import flat schema
            
                // Create Event
                Event xepEvent = xepPersister.GetEvent(className);
                IRISADOConnection connection = (IRISADOConnection) xepPersister.GetAdoNetConnection();
                IRIS native = IRIS.CreateIRIS(connection);

                // Task 2
                // Uncomment the line below to run task 2
                // Task2(connection);

                // Task 3
                // Uncomment the line below to run task 3
                // Task3(connection, xepEvent);

                // Task 4
                // Comment out Task 2, Task 3 and uncomment the line below to run task 4
                // Task4(connection, native, xepEvent);

                xepEvent.Close();
                xepPersister.Close();

            
            } catch (Exception e) { 
                Console.WriteLine("Interactive prompt failed:\n" + e); 
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Trade[] sampleArray = null;

            // Initialize dictionary to store connection details from config.txt
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary = generateConfig("..\\..\\..\\config.txt");

            // Retrieve connection information from configuration file
            string ip        = dictionary["ip"];
            int    port      = Convert.ToInt32(dictionary["port"]);
            string Namespace = dictionary["namespace"];
            string username  = dictionary["username"];
            string password  = dictionary["password"];
            String className = "myApp.Trade";

            try
            {
                // Connect to database using EventPersister
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(ip, port, Namespace, username, password);
                Console.WriteLine("Connected to InterSystems IRIS.");
                xepPersister.DeleteExtent(className);   // remove old test data
                xepPersister.ImportSchema(className);   // import flat schema

                // Create Event
                Event xepEvent = xepPersister.GetEvent(className);

                // Starting interactive prompt
                bool always = true;
                while (always)
                {
                    Console.WriteLine("1. Make a trade (do not save)");
                    Console.WriteLine("2. Confirm all trades");
                    Console.WriteLine("3. Generate and save multiple trades");
                    Console.WriteLine("4. Retrieve all trades; show execution statistics");
                    Console.WriteLine("5. ADO.NET Comparison - Create and save multiple trades");
                    Console.WriteLine("6. Update all trades; show execution statistics");
                    Console.WriteLine("7. Quit");
                    Console.WriteLine("What would you like to do? ");

                    String option = Console.ReadLine();
                    switch (option)
                    {
                    // Task 2
                    case "1":
                        sampleArray = Task2CreateTrade(sampleArray);
                        break;

                    case "2":
                        Task2SaveTrade(sampleArray, xepEvent);
                        sampleArray = null;
                        break;

                    // Task 3
                    case "3":
                        Task3(sampleArray, xepEvent);
                        break;

                    // Task 5
                    case "4":
                        Task5(xepEvent);
                        break;

                    // Task 4
                    case "5":
                        Task4(sampleArray, xepPersister);
                        break;

                    // Task 6
                    case "6":
                        Task6(xepEvent);
                        break;

                    case "7":
                        Console.WriteLine("Exited.");
                        always = false;
                        break;

                    default:
                        Console.WriteLine("Invalid option. Try again!");
                        break;
                    }
                }
                xepEvent.Close();
                xepPersister.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Interactive prompt failed:\n" + e);
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Trade[] sampleArray = null;
            Console.WriteLine("Hello World!");

            String ip        = "localhost";
            int    port      = 51773;
            String username  = "******";
            String password  = "******";
            String Namespace = "USER";
            String className = "myApp.Trade";

            try {
                // Connect to database using EventPersister
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(ip, port, Namespace, username, password);
                Console.WriteLine("Connected to InterSystems IRIS.");
                xepPersister.DeleteExtent(className);   // Remove old test data
                xepPersister.ImportSchema(className);   // Import flat schema

                // Create Event
                Event xepEvent = xepPersister.GetEvent(className);

                // Starting interactive prompt
                bool always = true;
                while (always)
                {
                    Console.WriteLine("1. Make a trade (do not save)");
                    Console.WriteLine("2. Confirm all trades");
                    Console.WriteLine("3. Generate and save multiple trades");
                    Console.WriteLine("4. Retrieve all trades; show execution statistics");
                    Console.WriteLine("5. ADO.NET Comparison - Create and save multiple trades");
                    Console.WriteLine("6. Quit");
                    Console.WriteLine("What would you like to do? ");

                    String option = Console.ReadLine();

                    switch (option)
                    {
                    // Task 2
                    case "1":
                        // Uncomment below line to run Task 2 - Create Trade
                        // sampleArray = Task2CreateTrade(sampleArray);
                        break;

                    case "2":
                        // Uncomment below line to run Task 2 - Save Trade
                        // Task2SaveTrade(sampleArray, xepEvent);
                        sampleArray = null;
                        break;

                    // Task 3
                    case "3":
                        // Uncomment below line to run Task 3
                        //Task3(sampleArray, xepEvent);
                        break;

                    // Task 5 + Task 6
                    case "4":
                        // Uncomment below line to run Task 5
                        // Task5(xepEvent);
                        // Uncomment below line to run Task 6
                        // Task6(xepEvent);
                        break;

                    // Task 4
                    case "5":
                        // Uncomment below line to run Task 4
                        // Task4(sampleArray, xepPersister);
                        break;

                    case "6":
                        Console.WriteLine("Exited.");
                        always = false;
                        break;

                    default:
                        Console.WriteLine("Invalid option. Try again!");
                        break;
                    }
                }
                xepEvent.Close();
                xepPersister.Close();
            } catch (Exception e) {
                Console.WriteLine("Interactive prompt failed:\n" + e);
            }
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // Initialize dictionary to store connection details from config.txt
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary = generateConfig("..\\..\\..\\config.txt");

            // Retrieve connection information from configuration file
            string ip        = dictionary["ip"];
            int    port      = Convert.ToInt32(dictionary["port"]);
            string Namespace = dictionary["namespace"];
            string username  = dictionary["username"];
            string password  = dictionary["password"];
            String className = "myApp.StockInfo";

            try
            {
                // Connect to database using EventPersister
                EventPersister xepPersister = PersisterFactory.CreatePersister();
                xepPersister.Connect(ip, port, Namespace, username, password);
                Console.WriteLine("Connected to InterSystems IRIS.");
                xepPersister.DeleteExtent(className);   // Remove old test data
                xepPersister.ImportSchema(className);   // Import flat schema

                // Create Event
                Event             xepEvent   = xepPersister.GetEvent(className);
                IRISADOConnection connection = (IRISADOConnection)xepPersister.GetAdoNetConnection();
                IRIS native = IRIS.CreateIRIS(connection);

                // Starting interactive prompt
                bool always = true;
                while (always)
                {
                    Console.WriteLine("1. Retrieve all stock names");
                    Console.WriteLine("2. Create objects");
                    Console.WriteLine("3. Populate properties");
                    Console.WriteLine("4. Quit");
                    Console.WriteLine("What would you like to do? ");

                    String option = Console.ReadLine();
                    switch (option)
                    {
                    // Task 2
                    case "1":
                        Task2(connection);
                        break;

                    // Task 3
                    case "2":
                        Task3(connection, xepEvent);
                        break;

                    // Task 4
                    case "3":
                        Task4(connection, native, xepEvent);
                        break;

                    case "4":
                        Console.WriteLine("Exited.");
                        always = false;
                        break;

                    default:
                        Console.WriteLine("Invalid option. Try again!");
                        break;
                    }
                }

                xepEvent.Close();
                xepPersister.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Interactive prompt failed:\n" + e);
            }
        }