private SkypeFilter Filters()
        {
            var result = new SkypeFilter();

            if (!string.IsNullOrEmpty(FilterMessage))
            {
                var filters = GetFilters();
                var sql     = new string[filters.Length];
                var count   = 0;
                for (var i = 0; i < filters.Length; i++)
                {
                    var p = string.Format("@Body{0}", i);
                    sql[i] = string.Format("(M.body_xml LIKE {0})", p);
                    result.Parameters.Add(p, string.Format("%{0}%", filters[i]));
                    count++;
                }

                if (count > 0)
                {
                    result.Sql = " AND " + string.Join(FilterMessageAnd ? " AND " : " OR ", sql);
                }
            }

            if (FilterFrom.HasValue)
            {
                result.Sql += " AND M.timestamp >= @SecondsFrom";
                result.Parameters.Add("@SecondsFrom", FilterSeconds(FilterFrom.Value));
            }

            if (FilterTo.HasValue)
            {
                result.Sql += " AND M.timestamp <= @SecondsTo";
                result.Parameters.Add("@SecondsTo", FilterSeconds(FilterTo.Value, true));
            }

            if (!string.IsNullOrEmpty(FilterContact) && FilterContact != "All")
            {
                var contact = _contacts.FirstOrDefault(x => x.ToString() == FilterContact);
                if (contact != null)
                {
                    var convoIds = _participants
                                   .Where(x => x.Identity == contact.SkypeName)
                                   .Select(x => x.ConvoId)
                                   .ToArray();

                    result.Sql += " AND M.convo_id IN @ConvoIds";
                    result.Parameters.Add("@ConvoIds", convoIds);
                }
            }

            return(result);
        }
        private SkypeFilter Filters()
        {
            var result = new SkypeFilter();

            if (!string.IsNullOrEmpty(FilterMessage))
            {
                var filters = GetFilters();
                var sql = new string[filters.Length];
                var count = 0;
                for (var i = 0; i < filters.Length; i++)
                {
                    var p = string.Format("@Body{0}", i);
                    sql[i] = string.Format("(M.body_xml LIKE {0})", p);
                    result.Parameters.Add(p, string.Format("%{0}%", filters[i]));
                    count++;
                }

                if (count > 0)
                    result.Sql = " AND " + string.Join(FilterMessageAnd ? " AND " : " OR ", sql);
            }

            if (FilterFrom.HasValue)
            {
                result.Sql += " AND M.timestamp >= @SecondsFrom";
                result.Parameters.Add("@SecondsFrom", FilterSeconds(FilterFrom.Value));
            }

            if (FilterTo.HasValue)
            {
                result.Sql += " AND M.timestamp <= @SecondsTo";
                result.Parameters.Add("@SecondsTo", FilterSeconds(FilterTo.Value, true));
            }

            if (!string.IsNullOrEmpty(FilterContact) && FilterContact != "All")
            {
                var contact = _contacts.FirstOrDefault(x => x.ToString() == FilterContact);
                if (contact != null)
                {
                    var convoIds = _participants
                        .Where(x => x.Identity == contact.SkypeName)
                        .Select(x => x.ConvoId)
                        .ToArray();

                    result.Sql += " AND M.convo_id IN @ConvoIds";
                    result.Parameters.Add("@ConvoIds", convoIds);
                }
            }

            return result;
        }