Esempio n. 1
0
        public bool Add(string ModuleName, string FunctionName, System.Exception ex)
        {
            AUTH_EXCEPTIONAL_LOG ExLog = new AUTH_EXCEPTIONAL_LOG();

            ExLog.EXCEPTIONAL_LOG_ID = ExceptionalLogRepository.GetNewID("AUTH_EXCEPTIONAL_LOG", "EXCEPTIONAL_LOG_ID");
            ExLog.MODULE_NAME        = ModuleName;
            ExLog.FUNCTION_NAME      = FunctionName;
            ExLog.CATCH_TIME         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string ExcMsg = "";

            if (ex is System.Data.Entity.Validation.DbEntityValidationException)
            {
                ExcMsg = ((System.Data.Entity.Validation.DbEntityValidationException)ex).EntityValidationErrors.First().ValidationErrors.First().ErrorMessage;
            }
            else if (ex is System.Data.Entity.Validation.DbUnexpectedValidationException)
            {
            }
            else if (ex is System.Data.Entity.ModelConfiguration.ModelValidationException)
            {
            }
            else
            {
                ExcMsg = ex.Message;
            }


            ExLog.EXCEPTIONAL_TYPE        = ex.GetType().ToString();
            ExLog.EXCEPTIONAL_DESCRIPTION = ExcMsg;
            ExLog.STATE = "";
            ExceptionalLogRepository.Add(ExLog);
            ExceptionalLogRepository.SaveChanges();

            return(true);
        }
Esempio n. 2
0
        public object GetDetails(int page, int rows, string CatchTime, string ModuleName, string FunctionName, string ExceptionalType)
        {
            IQueryable <AUTH_EXCEPTIONAL_LOG> LOGINLOGQuery = ExceptionalLogRepository.GetQueryable();
            var HelpContent = LOGINLOGQuery.Where(c => c.CATCH_TIME.Contains(CatchTime) &&
                                                  c.MODULE_NAME.Contains(ModuleName) &&
                                                  c.FUNCTION_NAME.Contains(FunctionName) &&
                                                  c.EXCEPTIONAL_TYPE.Contains(ExceptionalType));

            HelpContent = HelpContent.OrderBy(h => h.EXCEPTIONAL_LOG_ID);
            int total = HelpContent.Count();

            HelpContent = HelpContent.Skip((page - 1) * rows).Take(rows);

            var temp = HelpContent.ToArray().Select(c => new
            {
                ID                      = c.EXCEPTIONAL_LOG_ID,
                CATCH_TIME              = c.CATCH_TIME,
                MODULE_NAME             = c.MODULE_NAME,
                FUNCTION_NAME           = c.FUNCTION_NAME,
                EXCEPTIONAL_TYPE        = c.EXCEPTIONAL_TYPE,
                EXCEPTIONAL_DESCRIPTION = c.EXCEPTIONAL_DESCRIPTION,
                STATE                   = c.STATE
            });

            return(new { total, rows = temp.ToArray() });
        }
Esempio n. 3
0
        public bool Delete(string exceptionalLogId, out string strResult)
        {
            strResult = string.Empty;
            bool result       = false;
            Guid exceptionid  = new Guid(exceptionalLogId);
            var  exceptionlog = ExceptionalLogRepository.GetQueryable().FirstOrDefault(lo => lo.ExceptionalLogID == exceptionid);

            if (exceptionlog != null)
            {
                try
                {
                    ExceptionalLogRepository.Delete(exceptionlog);
                    ExceptionalLogRepository.SaveChanges();
                    result = true;
                }
                catch (Exception e)
                {
                    strResult = "原因:" + e;
                }
            }
            else
            {
                strResult = "原因:未找到当前需要删除的数据!";
            }
            return(result);
        }
Esempio n. 4
0
        public System.Data.DataTable GetExceptionalLog(int page, int rows, string catchTime, string moduleName, string functionName)
        {
            IQueryable <ExceptionalLog> systemEventLogQuery = ExceptionalLogRepository.GetQueryable();
            var eventlogs = systemEventLogQuery
                            .Where(i => i.CatchTime.Contains(catchTime) && i.ModuleName.Contains(moduleName) && i.FunctionName.Contains(functionName))
                            .OrderByDescending(e => e.CatchTime)
                            .Select(e => new { e.CatchTime, e.ModuleName, e.FunctionName, e.ExceptionalType, e.ExceptionalDescription });

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("异常时间", typeof(string));
            dt.Columns.Add("模块名称", typeof(string));
            dt.Columns.Add("方法名称", typeof(string));
            dt.Columns.Add("异常类型", typeof(string));
            dt.Columns.Add("异常描述", typeof(string));
            foreach (var item in eventlogs)
            {
                dt.Rows.Add
                (
                    item.CatchTime,
                    item.ModuleName,
                    item.FunctionName,
                    item.ExceptionalType,
                    item.ExceptionalDescription
                );
            }
            return(dt);
        }
Esempio n. 5
0
        public object GetDetails(int page, int rows, string moduleName, string functionName)
        {
            IQueryable <ExceptionalLog> exceptionalLogQuery = ExceptionalLogRepository.GetQueryable();
            var exceptionalLog = exceptionalLogQuery
                                 .Where(e => e.ModuleName.Contains(moduleName) && e.FunctionName.Contains(functionName))
                                 .OrderByDescending(e => e.CatchTime);
            int total           = exceptionalLog.Count();
            var exceptionalLogs = exceptionalLog.Skip((page - 1) * rows).Take(rows);
            var exception       = exceptionalLogs
                                  .Select(e => new { e.ExceptionalLogID, e.CatchTime, e.ModuleName, e.FunctionName, e.ExceptionalType, e.ExceptionalDescription, e.State });

            return(new { total, rows = exception.ToArray() });
        }
Esempio n. 6
0
        public bool Emptys(out string strResult)
        {
            strResult = string.Empty;
            bool result       = false;
            var  exceptionlog = ExceptionalLogRepository.GetQueryable();

            if (exceptionlog != null)
            {
                foreach (var log in exceptionlog)
                {
                    ExceptionalLogRepository.Delete(log);
                }
                ExceptionalLogRepository.SaveChanges();
                result = true;
            }
            else
            {
                strResult = "原因:未找到当前需要删除的数据!";
            }
            return(result);
        }
Esempio n. 7
0
        public bool CreateExceptionLog(string ModuleNam, string FunctionName, string ExceptionalType, string ExceptionalDescription, string State)
        {
            var moduleRepository = ModuleRepository.GetQueryable().Where(m => m.ModuleURL == ModuleNam).Select(m => new { modulname = m.ModuleName }).ToArray();

            if (moduleRepository.Length > 0)
            {
                var ExceptionalLogs = new ExceptionalLog()
                {
                    ExceptionalLogID       = Guid.NewGuid(),
                    CatchTime              = DateTime.Now.ToString(),
                    ModuleName             = moduleRepository[0].modulname,
                    FunctionName           = FunctionName,
                    ExceptionalType        = ExceptionalType,
                    ExceptionalDescription = ExceptionalDescription,
                    State = State,
                };
                ExceptionalLogRepository.Add(ExceptionalLogs);
                ExceptionalLogRepository.SaveChanges();
            }
            return(true);
        }