Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        public IActionResult GetEmpty(ControllerContext context)
        {
            Debug.Print(context.ControllerName);

            Debug.Print("Emulator => GetEmpty");

            return EmptyResult();
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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");
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public IActionResult Stop(ControllerContext context)
        {
            ServiceManager.Current.StopAll();

            return EmptyResult();
        }
Exemplo n.º 9
0
 public IActionResult Reboot(ControllerContext context)
 {
     return EmptyResult();
 }
Exemplo n.º 10
0
        public IActionResult Restart(ControllerContext context)
        {
            ServiceManager.Current.RestartAll();

            return EmptyResult();
        }
Exemplo n.º 11
0
 public IActionResult GetExecption(ControllerContext context)
 {
     throw new NullReferenceException("Testing Null Reference Exception");
 }
Exemplo n.º 12
0
        public IActionResult GetError(ControllerContext context)
        {
            Debug.Print("Test Harness => GetError");

            return new HttpStatusCodeResult(404, "Page Not Found");
        }
Exemplo n.º 13
0
 public IActionResult GetRedirectToGoogle(ControllerContext context)
 {
     return RedirectResult("http://www.google.com/");
 }
Exemplo n.º 14
0
 public IActionResult GetRedirectToGetFile(ControllerContext context)
 {
     return RedirectResult("Home", "GetFile");
 }
Exemplo n.º 15
0
        public IActionResult GetGoogle(ControllerContext context)
        {
            Debug.Print("Emulator => GetGoogle");

            return RedirectResult("http://www.google.com/");
        }
Exemplo n.º 16
0
 public IActionResult GetRedirect(ControllerContext context)
 {
     return RedirectResult("test", "getjson");
 }
Exemplo n.º 17
0
 public IActionResult GetEmpty(ControllerContext context)
 {
     return EmptyResult();
 }