public static ListViewItem[] UpdateFiltering(IEnumerable <GeneralPhone> phones, FilterParams filterParams) { IEnumerable <SmsMessage> allSms = new SmsMessage[0]; allSms = phones.Select(p => p.UseComponent <Memory>().Get <SmsMessage>()).SelectMany(p => p); Func <SmsMessage, bool> where; if (filterParams.Logic == LogicOperand.OR) { where = sm => (filterParams.SubString == FILTER_ALL_VALUES ? true : sm.Text.Contains(filterParams.SubString)) || (filterParams.ReceivedFrom == FILTER_ALL_VALUES ? true : sm.ReceivedFrom == filterParams.ReceivedFrom) || sm.SentTime.CompareTo(filterParams.From) >= 0 || sm.SentTime.CompareTo(filterParams.To) <= 0; } else { where = sm => (filterParams.SubString == FILTER_ALL_VALUES ? true : sm.Text.Contains(filterParams.SubString)) && (filterParams.ReceivedFrom == FILTER_ALL_VALUES ? true : sm.ReceivedFrom == filterParams.ReceivedFrom) && sm.SentTime.CompareTo(filterParams.From) >= 0 && sm.SentTime.CompareTo(filterParams.To) <= 0; }; return(allSms.Where(where).GroupBy(sm => new { sm.ReceivedFrom, sm.SendTo, sm.Text }).Select(g => g.First()) .Select(sm => new ListViewItem(new[] { sm.ReceivedFrom, sm.SendTo, sm.Text })) .ToArray()); }
public static string[] FilteringSenders(IEnumerable <IPhone> phones) { IEnumerable <SmsMessage> allSms = new SmsMessage[0]; allSms = phones.Select(p => p.UseComponent <Memory>().Get <SmsMessage>()).SelectMany(p => p); var receivedFrom = allSms.Where(c => c.ReceivedFrom != null).Select(c => c.ReceivedFrom).Distinct(); return(new List <string>() { FILTER_ALL_VALUES }.Concat(receivedFrom).ToArray()); }
public static string[] FilteringSenders(IEnumerable <GeneralPhone> phones) { IEnumerable <SmsMessage> allSms = new SmsMessage[0]; foreach (IPhone phone in phones) { allSms = allSms.Concat(phone.UseComponent <Memory>().Get <SmsMessage>()); } var receivedFrom = allSms.Where(c => c.ReceivedFrom != null).Select(c => c.ReceivedFrom).Distinct(); return(new List <string>() { FILTER_ALL_VALUES }.Concat(receivedFrom).ToArray()); }