Пример #1
0
        //public UserControl userControl2 { get; set; }

        public Form1()
        {
            InitializeComponent();
            m_pSKCenter  = new SKCenterLib();
            m_pSKCenter2 = new SKCenterLib();

            m_pSKQuote          = new SKQuoteLib();
            skQuote1.SKQuoteLib = m_pSKQuote;

            m_pSKOSQuote = new SKOSQuoteLib();

            m_pSKCenter2.OnShowAgreement += new _ISKCenterLibEvents_OnShowAgreementEventHandler(this.OnShowAgreement);

            m_pSKReply          = new SKReplyLib();
            skReply1.SKReplyLib = m_pSKReply;

            m_pSKReply.OnReplyMessage += new _ISKReplyLibEvents_OnReplyMessageEventHandler(this.OnAnnouncement);


            txtAccount.Text  = System.Configuration.ConfigurationManager.AppSettings.Get("Username");
            txtPassWord.Text = System.Configuration.ConfigurationManager.AppSettings.Get("Password");

            StatusListBox.Items.Add("DB Conn: " + connectionstr);
            StatusListBox.Items.Add("TradeSession: " + (util.GetTradeSession() == 1? "AM盤":"全盤"));

            util.RecordLog(connectionstr, "SKQuote login, Session:" + (util.GetTradeSession() == 1 ? "Morning session" : "Night session"), util.INFO);
        }
Пример #2
0
 private void DeleteTickData()
 {
     try
     {
         using (SqlConnection connection = new SqlConnection(connectionstr))
         {
             SqlCommand sqlcmd = new SqlCommand();
             sqlcmd.CommandText = @" TRUNCATE TABLE dbo.TickData ";
             connection.Open();
             sqlcmd.Connection = connection;
             sqlcmd.ExecuteNonQuery();
         }
     }
     catch (Exception ex)
     {
         util.RecordLog(connectionstr, ex.Message, util.ALARM);
     }
 }
Пример #3
0
        void m_SKQuoteLib_OnNotifyKLineData(string bstrStockNo, string bstrData)
        {
            listKLine.Items.Add("[OnNotifyKLineData]" + bstrData);

            string KLineTpye, targettable;

            KLineTpye = boxKLine.SelectedIndex.ToString();
            //1 AM 盤, 0 全盤
            targettable = boxTradeSession.SelectedIndex == 1 ? "StockHistoryDaily" : "StockHistoryDaily_ALL";

            try
            {
                using (SqlConnection connection = new SqlConnection(connectionstr))
                {
                    SqlCommand   sqlcmd      = new SqlCommand();
                    SqlParameter stockPara   = new SqlParameter();
                    SqlParameter datePara    = new SqlParameter();
                    SqlParameter timePara    = new SqlParameter();
                    SqlParameter openPara    = new SqlParameter();
                    SqlParameter highestPara = new SqlParameter();
                    SqlParameter lowestPara  = new SqlParameter();
                    SqlParameter closePara   = new SqlParameter();
                    SqlParameter volPara     = new SqlParameter();

                    connection.Open();

                    sqlcmd.Connection  = connection;
                    sqlcmd.CommandType = CommandType.Text;

                    stockPara   = sqlcmd.Parameters.Add("@stockno", SqlDbType.VarChar, 16);
                    datePara    = sqlcmd.Parameters.Add("@sdate", SqlDbType.Date);
                    openPara    = sqlcmd.Parameters.Add("@open", SqlDbType.VarChar, 8);
                    highestPara = sqlcmd.Parameters.Add("@highest", SqlDbType.VarChar, 8);
                    lowestPara  = sqlcmd.Parameters.Add("@lowest", SqlDbType.VarChar, 8);
                    closePara   = sqlcmd.Parameters.Add("@close", SqlDbType.VarChar, 8);
                    volPara     = sqlcmd.Parameters.Add("@vol", SqlDbType.VarChar, 8);

                    stockPara.Direction   = ParameterDirection.Input;
                    datePara.Direction    = ParameterDirection.Input;
                    openPara.Direction    = ParameterDirection.Input;
                    highestPara.Direction = ParameterDirection.Input;
                    lowestPara.Direction  = ParameterDirection.Input;
                    closePara.Direction   = ParameterDirection.Input;
                    volPara.Direction     = ParameterDirection.Input;

                    string[] sdata = null;
                    //Minute
                    if (KLineTpye == "0")
                    {
                        //typelength = 6;
                        timePara           = sqlcmd.Parameters.Add("@stime", SqlDbType.VarChar, 6);
                        timePara.Direction = ParameterDirection.Input;
                        sdata = bstrData.Split(new Char[] { ',' });

                        stockPara.Value    = bstrStockNo;
                        datePara.Value     = sdata[0];
                        timePara.Value     = sdata[1];
                        openPara.Value     = sdata[2];
                        highestPara.Value  = sdata[3];
                        lowestPara.Value   = sdata[4];
                        closePara.Value    = sdata[5];
                        volPara.Value      = sdata[6];
                        sqlcmd.CommandText = @" IF NOT EXISTS (SELECT 1 FROM [dbo].StockHistoryMin WHERE stockNo=@stockno AND sdate=@sdate AND stime=@stime)  
                                    BEGIN  INSERT INTO [dbo].[StockHistoryMin] ([stockNo],[sdate],[stime],[open],[highest],[lowest], [Close],[vol] ) VALUES
                                    (@stockno, @sdate,@stime, @open, @highest, @lowest, @close, @vol) END ";
                    }
                    //Daily
                    else if (KLineTpye == "4")
                    {
                        sdata              = bstrData.Split(new Char[] { ',' });
                        stockPara.Value    = bstrStockNo;
                        datePara.Value     = sdata[0];
                        openPara.Value     = sdata[1];
                        highestPara.Value  = sdata[2];
                        lowestPara.Value   = sdata[3];
                        closePara.Value    = sdata[4];
                        volPara.Value      = sdata[5];
                        sqlcmd.CommandText = "IF NOT EXISTS (SELECT 1 FROM [dbo]." + targettable + " WHERE stockNo=@stockno AND sdate=@sdate)  " +
                                             " BEGIN INSERT INTO [dbo]." + targettable + @" ([stockNo],[sdate],[open],[highest],[lowest], [Close],[vol] )
                    VALUES (@stockno, @sdate,@open, @highest, @lowest, @close, @vol) END ";
                    }
                    sqlcmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                util.RecordLog(connectionstr, ex.Message);
            }
        }