public int Execute(IHttpContext context, string path, string scriptName)
        {
            IRequest request = context.Request;

            // Determine if there's content to write to stdin
            bool hasBody = request.Body != null && request.Body.Length > 0;

            _hasError    = false;
            _hasTimedOut = false;

            _error = new StringBuilder();



            System.Collections.Generic.Dictionary <string, string> DSL   = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/wandsl.info");
            System.Collections.Generic.Dictionary <string, string> WLAN  = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/wlan.info");
            System.Collections.Generic.Dictionary <string, string> TAM   = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/tam.info");
            System.Collections.Generic.Dictionary <string, string> DEVI  = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/Deviceinfo.info");
            System.Collections.Generic.Dictionary <string, string> WAN   = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/wanppp.info");
            System.Collections.Generic.Dictionary <string, string> TEL   = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/phone.info");
            System.Collections.Generic.Dictionary <string, string> LAN   = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/lan.info");
            System.Collections.Generic.Dictionary <string, string> USB   = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/usb.info");
            System.Collections.Generic.Dictionary <string, string> DECT  = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/dect.info");
            System.Collections.Generic.Dictionary <string, string> I2C   = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/i2c.info");
            System.Collections.Generic.Dictionary <string, string> ALARM = FeuerwehrCloud.Helper.AppSettings.Load("dyndata/alarm.info");
            System.Text.StringBuilder SB = new StringBuilder();
            SB.AppendLine("<?");

            SB.AppendLine("/* This file is automatically generated by DEIVA.");
            SB.AppendLine("   Do not modify this file -- YOUR CHANGES WILL BE ERASED!");
            SB.AppendLine("*/");
            SB.AppendLine("");

            SB.AppendLine("  class DEIVA_ALARM {");
            foreach (var item in ALARM)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_LAN {");
            foreach (var item in LAN)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_USB {");
            foreach (var item in USB)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_I2C {");
            foreach (var item in I2C)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_DSL {");
            foreach (var item in DSL)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_WLAN {");
            foreach (var item in WLAN)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_WAN {");
            foreach (var item in WAN)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_DEVICE {");
            foreach (var item in DEVI)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_TEL {");
            foreach (var item in TEL)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_TAM {");
            foreach (var item in TAM)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA_DECT {");
            foreach (var item in DECT)
            {
                SB.AppendLine("     function " + item.Key + "() {");
                SB.AppendLine("       return \"" + item.Value.Replace("\"", "\\\"").Replace("\n", "\\\n").Replace("\r", "\\\r") + "\";");
                SB.AppendLine("     }");
            }
            SB.AppendLine("  }");
            SB.AppendLine("");
            SB.AppendLine("  class DEIVA {");
            SB.AppendLine("    public function __construct() {");
            SB.AppendLine("      $this->DSL = new DEIVA_DSL();");
            SB.AppendLine("      $this->WAN = new DEIVA_WAN();");
            SB.AppendLine("      $this->TEL = new DEIVA_TEL();");
            SB.AppendLine("      $this->DEVICE = new DEIVA_DEVICE();");
            SB.AppendLine("      $this->WLAN = new DEIVA_WLAN();");
            SB.AppendLine("      $this->TAM = new DEIVA_TAM();");
            SB.AppendLine("      $this->LAN = new DEIVA_LAN();");
            SB.AppendLine("      $this->USB = new DEIVA_USB();");
            SB.AppendLine("      $this->I2C = new DEIVA_I2C();");
            SB.AppendLine("      $this->ALARM = new DEIVA_ALARM();");
            SB.AppendLine("      $this->DECT = new DEIVA_DECT();");
            SB.AppendLine("    }");
            SB.AppendLine("  }");
            SB.AppendLine("?>");
            System.IO.File.WriteAllText("web/DEIVA.php", SB.ToString());
            // Create the child process.
            Process process = new Process();

            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.FileName         = _application;
            process.StartInfo.WorkingDirectory = System.Environment.CurrentDirectory;
            var variables = CgiHelper.GetEnvironmentVariables(context, path, scriptName);

            process.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
            process.StartInfo.StandardErrorEncoding  = System.Text.Encoding.UTF8;
            foreach (var item in variables)
            {
                process.StartInfo.EnvironmentVariables.Add(item.Key, item.Value);
                Console.WriteLine("export " + item.Key + "=" + item.Value);
            }

            // Read stderr asynchronously
            process.EnableRaisingEvents = true;
            process.ErrorDataReceived  += new DataReceivedEventHandler
                                          (
                delegate(object sender, DataReceivedEventArgs e)
            {
                if (!String.IsNullOrWhiteSpace(e.Data))
                {
                    _hasError = true;
                    _error.AppendLine(e.Data);
                }
            }
                                          );

            // If there's content to write, redirect stdin
            if (hasBody)
            {
                process.StartInfo.RedirectStandardInput = true;
            }

            // Start the process
            process.Start();

            if (hasBody)
            {
                // Reset stream position!
                request.Body.Position = 0;

                // Write content to stdin
                using (var input = new StreamReader(request.Body))
                {
                    char[] buffer = new char[1024];
                    int    count;
                    while ((count = input.Read(buffer, 0, 1024)) > 0)
                    {
                        process.StandardInput.Write(buffer, 0, count);
                    }
                }
            }

            // Begin asynchronously reading stderr
            process.BeginErrorReadLine();

            // Read stdout
            _response = process.StandardOutput.ReadToEnd();

            // Cancel asynchronous reading of stderr
            if (!process.WaitForExit(_timeout))
            {
                try
                {
                    process.Kill();
                }
                catch (Exception)
                { }

                _hasTimedOut = true;
            }

            int exitcode = process.ExitCode;

            process.Close();

            return(exitcode);
        }