Esempio n. 1
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 CallLogListViewItem(ProcessedCallLog callLog)
     : base()
 {
     this.CallLog = callLog;
 }
Esempio n. 3
0
 /// <summary>
 /// Add call log to a dictionary using a key, e.g., number or name. Use a list
 /// for key collisions.
 /// </summary>
 /// <param name="dict"></param>
 /// <param name="key"></param>
 /// <param name="pcl"></param>
 private void AddRecordToDict(Dictionary <string, List <ProcessedCallLog> > dict, string key, ProcessedCallLog pcl)
 {
     if ((key == null) || (key == MetaField.DEFAULT_STRING))
     {
         return;
     }
     if (!dict.ContainsKey(key))
     {
         List <ProcessedCallLog> list = new List <ProcessedCallLog>();
         list.Add(pcl);
         dict.Add(key, list);
     }
     else
     {
         dict[key].Add(pcl);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Attempts to eliminate duplicate call logs by timestamp and number.
        /// It chooses to keep the least ambiguous call log.
        /// </summary>
        private List <ProcessedCallLog> EliminateDupCallLogs(List <ProcessedCallLog> callLogs)
        {
            HashSet <int>    remove    = new HashSet <int>();
            HashSet <string> completed = new HashSet <string>();

            foreach (ProcessedCallLog pcl in callLogs)
            {
                try {
                    if (!pcl.MetaData.TimeStamp.HasValue)
                    {
                        continue;
                    }
                    if (remove.Contains(pcl.Id))
                    {
                        continue;
                    }
                    string hash = String.Format("{0}:::{1}",
                                                ((DateTime)pcl.MetaData.TimeStamp).ToString("yyyy-MM-dd HH:mm:ss"),
                                                pcl.MetaData.Number);
                    if (completed.Contains(hash))
                    {
                        continue;
                    }
                    List <ProcessedCallLog> dups = new List <ProcessedCallLog>();
                    dups.Add(pcl);
                    ProcessedCallLog alpha = pcl;
                    int alphaRank          = RankCallLogType(pcl.MetaData.Type);
                    foreach (ProcessedCallLog pcl2 in callLogs)
                    {
                        if (!pcl2.MetaData.TimeStamp.HasValue)
                        {
                            continue;
                        }
                        if (pcl.Id == pcl2.Id)
                        {
                            continue;
                        }
                        string hash2 = String.Format("{0}:::{1}",
                                                     ((DateTime)pcl2.MetaData.TimeStamp).ToString("yyyy-MM-dd HH:mm:ss"),
                                                     pcl2.MetaData.Number);
                        if (hash != hash2)
                        {
                            continue;
                        }
                        dups.Add(pcl2);
                        int r = RankCallLogType(pcl2.MetaData.Type);
                        if (r < alphaRank)
                        {
                            alpha     = pcl2;
                            alphaRank = r;
                        }
                    }
                    completed.Add(hash);
                    if (dups.Count <= 1)
                    {
                        continue;
                    }
                    for (int n = 1; n < dups.Count; n++)
                    {
                        if (RankCallLogType(dups[n].MetaData.Type) > alphaRank)
                        {
                            remove.Add(dups[n].Id);
                        }
                    }
                } catch {
                }
            }
            if (remove.Count == 0)
            {
                return(callLogs);
            }
            List <ProcessedCallLog> newCallLogs = new List <ProcessedCallLog>();

            foreach (ProcessedCallLog pcl in callLogs)
            {
                if (remove.Contains(pcl.Id))
                {
                    continue;
                }
                newCallLogs.Add(pcl);
            }
            return(newCallLogs);
        }
Esempio n. 5
0
 /// <summary>
 /// Cycle through the list of call log filters to determine if the
 /// supplied call log should be filtered.
 /// </summary>
 /// <param name="pcl"></param>
 /// <returns>True if it should be filtered, false if it should be kept.</returns>
 public bool IsFiltered(ProcessedCallLog pcl)
 {
     foreach (Filter filter in clFilters) {
         switch (filter.IsFiltered(pcl)) {
             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;
 }
Esempio n. 6
0
 /// <summary>
 /// For a call log: does this filter affect the record?
 /// </summary>
 /// <param name="pcl"></param>
 /// <returns></returns>
 public FilterResult IsFiltered(ProcessedCallLog pcl)
 {
     switch (fieldType) {
         case FieldType.TIMESTAMP:
             if (filterType == FilterType.AGE) {
                 return AgeCheck(pcl.MetaData.TimeStamp);
             }
             break;
         case FieldType.PHONENUM:
             break;
         case FieldType.NAME:
             break;
         case FieldType.CLTYPE:
             break;
         default:
             break;
     }
     return FilterResult.NOTAPPLICABLE;
 }
Esempio n. 7
0
 /// <summary>
 /// Add call log to a dictionary using a key, e.g., number or name. Use a list
 /// for key collisions.
 /// </summary>
 /// <param name="dict"></param>
 /// <param name="key"></param>
 /// <param name="pcl"></param>
 private void AddRecordToDict(Dictionary<string, List<ProcessedCallLog>> dict, string key, ProcessedCallLog pcl)
 {
     if ((key == null) || (key == MetaField.DEFAULT_STRING)) {
         return;
     }
     if (!dict.ContainsKey(key)) {
         List<ProcessedCallLog> list = new List<ProcessedCallLog>();
         list.Add(pcl);
         dict.Add(key, list);
     } else {
         dict[key].Add(pcl);
     }
 }