Exemplo n.º 1
0
    public static void LogError(ErrorCode pCode, string pStackTrace = null, string pErrorMessage = null)
    {
        ErrorLogTableAdapter logAdapter = new ErrorLogTableAdapter();
        bool addedRow = false;

        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            SysUserTableAdapter          adapter = new SysUserTableAdapter();
            ONyRDataSet.SysUserDataTable table   = adapter.GetDataByUserName(HttpContext.Current.User.Identity.Name);

            if (table.Count > 0)
            {
                logAdapter.ErrorLog(table[0].ID, (int)pCode, pStackTrace, pErrorMessage);
                addedRow = true;
            }

            adapter.Dispose();
            table.Dispose();
        }

        if (!addedRow)
        {
            logAdapter.ErrorLog(null, (int)pCode, pStackTrace, pErrorMessage);
        }

        logAdapter.Dispose();
    }
Exemplo n.º 2
0
    public List <ErrorLogVO> LoadErrorLogEntries(int min, int max)
    {
        List <ErrorLogVO> result = null;

        try
        {
            AuthenticationService.CheckIfUSerIsAuthenticated();
            LogService.Log("LogService", "LoadErrorLogs", String.Format("Min:{0}; Max: {1}", min, max));

            ErrorLogTableAdapter adapter = new ErrorLogTableAdapter();
            result = new List <ErrorLogVO>();

            ONyRDataSet.ErrorLogDataTable table = adapter.GetDataByRowNumber(min, max);
            for (int i = 0; i < table.Count; ++i)
            {
                DateTime date;
                try
                {
                    date = table[i].Date;
                }
                catch (Exception)
                {
                    date = DateTime.MinValue;
                }
                int userID;
                try
                {
                    userID = table[i].UserID;
                }
                catch (Exception)
                {
                    userID = -1;
                }
                String errorMessage;
                try
                {
                    errorMessage = table[i].ErrorMessage;
                }
                catch (Exception)
                {
                    errorMessage = "";
                }
                String stacktrace;
                try
                {
                    stacktrace = table[i].StackTrace;
                }
                catch (Exception)
                {
                    stacktrace = "";
                }
                result.Add(new ErrorLogVO(table[i].ID, date, userID, table[i].ErrorCode, errorMessage, stacktrace));
            }

            adapter.Dispose();
        }
        catch (ONyRException e)
        {
            LogService.LogError(e.ErrorCode, e.StackTrace);
            throw new FaultException <ONyRFaultException>(new ONyRFaultException((int)e.ErrorCode));
        }
        catch (Exception e)
        {
            LogService.LogError(ErrorCode.UnknownError, e.StackTrace, e.Message);
            throw new FaultException <ONyRFaultException>(new ONyRFaultException((int)ErrorCode.UnknownError));
        }

        return(result);
    }