Пример #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();
        }
 public Boolean end()
 {
     try
     {
         cd.Dispose();
         conn.Close();
     }
     finally
     {
     }
     return(true);
 }
Пример #3
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();
        }
Пример #4
0
 public void close()
 {
     conn.Close();
 }
Пример #5
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);
        }
    }