Пример #1
0
        /// <summary>
        /// Takes the list of SMS metafields and generates a list of ProcessedSms
        /// objects. Eliminates those whose timestamps seem to clearly be out of range.
        /// </summary>
        /// <param name="metaList">List of SMS records to be filtered.</param>
        /// <param name="pruneTimestamp">Whether or not to use the timestamp of an SMS as a parameter for filtering.</param>
        /// <param name="lower">Lower limit for timestamps.</param>
        /// <param name="upper">Upper limit for timestamps.</param>
        /// <returns>A list of processed SMS records.</returns>
        private List <ProcessedSms> GetSmsEntries(List <MetaField> metaList, bool pruneTimestamp, DateTime lower, DateTime upper)
        {
            List <ProcessedSms> pList = new List <ProcessedSms>();

            foreach (MetaSms mf in metaList)
            {
                // TODO: Can we assume a timestamp?
                if (!mf.TimeStamp.HasValue)
                {
                    continue;
                }
                if (pruneTimestamp && ((mf.TimeStamp.Value < lower) || (mf.TimeStamp.Value > upper)))
                {
                    continue;
                }
                ProcessedSms psms = new ProcessedSms(mf);
                // Save numbers for later cross referencing.
                AddNumber(sms1NumbersFull, mf.Number);
                AddNumber(sms1Numbers7, mf.SevenDigit);
                AddNumber(sms2NumbersFull, mf.Number2);
                AddNumber(sms2Numbers7, mf.SevenDigit2);
                AddRecordToDict(smsSevenDigits, mf.SevenDigit, psms);
                if (mf.SevenDigit != mf.SevenDigit2)
                {
                    AddRecordToDict(smsSevenDigits, mf.SevenDigit2, psms);
                }
                else
                {
                    try {
                        if (mf.Number != mf.Number2)
                        {
                            AddRecordToDict(smsSevenDigits, mf.SevenDigit2, psms);
                        }
                    } catch {
                    }
                }
                pList.Add(psms);
            }
            return(pList);
        }
Пример #2
0
        /// <summary>
        /// Remove fields if their dates are out of range.
        /// </summary>
        /// <param name="minDate"></param>
        /// <param name="maxDate"></param>
        private void EliminateByDate(DateTime minDate, DateTime maxDate)
        {
            // Start will call logs.
            int n = 0;

            while (n < callLogFields.Count)
            {
                ProcessedCallLog pcl = callLogFields[n];
                if ((pcl.MetaData.TimeStamp > maxDate) || (pcl.MetaData.TimeStamp < minDate))
                {
                    RemNumber(callLogNumbersFull, pcl.MetaData.Number);
                    RemNumber(callLogNumbers7, pcl.MetaData.SevenDigit);
                    callLogFields.RemoveAt(n);
                }
                else
                {
                    n++;
                }
            }
            // Now do the SMS entries.
            n = 0;
            while (n < smsFields.Count)
            {
                ProcessedSms sms = smsFields[n];
                if ((sms.MetaData.TimeStamp > maxDate) || (sms.MetaData.TimeStamp < minDate))
                {
                    RemNumber(sms1NumbersFull, sms.MetaData.Number);
                    RemNumber(sms1Numbers7, sms.MetaData.SevenDigit);
                    RemNumber(sms2NumbersFull, sms.MetaData.Number2);
                    RemNumber(sms2Numbers7, sms.MetaData.SevenDigit2);
                    smsFields.RemoveAt(n);
                }
                else
                {
                    n++;
                }
            }
        }
 public SmsListViewItem(ProcessedSms sms)
     : base()
 {
     this.SmsEntry = sms;
 }
Пример #4
0
 /// <summary>
 /// Add an SMS entry to a dictionary using a key, e.g., number. Use a list
 /// for key collisions.
 /// </summary>
 /// <param name="dict"></param>
 /// <param name="key"></param>
 /// <param name="psms"></param>
 private void AddRecordToDict(Dictionary <string, List <ProcessedSms> > dict, string key, ProcessedSms psms)
 {
     if (!dict.ContainsKey(key))
     {
         List <ProcessedSms> list = new List <ProcessedSms>();
         list.Add(psms);
         dict.Add(key, list);
     }
     else
     {
         dict[key].Add(psms);
     }
 }
Пример #5
0
 /// <summary>
 /// For an SMS record: does this filter affect it?
 /// </summary>
 /// <param name="psms"></param>
 /// <returns></returns>
 public FilterResult IsFiltered(ProcessedSms psms)
 {
     switch (fieldType) {
         case FieldType.TIMESTAMP:
             if (filterType == FilterType.AGE) {
                 return AgeCheck(psms.MetaData.TimeStamp);
             }
             break;
         case FieldType.PHONENUM:
             break;
         case FieldType.SMSTEXT:
             break;
         default:
             break;
     }
     return FilterResult.NOTAPPLICABLE;
 }
Пример #6
0
 /// <summary>
 /// Cycle through the list of SMS filters to determine if the supplied
 /// SMS record should be filtered.  
 /// </summary>
 /// <param name="psms"></param>
 /// <returns>True if it should be filtered, false if it should be kept.</returns>
 public bool IsFiltered(ProcessedSms psms)
 {
     foreach (Filter filter in smsFilters) {
         switch (filter.IsFiltered(psms)) {
             case Filter.FilterResult.NOTAPPLICABLE:
                 break;
             case Filter.FilterResult.ACCEPT:
                 return false;
             case Filter.FilterResult.REJECT:
                 return true;
         }
     }
     // Default is to keep the record.
     return false;
 }
Пример #7
0
 /// <summary>
 /// Takes the list of SMS metafields and generates a list of ProcessedSms
 /// objects. Eliminates those whose timestamps seem to clearly be out of range.
 /// </summary>
 /// <param name="metaList">List of SMS records to be filtered.</param>
 /// <param name="pruneTimestamp">Whether or not to use the timestamp of an SMS as a parameter for filtering.</param>
 /// <param name="lower">Lower limit for timestamps.</param>
 /// <param name="upper">Upper limit for timestamps.</param>
 /// <returns>A list of processed SMS records.</returns>
 private List<ProcessedSms> GetSmsEntries(List<MetaField> metaList, bool pruneTimestamp, DateTime lower, DateTime upper)
 {
     List<ProcessedSms> pList = new List<ProcessedSms>();
     foreach (MetaSms mf in metaList) {
         // TODO: Can we assume a timestamp?
         if (!mf.TimeStamp.HasValue) continue;
         if (pruneTimestamp && ((mf.TimeStamp.Value < lower) || (mf.TimeStamp.Value > upper))) {
             continue;
         }
         ProcessedSms psms = new ProcessedSms(mf);
         // Save numbers for later cross referencing.
         AddNumber(sms1NumbersFull, mf.Number);
         AddNumber(sms1Numbers7, mf.SevenDigit);
         AddNumber(sms2NumbersFull, mf.Number2);
         AddNumber(sms2Numbers7, mf.SevenDigit2);
         AddRecordToDict(smsSevenDigits, mf.SevenDigit, psms);
         if (mf.SevenDigit != mf.SevenDigit2) {
             AddRecordToDict(smsSevenDigits, mf.SevenDigit2, psms);
         } else {
             try {
                 if (mf.Number != mf.Number2) {
                     AddRecordToDict(smsSevenDigits, mf.SevenDigit2, psms);
                 }
             } catch {
             }
         }
         pList.Add(psms);
     }
     return pList;
 }
Пример #8
0
 /// <summary>
 /// Add an SMS entry to a dictionary using a key, e.g., number. Use a list
 /// for key collisions.
 /// </summary>
 /// <param name="dict"></param>
 /// <param name="key"></param>
 /// <param name="psms"></param>
 private void AddRecordToDict(Dictionary<string, List<ProcessedSms>> dict, string key, ProcessedSms psms)
 {
     if (!dict.ContainsKey(key)) {
         List<ProcessedSms> list = new List<ProcessedSms>();
         list.Add(psms);
         dict.Add(key, list);
     } else {
         dict[key].Add(psms);
     }
 }