public ActionResult AddTag(Guid id, string name, string value) { var targets = new Targets(); var target = targets.GetTarget(id); if (target.Tags.ContainsKey(name)) throw new HttpException(406, "Tag name already exists"); target.Tags.Add(name, value); targets.UpdateTarget(target); if (Request.IsAjaxRequest()) return Json(null); else return RedirectToAction("EditTags", new { id = id }); }
public ActionResult ConfirmDelete(Guid id) { var targets = new Targets(); var groups = new Groups(); var target = targets.GetTarget(id); var group = groups.GetGroup(target.GroupKey); var model = new TargetDetails() { Target = target, Group = group, }; return View(model); }
// // GET: /Instances/Create public ActionResult Create(Guid tid) { var targets = new Targets(); var groups = new Groups(); var target = targets.GetTarget(tid); var group = groups.GetGroup(target.GroupKey); var model = new InstanceDetails() { Instance = new Instance(), Target = target, Group = group, }; return View(model); }
// // GET: /TargetApps/ public ActionResult Index(Guid tid, string q = null, int o = 0, int c = 50) { var targetApps = new TargetApps(); var targets = new Targets(); var groups = new Groups(); var targetAppList = targetApps.SearchTargetApps(tid, q, o, c); var target = targets.GetTarget(tid); var group = groups.GetGroup(target.GroupKey); var model = new TargetAppsIndex() { TargetAppList = targetAppList, Target = target, Group = group, }; return View(model); }
// // GET: /Instances/ConfirmDelete/5 public ActionResult ConfirmDelete(Guid id) { var instances = new Instances(); var targets = new Targets(); var groups = new Groups(); var instance = instances.GetInstance(id); var target = targets.GetTarget(instance.TargetKey); var group = groups.GetGroup(target.GroupKey); var model = new InstanceDetails() { Instance = instance, Target = target, Group = group, }; return View(model); }
public virtual void ToLockOn() { if (!lockOn) { target = targetControl.GetTarget(); if (target != null) { lockOn = true; } else { lockOn = false; } } else { lockOn = false; } animator.SetBool("LockOn", lockOn); }
// // GET: /Logs/ public ActionResult Index(Guid iid, string m = null, int c = 50) { var logs = new Logs(); var instances = new Instances(); var targets = new Targets(); var groups = new Groups(); var logPage = logs.GetLogEntryPage(iid, m, c); var instance = instances.GetInstance(iid); var target = targets.GetTarget(instance.TargetKey); var group = groups.GetGroup(target.GroupKey); var model = new LogIndex() { LogEntryPage = logPage, Instance = instance, Target = target, Group = group, }; return View(model); }
public ActionResult Details(Guid iid, long t, LogStatus s) { var logs = new Logs(); var instances = new Instances(); var targets = new Targets(); var groups = new Groups(); var log = logs.GetLogEntry(iid, new DateTime(t, DateTimeKind.Utc), s); var instance = instances.GetInstance(iid); var target = targets.GetTarget(instance.TargetKey); var group = groups.GetGroup(target.GroupKey); var model = new LogDetails() { LogEntry = log, Instance = instance, Target = target, Group = group, }; return View(model); }
public void Execute(CommandLineApplication cmd) { cmd.HelpOption("-? | -h | --help"); cmd.Description = Description; var pretty = cmd.Option("--pretty | -p", "pretty print json", CommandOptionType.NoValue); var verbose = cmd.Option("--verbose | -v", "verbose execution", CommandOptionType.NoValue); var target = cmd.Option("--target | -t", "target", CommandOptionType.SingleValue); Register(cmd); cmd.OnExecute(() => { Pretty = pretty.HasValue(); Verbose = verbose.HasValue(); Endpoint = Async.Execute(() => Targets.GetTarget(target.Value()))?.Url; try { var response = Execute(); if (response != null) { Print(response); } else { throw new Exception("response is null"); } } catch (Exception e) { Print(new { error = e.Message }); } return(0); }); }
public ActionResult Create(Guid tid, string name) { var newInstance = new Instance() { Name = name, TargetKey = tid, }; if (string.IsNullOrWhiteSpace(name)) ModelState.AddModelError("name", "Name is required."); if (ModelState.IsValid) { try { var instances = new Instances(); instances.CreateInstance(newInstance); return RedirectToAction("Details", new { id = newInstance.Key }); } catch (Exception ex) { ModelState.AddModelError("Error", ex); } } var targets = new Targets(); var groups = new Groups(); var target = targets.GetTarget(tid); var group = groups.GetGroup(target.GroupKey); var model = new InstanceDetails() { Instance = newInstance, Target = target, Group = group, }; return View(model); }
public ActionResult Delete(Guid id, FormCollection collection) { var instances = new Instances(); var instance = instances.GetInstance(id); try { instances.DeleteInstance(id); return RedirectToAction("Index", new { tid = instance.TargetKey }); } catch(Exception ex) { ModelState.AddModelError("Error", ex); } var targets = new Targets(); var groups = new Groups(); var target = targets.GetTarget(instance.TargetKey); var group = groups.GetGroup(target.GroupKey); var model = new InstanceDetails() { Instance = instance, Target = target, Group = group, }; return View("ConfirmDelete", model); }
// // GET: /Instances/ public ActionResult Index(Guid tid, string q = null, int o = 0, int c = 50) { if (o < 0) o = 0; if (c < 1) o = 1; if (c > 100) o = 100; var instances = new Instances(); var targets = new Targets(); var groups = new Groups(); var instanceList = instances.SearchInstances(tid, q, o, c); var target = targets.GetTarget(tid); var group = groups.GetGroup(target.GroupKey); var model = new InstanceIndex() { InstanceList = instanceList, Target = target, Group = group, }; return View(model); }
public ActionResult Version(Guid tid, Guid aid) { var targetAppVersions = new TargetAppVersions(); var versions = new Versions(); var apps = new Apps(); var targets = new Targets(); var groups = new Groups(); Version version; var versionKey = targetAppVersions.GetTargetAppVersion(tid, aid); if (versionKey.HasValue) { try { version = versions.GetVersion(versionKey.Value); } catch (Exception) { version = null; } } else { version = null; } var app = apps.GetApp(aid); var target = targets.GetTarget(tid); var group = groups.GetGroup(target.GroupKey); var model = new TargetAppVersionDetails() { Version = version, App = app, Target = target, Group = group, }; return View(model); }
public JsonResult UpdateTag(Guid id, string oldName, string name, string value) { var targets = new Targets(); var target = targets.GetTarget(id); if (!target.Tags.ContainsKey(oldName)) throw new HttpException(404, "Tag not found"); if (oldName == name) { target.Tags[name] = value; } else if (target.Tags.ContainsKey(name)) { throw new HttpException(406, "Tag name already exists"); } else { target.Tags.Remove(oldName); target.Tags.Add(name, value); } targets.UpdateTarget(target); return Json(null); }
public JsonResult RemoveTag(Guid id, string name) { var targets = new Targets(); var target = targets.GetTarget(id); if (!target.Tags.ContainsKey(name)) throw new HttpException(404, "Tag not found"); target.Tags.Remove(name); targets.UpdateTarget(target); return Json(null); }
public ActionResult Edit(Guid id, string name) { Target target = null; try { var targets = new Targets(); target = targets.GetTarget(id); target.Name = name; targets.UpdateTarget(target); return RedirectToAction("Details", new { id = target.Key }); } catch (Exception ex) { ModelState.AddModelError("Error", ex); } var groups = new Groups(); Group group = null; if (target != null) group = groups.GetGroup(target.GroupKey); var model = new TargetDetails() { Target = target, Group = group, }; return View(model); }
public ActionResult Delete(Guid id) { var targets = new Targets(); var target = targets.GetTarget(id); try { targets.DeleteTarget(id); return RedirectToAction("Index", new { gid = target.GroupKey }); } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); var groups = new Groups(); var group = groups.GetGroup(target.GroupKey); var model = new TargetDetails() { Target = target, Group = group, }; return View("ConfirmDelete", model); } }