Exemple #1
0
        public static void Task4(IRISADOConnection connection, IRIS native, Event xepEvent){
            String sql = "SELECT distinct name FROM demo.stock";
            IRISCommand cmd = new IRISCommand(sql, connection);
            IRISDataReader reader = cmd.ExecuteReader();

            var array = new List<StockInfo>();
            while(reader.Read()){
                StockInfo stock = new StockInfo();
                stock.name = (string) reader[reader.GetOrdinal("Name")];
                Console.WriteLine("created stockinfo array.");
            
                // Generate mission and founder names (Native API)
                stock.founder = native.ClassMethodString("%PopulateUtils", "Name");
                stock.mission = native.ClassMethodString("%PopulateUtils", "Mission");
                Console.WriteLine("Adding object with name " + stock.name + " founder " + stock.founder + " and mission " + stock.mission);
                array.Add(stock);
            }
            xepEvent.Store(array.ToArray());
        }
Exemple #2
0
 public static Trade[] GenerateData(IRIS irisNative, int objectCount)
 {
     Trade[] data = new Trade[objectCount];
     try{
         for (int i = 0; i < objectCount; i++)
         {
             DateTime tempDate   = Convert.ToDateTime("2018-01-01");
             double   tempAmount = (double)irisNative.ClassMethodDouble("%PopulateUtils", "Currency");
             String   tempName   = irisNative.ClassMethodString("%PopulateUtils", "String") +
                                   irisNative.ClassMethodString("%PopulateUtils", "String") +
                                   irisNative.ClassMethodString("%PopulateUtils", "String");
             String tempTrader = irisNative.ClassMethodString("%PopulateUtils", "Name");
             int    tempShares = new Random().Next(1, 20);
             data[i] = new Trade(tempName, tempDate, tempAmount, tempShares, tempTrader);
             Console.WriteLine("New trade: " + tempName + " , " + tempDate + " , " + tempAmount + " , " + tempShares + " , " + tempTrader);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
     return(data);
 }
Exemple #3
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);
        }
    }