Ejemplo n.º 1
0
        /// <summary>
        /// 讀取上市當沖標的資料寫入SQLite
        /// </summary>
        /// <param name="date">日期</param>
        public static bool WriteListedAlertToSQL(string date)
        {
            List <string> Data = new List <string>();
            // 爬取資料
            var AlertIndfo = ParseListedAlert(date);

            if (AlertIndfo != null)
            {
                foreach (var item in AlertIndfo)
                {
                    Data.Add(item.Key + "_" + item.Value);
                }

                // 寫入SQLite
                SQliteDb sQlite       = new SQliteDb();
                string   insertString = "";
                if (sQlite.DataAdd(Args_.ListedAlert_saveDir, $"Data{date}", Args_.ListedAlert_header, Data, insertString))
                {
                    Console.WriteLine($"{date} : 完成");
                    return(true);
                }
            }

            Console.WriteLine($"{date}:上市當沖標的取得失敗!");
            return(false);
        }
Ejemplo n.º 2
0
        private void OTCalertRun()
        {
            string startDate      = "";
            string startDateSlash = "";
            string endDate        = "";
            string endDateSlash   = "";

            this.Invoke((MethodInvoker) delegate()
            {
                label1.Text    = "新增中..";
                startDate      = MyFunction.SolarToVids(txt_fromday.Text, false);
                startDateSlash = MyFunction.SolarToVids(txt_fromday.Text, true);
                endDate        = MyFunction.SolarToVids(txt_endday.Text, false);
                endDateSlash   = MyFunction.SolarToVids(txt_endday.Text, true);
            });

            List <string> TestDays = MyFunction.GetAllDaysNoWeekend(startDateSlash, endDateSlash);
            SQliteDb      sQlite   = new SQliteDb();

            foreach (var item in TestDays)
            {
                // 資料表不存在 => 寫入SQLite
                if (!sQlite.CheckDatatable(Args_.ListedAlert_saveDir, "Data" + item))
                {
                    MyFunction.WriteListedAlertToSQL(item);
                }
                Thread.Sleep(5000);
            }
            this.Invoke((MethodInvoker) delegate()
            {
                label1.Text = "新增完畢";
            });
        }