简体   繁体   中英

Does MSoft provide a persistent client-side error reporting for server-side errors plugin or tool to use with MVC3 applications?

I'm working on an application which contains significant server-side data manipulation and work. I would like to provide constant status updated and error reports related to this work, to the client.

The client might, for example, fire off a job or batch of jobs running server side, based on some data he uploaded. Then he might proceed to do other work on the site, while the jobs continue to run.

Does MSoft provide a nice tool for showing status updates and error reports to the client? I imagine some sort of polling javascript app, or maybe a pre-defined subform etc.., that could sit in a footer or be dynamically loaded over a corner of the screen when appropriate.

Come to think of it, I'd probably be happy with any other implementation of this kind of tool, as long as it's up to date and sees lively support.

I had a similar requirement to refresh reports and went down the asynchronous controller route until I realized the limitations. I decided to implement a solution that registers the report refresh from the ASP.NET MVC3 application and made a Windows Service that polls requests every 2 minutes for processing.

View

$("#btnRefresh").live("click", function(e) {
    $.ajax({
            type: "POST",
            url: '@Url.Action("Refresh")',
            data: "reportId=@Model.Id"
        })
        .done(function(message) {
            alert(message);
        })
        .fail(function(serverResponse) {
            alert("Error occurred while processing request: " + serverResponse.responseText);
        });

    e.preventDefault();
});

Controller Action

[HttpPost, VerifyReportAccess]
public ActionResult Refresh(Guid reportId)
{
    string message;

    try
    {
        message = _publisher.RequestRefresh(reportId);
    }
    catch(Exception ex)
    {
        HttpContext.Response.StatusCode = (Int32)HttpStatusCode.BadRequest;
        message = ex.Message;
    }

    return Json(message);
}

Repository

public string RequestRefresh(Guid reportId)
{
    var scheduledReport = _repository.GetScheduleForReport(reportId);

    if (scheduledReport.CompanyId == Guid.Empty)
        throw new Exception("Requested Report Not Found");

    if(_repository.CheckPendingRefresh(scheduledReport))
        return "A request to refresh this report is already pending.";

    _repository.ScheduleReportRefresh(scheduledReport);

    return "A request to refresh the report has been submitted. The report will appear online when available.";
}

The windows service runs the same class library code as the nightly ETL process to refresh the report.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM