How do I Display a Message across projects?

余生长醉 提交于 2021-02-08 11:32:36

问题


We have one Visual Studio 2019 ASP.NET solution with 22 projects, one of which is called BusinessLogic and one which is called Web.

In BusinessLogic, we have code to log errors, and it used by all projects in the solution.

public static Guid? StartDebugLog(String module, String method, String message)
{
    if (ApplicationSettings.IsDebugLogActive)
    {
        using (BPIContext context = SessionManager.CreateNewBPIContext)
        {
            DebugLog debugLogObject = new DebugLog();
            debugLogObject.ID = Guid.NewGuid();
            debugLogObject.Module = module;
            debugLogObject.Method = method;
            debugLogObject.StartTime = DateTime.Now;
            if (message == null)
                debugLogObject.Message = "(NULL)";
            else
                debugLogObject.Message = message;
            context.AddToDebugLog(debugLogObject);
            context.SaveChanges();
            return debugLogObject.ID;
        }
    }
    return null;
}

The problem is that this routine is hiding important errors from our customers. Yes, they can go into the application logs, but simply starting the application creates over 100 entries in the application log. Finding errors would be a daunting task to ask of our customers.

I need a way for this routine to be able to display a basic message so that customers do not continue on, thinking everything is OK. Something like alert("An error has occurred."), but the *BusinessLogic project does not have access to the Web project.

Is there a recommended way to create a CALLBACK or something? Most of my background is in Windows Forms where this would be simple. Something like this:

            ...
            context.AddToDebugLog(debugLogObject);
            context.SaveChanges();
            if (WebCallback != null)
            {
                WebCallback(debugLogObject);
            }
            return debugLogObject.ID;
            ...

I'm not even sure if this is possible in a Web environment. If it is not possible, that's an answer too.

For a "Part 2", some of our newer modules are displayed by dropping them into an iFrame. Is there a way to create something that will allow information from the iFrame to pass to the parent? Currently, all messages that are sent in the iFrame appear to get lost.

来源:https://stackoverflow.com/questions/65494952/how-do-i-display-a-message-across-projects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!