/// <summary> /// Returns a percentile value of column filling /// </summary> /// <param name="column">Column name</param> /// <param name="option">Populated or empty filled</param> /// <returns>Percentile value of filling (94% for example)</returns> private float GetScoreOfAColumn(string column, ColumnScoreOption option) { // Number of relevant fields float fields = 0; SynchronizedObservableCollection <Contact> contacts = ContactsManager.Current.ContactsCache; // If contacts is not empty if (contacts.Count > 0) { // In every contact foreach (Contact contact in contacts) { // Get value of specified column string fieldValue = contact.GetType().GetProperty(column).GetValue(contact, null) as string; // For non empty cells if (option == ColumnScoreOption.Populated) { if (!string.IsNullOrEmpty(fieldValue)) { fields++; } } // For empty cells if (option == ColumnScoreOption.Empty) { if (string.IsNullOrEmpty(fieldValue)) { fields++; } } } float onePercent = ((float)contacts.Count) / 100; // Count of fields / 1% return(fields / onePercent); } else { return(0); } }
/// <summary> /// Returns a percentile value of column filling /// </summary> /// <param name="column">Column name</param> /// <param name="option">Populated or empty filled</param> /// <returns>Percentile value of filling (94% for example)</returns> private float GetScoreOfAColumn(string column, ColumnScoreOption option) { // Number of relevant fields float fields = 0; SynchronizedObservableCollection<Contact> contacts = ContactsManager.Current.ContactsCache; // If contacts is not empty if (contacts.Count > 0) { // In every contact foreach (Contact contact in contacts) { // Get value of specified column string fieldValue = contact.GetType().GetProperty(column).GetValue(contact, null) as string; // For non empty cells if (option == ColumnScoreOption.Populated) { if (!string.IsNullOrEmpty(fieldValue)) fields++; } // For empty cells if (option == ColumnScoreOption.Empty) { if (string.IsNullOrEmpty(fieldValue)) fields++; } } float onePercent = ((float)contacts.Count) / 100; // Count of fields / 1% return fields / onePercent; } else { return 0; } }