if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[T_task]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[T_task] GO
public static void taskeval(string id){ int dq = 0; SqlDataReader dr = Class.Dbconn.dataReader("select * from T_task where dq=0 and id=" + id); if (dr.Read()){ string type = dr["type"].ToString(), msg = Class.Tool.ConverHtml(dr["msg"].ToString(), 2), propath = Class.Tool.ConverHtml(dr["propath"].ToString(), 2), url = Class.Tool.ConverHtml(dr["url"].ToString(), 2), ishthtml = (dr["ishturl"].ToString() == "1") ? "1" : "0", zxtime = dr["zxtime"].ToString(), zxtype = dr["zxtype"].ToString(), isdtime=dr["isdtime"].ToString(), ktime = dr["ktime"].ToString(), dtime = dr["dtime"].ToString() + " " + zxtime, zxweekg = dr["zxweekg"].ToString(), ismonth = dr["ismonth"].ToString(), zxmonth=dr["zxmonth"].ToString(), zxmonthday=dr["zxmonthday"].ToString();
int zxday = int.Parse(dr["zxday"].ToString()), zxweek = int.Parse(dr["zxweek"].ToString()); DateTime dtktime = DateTime.Parse(ktime), dtdtime = DateTime.Parse(dtime); TimeSpan ts = DateTime.Now.Subtract(dtktime); if (isdtime == "1" && (dtdtime < DateTime.Now)){ dq = 1; }else{ bool sf = false; switch (zxtype) { case "每天": if (ts.Days % zxday == 0){ sf = true; } break; case "每周": int j=int.Parse(Class.Tool.week(DateTime.Now, 1)); TimeSpan ts2 = DateTime.Now.AddDays(1-j) - dtktime; int zxw = ts2.Days/7; if (ts2.Days-zxw*7>0){zxw+=1;} if (zxw % zxweek ==0){ string[] w = zxweekg.Split(','); if (w[j - 1] == "1") { sf = true; } } break; case "每月": string[] m=zxmonth.Split(','); if (m[DateTime.Now.Month - 1] == "1") { if (ismonth == "2"){ if (Class.Tool.week(DateTime.Now, 2) == Class.Tool.week(DateTime.Now, 2)) {sf = true;} }else{ if(DateTime.Now.Day == int.Parse(zxmonthday)) { sf = true; } } } break; case "一次": sf = true; dq = 1; break; } if(sf){eval(type, msg, propath, url, ishthtml);} } } dr.Close();
if (dq == 1) { Class.Dbconn.ExecuteSql("update T_task set dq=1 where id="+id); } }
public static void foreval(string dts,string user) { if (!isdt){ dt = Class.Dbconn.dataTable("select id,zxtime from T_task where dq=0 and userid='" + user + "'"); isdt = true; } for (int i = 0; i<dt.Rows.Count; i++){ if (dts==dt.Rows[i][1].ToString()){ Tool.task.taskeval(dt.Rows[i][0].ToString()); } } } }