Beispiel #1
0
        protected T GetLogFromRawLog <T>(StoredLogType logType, string applicationId, string message)
            where T : AppLog
        {
            var outerData = JsonUtils.Deserialize <RawLogData>(message);

            if (outerData == null)
            {
                throw new Exception("Unable to deserialize the log message -  " + message);
            }

            var item = JsonUtils.Deserialize <T>(outerData.Data);

            if (item == null)
            {
                throw new Exception("Unable to deserialize the log internal message -  " + outerData.Data);
            }

            item.LogId         = Guid.NewGuid();
            item.LogType       = (int)logType;
            item.ApplicationId = applicationId;
            if (item.Longdate.IsInvalidDate())
            {
                item.Longdate = DateTime.UtcNow;
            }
            item.ReceivedDate    = outerData.ReceiveDate;
            item.LongdateAsTicks = item.Longdate.Ticks;
            return(item);
        }
Beispiel #2
0
 public void AddListToQue(StoredLogType logType, string logListString, DateTime date, string applicationId)
 {
     if (string.IsNullOrEmpty(logListString) == false)
     {
         queue.Enqueue(new RawLogData {
             Type = logType, Data = logListString, IsListData = true, ReceiveDate = date, ApplicationId = applicationId
         });
     }
 }
Beispiel #3
0
 public void AddToDb(StoredLogType logType, string logString, DateTime date, string applicationId)
 {
     if (string.IsNullOrEmpty(logString) == false)
     {
         logRepository.SaveLog(new RawLogData {
             Type = logType, Data = logString, ReceiveDate = date, ApplicationId = applicationId
         });
     }
 }
Beispiel #4
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetUserNames(StoredLogType logType, BaseSearchCriteria search)
 {
     try
     {
         return(logReadRepository.GetUserNames(logType, search));
     }
     catch (Exception ex)
     {
         log.Error(ex, "Error when getting User Names");
         return(new ReturnListModel <string>("Error when getting User Names", ex));
     }
 }
Beispiel #5
0
 public ReturnListWithSearchModel <int, BaseSearchCriteria> GetThreadIds(StoredLogType logType, BaseSearchCriteria search)
 {
     try
     {
         return(logReadRepository.GetThreadIds(logType, search));
     }
     catch (Exception ex)
     {
         log.Error(ex, "Error when getting Log levels");
         return(new ReturnListModel <int>("Error when getting Log levels", ex));
     }
 }
Beispiel #6
0
 public ReturnModel <bool> DeleteLog(StoredLogType logType, string id)
 {
     try
     {
         appLogWriter.Delete <AppLog>(x => x.LogId == SafeUtils.Guid(id) && x.LogType == (int)logType);
         return(new ReturnModel <bool>(true));
     }
     catch (Exception ex)
     {
         log.Error(ex, "Error when getting Deleting App Log  - id = " + id);
         return(new ReturnModel <bool>(ex));
     }
 }
Beispiel #7
0
 public ReturnModel <bool> DeleteAllLogs(StoredLogType logType)
 {
     try
     {
         appLogWriter.Delete <AppLog>(x => x.LogType == (int)logType);
         return(new ReturnModel <bool>(true));
     }
     catch (Exception ex)
     {
         log.Error(ex, $"Error when Deleting App Log  for type = {logType} ");
         return(new ReturnModel <bool>(ex));
     }
 }
Beispiel #8
0
        public Tuple <long, long> DeleteOldLogs(StoredLogType logType, DateTime pastDate)
        {
            try
            {
                log.Info("Deleting App Log  for days less than " + pastDate);
                appLogWriter.Delete <AppLog>(x => x.Longdate < pastDate && x.LogType == (int)logType);
                appLogWriter.Commit();
            }
            catch (Exception ex)
            {
                log.Error(ex, "Error when getting Deleting App Log  for days less than " + pastDate);
            }

            return(null);
        }
Beispiel #9
0
        public ReturnModel <bool> DeleteOldLogs(StoredLogType logType, DateTime pastDate)
        {
            try
            {
                log.Info("Deleting App Log  for days less than " + pastDate);
                using (var session = appLogProvider.OpenSession <AppLog>())
                {
                    //fixme: delete by 100 items at a time
                    var items = session.Query().Where(x => x.Longdate < pastDate && x.LogType == (int)logType).ToArray();
                    session.Delete(items);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex, "Error when getting Deleting App Log  for days less than " + pastDate);
            }

            return(null);
        }
Beispiel #10
0
        public ReturnModel <bool> DeleteAllLogs(StoredLogType logType)
        {
            try
            {
                using (var session = appLogProvider.OpenSession <AppLog>())
                {
                    //fixme: delete by 100 items at a time
                    var items = session.Query().Where(x => x.LogType == (int)logType).ToArray();
                    session.Delete(items);
                }

                return(new ReturnModel <bool>(true));
            }
            catch (Exception ex)
            {
                log.Error(ex, $"Error when Deleting App Log  for type = {logType} ");
                return(new ReturnModel <bool>(ex));
            }
        }
Beispiel #11
0
        public ReturnModel <bool> DeleteLog(StoredLogType logType, string id)
        {
            try
            {
                using (var session = appLogProvider.OpenSession <AppLog>())
                {
                    //fixme: delete by 100 items at a time
                    var items = session.Query().Where(x => x.LogId == SafeUtils.Guid(id) && x.LogType == (int)logType).ToArray();
                    session.Delete(items);
                }

                return(new ReturnModel <bool>(true));
            }
            catch (Exception ex)
            {
                log.Error(ex, "Error when getting Deleting App Log  - id = " + id);
                return(new ReturnModel <bool>(ex));
            }
        }
        public ReturnModel <bool> DeleteAllLogs(StoredLogType logType)
        {
            if (logType == StoredLogType.AppLog)
            {
                if (client.IndexExists(appLogIndexName).Exists)
                {
                    client.DeleteIndex(appLogIndexName);
                }
            }

            if (logType == StoredLogType.PerfLog)
            {
                if (client.IndexExists(perfLogIndexName).Exists)
                {
                    client.DeleteIndex(perfLogIndexName);
                }
            }

            return(ReturnModel <bool> .Success(true));
        }
Beispiel #13
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetSeverityNames(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns(logType, search, x => x.Severity, "Severity"));
 }
Beispiel #14
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetUserNames(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns(logType, search, x => x.UserIdentity, "User"));
 }
Beispiel #15
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetMachineNames(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns(logType, search, x => x.MachineName, "Machine"));
 }
Beispiel #16
0
 // Parameters
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetAppNames(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns(logType, search, x => x.App, "Application"));
 }
Beispiel #17
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetSeverityNames(StoredLogType logType, BaseSearchCriteria search)
 {
     throw new Exception();
 }
Beispiel #18
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetIps(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns(logType, search, x => x.RemoteAddress, "RemoteAddress"));
 }
Beispiel #19
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetUserNames(StoredLogType logType, BaseSearchCriteria search)
 {
     throw new NotImplementedException();
 }
Beispiel #20
0
 public ReturnListWithSearchModel <int, BaseSearchCriteria> GetThreadIds(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns <int>(logType, search, x => x.ThreadId, "ThreadId"));
 }
 public Tuple <long, long> DeleteOldLogs(StoredLogType logType, DateTime pastDate)
 {
     throw new NotImplementedException();
 }
 public ReturnModel <bool> DeleteLog(StoredLogType logType, string id)
 {
     throw new NotImplementedException();
 }
Beispiel #23
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetFunctions(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns(logType, search, x => x.FunctionName, "FunctionName"));
 }
Beispiel #24
0
 public ReturnModel <bool> DeleteOldLogs(StoredLogType logType, DateTime pastDate)
 {
     dbManager.Delete <AppLog>(x => x.LogType == (int)logType && x.Longdate < pastDate);
     return(ReturnModel <bool> .Success(true));
 }
Beispiel #25
0
 public ReturnListWithSearchModel <string, BaseSearchCriteria> GetFiles(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns(logType, search, x => x.CurrentSourceFilename, "CurrentSourceFilename"));
 }
Beispiel #26
0
 public ReturnModel <bool> DeleteLog(StoredLogType logType, string id)
 {
     dbManager.Delete <AppLog>(x => x.LogType == (int)logType && x.LogId == SafeUtils.Guid(id));
     return(ReturnModel <bool> .Success(true));
 }
Beispiel #27
0
 public ReturnListWithSearchModel <int, BaseSearchCriteria> GetProcessIds(StoredLogType logType, BaseSearchCriteria search)
 {
     return(GetDistinctColumns(logType, search, x => x.ProcessId, "ProcessId"));
 }
 public ReturnModel <bool> DeleteAllLogs(StoredLogType logType)
 {
     throw new NotImplementedException();
 }
Beispiel #29
0
 //protected abstract ReturnListWithSearchModel<string, BaseSearchCriteria> GetDistinctColumns(StoredLogType logType, BaseSearchCriteria search, Expression<Func<AppLog, string>> selector, string columnType);
 protected abstract ReturnListWithSearchModel <T, BaseSearchCriteria> GetDistinctColumns <T>(StoredLogType logType, BaseSearchCriteria search, Expression <Func <AppLog, T> > selector, string columnType);
Beispiel #30
0
 protected override ReturnListWithSearchModel <T, BaseSearchCriteria> GetDistinctColumns <T>(StoredLogType logType, BaseSearchCriteria search, Expression <Func <AppLog, T> > selector, string columnType)
 {
     try
     {
         using (var reader = GetNewAppReader().OpenSession <AppLog>())
         {
             LuceneQueryStatistics stats = null;
             var lst       = reader.Query().Where(x => x.LogType == (int)logType).Select(selector).Distinct().CaptureStatistics(x => stats = x);
             var totalRows = lst.AsQueryable().Count();
             search.TotalRowCount = totalRows;
             var resultList = lst.ApplyPaging(search.Page, search.PageSize).Distinct().ToList();
             search.CurrentRows = resultList.Count;
             return(new ReturnListWithSearchModel <T, BaseSearchCriteria>(search, resultList, totalRows));
         }
     }
     catch (Exception ex)
     {
         log.Error(ex, $"Error when getting {columnType} list ");
         search.TotalRowCount = 0;
         search.CurrentRows   = 0;
         return(new ReturnListWithSearchModel <T, BaseSearchCriteria>(search, $"Error when getting {columnType} list ", ex));
     }
 }