Example #1
0
        public static void StoreStockData(IRIS irisNative, IRISConnection dbconnection)
        {
            // Clear global from previous runs
            irisNative.Kill("^nyse");
            Console.WriteLine("Storing stock data using Native API...");

            // Get stock data using JDBC and write global

            try {
                String         sql    = "select top 1000 TransDate, Name, StockClose, StockOpen, High, Low, Volume from Demo.Stock";
                IRISCommand    cmd    = new IRISCommand(sql, dbconnection);
                IRISDataReader reader = cmd.ExecuteReader();
                ArrayList      list   = new ArrayList();
                string         result;

                while (reader.Read())
                {
                    DateTime dt = (DateTime)reader[reader.GetOrdinal("TransDate")];
                    result = (string)reader[reader.GetOrdinal("Name")] +
                             dt.ToString("MM/dd/yyyy") +
                             reader[reader.GetOrdinal("High")] +
                             reader[reader.GetOrdinal("Low")] +
                             reader[reader.GetOrdinal("StockOpen")] +
                             reader[reader.GetOrdinal("StockClose")] +
                             (int)reader[reader.GetOrdinal("Volume")];
                    list.Add(result);
                }

                Console.WriteLine("Duong");

                int  id           = list.Count;
                long startConsume = DateTime.Now.Ticks;

                for (int i = 0; i < id; i++)
                {
                    irisNative.Set(list[i], "^nyse", i + 1);
                }

                long totalConsume = DateTime.Now.Ticks - startConsume;
                Console.WriteLine("Stored natively successfully. Execution time: " + totalConsume / TimeSpan.TicksPerMillisecond + " ms");
            }
            catch (Exception e) {
                Console.WriteLine("Error either retrieving data using JDBC or storing to globals: " + e);
            }
        }
 public void Clear()
 {
     _irisNative.Kill(GlobalsNativeConstants.CollectionGlobals, CollectionName);
     Initialize();
 }