/// <summary> /// 运行计划任务 /// </summary> public static void RunTask() { int intID = 0; int intSID = 0; int intCategory = 0; string strTask = ""; byte byteStatus = 0; string strSQL = "SELECT TOP 1 ID,[SID],Category,Task,RunTime,[Status] FROM Fx_Task WHERE [Status] = 1 AND RunTime < CONVERT(Char(10),GetDate()+1,120) ORDER BY RunTime"; try { Console.WriteLine("==================== [计划任务] 开始 ================== \r\n"); DataRow dr = SqlHelper.ExecuteDataRow(SqlLibrary.GetFx_Main(), CommandType.Text, strSQL); intID = Convert.ToInt32(dr["ID"]); intSID = Convert.ToInt32(dr["SID"]); intCategory = Convert.ToInt32(dr["Category"]); strTask = Convert.ToString(dr["Task"]); byteStatus = Convert.ToByte(dr["Status"]); string[] arrTask = strTask.Split(new char[] { ' ' }); Console.WriteLine(Convert.ToDateTime(dr["RunTime"]) + "<" + DateTime.Now + "&&" + byteStatus); if (Convert.ToDateTime(dr["RunTime"]) < DateTime.Now && byteStatus == 1) { Console.WriteLine(">>>>>>>>>进入计划任务判断<<<<<<<<"); SysConsole(intSID, arrTask[0].ToLower().ToString(), arrTask[1].ToLower().ToString()); SqlLibrary.Fx_UpdateTaskRuntime(intID); Console.WriteLine("发送对像:" + intSID + " 命令:" + arrTask[0].ToString() + " 参数:" + arrTask[1].ToString() + " 任务编号:" + intID + "\r\n"); Console.WriteLine("==================== [计划任务] 结束 ================== \r\n"); } } catch { Console.WriteLine("---[没有计划任务要执行]--- \r\n"); Console.WriteLine("==================== [计划任务] 结束 ================== \r\n"); } }