Пример #1
0
        static void Main(string[] args)
        {
            // Create a connection to Cache
            //CacheConnection conn = new CacheConnection();
            IRISConnection conn = new IRISConnection();
            IRIS           iris;

            // Cache server Connection Information
            // Set Server to your IP address and port to Cache SuperServer port, Log File is optional
            conn.ConnectionString = "Server = localhost; Log File=cprovider.log;Port=1972; Namespace=USER; Password = SYS; User ID = _SYSTEM;";

            //Open a Connection to Cache
            conn.Open();

            //CacheMethodSignature ms = new CacheMethodSignature();

            //ms.SetReturnType(conn, ClientTypeId.tString);
            iris = IRIS.CreateIRIS(conn);
            //CacheObject.RunClassMethod(conn, "%SYSTEM.Version", "GetVersion", ms);
            string ReturnValue = iris.ClassMethodString("%SYSTEM.Version", "GetVersion");

            //Console.Write("ReturnValue = " + ms.ReturnValue._Value);
            Console.Write("ReturnValue = " + ReturnValue);

            conn.Close();
        }
Пример #2
0
        public void init()
        {
            adbksrc = new ADBKDatasource();
            //adbksrc.connect("localhost", "1972", "_system", "SYS", "user");
            configconn consetup = new configconn();

            consetup.LoadSetupFile("..\\connectioninfo.json");
            adbksrc.connect(consetup.co.hostname, consetup.co.port.ToString(), consetup.co.username, consetup.co.password, consetup.co.irisnamespace);
            iris = IRIS.CreateIRIS(adbksrc.conn);
        }
 public cacheDirectWapper(string constr)
 {
     try
     {
         conn.ConnectionString = constr;
         conn.Open();
         IRIS iris = IRIS.CreateIRIS(conn);
         cd = (IRISObject)iris.ClassMethodObject("CacheDirect.Emulator", "%New");
     }
     finally
     {
     }
 }
        public cacheDirectWapper(IRISConnection irisconn)
        {
            try
            {

                conn = irisconn;
                iris = IRIS.CreateIRIS(conn);
                cd = (IRISObject)iris.ClassMethodObject("CacheDirect.Emulator", "%New");

            }
            finally
            {
            }
        }
Пример #5
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);
            }
        }
Пример #6
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); 
            }
        }
        private void btnConnect_Click(object sender, EventArgs e)
        {
            //Retrieve connection information from form
            string ip        = txtServer.Text;
            int    port      = Convert.ToInt32(txtPort.Text);
            string Namespace = txtNamespace.Text;
            string username  = txtUsername.Text;
            string password  = txtPassword.Text;

            ///
            // Making connection using IRISConnecion
            connection = new IRISConnection();

            // Create connection string
            connection.ConnectionString = "Server = " + ip + "; Port = " + port + "; Namespace = " +
                                          Namespace + "; Password = "******"; User ID = " + username;
            connection.Open();
            txtLog.AppendText("Connected to " + connection.ConnectionString);

            irisNativeCn = IRIS.CreateIRIS(connection);
            ///
            grpUpload.Enabled = true;
        }
Пример #8
0
    public static void Main(String[] args)
    {
        try
        {
            // open connection to InterSystems IRIS instance using connection string
            IRISConnection conn = new IRISConnection();

            // edit this ConnectionString to match your environment
            conn.ConnectionString = "Server=localhost; Port=51773; Namespace=User; Password=SYS; User ID=_system; SharedMemory=false; logfile=./dbnative.log";
            conn.Open();


            // create IRIS Native object
            IRIS iris = IRIS.CreateIRIS(conn);

            Console.WriteLine("[1. Setting and getting a global]");

            // setting and getting a global
            // ObjectScript equivalent: set ^testglobal("1") = 8888
            iris.Set(8888, "^testglobal", "1");

            // ObjectScript equivalent: set globalValue = $get(^testglobal("1"))
            Int16?globalValue = iris.GetInt16("^testglobal", "1");

            Console.WriteLine("The value of ^testglobal(1) is " + globalValue);
            Console.WriteLine();


            Console.WriteLine("[2. Iterating over a global]");

            // modify global to iterate over
            // ObjectScript equivalent: set ^testglobal("1") = 8888
            // ObjectScript equivalent: set ^testglobal("2") = 9999
            iris.Set(8888, "^testglobal", "1");
            iris.Set(9999, "^testglobal", "2");

            // iterate over all nodes forwards
            Console.WriteLine("walk forwards");
            IRISIterator subscriptIter = iris.GetIRISIterator("^testglobal");
            foreach (var node in subscriptIter)
            {
                Console.WriteLine("subscript=" + subscriptIter.CurrentSubscript + ", value=" + node);
            }
            Console.WriteLine();


            Console.WriteLine("[3. Calling a class method]");

            // calling a class method
            // ObjectScript equivalent: set returnValue = ##class(%Library.Utility).Date(5)
            String returnValue = iris.ClassMethodString("%Library.Utility", "Date", 5);
            Console.WriteLine(returnValue);

            Console.WriteLine();

            // close IRIS object and connection
            iris.Close();
            conn.Close();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
Пример #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            String ip        = "localhost";
            int    port      = 51773;
            String username  = "******";
            String password  = "******";
            String Namespace = "USER";

            try {
                // Making connection
                IRISConnection connection = new IRISConnection();
                connection.ConnectionString = "Server = " + ip + "; Port = " + port + "; Namespace = " +
                                              Namespace + "; Password = "******"; User ID = " + username;
                connection.Open();
                Console.WriteLine("Connected to InterSystems IRIS.");

                IRIS irisNative = IRIS.CreateIRIS(connection);
                // Task 5 - Uncomment below line to run task 5
                // Console.WriteLine("on InterSystems IRIS version: " + irisNative.FunctionString("PrintVersion","^StocksUtil"));
                bool always = true;

                while (always)
                {
                    Console.WriteLine("1. Test");
                    Console.WriteLine("2. Store stock data");
                    Console.WriteLine("3. View stock data");
                    Console.WriteLine("4. Generate Trades");
                    Console.WriteLine("5. Quit");
                    Console.WriteLine("What would you like to do? ");
                    String option = Console.ReadLine();
                    switch (option)
                    {
                    // Task 1
                    case "1":
                        // Uncomment below line to run task 1
                        // SetTestGlobal(irisNative);
                        break;

                    // Task 2
                    case "2":
                        // Uncomment below line to run task 2
                        // StoreStockData(irisNative, connection);
                        break;

                    // Task 3
                    case "3":
                        // Uncomment 5 lines below to run task 3
                        // Console.WriteLine("Printing nyse globals...");
                        // long startPrint = DateTime.Now.Ticks; //To calculate execution time
                        // PrintNodes(irisNative, "nyse");
                        // long totalPrint = DateTime.Now.Ticks - startPrint;
                        // Console.WriteLine("Execution time: " + totalPrint/TimeSpan.TicksPerMillisecond + " ms");
                        break;

                    // Task 4
                    case "4":
                        // Uncomment below line to run task 4
                        // GenerateData(irisNative, 10);
                        break;

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

                    default:
                        Console.WriteLine("Invalid option. Try again!");
                        break;
                    }
                }
                irisNative.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error - Exception thrown: " + e);
            }
        }
Пример #10
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"];

            try
            {
                // Making connection using IRISConnecion
                IRISConnection connection = new IRISConnection();

                // Create connection string
                connection.ConnectionString = "Server = " + ip + "; Port = " + port + "; Namespace = " +
                                              Namespace + "; Password = "******"; User ID = " + username;
                connection.Open();
                Console.WriteLine("Connected to InterSystems IRIS.");

                IRIS irisNative = IRIS.CreateIRIS(connection);

                // Starting interactive prompt
                bool always = true;
                while (always)
                {
                    Console.WriteLine("1. Test");
                    Console.WriteLine("2. Store stock data");
                    Console.WriteLine("3. View stock data");
                    Console.WriteLine("4. Generate Trades");
                    Console.WriteLine("5. Call Routines");
                    Console.WriteLine("6. Quit");
                    Console.WriteLine("What would you like to do? ");

                    String option = Console.ReadLine();
                    switch (option)
                    {
                    // Task 1
                    case "1":
                        SetTestGlobal(irisNative);
                        break;

                    // Task 2
                    case "2":
                        StoreStockData(irisNative, connection);
                        break;

                    // Task 3
                    case "3":
                        Console.WriteLine("Printing nyse globals...");
                        long startPrint = DateTime.Now.Ticks;     // To calculate execution time

                        // Iterate over all nodes
                        PrintNodes(irisNative, "nyse");
                        long totalPrint = DateTime.Now.Ticks - startPrint;
                        Console.WriteLine("Execution time: " + totalPrint / TimeSpan.TicksPerMillisecond + " ms");
                        break;

                    // Task 4
                    case "4":
                        GenerateData(irisNative, 10);
                        break;

                    // Task 5
                    case "5":
                        Console.WriteLine("on InterSystems IRIS version: " + irisNative.FunctionString("PrintVersion", "^StocksUtil"));
                        break;

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

                    default:
                        Console.WriteLine("Invalid option. Try again!");
                        break;
                    }
                }
                irisNative.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error - Exception thrown: " + e);
            }
        }
        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);
            }
        }