• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Asp.Net MVC 3 + ExtJs 4.01做一个Quartz.Net管理平台

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

在原来的公司曾经用asp.net + extjs 2做过一个Quartz.Net简单管理平台(后来申请了著作权,尽然也可以),随着Asp.Net MVC 3和ExtJs 4的发布,突然有了重新用Asp.Net MVC 3 + ExtJs 4重新做一下的冲动(冲动是魔鬼呀。。。)。本次只实现了显示触发器Trigger的信息。

效果图:

 

1.定义TriggerInfo,这里为了方便起见只列出了TriggerInfo的定义

 1     using System;
 2     using System.Runtime.Serialization;
 3 
 4     [DataContract]
 5     public class TriggerInfo
 6     {
 7         [DataMember]
 8         public string CalendarName { getset; }
 9 
10         [DataMember]
11         public string Description { getset; }
12 
13         [DataMember]
14         public DateTime? EndTimeUtc { getset; }
15 
16         [DataMember]
17         public DateTime? FinalFireTimeUtc { getset; }
18 
19         [DataMember]
20         public string FireInstanceId { setget; }
21 
22         [DataMember]
23         public string FullJobName { getset; }
24 
25         [DataMember]
26         public string FullName { getset; }
27 
28         [DataMember]
29         public string Group { getset; }
30 
31         [DataMember]
32         public bool HasAdditionalProperties { getset; }
33 
34         [DataMember]
35         public bool HasMillisecondPrecision { getset; }
36 
37         [DataMember]
38         public string JobGroup { getset; }
39 
40         [DataMember]
41         public string JobName { getset; }
42 
43         [DataMember]
44         public string Key { getset; }
45 
46         [DataMember]
47         public bool MayFireAgain { getset; }
48 
49         [DataMember]
50         public int MisfireInstruction { getset; }
51 
52         [DataMember]
53         public string Name { getset; }
54 
55         [DataMember]
56         public DateTime? NextFireTimeUtc { getset; }
57 
58         [DataMember]
59         public DateTime? PreviousFireTimeUtc { getset; }
60 
61         [DataMember]
62         public int Priority { getset; }
63 
64         [DataMember]
65         public DateTime StartTimeUtc { getset; }
66 
67         [DataMember]
68         public string[] TriggerListenerNames { getset; }
69 
70         [DataMember]
71         public TriggerType TriggerType { getset; }
72 
73         [DataMember]
74         public TriggerStateInfo TriggerState { getset; }
75 
76         [DataMember]
77         public bool Volatile { getset; }
78 
79         [DataMember]
80         public int RepeatCount { getset; }
81 
82         [DataMember]
83         public TimeSpan RepeatInterval { getset; }
84 
85         [DataMember]
86         public int TimesTriggered { getset; }
87 
88         [DataMember]
89         public int RepeatIndefinitely { getset; }
90 
91         [DataMember]
92         public string CronExpressionString { getset; }
93 
94         [DataMember]
95         public TimeZoneInfo TimeZone { getset; }
96     }

2.定义服务契约IScheduleService

  1     using System;
  2     using System.ServiceModel;
  3 
  4     using DataContract;
  5 
  6     [ServiceContract]
  7     public interface IScheduleService
  8     {
  9         [OperationContract]
 10         void AddJob(JobInfo jobInfo, bool replace);
 11 
 12         [OperationContract]
 13         bool DeleteJob(string jobName, string groupName);
 14 
 15         [OperationContract]
 16         string[] GetJobGroupNames();
 17 
 18         [OperationContract]
 19         JobInfo GetJobDetail(string jobName, string groupName);
 20 
 21         [OperationContract]
 22         string[] GetJobNames(string groupName);
 23 
 24         [OperationContract]
 25         TriggerInfo GetTrigger(string triggerName, string groupName);
 26 
 27         [OperationContract]
 28         string[] GetTriggerGroupNames();
 29 
 30         [OperationContract]
 31         string[] GetTriggerNames(string groupName);
 32 
 33         [OperationContract]
 34         TriggerStateInfo GetTriggerState(string triggerName, string triggerGroup);
 35 
 36         [OperationContract]
 37         bool IsJobGroupPaused(string groupName);
 38 
 39         [OperationContract]
 40         bool IsTriggerGroupPaused(string groupName);
 41 
 42         [OperationContract]
 43         void PauseAll();
 44 
 45         [OperationContract]
 46         void PauseJob(string jobName, string groupName);
 47 
 48         [OperationContract]
 49         void PauseJobGroup(string groupName);
 50 
 51         [OperationContract]
 52         void PauseTrigger(string triggerName, string triggerGroup);
 53 
 54         [OperationContract]
 55         void PauseTriggerGroup(string triggerGroup);
 56 
 57         [OperationContract]
 58         DateTime? RescheduleJob(string triggerName, string triggerGroup, TriggerInfo newTrigger);
 59 
 60         [OperationContract]
 61         void ResumeAll();
 62 
 63         [OperationContract]
 64         void ResumeJob(string jobName, string groupName);
 65 
 66         [OperationContract]
 67         void ResumeJobGroup(string groupName);
 68 
 69         [OperationContract]
 70         void ResumeTrigger(string triggerName, string groupName);
 71 
 72         [OperationContract]
 73         void ResumeTriggerGroup(string groupName);
 74 
 75         [OperationContract]
 76         DateTime ScheduleJob(TriggerInfo trigger);
 77 
 78         [OperationContract]
 79         DateTime ScheduleJobByTrigger(JobInfo jobInfo, TriggerInfo trigger);
 80 
 81         [OperationContract]
 82         void Shutdown(bool waitForJobsToComplete);
 83 
 84         [OperationContract]
 85         void Standby();
 86 
 87         [OperationContract]
 88         void Start();
 89 
 90         [OperationContract]
 91         void StartDelayed(TimeSpan delay);
 92 
 93         [OperationContract]
 94         void TriggerJob(string jobName, string groupName);
 95 
 96         [OperationContract]
 97         void TriggerJobWithVolatileTrigger(string jobName, string groupName);
 98 
 99         [OperationContract]
100         void UnscheduleJob(string triggerName, string groupName);
101     }

3.实现服务契约IScheduleService的ScheduleService ,由于服务提交代码,只能描述一下了,这个类就是把Quartz.Net的Schedule封装了一下。

4.定义SchduleController,来输出Job和Trigger的信息

 1     using System.Collections.Generic;
 2     using System.Web.Mvc;
 3 
 4     using Vancl.Schedule.DataContract;
 5     using Vancl.Schedule.ServiceContract;
 6     using Vancl.Schedule.ServiceImpl;
 7 
 8     public class ScheduleController : Controller
 9     {
10         private readonly IScheduleService scheduleService = ScheduleService.Instance;
11 
12         /// <summary>
13         /// 获取所有任务
14         /// </summary>
15         /// <returns></returns>
16         public ActionResult GetJobs()
17         {
18             IList<JobInfo> jobInfoes = new List<JobInfo>();
19 
20             string[] groupNames = scheduleService.GetJobGroupNames();
21 
22             if (groupNames != null)
23             {
24                 foreach (string groupName in groupNames)
25                 {
26                     string[] jobNames = scheduleService.GetJobNames(groupName);
27 
28                     if (jobNames != null)
29                     {
30                         foreach (string jobName in jobNames)
31                         {
32                             jobInfoes.Add(scheduleService.GetJobDetail(jobName, groupName));
33                         }
34                     }
35                 }
36             }
37 
38             return new JsonResult() { Data = jobInfoes, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
39         }
40 
41         /// <summary>
42         /// 获取所有触发器
43         /// </summary>
44         /// <returns></returns>
45         public ActionResult GetTriggers()
46         {
47             IList<TriggerInfo> triggerInfoes = new List<TriggerInfo>();
48 
49             string[] groupNames = scheduleService.GetTriggerGroupNames();
50 
51             if (groupNames != null)
52             {
53                 foreach (string groupName in groupNames)
54                 {
55                     string[] triggerNames = scheduleService.GetTriggerNames(groupName);
56 
57                     if (triggerNames != null)
58                     {
59                         foreach (string triggerName in triggerNames)
60                         {
61                             TriggerInfo triggerInfo = scheduleService.GetTrigger(triggerName, groupName);
62                             triggerInfo.TriggerState = scheduleService.GetTriggerState(triggerName, groupName);
63                             triggerInfoes.Add(triggerInfo);
64                         }
65                     }
66                 }
67             }
68 
69             return new JsonResult() { Data = triggerInfoes, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
70         }
71     }

5.定义TriggerInfo,扩展于Ext.data.Model

1 Ext.define("Vancl.Cxcp.TriggerInfo", {
2     extend: 'Ext.data.Model',
3     fields: ['Name''Group''JobName''JobGroup''TriggerType''StartTimeUtc''PreviousFireTimeUtc''NextFireTimeUtc''MisfireInstruction''TriggerState']
4 });

 6.出于方便,我直接利用了Ext的desktop,下面是用于显示所有Trigger信息的Grid

 

<

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Asp.net Mvc Framework 二 (URL Routing初解)发布时间:2022-07-10
下一篇:
模拟Asp.Net Forums实现可以换皮肤的控件 (转载)发布时间:2022-07-10
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap