Log File


        public static void MessageShow( 
            System.Reflection.MethodBase oMethodBase,
            System.Exception oException,
            string sUserMessage = "message",
            string sCaptionSuffix = "")
        {
            string sText = "";
            string sCaption = "";

            string sSubroutineName = "";
            string sDeclaringType = "";
            string sClassName = "";
            string sExceptionMessage = "";
            string sInnerException = "";
            string sStackTrace = "";

            if (MyProject.Constants.FOUND_ERROR == true)
            {
                return;
            }

            sSubroutineName = oMethodBase.Name;
            if (sSubroutineName == ".ctor")
            {
                sSubroutineName = "Constructor";
            }
            sDeclaringType = oMethodBase.DeclaringType.ToString();
            sClassName = sDeclaringType.Substring(sDeclaringType.IndexOf(".") + 1);

            if (oException != null)
            {
                if (sCaptionSuffix != "Web Service Error")
                {
                    string msubstring = "";
                    msubstring = oException.Message;
                    if (msubstring.Length > 300)
                    {
                        msubstring = msubstring.Substring(0, 300);
                    }

                    sExceptionMessage = "*" + msubstring + "*" + Environment.NewLine +
                                        "(" + oException.Source + ")";
                }
                else
                {
                    sExceptionMessage = oException.Message.Substring(0, 300) + " ....";
                }

                if (oException.InnerException != null)
                {
                    sInnerException = oException.InnerException.Message;
                }
                sStackTrace = oException.StackTrace;
            }

            if (sUserMessage != "message")
            {
                sText = sUserMessage + Environment.NewLine + Environment.NewLine + sExceptionMessage;
            }
            else
            {
                sText = sExceptionMessage;
            }

            if (sCaptionSuffix.Length == 0)
            {
                sCaption = Constants.MESSAGE_CAPTION + sClassName + "-" + sSubroutineName;
            }
            else
            {
                sCaption = Constants.MESSAGE_CAPTION + sCaptionSuffix;
            }

            System.Windows.Forms.MessageBox.Show(sText, sCaption,
                System.Windows.Forms.MessageBoxButtons.OK,
                System.Windows.Forms.MessageBoxIcon.Exclamation);

            MyProject.Constants.FOUND_ERROR = true;
        }


© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext