public void OnHttpRequest(ReefHttpRequest request, ReefHttpResponse response) { string target = ParsePathInfo(request.PathInfo); LOGGER.Log(Level.Info, "Target: " + target + ". PathInfo: " + request.PathInfo); //if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("driverstatus")) if (target != null && target.Equals("driverstatus")) { LOGGER.Log(Level.Info, "Target: " + target + ". Driver status: " + driveStatus.ToString()); string msg = string.Format(CultureInfo.CurrentCulture, "Current Driver status: {0} ", driveStatus.ToString()); BuildHttpResponse(response, HttpStatusCode.OK, msg); return; } if (target != null && target.Equals("taskstatus")) { LOGGER.Log(Level.Info, "Target: " + target + ". TaskStatus string: " + _taskContext.TaskStatusString()); BuildHttpResponse(response, HttpStatusCode.OK, _taskContext.TaskStatusString()); return; } if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.Init) { BuildHttpResponse(response, HttpStatusCode.OK, "Driver is not ready, wait a few second then send request again!!!"); return; } if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.RunningTasks) { string msg = string.Format(CultureInfo.CurrentCulture, "A job is running. Please check driver status and then submit your job again."); BuildHttpResponse(response, HttpStatusCode.OK, msg); return; } if (target != null && target.ToLower(CultureInfo.CurrentCulture).Equals("run") && driveStatus == DriverStatus.Idle) { string numberOfTasks = getQueryValue(request.Querystring, "numberoftasks"); if (numberOfTasks == null) { BuildHttpResponse(response, HttpStatusCode.OK, "Please specify number of tasks to run"); return; } driveStatus = DriverStatus.RunningTasks; using (LOGGER.LogFunction("HelloSimpleEventHandlers::Processing a new Job from web request")) { _taskContext = new TaskContext(); _taskContext.TotalTasks = int.Parse(numberOfTasks, CultureInfo.CurrentCulture); BuildHttpResponse(response, HttpStatusCode.OK, "Job from web request is submitted and is running!!!"); } foreach (var c in _activeContexts) { SubmitNextTask(c); } return; } BuildHttpResponse(response, HttpStatusCode.OK, "Unsupported query"); }
public string getStatistics() { StringBuilder builder = new StringBuilder(); builder.Append(" Status:"); builder.Append(status.ToString()); builder.Append("\n Total messages processed:"); builder.Append(totalMessagesProcessed); builder.Append("\n Last processed message time:"); if (lastProcessedMessageTime == DateTime.MinValue) { builder.Append("None"); } else { builder.Append(lastProcessedMessageTime); } builder.Append("\n current messages in process:"); builder.Append(currentMessagesToBeProcessed); return(builder.ToString()); }