private void btnQuery_Click(object sender, EventArgs e) { var qry = new LogQuery(); qry.DateTime_From = new DateTime(2012, 02, 14); qry.DateTime_To = new DateTime(2012, 02, 16); NAppProfilerClient.SendQuery(qry, Guid.NewGuid()); }
public void ExceptionWhenFromOrToNotSet() { using (var reader = new NAppIndexReader(new ConfigManager())) { var qry = new LogQuery(); Assert.Throws<ArgumentException>(() => reader.Search(qry)); } }
private Tuple<LogQuery, string> ValidateSearchRequest(SearchRequest request) { var req = new LogQuery(); var errMsg = string.Empty; DateTime tempTime; if (DateTime.TryParseExact(request.fromDate, "yy-MM-dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out tempTime)) { req.DateTime_From = tempTime; } else { } return new Tuple<LogQuery, string>(req, errMsg); }
public void SearchForElapsedGreaterThan500() { using (var reader = new NAppIndexReader(new ConfigManager())) { var qry = new LogQuery() { DateTime_From = new DateTime(2011, 11, 03), DateTime_To = new DateTime(2011, 11, 06), TotalElapsed_From = TimeSpan.FromTicks(500), }; var ret = reader.Search(qry); Assert.That(ret, Is.Not.Null); } }
public void SearchInTimeRange() { using (var reader = new NAppIndexReader(new ConfigManager())) { var qry = new LogQuery() { DateTime_From = new DateTime(2011, 11, 03), DateTime_To = new DateTime(2011, 11, 06), }; var ret = reader.Search(qry); Assert.That(ret, Is.Not.Null); Assert.That(ret.DateTime_From, Is.EqualTo(qry.DateTime_From)); Assert.That(ret.DateTime_To, Is.EqualTo(qry.DateTime_To)); } }
public LogQueryResults Search(LogQuery query) { if (query.DateTime_From == DateTime.MinValue || query.DateTime_To == DateTime.MinValue) { throw new ArgumentException("DateTime_From or DateTime_To Not Set"); } var qryHeader = new BooleanQuery(); if (!string.IsNullOrWhiteSpace(query.Text)) { var textBooleanQuery = new BooleanQuery(); for (int i = 0; i < textQueryFields.Length; i++) { var termQry = new TermQuery(new Term(textQueryFields[i], query.Text)); textBooleanQuery.Add(termQry, BooleanClause.Occur.SHOULD); } qryHeader.Add(textBooleanQuery, BooleanClause.Occur.MUST); } if (query.ClientIP != null) { var ipStr = NAppIndexUpdater.ConvertIPToString(query.ClientIP); var termQry = new TermQuery(new Term(FieldKeys.ClientIP, ipStr)); qryHeader.Add(termQry, BooleanClause.Occur.MUST); } if (query.ServerIP != null) { var ipStr = NAppIndexUpdater.ConvertIPToString(query.ServerIP); var termQry = new TermQuery(new Term(FieldKeys.ServerIP, ipStr)); qryHeader.Add(termQry, BooleanClause.Occur.MUST); } if (query.ShowExceptions == LogQueryExceptions.ExceptionsOnly) { var termQry = new TermQuery(new Term(FieldKeys.Exception, "1")); qryHeader.Add(termQry, BooleanClause.Occur.MUST); } else if (query.ShowExceptions == LogQueryExceptions.SuccessesOnly) { var termQry = new TermQuery(new Term(FieldKeys.Exception, "1")); qryHeader.Add(termQry, BooleanClause.Occur.MUST); } var elapsedQuery = AddFromToQueryString(FieldKeys.Elapsed, query.TotalElapsed_From.Ticks, query.TotalElapsed_To.Ticks, TimeSpan.Zero.Ticks); if (elapsedQuery != null) { qryHeader.Add(elapsedQuery, BooleanClause.Occur.MUST); } var dtlQry = AddFromToQueryString(FieldKeys.Detail_Elapsed, query.DetailElapsed_From.Ticks, query.DetailElapsed_To.Ticks, TimeSpan.Zero.Ticks); if (dtlQry != null) { qryHeader.Add(dtlQry, BooleanClause.Occur.MUST); } var ret = new LogQueryResults() { DateTime_From = query.DateTime_From, DateTime_To = query.DateTime_To, }; if (qryHeader.Clauses().Count > 0) { ret.LogIDs = new List<LogQueryResultDetail>(); GetLogIDsFromMain(qryHeader, ret.DateTime_From, ret.DateTime_To, ret.LogIDs); } return ret; }
public static byte[] SerializeQuery(LogQuery item) { byte[] ret; using (var ms = new MemoryStream()) { Serializer.Serialize<LogQuery>(ms, item); ret = ms.ToArray(); } return ret; }
public static void SendQuery(LogQuery query, object messageBag) { CurrentSocket().Send(MessageTypes.Query, LogQuery.SerializeQuery(query), messageBag); }