示例#1
0
        public IQueryable<WatchListEntry> GetAll()
        {
            List<WatchListEntry> watchListEntries = new List<WatchListEntry>();

            using (OleDbConnection conn = new OleDbConnection(this.ConnectionString))
            {
                using (OleDbCommand cmd = new OleDbCommand(this.SelectAllCommand, conn))
                {
                    try
                    {
                        if (conn.State != System.Data.ConnectionState.Open)
                            conn.Open();

                        OleDbDataAdapter dataAdapter = new OleDbDataAdapter(cmd);
                        DataSet ds = new DataSet();
                        dataAdapter.Fill(ds);

                        DataTable watchListTable = ds.Tables[0];
                        WatchListEntry watchListEntry = null;
                        for (int i = 0; i < watchListTable.Rows.Count; ++i)
                        {
                            watchListEntry = new WatchListEntry();

                            watchListEntry.Id = Convert.ToInt32(watchListTable.Rows[i]["Id"]);
                            watchListEntry.BSESymbol = Convert.ToString(watchListTable.Rows[i]["BSESymbol"]);
                            watchListEntry.NSESymbol = Convert.ToString(watchListTable.Rows[i]["NSESymbol"]);
                            watchListEntry.Name = Convert.ToString(watchListTable.Rows[i]["Name"]);
                            watchListEntry.AltName1 = Convert.ToString(watchListTable.Rows[i]["AltName1"]);
                            watchListEntry.AltName2 = Convert.ToString(watchListTable.Rows[i]["AltName2"]);
                            watchListEntry.TempName = Convert.ToString(watchListTable.Rows[i]["TempName"]);
                            watchListEntry.Active = Convert.ToInt32(watchListTable.Rows[i]["Active"]);
                            watchListEntry.Alert = Convert.ToInt32(watchListTable.Rows[i]["Alert"]);
                            watchListEntry.ModifiedOn = Convert.ToInt32(watchListTable.Rows[i]["ModifiedOn"]);
                            watchListEntry.CreatedOn = Convert.ToInt32(watchListTable.Rows[i]["CreatedOn"]);

                            watchListEntries.Add(watchListEntry);
                        }

                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("[Error] GetAll() failed.", this.DataSource);
                        Console.WriteLine(e.Message);
                    }

                }
            }

            return watchListEntries.AsQueryable();
        }
示例#2
0
        private string GetNSEDownloadUrl(WatchListEntry wle)
        {
            string nseDownloadUrl = @"http://www.nseindia.com/content/equities/scripvol/datafiles/{0}-TO-{1}{2}EQN.csv";
            string strFromDate = string.Format("{0:dd-MM-yyyy}", fromDate);
            string strToDate = string.Format("{0:dd-MM-yyyy}", toDate);

            nseDownloadUrl = string.Format(nseDownloadUrl, strFromDate.Trim(), strToDate.Trim(), wle.NSESymbol.Trim());

            return nseDownloadUrl;
        }
示例#3
0
        private string GetBSEDownloadUrl(WatchListEntry wle)
        {
            string bseDownloadUrl = @"http://www.bseindia.com/stockinfo/stockprc2_excel.aspx?scripcd={0}&FromDate={1}&ToDate={2}&OldDMY=D";
            string strFromDate = string.Format("{0:MM/dd/yyyy}", fromDate);
            string strToDate = string.Format("{0:MM/dd/yyyy}", toDate);

            bseDownloadUrl = string.Format(bseDownloadUrl, wle.BSESymbol.Trim(), strFromDate.Trim(), strToDate.Trim());

            return bseDownloadUrl;
        }