internal void SendMessage(int roomNum, int time, DateTime now) { string[] sql = { "select t1.no,t2.name,t1.seat_no,t1.time_end,t2.wechat from tb_seat_student as t1,tb_student as t2 where t1.room=@room and t1.time_end<@nw and t1.isoutdate=0 and t1.issend_" + time + "_message=0 and t1.no=t2.no", "update tb_seat_student set issend_" + time + "_message=1 where room=@room and time_end<@nw and isoutdate=0 and issend_" + time + "_message=0" }; SqlParameter[] sp1 = { new SqlParameter("@room", roomNum), new SqlParameter("@nw", now.AddMinutes(time)) }; DataTable dt = SqlServerHelper.ExecuteDataTable(sql[0], sp1); string access_token = GetAccessToken(); //发送消息 foreach (DataRow item in dt.Rows) { Send(access_token, item[0].ToString(), roomNum.ToString(), seat_no2tableseat(MyConvert.toInt(item[2])), time.ToString(), MyConvert.toString(item[3])); } //发送消息结束。 SqlParameter[] sp2 = { new SqlParameter("@room", roomNum), new SqlParameter("@nw", now.AddMinutes(time)) }; SqlServerHelper.ExecuteNonQuery(sql[1], sp2); }
/// <summary> /// 系统启动时扫描一次本自习室座位的使用情况。 /// </summary> /// <param name="room"></param> /// <param name="SetColor"></param> public void Scan(int room, RemoteSetColor SetColor) { string sql = "select no from tb_seat where anyone=1"; DataTable dt = SqlServerHelper.ExecuteDataTable(sql); foreach (DataRow item in dt.Rows) { SetColor((int)item[0], Brushes.Red); } }