Esempio n. 1
0
        // Display all airports using ADO.NET
        public static void getAirports(IRISADOConnection connection)
        {
            try
            {
                // This query uses a special shorthand notation (->, known as an implicit join)
                // to retrieve data from a related table without requiring you to think about how to join tables
                String         sql    = "SELECT name, code, location->city, location->state, location->zip FROM demo.airport";
                IRISCommand    cmd    = new IRISCommand(sql, connection);
                IRISDataReader reader = cmd.ExecuteReader();

                Console.WriteLine("Name\t\t\t\t\tCode\t\tLocation");
                while (reader.Read())
                {
                    String name  = (String)reader[reader.GetOrdinal("name")];
                    String code  = (String)reader[reader.GetOrdinal("code")];
                    String city  = (String)reader[reader.GetOrdinal("city")];
                    String state = (String)reader[reader.GetOrdinal("state")];
                    String zip   = (String)reader[reader.GetOrdinal("zip")];
                    Console.WriteLine(name + "\t\t" + code + "\t\t" + city + ", " + state + " " + zip);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 2
0
        public List <string> searchbyname(string name)
        {
            idlist.Clear();
            List <string> anamelist = new List <string>();
            //CacheCommand cc = User.ADBK.ByName(adbksrc.conn);
            //CacheParameter cp = new CacheParameter("Name", CacheDbType.NVarChar);
            //cp.Value = name;
            //cc.Parameters.Add(cp);

            string        SQLtext = "call sqluser.ADBK_byname(?)";
            IRISCommand   ic      = new IRISCommand(SQLtext, adbksrc.conn);
            IRISParameter ip      = new IRISParameter("Name", IRISDbType.NVarChar);

            ip.Value = name;
            ic.Parameters.Add(ip);

            //CacheDataReader reader = cc.ExecuteReader();
            IRISDataReader reader = ic.ExecuteReader();

            while (reader.Read())
            {
                string id    = reader[reader.GetOrdinal("AID")].ToString();
                string aname = reader[reader.GetOrdinal("ANAME")].ToString();
                anamelist.Add(aname);
                idlist.Add(id);
            }
            return(anamelist);
        }
Esempio n. 3
0
 public static void Task2(IRISADOConnection connection){
     String sql = "SELECT distinct name FROM demo.stock";
     IRISCommand cmd = new IRISCommand(sql, connection);
     IRISDataReader reader = cmd.ExecuteReader();
     while(reader.Read()){
         Console.WriteLine(reader[reader.GetOrdinal("Name")]);
     }
 }
Esempio n. 4
0
 // Helper method: Find top 10 stocks on a particular date
 public static void FindTopOnDate(IRISADOConnection dbconnection, String onDate)
 {
     try
     {
         String      sql = "SELECT distinct top 10 TransDate,Name,StockClose,StockOpen,High,Low,Volume FROM Demo.Stock WHERE TransDate=? ORDER BY stockclose desc";
         IRISCommand cmd = new IRISCommand(sql, dbconnection);
         cmd.Parameters.AddWithValue("TransDate", Convert.ToDateTime(onDate));
         IRISDataReader reader = cmd.ExecuteReader();
         Console.WriteLine("Date\t\tName\tOpening Price\tDaily High\tDaily Low\tClosing Price\tVolume");
         while (reader.Read())
         {
             DateTime date   = (DateTime)reader[reader.GetOrdinal("TransDate")];
             decimal  open   = (decimal)reader[reader.GetOrdinal("StockOpen")];
             decimal  high   = (decimal)reader[reader.GetOrdinal("High")];
             decimal  low    = (decimal)reader[reader.GetOrdinal("Low")];
             decimal  close  = (decimal)reader[reader.GetOrdinal("StockClose")];
             int      volume = (int)reader[reader.GetOrdinal("Volume")];
             String   name   = (string)reader[reader.GetOrdinal("Name")];
             Console.WriteLine(date.ToString("MM/dd/yyyy") + "\t" + name + "\t" + open + "\t" + high + "\t" + low + "\t" + close + "\t" + volume);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Esempio n. 5
0
        public List <string> searchbyname(string name)
        {
            //CacheCommand cc;
            IRISCommand ic;

            idlist.Clear();
            List <string> anamelist = new List <string>();

            try
            {
                //cc = new CacheCommand("Select AID, ANAME from ADBK WHERE ANAME %startswith ?", adbksrc.conn);
                //CacheParameter cp = new CacheParameter("Name", CacheDbType.NVarChar);
                //cp.Value = name;
                //cc.Parameters.Add(cp);
                //CacheDataReader reader = cc.ExecuteReader();
                ic = new IRISCommand("Select AID, ANAME from ADBK WHERE ANAME %startswith ?", adbksrc.conn);
                IRISParameter ip = new IRISParameter("Name", IRISDbType.NVarChar);
                ip.Value = name;
                ic.Parameters.Add(ip);
                IRISDataReader reader = ic.ExecuteReader();

                while (reader.Read())
                {
                    string id    = reader[reader.GetOrdinal("AID")].ToString();
                    string aname = reader[reader.GetOrdinal("ANAME")].ToString();
                    anamelist.Add(aname);
                    idlist.Add(id);
                }
                return(anamelist);
            }
            catch (Exception err)
            {
                MessageBox.Show("searchbynameエラー " + err.Message);
                return(anamelist);
            }
            //return anamelist;
        }
Esempio n. 6
0
 //public void updatedatamodel(CacheDataReader reader) {
 public void updatedatamodel(IRISDataReader reader)
 {
     try
     {
         while (reader.Read())
         {
             Age       = (long)reader.GetInt32(reader.GetOrdinal("AAGE"));
             City      = reader[reader.GetOrdinal("ACITY")].ToString();
             HomePhone = reader[reader.GetOrdinal("APHHOME")].ToString();
             Name      = reader[reader.GetOrdinal("ANAME")].ToString();
             Street    = reader[reader.GetOrdinal("ASTREET")].ToString();
             WorkPhone = reader[reader.GetOrdinal("APHWORK")].ToString();
             ZipCode   = reader[reader.GetOrdinal("AZIP")].ToString();
             dob       = reader.GetDate(reader.GetOrdinal("ABTHDAY")).ToShortDateString();
             id        = reader[reader.GetOrdinal("AID")].ToString();
             newflag   = false;
         }
     }
     catch (Exception err)
     {
         //MessageBox.Show("CacheDataReaderエラー " + err.Message);
         MessageBox.Show("IRISDataReaderエラー " + err.Message);
     }
 }
Esempio n. 7
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());
        }
Esempio n. 8
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);
            }
        }
        // Task 3: Generate sample stock info objects and stored into database using XEP
        public static void Task3(IRISADOConnection connection, 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.");
                stock.founder = "test founder";
                stock.mission = "some mission statement";
                Console.WriteLine("Adding object with name " + stock.name + " founder " + stock.founder + " and mission " + stock.mission);
                array.Add(stock);
            }
            xepEvent.Store(array.ToArray());
        }
Esempio n. 10
0
        // Helper method: View Portfolio Table to see % gain or loss
        public static void PortfolioProfile(IRISADOConnection dbconnection, String sellDate)
        {
            decimal  cumulStartValue = 0;
            decimal  cumulEndValue   = 0;
            DateTime t = DateTime.Now;

            try
            {
                String      sql = "SELECT pf.Name, pf.PurchasePrice, pf.PurchaseDate, pf.Shares, pf.DateTimeUpdated, st.StockClose FROM Demo.Portfolio as pf JOIN Demo.Stock as st on st.Name = pf.Name WHERE st.TransDate = ?";
                IRISCommand cmd = new IRISCommand(sql, dbconnection);
                cmd.Parameters.AddWithValue("Name", Convert.ToDateTime(sellDate));
                IRISDataReader reader = cmd.ExecuteReader();
                Console.WriteLine("Name" + " " + "Purchase Date" + " " + "Purchase Price" + " " + "Stock Close\tShares\tDatetime Updated\t% Change" + "   " + "Gain or Loss");

                while (reader.Read())
                {
                    String   name            = (string)reader[reader.GetOrdinal("Name")];
                    DateTime purchaseDate    = (DateTime)reader[reader.GetOrdinal("purchaseDate")];
                    decimal  purchasePrice   = (decimal)reader[reader.GetOrdinal("PurchasePrice")];
                    decimal  stockClose      = (decimal)reader[reader.GetOrdinal("StockClose")];
                    int      shares          = (int)reader[reader.GetOrdinal("Shares")];
                    DateTime dateTimeUpdated = (DateTime)reader[reader.GetOrdinal("DateTimeUpdated")];
                    decimal  percentChange   = (stockClose - purchasePrice) / (purchasePrice) * 100;
                    decimal  startValue      = purchasePrice * shares;
                    decimal  endValue        = stockClose * shares;
                    decimal  gainOrLoss      = Math.Round(endValue - startValue, 2);
                    cumulStartValue += startValue;
                    cumulEndValue   += endValue;
                    Console.WriteLine(name + "\t" + purchaseDate.ToString("MM/dd/yyyy") + "\t" + purchasePrice + "\t  " + stockClose + "\t" + shares + "\t"
                                      + dateTimeUpdated + "\t" + String.Format("{0:0.##}", percentChange) + "\t     " + gainOrLoss);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error printing portfolio information: " + e);
            }
        }