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); }
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 }); } }
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 }); } }
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)); } }
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)); } }
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)); } }
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)); } }
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); }
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); }
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)); } }
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)); }
public ReturnListWithSearchModel <string, BaseSearchCriteria> GetSeverityNames(StoredLogType logType, BaseSearchCriteria search) { return(GetDistinctColumns(logType, search, x => x.Severity, "Severity")); }
public ReturnListWithSearchModel <string, BaseSearchCriteria> GetUserNames(StoredLogType logType, BaseSearchCriteria search) { return(GetDistinctColumns(logType, search, x => x.UserIdentity, "User")); }
public ReturnListWithSearchModel <string, BaseSearchCriteria> GetMachineNames(StoredLogType logType, BaseSearchCriteria search) { return(GetDistinctColumns(logType, search, x => x.MachineName, "Machine")); }
// Parameters public ReturnListWithSearchModel <string, BaseSearchCriteria> GetAppNames(StoredLogType logType, BaseSearchCriteria search) { return(GetDistinctColumns(logType, search, x => x.App, "Application")); }
public ReturnListWithSearchModel <string, BaseSearchCriteria> GetSeverityNames(StoredLogType logType, BaseSearchCriteria search) { throw new Exception(); }
public ReturnListWithSearchModel <string, BaseSearchCriteria> GetIps(StoredLogType logType, BaseSearchCriteria search) { return(GetDistinctColumns(logType, search, x => x.RemoteAddress, "RemoteAddress")); }
public ReturnListWithSearchModel <string, BaseSearchCriteria> GetUserNames(StoredLogType logType, BaseSearchCriteria search) { throw new NotImplementedException(); }
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(); }
public ReturnListWithSearchModel <string, BaseSearchCriteria> GetFunctions(StoredLogType logType, BaseSearchCriteria search) { return(GetDistinctColumns(logType, search, x => x.FunctionName, "FunctionName")); }
public ReturnModel <bool> DeleteOldLogs(StoredLogType logType, DateTime pastDate) { dbManager.Delete <AppLog>(x => x.LogType == (int)logType && x.Longdate < pastDate); return(ReturnModel <bool> .Success(true)); }
public ReturnListWithSearchModel <string, BaseSearchCriteria> GetFiles(StoredLogType logType, BaseSearchCriteria search) { return(GetDistinctColumns(logType, search, x => x.CurrentSourceFilename, "CurrentSourceFilename")); }
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)); }
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(); }
//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);
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)); } }