- sqlserver:"Persist Security Info = False; User ID =sa; Password =123456; Initial Catalog =schedule_master; Server =." - postgresql:"Server=localhost;Port=5432;Database=schedule_master;User Id=postgres;Password=123456;Pooling=true;MaxPoolSize=20;" - mysql:"Data Source=localhost;Database=schedule_master;User ID=root;Password=123456;pooling=true;CharSet=utf8mb4;port=3306;sslmode=none;TreatTinyAsBoolean=true"修改Host的配置文件和支持的数据库,框架默认使用Mysql
dotnet Hos.ScheduleMaster.QuartzHost.dll --urls http://*:30003
配置Http调度任务
5、准备就绪后,使用后台查看节点管理,可以看到web主节点30000和任务调度的接口30002已经在运行namespace TaskExcuteService { class AssemblyTask : TaskBase { public override void Run(TaskContext context) { context.WriteLog("程序集任务"); } } }2、找到debug目录,去掉Base程序集,然后添加为压缩文件
HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Add("ms_auth_user", "admin"); client.DefaultRequestHeaders.Add("ms_auth_secret", SecurityHelper.MD5($"admin{SecurityHelper.MD5("111111")}}admin"));所有接口采用统一的返回格式,字段如下:
HttpClient client = new HttpClient(); List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>(); args.Add(new KeyValuePair<string, string>("MetaType", "1")); args.Add(new KeyValuePair<string, string>("RunLoop", "true")); args.Add(new KeyValuePair<string, string>("CronExpression", "33 0/8 * * * ?")); args.Add(new KeyValuePair<string, string>("Remark", "By Xunit Tester Created")); args.Add(new KeyValuePair<string, string>("StartDate", DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss"))); args.Add(new KeyValuePair<string, string>("Title", "程序集接口测试任务")); args.Add(new KeyValuePair<string, string>("AssemblyName", "Hos.ScheduleMaster.Demo")); args.Add(new KeyValuePair<string, string>("ClassName", "Hos.ScheduleMaster.Demo.Simple")); args.Add(new KeyValuePair<string, string>("CustomParamsJson", "[{\"ParamKey\":\"k1\",\"ParamValue\":\"1111\",\"ParamRemark\":\"r1\"},{\"ParamKey\":\"k2\",\"ParamValue\":\"2222\",\"ParamRemark\":\"r2\"}]")); args.Add(new KeyValuePair<string, string>("Keepers", "1")); args.Add(new KeyValuePair<string, string>("Keepers", "2")); //args.Add(new KeyValuePair<string, string>("Nexts", "")); //args.Add(new KeyValuePair<string, string>("Executors", "")); HttpContent reqContent = new FormUrlEncodedContent(args); var response = await client.PostAsync("http://localhost:30000/api/Task/Create", reqContent); var content = await response.Content.ReadAsStringAsync(); Debug.WriteLine(content);
HttpClient client = new HttpClient(); List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>(); args.Add(new KeyValuePair<string, string>("MetaType", "2")); args.Add(new KeyValuePair<string, string>("RunLoop", "true")); args.Add(new KeyValuePair<string, string>("CronExpression", "22 0/8 * * * ?")); args.Add(new KeyValuePair<string, string>("Remark", "By Xunit Tester Created")); args.Add(new KeyValuePair<string, string>("StartDate", DateTime.Today.ToString("yyyy-MM-dd HH:mm:ss"))); args.Add(new KeyValuePair<string, string>("Title", "Http接口测试任务")); args.Add(new KeyValuePair<string, string>("HttpRequestUrl", "http://localhost:56655/api/1.0/value/jsonpost")); args.Add(new KeyValuePair<string, string>("HttpMethod", "POST")); args.Add(new KeyValuePair<string, string>("HttpContentType", "application/json")); args.Add(new KeyValuePair<string, string>("HttpHeaders", "[]")); args.Add(new KeyValuePair<string, string>("HttpBody", "{ \"Posts\": [{ \"PostId\": 666, \"Title\": \"tester\", \"Content\":\"testtesttest\" }], \"BlogId\": 111, \"Url\":\"qweqrrttryrtyrtrtrt\" }")); HttpContent reqContent = new FormUrlEncodedContent(args); var response = await client.PostAsync("http://localhost:30000/api/Task/Create", reqContent); var content = await response.Content.ReadAsStringAsync(); Debug.WriteLine(content);
for (int i = 0; i < 5; i++) { int rndNum = new Random().Next(20, 500); List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>(); args.Add(new KeyValuePair<string, string>("SourceApp", "TestApp")); args.Add(new KeyValuePair<string, string>("Topic", "TestApp.Trade.TimeoutCancel")); args.Add(new KeyValuePair<string, string>("ContentKey", i.ToString())); args.Add(new KeyValuePair<string, string>("DelayTimeSpan", rndNum.ToString())); args.Add(new KeyValuePair<string, string>("DelayAbsoluteTime", DateTime.Now.AddSeconds(rndNum).ToString("yyyy-MM-dd HH:mm:ss"))); args.Add(new KeyValuePair<string, string>("NotifyUrl", "http://localhost:56655/api/1.0/value/delaypost")); args.Add(new KeyValuePair<string, string>("NotifyDataType", "application/json")); args.Add(new KeyValuePair<string, string>("NotifyBody", "{ \"Posts\": [{ \"PostId\": 666, \"Title\": \"tester\", \"Content\":\"testtesttest\" }], \"BlogId\": 111, \"Url\":\"qweqrrttryrtyrtrtrt\" }")); HttpContent reqContent = new FormUrlEncodedContent(args); var response = await client.PostAsync("http://localhost:30000/api/DelayTask/Create", reqContent); var content = await response.Content.ReadAsStringAsync(); Debug.WriteLine(content); }