-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathSchedulerController.cs
More file actions
117 lines (104 loc) · 3.71 KB
/
SchedulerController.cs
File metadata and controls
117 lines (104 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using ExpressBase.Common;
using ExpressBase.Common.Data;
using ExpressBase.Common.Structures;
using ExpressBase.Objects;
using ExpressBase.Objects.ServiceStack_Artifacts;
using ExpressBase.Scheduler.Jobs;
using ExpressBase.Web.BaseControllers;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using ServiceStack;
using ServiceStack.Redis;
using System;
using System.Collections.Generic;
namespace ExpressBase.Web.Controllers
{
public class SchedulerController : EbBaseIntCommonController
{
public SchedulerController(IServiceClient sclient, IRedisClient redis) : base(sclient, redis) { }
[HttpGet]
public IActionResult Schedule()
{
return View();
}
public IActionResult SchedulelistCall(int obj)
{
return ViewComponent("SchedulerListing", new { objid = obj });
}
[HttpPost]
public void Schedule(string name, string expression, int objId, JobTypes type, string message, string users, string groups, string cronstring)
{
string Refid = string.Empty;
List<Param> _param = new List<Param>
{
new Param
{
Name = "FromDate",
Type = ((int)EbDbTypes.DateTime).ToString(),
Value = DateTime.Now.ToString("yyyy-MM-dd")
},
new Param
{
Name = "ToDate",
Type = ((int)EbDbTypes.DateTime).ToString(),
Value = DateTime.Now.ToString("yyyy-MM-dd")
},
};
if (objId > 0)
{
EbObjectFetchLiveVersionResponse res = this.ServiceClient.Get<EbObjectFetchLiveVersionResponse>(new EbObjectFetchLiveVersionRequest() { Id = objId });
if (res?.Data.Count > 0)
{
EbApi api = EbSerializers.Json_Deserialize(res.Data[0].Json);
Refid = api?.RefId;
}
}
EbTask task = new EbTask
{
Name = name,
Expression = expression,
JobType = type,
CronString = cronstring,
JobArgs = new EbJobArguments
{
Params = _param,
ObjId = objId,
RefId = Refid,
SolnId = ViewBag.cid,
UserId = ViewBag.UId,
UserAuthId = ViewBag.UAuthId,
ToUserIds = users,
ToUserGroupIds = groups,
Message = message
}
};
this.ServiceClient.Post(new ScheduleMQRequest { Task = task });
}
[HttpGet]
public IActionResult SchedulesList()
{
return View();
}
[HttpPost]
public void UpdateSchedule(EbTask task, string triggerkey, string jobkey, int id)
{
this.ServiceClient.Post(new RescheduleMQRequest { Task = task, TriggerKey = triggerkey, JobKey = jobkey, Id = id });
}
[HttpPost]
public void Unschedule(string triggerkey)
{
this.ServiceClient.Post(new UnscheduleMQRequest { TriggerKey = triggerkey });
}
[HttpPost]
public void DeleteJob(string jobkey, int id)
{
DeleteJobMQResponse ds = this.ServiceClient.Post(new DeleteJobMQRequest { JobKey = jobkey, Id = id });
}
[HttpPost]
public string GetUser_Group()
{
GetAllUsersResponse res = this.ServiceClient.Get<GetAllUsersResponse>(new GetAllSlackRequest());
return JsonConvert.SerializeObject(res);
}
}
}