示例#1
0
        private IEnumerable <Entry> GetEntries(int offset, int length, SQLiteStatement query, int bindOffset)
        {
            query.Bind(bindOffset + 1, length);
            query.Bind(bindOffset + 2, offset);

            while (query.Step())
            {
                var id           = query.ColumnInt(0);
                var type         = (EntryType)query.ColumnInt(1);
                var connectionId = query.ColumnInt(2);
                var database     = query.ColumnText(3);
                var start        = query.ColumnText(4);
                var end          = query.ColumnText(5);
                var text         = query.ColumnText(6);
                var plan         = query.ColumnText(7);
                var results      = query.ColumnText(8);

                var startDate = DateTime.Parse(start, null, DateTimeStyles.RoundtripKind);
                var endDate   = DateTime.Parse(end, null, DateTimeStyles.RoundtripKind);

                var resultsTable = JsonConvert.DeserializeObject <DataTable>(results);

                yield return(new Entry
                {
                    Id = id,
                    Parent = this,
                    Type = type,
                    Connection = connectionId,
                    Database = database,
                    Start = startDate,
                    End = endDate,
                    Text = text,
                    Plan = plan,
                    Results = resultsTable,
                });
            }

            query.Reset();
        }
示例#2
0
        private static void BindFilters(SQLiteStatement query, ISet <Filter> filters)
        {
            var i = 1;

            foreach (var filter in filters)
            {
                if (filter.Type != null)
                {
                    query.Bind(i++, (int)filter.Type);
                }

                if (filter.Database != null)
                {
                    query.Bind(i++, string.Format(CultureInfo.InvariantCulture, "%{0}%", filter.Database));
                }

                if (filter.After != null && filter.After != default(DateTime))
                {
                    query.Bind(i++, filter.After.ToString("o", CultureInfo.InvariantCulture));
                }

                if (filter.Before != null && filter.Before != default(DateTime))
                {
                    query.Bind(i++, filter.Before.ToString("o", CultureInfo.InvariantCulture));
                }

                if (filter.Complete != null)
                {
                    query.Bind(i++, default(DateTime).ToString("o", CultureInfo.InvariantCulture));
                }

                if (filter.Text != null)
                {
                    query.Bind(i++, string.Format(CultureInfo.InvariantCulture, "%{0}%", filter.Text));
                }

                if (filter.Plan != null)
                {
                    query.Bind(i++, string.Format(CultureInfo.InvariantCulture, "%{0}%", filter.Plan));
                }
            }
        }