public ActionResult Settings(ControllerContext context) { string cfgPath = ServiceManager.Current.StorageRoot + @"\settings.xml"; JObject jdom = new JObject(); if (context.HttpContext.Request.HttpMethod.ToUpper().Equals("POST")) { foreach (DictionaryEntry parameters in context.HttpContext.Request.Form) { IParameter parameter = (IParameter)parameters.Value; if (!StringUtility.IsNullOrEmpty(parameter.Name) && !StringUtility.IsNullOrEmpty(parameter.Value)) ConfigManager.SetSetting(parameter.Name, parameter.Value); } ConfigManager.Save(cfgPath); } else { ConfigManager.Load(cfgPath); foreach (DictionaryEntry parameter in ConfigManager.GetSettings()) { jdom.Add(parameter.Key.ToString(), parameter.Value.ToString()); } } return JsonResult(jdom); }
public IActionResult GetJson(ControllerContext context) { JArray jcar = new JArray(); jcar.Add(new JProperty("make", "ford")); jcar.Add(new JProperty("model", "mustang")); jcar.Add(new JProperty("color", "blue")); JArray jcar1 = new JArray(); jcar1.Add(new JProperty("make", "bmw")); jcar1.Add(new JProperty("model", "M5")); jcar1.Add(new JProperty("color", "black")); JArray jgroup = new JArray(); jgroup.Add(new JProperty("group", "car")); jgroup.Add(new JProperty("type", jcar)); jgroup.Add(new JProperty("type", jcar1)); JArray jar = new JArray(); jar.Add(new JProperty("style", "")); jar.Add(new JProperty("data-role", "update")); jar.Add(new JProperty("data-inset", "true")); jar.Add(new JProperty("group", jgroup)); JObject jdom = new JObject(); jdom.Add("date", new DateTime(1983, 3, 20).ToString()); jdom.Add("data-role", "update"); jdom.Add("style", jar); return JsonResult(jdom); }
public IActionResult Index(ControllerContext context) { string ipAddress = ServiceManager.Current.HttpService.InterfaceAddress.ToString(); string port = ServiceManager.Current.HttpService.ActivePort.ToString(); ViewData["IPADDRESS"] = string.Concat(ipAddress, ":", port); return View(); }
public IActionResult GetEmpty(ControllerContext context) { Debug.Print(context.ControllerName); Debug.Print("Emulator => GetEmpty"); return EmptyResult(); }
public IActionResult GetFile(ControllerContext context) { string rootFilePath = string.Concat(ServiceManager.Current.StorageRoot, @"\", MicroServer.Net.Http.Constants.HTTP_WEB_ROOT_FOLDER, @"\"); string fileNamePath = @"\content\images\bay.jpg"; return FileResult(rootFilePath, fileNamePath); }
public IActionResult GetHello(ControllerContext context) { string response = "<doctype !html><html><head><title>Hello, world!</title>" + "<style>body { background-color: #111 }" + "h1 { font-size:2cm; text-align: center; color: white;}</style></head>" + "<body><h1>" + DateTime.Now.ToString() + "</h1></body></html>\r\n"; return ContentResult(response, "text/html"); }
public ActionResult Info(ControllerContext context) { JObject jdom = new JObject(); jdom.Add("software", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()); jdom.Add("version", SystemInfo.Version.ToString()); jdom.Add("oemString", SystemInfo.OEMString); jdom.Add("isEmulator", SystemInfo.IsEmulator.ToString()); jdom.Add("idModel", SystemInfo.SystemID.Model); jdom.Add("idOem", SystemInfo.SystemID.OEM); jdom.Add("idSku", SystemInfo.SystemID.SKU); jdom.Add("availableMemory", Debug.GC(false).ToString("n0") + " bytes"); jdom.Add("ipAddress", HttpService.Current.InterfaceAddress.ToString()); jdom.Add("ipPort", HttpService.Current.ServicePort); jdom.Add("hostname", ServiceManager.Current.ServerName); jdom.Add("dnsSuffix", ServiceManager.Current.DnsSuffix); jdom.Add("sntpEnabled", ServiceManager.Current.SntpEnabled); jdom.Add("dhcpEnabled", ServiceManager.Current.DhcpEnabled); jdom.Add("dnsEnabled", ServiceManager.Current.DnsEnabled); jdom.Add("httpEnabled", ServiceManager.Current.HttpEnabled); jdom.Add("loglevel", ServiceManager.Current.LogLevel.ToString()); return JsonResult(jdom); }
public IActionResult Stop(ControllerContext context) { ServiceManager.Current.StopAll(); return EmptyResult(); }
public IActionResult Reboot(ControllerContext context) { return EmptyResult(); }
public IActionResult Restart(ControllerContext context) { ServiceManager.Current.RestartAll(); return EmptyResult(); }
public IActionResult GetExecption(ControllerContext context) { throw new NullReferenceException("Testing Null Reference Exception"); }
public IActionResult GetError(ControllerContext context) { Debug.Print("Test Harness => GetError"); return new HttpStatusCodeResult(404, "Page Not Found"); }
public IActionResult GetRedirectToGoogle(ControllerContext context) { return RedirectResult("http://www.google.com/"); }
public IActionResult GetRedirectToGetFile(ControllerContext context) { return RedirectResult("Home", "GetFile"); }
public IActionResult GetGoogle(ControllerContext context) { Debug.Print("Emulator => GetGoogle"); return RedirectResult("http://www.google.com/"); }
public IActionResult GetRedirect(ControllerContext context) { return RedirectResult("test", "getjson"); }
public IActionResult GetEmpty(ControllerContext context) { return EmptyResult(); }