Exemplo n.º 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();
        }
Exemplo n.º 2
0
        public void connect(String server, String port, String userid, String password, String nspace)
        {
            try
            {
                // Create a connection to Cache
                // Create a connection to IRIS
                //conn = new CacheConnection();
                conn = new IRISConnection();

                //string cacheConnectString = "Server = " + server + "; Log File=cprovider.log;Port=" + port + "; Namespace=" + nspace + "; Password = "******";User ID = " + userid + ";";
                string IRISConnectString = "Server = " + server + "; Log File=cprovider.log;Port=" + port + "; Namespace=" + nspace + "; Password = "******";User ID = " + userid + ";";
                // Cache server Connection Information
                // IRIS server Connection Information
                //conn.ConnectionString = cacheConnectString;
                conn.ConnectionString = IRISConnectString;
                //Open a Connection to Cache
                //Open a Connection to IRIS
                conn.Open();
            }

            catch (Exception err)
            {
                MessageBox.Show("ERROR: " + err.Message);
            }
        }
 public cacheDirectWapper(string constr)
 {
     try
     {
         conn.ConnectionString = constr;
         conn.Open();
         IRIS iris = IRIS.CreateIRIS(conn);
         cd = (IRISObject)iris.ClassMethodObject("CacheDirect.Emulator", "%New");
     }
     finally
     {
     }
 }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            IRISCommand     spIRIS;
            IRISConnection  cnIRIS;
            IRISTransaction txIRIS = null;

            //存在するファイルを指定する
            FileStream fs = new FileStream(
                @"c:\temp\test.jpeg", FileMode.Open, FileAccess.Read);

            int fileSize = (int)fs.Length;   // ファイルのサイズ

            byte[] buf = new byte[fileSize]; // データ格納用配列

            long readSize;                   // Readメソッドで読み込んだバイト数
            int  remain = fileSize;          // 読み込むべき残りのバイト数

            readSize = fs.Read(buf, 0, (int)fs.Length);

            string IRISConnectString = "Server = localhost;Port=1972;Namespace=User;Password=SYS;User ID = _SYSTEM;";

            cnIRIS = new IRISConnection(IRISConnectString);
            cnIRIS.Open();
            spIRIS = new IRISCommand("Insert into MyApp.Person2(Name, Picture) Values(?, ?)", cnIRIS, txIRIS);

            IRISParameter pName = new IRISParameter();

            pName.ParameterName = "Name";
            pName.IRISDbType    = IRISDbType.NVarChar;
            pName.Direction     = ParameterDirection.Input;
            pName.Value         = "Hoge Hoge";
            spIRIS.Parameters.Add(pName);

            IRISParameter pPicture = new IRISParameter();

            pPicture.ParameterName = "Picture";
            pPicture.IRISDbType    = IRISDbType.LongVarBinary;
            pPicture.Direction     = ParameterDirection.Input;
            pPicture.Value         = buf;
            spIRIS.Parameters.Add(pPicture);

            spIRIS.ExecuteNonQuery();

            fs.Dispose();
            cnIRIS.Close();
        }
        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;
        }
Exemplo n.º 6
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);
        }
    }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 9
0
        public ConsoleApp()
        {
            //
            // TODO: Add code to start application here
            //
            try
            {
                // Create a cacheDirectWapper instance
             #if AUTOCONNECT
                cacheDirectWapper cdw = new cacheDirectWapper("Server = localhost; Log File=cprovider.log;Port=51773; Namespace=USER; Password = SYS; User ID = _system;");
             #else
                IRISConnection irisconn = new IRISConnection();
                irisconn.ConnectionString = "Server = localhost; Log File=cprovider.log;Port=51773; Namespace=USER; Password = SYS; User ID = _system;";
                irisconn.Open();
                cacheDirectWapper cdw = new cacheDirectWapper(irisconn);
             #endif

                cdw.ErrorEvent   += OnError;
                cdw.ExecuteEvent += Executed;

                cdw.P0     = "ABC;DEF;GHI";
                cdw.P1     = ";";
                cdw.PDELIM = ";";

                cdw.Execute("=$PIECE(P0,P1,2)");

                Debug.Print("P1 = " + cdw.P1);
                Debug.Print("VALUE = " + cdw.VALUE);
                Debug.Print("ErrorName = " + cdw.ErrorName);
                Debug.Print("\n");

                cdw.P0     = "あいうえお;かきくけこ;さしすせそ";
                cdw.P1     = ";";
                cdw.PDELIM = ";";

                cdw.Execute("=$PIECE(P0,P1,2)");

                Debug.Print("P1 = " + cdw.P1);
                Debug.Print("VALUE = " + cdw.VALUE);
                Debug.Print("ErrorName = " + cdw.ErrorName);
                Debug.Print("\n");

                cdw.Execute("set PLIST(1)= 123,PLIST(2)=456,PLIST(3)=7890");

                Debug.Print("PLIST(1) = " + cdw.getPLIST(1));
                Debug.Print("PLIST(2) = " + cdw.getPLIST(2));
                Debug.Print("PLIST(3) = " + cdw.getPLIST(3));
                Debug.Print("PLIST # = " + cdw.getPLISTLength().ToString());
                Debug.Print("PLIST = " + cdw.PLIST);
                Debug.Print("ErrorName = " + cdw.ErrorName);
                Debug.Print("\n");

                cdw.Code     = "set %X=345 d INT^%XD set P0 = %D";
                cdw.ExecFlag = 1;

                Debug.Print("P0 = " + cdw.P0);
                Debug.Print("ErrorName = " + cdw.ErrorName);
                Debug.Print("\n");

                Debug.Print("wait for 5 seconds ");
                cdw.Code     = "set P0=23456";
                cdw.Interval = 5000;
                cdw.ExecFlag = 3;

                Console.WriteLine("Waiting for 5 seconds till the timer expires ");
                Console.WriteLine("If 5 seconds passed, Please press any key");
                Console.ReadLine();

                Debug.Print("P0 = " + cdw.P0);
                Debug.Print("ErrorName = " + cdw.ErrorName);
                Debug.Print("\n");

                cdw.ExecFlag = 2;
                cdw.Code     = "=$zv";
                cdw.P0       = cdw.VALUE;

                Debug.Print("P0 = " + cdw.P0);
                Debug.Print("VALUE = " + cdw.VALUE);
                Debug.Print("\n");

                cdw.Execute("set a = P00");

                Debug.Print("ErrorName = " + cdw.ErrorName);
                Debug.Print("\n");
                // Cleanup CachedirectWapper

                cdw.end();
            }
            finally
            {
            }
        }