protected void RunAgent(List <XmlNode> agentNodes, List <Item> scheduleItems) { Job.Total = agentNodes.Count + scheduleItems.Count; foreach (XmlNode node in agentNodes) { Job.AddMessage("Running {0}", new object[] { node.Attributes["type"] }); if (node != null) { object obj2 = ReflectionUtil.CreateObject(node); string methodName = node.Attributes["method"].Value; if (obj2 != null) { MethodInfo method = ReflectionUtil.GetMethod(obj2.GetType(), methodName, true, true, true, new object[0]); if (method != null) { ReflectionUtil.InvokeMethod(method, new object[0], obj2); } } } Job.Processed += 1L; } scheduleItems.Where(itm => itm.TemplateID == TemplateIDs.Schedule).ToList().ForEach(itm => { var scheduledItem = new ScheduleItem(itm); Job.AddMessage("Running {0}", new object[] { scheduledItem.DisplayName }); scheduledItem.Execute(); Job.Processed += 1L; }); }
public ActionResult RunTask(string itemid) { try { Job.Total = 1; Item itm = Factory.GetDatabase("master").GetItem(itemid); var scheduledItem = new ScheduleItem(itm); Job.AddMessage("Running {0}", new object[] { scheduledItem.DisplayName }); scheduledItem.Execute(); Job.Processed += 1; } catch (Exception ex) { Log.Error("could not execute", ex, this); return (Json( new { Status = "Error", Success = false, Message = Translate.Text("Oops! System error, please try again") }, JsonRequestBehavior.AllowGet)); } return(Json(new { Status = "Success", Success = true, Message = Translate.Text("Sucessfully executed!") }, JsonRequestBehavior.AllowGet)); }
public ActionResult RunAgent(string type) { try { Job.Total = 1; if (string.IsNullOrEmpty(type)) { return (base.Json( new { Status = "Error", Success = false, Message = Translate.Text("Oops! System error, please try again") }, JsonRequestBehavior.AllowGet)); } XmlNode agentNode = GetAgentNode(type); if (agentNode == null) { return (base.Json( new { Status = "Error", Success = false, Message = Translate.Text("Oops! System error, please try again") }, JsonRequestBehavior.AllowGet)); } Job.AddMessage("Running {0}", new object[] { agentNode.Attributes["type"] }); object obj2 = ReflectionUtil.CreateObject(agentNode); string methodName = agentNode.Attributes["method"].Value; if (obj2 != null) { MethodInfo method = ReflectionUtil.GetMethod(obj2.GetType(), methodName, true, true, true, new object[0]); if (method != null) { ReflectionUtil.InvokeMethod(method, new object[0], obj2); } } Job.Processed += 1; return(Json( new { Status = "Success", Success = true, Message = Translate.Text("Sucessfully executed!") }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error("could not run agent", ex, this); return (base.Json( new { Status = "Error", Success = false, Message = Translate.Text("Oops! System error, please try again") }, JsonRequestBehavior.AllowGet)); } }