Exemple #1
0
        /// <summary>
        /// Sets logs destinations for current CurrCode - LogSQL_ConnString, LogXML_DirPath
        /// </summary>
        public static Mx S(this Mx CurrCode, string LogSQL_ConnString = null, string LogXML_DirPath = null)
        {
            Mx Res = new Mx();

            CurrCode.Lq = LogSQL_ConnString;
            CurrCode.Lx = LogXML_DirPath;

            return(Res);
        }
Exemple #2
0
        /// <summary>
        /// Create new Common method execution details for common code with current LogError setting
        /// </summary>
        public static Mx M(this bool LogError, string ClassName = null, string MethodName = null, string CustomDetails = null, string ParametersData = null, int?ArraySize = null, Ab Block = null, int?LogIndex = null)
        {
            Mx Res = new Mx();

            Res.C  = ClassName;
            Res.M  = MethodName;
            Res.L  = LogError;
            Res.P  = ParametersData;
            Res.D  = CustomDetails;
            Res.As = ArraySize;
            Res.Li = LogIndex;
            Res.B  = Block;

            return(Res);
        }
Exemple #3
0
        /// <summary>
        /// Sets method context Arrays data for current CurrCode - ArraySize, ArrayBlockSize, CustomArrayBlockMessage
        /// </summary>
        public static Mx S(this Mx CurrCode, int?ArraySize = null, int?ArrayBlockSize = null, string CustomArrayBlockMessage = null)
        {
            Mx Res = new Mx();

            if (ArrayBlockSize != null || CustomArrayBlockMessage != null)
            {
                CurrCode.B = new Ab()
                {
                    S = ArrayBlockSize, M = CustomArrayBlockMessage
                }
            }
            ;
            CurrCode.As = ArraySize;

            return(Res);
        }
Exemple #4
0
        /// <summary>
        /// Run Common Sync Try FuncToRunSync With Errors And Performance Logging based on CurrCodeType.
        /// Logging is saved to CustomLogToAddRecords or default static logs (_.D.L)
        /// </summary>
        public static T r <T>(this Lg CurrLog, f <T> FuncToRunSync, Cx CustomCodeType = null, Mx CustomMethodContext = null, T ReturnOnError = default)
        {
            if (FuncToRunSync == null)
            {
                return(ReturnOnError);
            }

            var t       = CustomCodeType;
            Prf PerfLog = null;
            var ef      = false;

            if (t.S != null && t.S.P == true)
            {
                PerfLog = CurrLog.P(t, CustomMethodContext);
            }

            T Result = ReturnOnError;

            if (CustomCodeType.T)
            {
                try
                {
                    Result = FuncToRunSync();
                }
                catch (Exception exc)
                {
                    if (t.S != null && t.S.L == true)
                    {
                        CurrLog.E(null, exc, t, CustomMethodContext);
                    }
                    ef = true;
                }
            }
            else
            {
                Result = FuncToRunSync();
            }

            if (t.S != null && t.S.P == true)
            {
                CurrLog.Pa(PerfLog, null, t);
            }

            if (ef)
            {
                return(ReturnOnError);
            }

            return(Result);
        }
Exemple #5
0
        /// <summary>
        /// Run Common Try FuncToRun With Errors And Performance Logging based on CurrContext and optional CustomCodeType.
        /// </summary>
        public static T r <T, Tx>(this Ax <Tx> CurrContext, f <Cx, T> FuncToRun, Tx CustomCodeType = default, Mx CustomMethodContext = null, T ReturnOnError = default)
        {
            if (CurrContext == null || FuncToRun == null)
            {
                return(ReturnOnError);
            }
            Cx x = null;

            if (CustomCodeType != null && CurrContext.T != null)
            {
                x = CurrContext.T.v(CustomCodeType);
            }
            return(CurrContext.L.r(() => FuncToRun(x), x, CustomMethodContext, ReturnOnError));
        }
Exemple #6
0
        /// <summary>
        /// Run Common Async Try FuncToRunAsync With Errors And Performance Logging based on CurrContext and optional CustomCodeType.
        /// </summary>
        public static async Task <T> R <T, Tx>(this Ax <Tx> CurrContext, f <Cx, Task <T> > FuncToRunAsync, Tx CustomCodeType = default, Mx CustomMethodContext = null, T ReturnOnError = default)
        {
            if (CurrContext == null || FuncToRunAsync == null)
            {
                return(ReturnOnError);
            }
            Cx x = null;

            if (CustomCodeType != null && CurrContext.T != null)
            {
                x = CurrContext.T.v(CustomCodeType);
            }
            return(await CurrContext.L.R(() => FuncToRunAsync(x), x, CustomMethodContext, ReturnOnError));
        }