在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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 CREATE TABLE [dbo].[T_task] ( [id] [int] IDENTITY (1, 1) NOT NULL , [userid] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NULL , [type] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [zxtype] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [zxtime] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [zxday] [int] NULL , [zxweek] [int] NULL , [zxweekg] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [ismonth] [int] NULL , [zxmonth] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [zxmonthday] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [zxmonthweek] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [zxmonthweekday] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [kday] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [ktime] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [dtime] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [isdtime] [int] NULL , [kcf] [int] NULL , [kcftime] [int] NULL , [ktype] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL , [msg] [text] COLLATE Chinese_PRC_CI_AS NULL , [propath] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL , [url] [nvarchar] (200) COLLATE Chinese_PRC_CI_AS NULL , [ishturl] [int] NULL , [remark] [text] COLLATE Chinese_PRC_CI_AS NULL , [dq] [int] NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO ALTER TABLE [dbo].[T_task] ADD CONSTRAINT [DF_T_task_dq] DEFAULT (0) FOR [dq], CONSTRAINT [PK_T_task] PRIMARY KEY CLUSTERED ( [id] ) ON [PRIMARY] GO
type 1:只弹出提示。2:运行指定程序 3:打开url zxmonth 月份 1,2,3,4,5,6,7,8,9,10,11,12 zxmonthweekday 选择每个星期几执行。1/2/3/4/5/6/7 msg 要提示的信息
using System;
using System.Collections.Generic; using System.Text; using System.IO; using System.Data; using System.Data.SqlClient; namespace tosky.Tool { public class task { public task(){ } public static DataTable dt; public static bool isdt=false; public static void evaltask(string id) { SqlDataReader dr = Class.Dbconn.dataReader("select * from T_task where id=" + id); if (dr.Read()){ eval(dr["type"].ToString(), Class.Tool.ConverHtml(dr["msg"].ToString(), 2), Class.Tool.ConverHtml(dr["propath"].ToString(), 2), Class.Tool.ConverHtml(dr["url"].ToString(), 2), (dr["ishturl"].ToString() == "1") ? "1" : "0"); } else { Class.Tool.alert("不存在此ID:"+id+" 的任务",1); } dr.Close(); } public static void eval(string type,string msg,string propath,string url,string ishturl) { Vote v = new Vote(); switch (type) { case "即时提示": v.StayTime = 60000; v.title = "任务提醒 (60秒后关闭)"; v.taskvote(msg); v.ScrollShow(); break; case "运行程序": try{ System.Diagnostics.Process.Start(url);v.Dispose(); }catch (Exception ex){ v.StayTime=5000; v.title = "运行程序 (5秒后关闭)"; v.showvote("打开程序失败,错误:"+ex.Message); v.ScrollShow(); } break; case "打开URL": if (ishturl == "1") { v.StayTime = 5000; v.HeightMax = 80; v.title = "后台打开URL (5秒后关闭)"; if (Class.Tool.DownHtml(url) != null){ msg = "后台打开URL " + url + " 完成!"; }else{ msg = "后台打开URL:" + url + " 失败!"; } v.showvote(msg); v.ScrollShow(); }else{ Class.Tool.openie(url); v.Dispose(); } break; } } 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()); } } } } }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论