public static ListSchedulesResponse Unmarshall(UnmarshallerContext _ctx) { ListSchedulesResponse listSchedulesResponse = new ListSchedulesResponse(); listSchedulesResponse.HttpResponse = _ctx.HttpResponse; listSchedulesResponse.RequestId = _ctx.StringValue("ListSchedules.RequestId"); listSchedulesResponse.NextToken = _ctx.StringValue("ListSchedules.NextToken"); List <ListSchedulesResponse.ListSchedules_SchedulesItem> listSchedulesResponse_schedules = new List <ListSchedulesResponse.ListSchedules_SchedulesItem>(); for (int i = 0; i < _ctx.Length("ListSchedules.Schedules.Length"); i++) { ListSchedulesResponse.ListSchedules_SchedulesItem schedulesItem = new ListSchedulesResponse.ListSchedules_SchedulesItem(); schedulesItem.ScheduleName = _ctx.StringValue("ListSchedules.Schedules[" + i + "].ScheduleName"); schedulesItem.Description = _ctx.StringValue("ListSchedules.Schedules[" + i + "].Description"); schedulesItem.ScheduleId = _ctx.StringValue("ListSchedules.Schedules[" + i + "].ScheduleId"); schedulesItem.Payload = _ctx.StringValue("ListSchedules.Schedules[" + i + "].Payload"); schedulesItem.CronExpression = _ctx.StringValue("ListSchedules.Schedules[" + i + "].CronExpression"); schedulesItem.Enable = _ctx.BooleanValue("ListSchedules.Schedules[" + i + "].Enable"); schedulesItem.CreatedTime = _ctx.StringValue("ListSchedules.Schedules[" + i + "].CreatedTime"); schedulesItem.LastModifiedTime = _ctx.StringValue("ListSchedules.Schedules[" + i + "].LastModifiedTime"); listSchedulesResponse_schedules.Add(schedulesItem); } listSchedulesResponse.Schedules = listSchedulesResponse_schedules; return(listSchedulesResponse); }
public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonGlueDataBrewConfig config = new AmazonGlueDataBrewConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonGlueDataBrewClient client = new AmazonGlueDataBrewClient(creds, config); ListSchedulesResponse resp = new ListSchedulesResponse(); do { ListSchedulesRequest req = new ListSchedulesRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.ListSchedules(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Schedules) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListSchedulesResponse response = new ListSchedulesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("NextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Schedules", targetDepth)) { var unmarshaller = new ListUnmarshaller <Schedule, ScheduleUnmarshaller>(ScheduleUnmarshaller.Instance); response.Schedules = unmarshaller.Unmarshall(context); continue; } } return(response); }
public ActionResult <ListSchedulesResponse> Post(ListSchedules request) { ListSchedulesResponse ret = new ListSchedulesResponse(); GXSelectArgs arg = GXSelectArgs.SelectAll <GXSchedule>(); arg.Distinct = true; arg.Where.And <GXSchedule>(q => q.Removed == DateTime.MinValue); if (request.ObjectId != 0) { arg.Joins.AddInnerJoin <GXSchedule, GXScheduleToAttribute>(s => s.Id, o => o.ScheduleId); arg.Joins.AddInnerJoin <GXScheduleToAttribute, GXAttribute>(s => s.AttributeId, o => o.Id); arg.Where.And <GXAttribute>(q => q.ObjectId == request.ObjectId); } else if (request.DeviceId != 0) { arg.Joins.AddInnerJoin <GXSchedule, GXScheduleToAttribute>(s => s.Id, o => o.ScheduleId); arg.Joins.AddInnerJoin <GXScheduleToAttribute, GXAttribute>(s => s.AttributeId, o => o.Id); arg.Joins.AddInnerJoin <GXAttribute, GXObject>(s => s.ObjectId, o => o.Id); arg.Where.And <GXObject>(q => q.DeviceId == request.DeviceId); } /* * if ((request.Targets & TargetType.Attribute) != 0) * { * arg.Columns.Add<GXObject>(); * arg.Columns.Add<GXScheduleToAttribute>(); * arg.Joins.AddLeftJoin<GXSchedule, GXScheduleToAttribute>(s => s.Id, o => o.ScheduleId); * arg.Joins.AddLeftJoin<GXScheduleToAttribute, GXAttribute>(s => s.AttributeId, o => o.Id); * arg.Joins.AddInnerJoin<GXAttribute, GXObject>(s => s.ObjectId, o => o.Id); * arg.Where.And<GXObject>(q => q.Removed == DateTime.MinValue); * arg.Where.And<GXAttribute>(q => q.Removed == DateTime.MinValue); * } */ ret.Schedules = host.Connection.Select <GXSchedule>(arg).ToArray(); foreach (GXSchedule it in ret.Schedules) { arg = GXSelectArgs.SelectAll <GXObject>(); arg.Columns.Add <GXAttribute>(); arg.Distinct = true; arg.Joins.AddInnerJoin <GXSchedule, GXScheduleToAttribute>(s => s.Id, o => o.ScheduleId); arg.Joins.AddInnerJoin <GXScheduleToAttribute, GXAttribute>(s => s.AttributeId, o => o.Id); arg.Joins.AddInnerJoin <GXAttribute, GXObject>(s => s.ObjectId, o => o.Id); arg.Where.And <GXObject>(q => q.Removed == DateTime.MinValue); arg.Where.And <GXAttribute>(q => q.Removed == DateTime.MinValue); arg.Where.And <GXSchedule>(q => q.Id == it.Id); it.Objects = host.Connection.Select <GXObject>(arg); } return(ret); }
private async void DoWork(object state) { _logger.LogWarning("Timed Background Service is working."); try { DateTime now = DateTime.Now; ListSchedulesResponse list = null; using (System.Net.Http.HttpResponseMessage response = await Helpers.client.PostAsJsonAsync(Startup.ServerAddress + "/api/schedule/ListSchedules", new ListSchedules())) { Helpers.CheckStatus(response); list = await response.Content.ReadAsAsync <ListSchedulesResponse>(); } List <GXTask> tasks = new List <GXTask>(); foreach (GXSchedule it in list.Schedules) { GXDateTime dt = new GXDateTime(it.Start); if (it.ExecutionTime == DateTime.MinValue) { it.ExecutionTime = now; } if (Equals(dt, now)) { _logger.LogTrace("+"); foreach (GXObject obj in it.Objects) { foreach (GXAttribute a in obj.Attributes) { GXTask t = new GXTask() { Object = obj, TaskType = TaskType.Read, Index = a.Index }; tasks.Add(t); } } it.ExecutionTime = now; UpdateScheduleExecutionTime us = new UpdateScheduleExecutionTime(); us.Id = it.Id; us.Time = now; using (System.Net.Http.HttpResponseMessage response = await Helpers.client.PostAsJsonAsync(Startup.ServerAddress + "/api/schedule/UpdateScheduleExecutionTime", us)) { Helpers.CheckStatus(response); UpdateScheduleExecutionTime r = await response.Content.ReadAsAsync <UpdateScheduleExecutionTime>(); } } else if (now.Minute == 0) { Console.WriteLine(dt.ToFormatString()); Console.WriteLine(now.ToString()); } } if (tasks.Count != 0) { AddTask at = new AddTask(); at.Actions = tasks.ToArray(); using (System.Net.Http.HttpResponseMessage response = await Helpers.client.PostAsJsonAsync(Startup.ServerAddress + "/api/task/AddTask", at)) { Helpers.CheckStatus(response); } } } catch (Exception ex) { _logger.LogInformation(ex.Message); } }