public ActionResult AddScheduling(SchedulingModel schedulingModel) { if (taskScheduling.GetByName(schedulingModel.Name) != null) { return(new ResponseModel <string>(ErrorCode.record_exist, "")); } Data.Models.TaskScheduling scheduling = new Data.Models.TaskScheduling() { Name = schedulingModel.Name, Description = schedulingModel.Description, Api = schedulingModel.Api, Status = SchedulingStateEnum.Stoped }; if (schedulingModel.Trigger != null) { schedulingModel.TriggerIds.Add(schedulingModel.Trigger.Value); } List <DateTimeOffset> nextRunTimes = new List <DateTimeOffset>(); var list = taskTrigger.GetByIds(schedulingModel.TriggerIds).Select(s => s.Crons); scheduling.NextRunTime = GetNextRunTimeByCrons(list); //nextRunTimes[0].LocalDateTime; int count = taskScheduling.InsertScheduling(new List <object>() { scheduling, new { triggerIds = schedulingModel.TriggerIds } }); if (count > 0) { return(new ResponseModel <string>(ErrorCode.success, "")); } return(new ResponseModel <string>(ErrorCode.server_exception, "")); }
public SchedulingModel GetSchedulingById(int ScheduleID) { var url = "api/EquipmentScheduling/" + ScheduleID; string result = SC.Getcaller(url); if (result != null) { SchedulingModel scheduling = JsonConvert.DeserializeObject <SchedulingModel>(result); return(scheduling); } else { return(null); } }
protected void linkUpdateAll_Command(object sender, CommandEventArgs e) { try { if (e.CommandName == "Update") { int _cmdArg = Convert.ToInt32(e.CommandArgument); SchedulingModel li = SS.GetSchedulingById(_cmdArg); Session["scheduleId"] = _cmdArg.ToString(); int obs = li.ObjectSensorId; int _days = li.Days; bool cbstatus = false; var lb = (LinkButton)sender; var row = (GridViewRow)lb.NamingContainer; if (row != null) { TextBox S_Time = row.FindControl("txtstarttime") as TextBox; string StartTime = S_Time.Text; TextBox E_Time = row.FindControl("txtendtime") as TextBox; string EndTime = E_Time.Text; CheckBox chk = (CheckBox)row.FindControl("chkstatus"); if (chk.Checked == true) { cbstatus = true; } bool responce = SS.PutEquipmentScheduling(_cmdArg, Convert.ToInt32(ddlObject.SelectedValue), StartTime, EndTime, _days, obs, cbstatus); if (responce == true) { GvdBindObjdetail(Convert.ToInt32(ddlObject.SelectedValue), Convert.ToInt32(ddlDays.SelectedValue)); _alert = AlertsClass.SuccessUpdate; } } allowStaticMethods("ALerts('" + _alert + "');staticMethod();"); } } catch (Exception) { BindingClass.ExceptionAlertScriptManager(this.Page, this.GetType()); } }
private List <ScheduledTask> Run() { Project project = CreateProject(); if (project == null) { MessageBox.Show("There are no Tasks to be processed."); return(new List <ScheduledTask>()); } SchedulingModel m = new SchedulingModel(true); m.Initialize(project); IDictionary <int, double> schedule = m.Solve(); //ProjectUtilities.PrintProjectSchedule(project, schedule); var results = new List <ScheduledTask>(); foreach (var taskSchedule in schedule) { ProjectScheduling.Task task = project.Tasks[taskSchedule.Key]; double start = Math.Round(taskSchedule.Value, 3); results.Add(new ScheduledTask(task, start, start + task.Duration)); } Dictionary <ProjectScheduling.Task, List <ScheduledTask> > bakn = new Dictionary <ProjectScheduling.Task, List <ScheduledTask> >(); foreach (var key in results) { if (bakn.ContainsKey(key.task)) { bakn[key.task].Add(key); } else { bakn.Add(key.task, new List <ScheduledTask>()); bakn[key.task].Add(key); } } //Console.WriteLine(ProjectUtilities.ToCsv(project, schedule)); return(results); }
public void InitializeTest() { _scheduledModel = new SchedulingModel(); }