public void SetDataToPM() { while (true) { try { DateTime DT = DateTime.Now; string xqj = DT.DayOfWeek.ToString(); if (xqj == "Saturday") { SetThreadText(Logtxt, "\r\n今日星期六,不进行制作分时走势 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Thread.Sleep(30000); } if (xqj == "Sunday") { SetThreadText(Logtxt, "\r\n今日星期日,不进行制作分时走势 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); Thread.Sleep(30000); } if ((xqj != "Sunday") && (xqj != "Saturday")) { DateTime NowTime = DateTime.Parse(DateTime.Now.TimeOfDay.ToString()); DateTime ErTopTime = DateTime.Parse("09:05:00"); DateTime TopTime = DateTime.Parse("09:25:00"); DateTime BottomTime = DateTime.Parse("15:05:00"); if (ErTopTime < NowTime && NowTime < TopTime) { GetReatNowPrice.InitDataBase();//初始化分时走势 string Title = "初始化分时走势成功" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"; if (Logtxt.Text.Length > 32767) { Logtxt.Text = ""; } SetThreadText(Logtxt, Title + Logtxt.Text); } if (TopTime < NowTime && NowTime < BottomTime) { GetReatNowPrice.GetStockInfo(); string Title = "制作分时走势成功" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"; if (Logtxt.Text.Length > 32767) { Logtxt.Text = ""; } SetThreadText(Logtxt, Title + Logtxt.Text); Thread.Sleep(int.Parse(textBox2.Text)); } else { Thread.Sleep(30000); SetThreadText(Logtxt, "收盘时间,不制作分时走势!" + Logtxt.Text); } } } catch (Exception exp) { } } }
private void button2_Click(object sender, EventArgs e) { GetReatNowPrice.InitDataBase(); MessageBox.Show("已经完成"); }