Exemplo n.º 1
0
        public Stream Index()
        {
            try
            {
                string html = LoadHtml("TaskerIndex.htm");

                #region Instances
                StringBuilder ul = new StringBuilder();
                ul.Append("<div class='listbox'><span style='font-weight:bold'>Worker Processes</span>");
                ul.Append("<ul>");
                for (int i = 0; i < _serverConfig.Instances.Length; i++)
                {
                    InstanceConnection conn = new InstanceConnection("localhost:" + _serverConfig.Instances[i].Port);

                    ul.Append("<li class='servicelink'>Instance " + (i + 1));
                    try
                    {
                        DateTime start = DateTime.Now;
                        string   ping;
                        for (int p = 0; p < 20; p++)
                        {
                            ping = conn.Ping();
                        }
                        TimeSpan ts = DateTime.Now - start;

                        ul.Append(" ... running (" + conn.Ping() + ") ... " + Math.Round(ts.TotalMilliseconds / 20, 1) + "ms/ping");
                    }
                    catch (Exception ex)
                    {
                        ul.Append(" ... error (" + ex.Message + ")");
                    }
                    ul.Append("</li>");
                }
                ul.Append("</ul></div>");
                html = html.Replace("[INSTANCES]", ul.ToString());
                #endregion

                return(HtmlStream(html));
            }
            catch (UnauthorizedAccessException)
            {
                return(WriteUnauthorized());
            }
        }