private HttpStatusCode Home(HttpServerContext httpContext) { var queuename = httpContext.QueryString["queue"] ?? ""; // httpContext.ResponseHeader["Content-Type"] = "text/html"; httpContext.BeginWrite(); // var action = new HomeAction(); action.actionType = Action.HOME; action.channel = new HttpState(httpContext, false); action.queue = queuename; action.id = ""; // Program.ActionProcessor.Push(action); // return(System.Net.HttpStatusCode.OK); }
private void Home(HomeAction action) { if (string.IsNullOrEmpty(action.queue) == false) { var p = Program.QueueManager.GetProperty(action.queue); if (p == null) { action.propertys = new QueueProperty[0]; } else { action.propertys = new QueueProperty[] { p } }; } else { action.propertys = Program.QueueManager.GetPropertys(100); } action.channel.Send(action); }
private void Home(HomeAction action) { var hostname = HttpHandler.hostname; var version = HttpHandler.version; var servername = Program.ServiceContext.ServiceName; // var listBuild = new StringBuilder(); // var propertyIndex = 0; QueueProperty[] queuePropertys = action.propertys; if (queuePropertys == null) { listBuild.AppendLine("<tbody>"); listBuild.AppendLine("<tr>"); listBuild.AppendLine("<td align=\"left\" colspan=\"4\" style=\"color:#ff8000;\">search timeout.</td>"); listBuild.AppendLine("</tr>"); listBuild.AppendLine("</tbody>"); } else if (queuePropertys.Length == 0) { listBuild.AppendLine("<tbody>"); listBuild.AppendLine("<tr>"); listBuild.AppendLine("<td align=\"left\" colspan=\"4\" style=\"color:#ff8000;\">no queue.</td>"); listBuild.AppendLine("</tr>"); listBuild.AppendLine("</tbody>"); } else { int l = 0; for (propertyIndex = 0, l = queuePropertys.Length; propertyIndex < l; propertyIndex++) { var property = queuePropertys[propertyIndex]; if (property == null) { break; } listBuild.AppendLine("<tbody>"); listBuild.AppendLine("<tr>"); listBuild.AppendLine("<td align=\"left\">" + property.name + "</td>"); listBuild.AppendLine("<td align=\"center\">" + property.wait + "</td>"); listBuild.AppendLine("<td align=\"center\">" + property.pull + "</td>"); listBuild.AppendLine("<td align=\"center\">" + property.count + "</td>"); listBuild.AppendLine("</tr>"); listBuild.AppendLine("</tbody>"); } } // var build = new StringBuilder(); build.AppendLine("<!DOCTYPE html>"); build.AppendLine("<html>"); build.AppendLine("<head>"); build.AppendLine("<style type=\"text/css\">"); build.AppendLine(".tb1{ background-color:#D5D5D5;}"); build.AppendLine(".tb1 td{ background-color:#FFF;}"); build.AppendLine(".tb1 tr.None td{ background-color:#FFF;}"); build.AppendLine(".tb1 tr.Success td{ background-color:#FFF;}"); build.AppendLine(".tb1 tr.Failed td{ background-color:#FAEBD7;}"); build.AppendLine(".tb1 tr.Running td{ background-color:#F5FFFA;}"); build.AppendLine("img,form{ border:0px;}"); build.AppendLine("img.button{ cursor:pointer; }"); build.AppendLine("a { padding-left:5px; }"); build.AppendLine("</style>"); build.AppendLine("<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">"); build.AppendLine("<title>" + servername + " Via " + hostname + "</title>"); build.AppendLine("</head>"); build.AppendLine("<body>"); build.AppendLine("<div>"); build.AppendLine("Powered by <a href=\"http://www.aooshi.org/adf\" target=\"_blank\">Adf.QueueServer</a> "); build.Append('v'); build.Append(version.Major); build.Append("."); build.Append(version.Minor); build.Append("."); build.Append(version.Build); build.AppendLine(" Via " + hostname); build.AppendLine(" , Connection: <font color=\"green\">" + Program.ConnectionCounter + "</font>"); build.AppendLine(" , Queue: <font color=\"green\" id=\"queuecount\">" + Program.QueueManager.Count + "</font>"); build.AppendLine("</div>"); build.AppendLine("<div>"); build.AppendLine("<form action\"" + this.httpContext.Path + "\" method=\"get\">"); build.AppendLine("<input type=\"text\" value=\"" + action.queue + "\" name=\"queue\" placeholder=\"queue name\" style=\"width:220px;\" />"); build.AppendLine("<input type=\"submit\" value=\"list\" />"); build.AppendLine("<input type=\"button\" value=\"home\" onclick=\"this.form['queue'].value='';this.form.submit();\" />"); build.AppendLine("<input type=\"button\" value=\"create\" onclick=\"CreateQueue(this.form);\" />"); build.AppendLine("<input type=\"button\" value=\"delete\" onclick=\"DeleteQueue(this.form);\" />"); build.AppendLine("<input type=\"button\" value=\"clear\" onclick=\"ClearQueue(this.form);\" />"); if (string.IsNullOrEmpty(action.queue)) { build.AppendLine(" List random " + propertyIndex + " queue"); } else { build.AppendLine(" Search " + action.queue + " result"); } build.AppendLine("<span id=\"msg\"></span>"); build.AppendLine("</form></div>"); build.AppendLine("<table class=\"tb1\" width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\">"); build.AppendLine("<thead>"); build.AppendLine("<tr>"); build.AppendLine("<th align=\"left\">Queue</th>"); build.AppendLine("<th width=\"160\">Wait</th>"); build.AppendLine("<th width=\"160\">Pull</th>"); build.AppendLine("<th width=\"160\">Count</th>"); build.AppendLine("</tr>"); build.AppendLine("</thead>"); build.Append(listBuild); build.AppendLine("</table>"); build.AppendLine("<script type=\"text/javascript\" src=\"ajax.js\"></script>"); build.AppendLine("<script type=\"text/javascript\" src=\"control.js\"></script>"); build.AppendLine("</body>"); build.AppendLine("</html>"); try { this.httpContext.Write(build.ToString()); this.httpContext.EndWrite(); } catch (System.Net.Sockets.SocketException) { this.available = false; } catch (InvalidOperationException) { this.available = false; } catch (Exception exception) { this.available = false; Program.LogManager.Exception(exception); } }