Menu

[r2]: / trunk / GoogleContactsSync / ContactsMatcher.cs  Maximize  Restore  History

Download this file

748 lines (653 with data), 34.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
using System;
using System.Collections.Generic;
using System.Text;
using Google.GData.Client;
using Google.GData.Contacts;
using Google.GData.Extensions;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Collections.ObjectModel;
namespace WebGear.GoogleContactsSync
{
internal static class ContactsMatcher
{
/// <summary>
/// Time tolerance in seconds - used when comparing date modified.
/// </summary>
public static int TimeTolerance = 20;
/// <summary>
/// Matches outlook and google contact by a) google id b) properties.
/// </summary>
/// <param name="outlookContacts"></param>
/// <param name="googleContacts"></param>
/// <returns>Returns a list of match pairs (outlook contact + google contact) for all contact. Those that weren't matche will have it's peer set to null</returns>
public static ContactMatchList MatchContacts(Syncronizer sync)
{
ContactMatchList result = new ContactMatchList(Math.Max(sync.OutlookContacts.Count, sync.GoogleContacts.Capacity));
int googleContactsMatched = 0;
bool listingDuplicates = false;
string duplicatesList = "";
//for each outlook contact try to get google contact id from user properties
//if no match - try to match by properties
//if no match - create a new match pair without google contact.
//foreach (Outlook._ContactItem olc in outlookContacts)
for (int i = 1; i <= sync.OutlookContacts.Count; i++)
{
try
{
if (!(sync.OutlookContacts[i] is Outlook.ContactItem))
continue;
}
catch
{
//this is needed because some contacts throw exceptions
continue;
}
Outlook.ContactItem olc = sync.OutlookContacts[i] as Outlook.ContactItem;
// check if a duplicate
Collection<Outlook.ContactItem> duplicates;
if (!string.IsNullOrEmpty(olc.Email1Address))
{
duplicates = sync.OutlookContactByEmail(olc.Email1Address);
if (duplicates.Count > 1)
{
if (!listingDuplicates)
{
duplicatesList = "Outlook contacts with the same email have been found. Please delete duplicates of:";
listingDuplicates = true;
}
string str = olc.FileAs + " (" + olc.Email1Address + ")";
if (!duplicatesList.Contains(str))
duplicatesList += Environment.NewLine + str;
continue;
}
else
{
ContactMatch dup = result.Find(delegate(ContactMatch match)
{
return match.OutlookContact != null && match.OutlookContact.Email1Address == olc.Email1Address;
});
if (dup != null)
{
if (sync.Logger != null)
sync.Logger.Log(string.Format("Duplicate contact found ({0}). Skipping", olc.FileAs), EventType.Information);
continue;
}
}
}
//if (duplicates.Count != 1)
//{
// // if this is the first item in the duplicates
// // collection, then proceed, otherwise skip.
// int index = sync.IndexOf(duplicates, olc); //duplicates.IndexOf(olc);
// if (index == -1)
// throw new Exception("Did not find self in duplicates");
// if (index != 0)
// continue;
//}
if (!IsContactValid(olc))
{
if (sync.Logger != null)
sync.Logger.Log(string.Format("Invalid outlook contact ({0}). Skipping", olc.FileAs), EventType.Warning);
continue;
}
// only match if there is either an email or telephone or else
// a matching google contact will be created at each sync
if (olc.Email1Address != null ||
olc.Email2Address != null ||
olc.Email3Address != null ||
olc.PrimaryTelephoneNumber != null ||
olc.HomeTelephoneNumber != null ||
olc.MobileTelephoneNumber != null ||
olc.BusinessTelephoneNumber != null
)
{
//create a default match pair with just outlook contact.
ContactMatch match = new ContactMatch(olc, null);
#region Match by google id
//try to match this contact to one of google contacts.
Outlook.UserProperty idProp = olc.UserProperties[sync.OutlookPropertyNameId];
if (idProp != null)
{
AtomId id = new AtomId((string)idProp.Value);
ContactEntry foundContact = sync.GoogleContacts.FindById(id) as ContactEntry;
if (foundContact != null && foundContact.Deleted)
{
//google contact was deleted, but outlook contact is still referencing it.
idProp.Value = "";
//TODO: delete outlook contact too?
}
if (foundContact == null)
{
//google contact not found. delete property.
idProp.Value = "";
}
else if (foundContact != null)
//we found a match by google id
match.AddGoogleContact(foundContact);
}
#endregion
if (match.GoogleContact == null)
{
//no match found. match by common properties
#region Match by properties
//foreach google contac try to match and create a match pair if found some match(es)
foreach (ContactEntry entry in sync.GoogleContacts)
{
//Console.WriteLine(" - "+entry.Title.Text);
if (entry.Deleted)
continue;
//1. try to match by name
if (!string.IsNullOrEmpty(olc.FullName) && olc.FullName.Equals(entry.Title.Text, StringComparison.InvariantCultureIgnoreCase))
{
match.AddGoogleContact(entry);
continue;
}
//1.1 try to match by file as
if (!string.IsNullOrEmpty(olc.FileAs) && olc.FileAs.Equals(entry.Title.Text, StringComparison.InvariantCultureIgnoreCase))
{
match.AddGoogleContact(entry);
continue;
}
//2. try to match by emails
if (FindEmail(olc.Email1Address, entry.Emails) != null)
{
match.AddGoogleContact(entry);
continue;
}
if (FindEmail(olc.Email2Address, entry.Emails) != null)
{
match.AddGoogleContact(entry);
continue;
}
if (FindEmail(olc.Email3Address, entry.Emails) != null)
{
match.AddGoogleContact(entry);
continue;
}
#region Phone numbers
//3. try to match by phone numbers
if (FindPhone(olc.MobileTelephoneNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
continue;
}
//don't match by home or business bumbers, because several people may share the same home or business number
continue;
//if (FindPhone(olc.PrimaryTelephoneNumber, entry.Phonenumbers) != null)
//{
// match.AddGoogleContact(entry);
// continue;
//}
if (FindPhone(olc.HomeTelephoneNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
continue;
}
if (FindPhone(olc.BusinessTelephoneNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
continue;
}
if (FindPhone(olc.BusinessFaxNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
//continue;
}
if (FindPhone(olc.HomeFaxNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
//continue;
}
if (FindPhone(olc.PagerNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
//continue;
}
if (FindPhone(olc.RadioTelephoneNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
//continue;
}
if (FindPhone(olc.OtherTelephoneNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
//continue;
}
if (FindPhone(olc.CarTelephoneNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
//continue;
}
if (FindPhone(olc.Business2TelephoneNumber, entry.Phonenumbers) != null)
{
match.AddGoogleContact(entry);
//continue;
}
#endregion
}
#endregion
}
//check if a match was found.
if (match.AllGoogleContactMatches.Count > 0)
{
googleContactsMatched += match.AllGoogleContactMatches.Count;
//remove google contact from the list so it's not matched twice.
foreach (ContactEntry contact in match.AllGoogleContactMatches)
sync.GoogleContacts.Remove(contact);
}
else
{
if (sync.Logger != null)
sync.Logger.Log(string.Format("No match found for outlook contact ({0})", olc.FileAs), EventType.Information);
}
result.Add(match);
}
else
{
// no telephone and email
if (sync.Logger != null)
sync.Logger.Log(string.Format("Skipping outlook contact ({0})", olc.FileAs), EventType.Warning);
}
}
if (listingDuplicates)
{
throw new DuplicateDataException(duplicatesList);
}
//return result;
if (sync.SyncOption != SyncOption.OutlookToGoogleOnly)
{
//for each google contact that's left (they will be nonmatched) create a new match pair without outlook contact.
foreach (ContactEntry entry in sync.GoogleContacts)
{
// only match if there is either an email or telephone or else
// a matching google contact will be created at each sync
if (entry.Emails.Count != 0 || entry.Phonenumbers.Count != 0)
{
ContactMatch match = new ContactMatch(null, entry); ;
result.Add(match);
}
else
{
// no telephone and email
}
}
}
return result;
}
private static bool IsContactValid(Outlook.ContactItem contact)
{
/*if (!string.IsNullOrEmpty(contact.FileAs))
return true;*/
if (!string.IsNullOrEmpty(contact.Email1Address))
return true;
if (!string.IsNullOrEmpty(contact.Email2Address))
return true;
if (!string.IsNullOrEmpty(contact.Email3Address))
return true;
if (!string.IsNullOrEmpty(contact.HomeTelephoneNumber))
return true;
if (!string.IsNullOrEmpty(contact.BusinessTelephoneNumber))
return true;
if (!string.IsNullOrEmpty(contact.MobileTelephoneNumber))
return true;
if (!string.IsNullOrEmpty(contact.HomeAddress))
return true;
if (!string.IsNullOrEmpty(contact.BusinessAddress))
return true;
if (!string.IsNullOrEmpty(contact.OtherAddress))
return true;
if (!string.IsNullOrEmpty(contact.Body))
return true;
return false;
}
public static void SyncContacts(Syncronizer sync)
{
foreach (ContactMatch match in sync.Contacts)
{
SyncContact(match, sync);
}
}
public static void SyncContact(ContactMatch match, Syncronizer sync)
{
if (match.GoogleContact == null && match.OutlookContact != null)
{
//no google contact
//TODO: check SyncOption
//TODO: found that when a contacts doesn't have anything other that the name - it's not returned in the google contacts list.
Outlook.UserProperty idProp = match.OutlookContact.UserProperties[sync.OutlookPropertyNameId];
if (idProp != null && (string)idProp.Value!="")
{
AtomId id = new AtomId((string)idProp.Value);
ContactEntry matchingGoogleContact = sync.GoogleContacts.FindById(id) as ContactEntry;
if (matchingGoogleContact == null)
{
//TODO: make sure that outlook contacts don't get deleted when deleting corresponding google contact when testing.
//solution: use ResetMatching() method to unlink this relation
//sync.ResetMatches();
return;
}
}
//create a Google contact from Outlook contact
match.GoogleContact = new ContactEntry();
ContactSync.UpdateContact(match.OutlookContact, match.GoogleContact);
sync.OverwriteContactGroups(match.OutlookContact, match.GoogleContact);
}
else if (match.OutlookContact == null && match.GoogleContact != null)
{
// no outlook contact
string outlookId = ContactPropertiesUtils.GetGoogleOutlookContactId(sync.SyncProfile, match.GoogleContact);
if (outlookId != null)
{
//TODO: make sure that google contacts don't get deleted when deleting corresponding outlook contact when testing.
//solution: use ResetMatching() method to unlink this relation
//sync.ResetMatches();
return;
}
//TODO: check SyncOption
//create a Outlook contact from Google contact
match.OutlookContact = sync.OutlookApplication.CreateItem(Outlook.OlItemType.olContactItem) as Outlook.ContactItem;
ContactSync.MergeContacts(match.GoogleContact, match.OutlookContact);
sync.OverwriteContactGroups(match.GoogleContact, match.OutlookContact);
}
else if (match.OutlookContact != null && match.GoogleContact != null)
{
//merge contact details
//TODO: check if there are multiple matches
if (match.AllGoogleContactMatches.Count > 1)
{
//loop from 2-nd item
for (int m = 1; m < match.AllGoogleContactMatches.Count; m++)
{
ContactEntry entry = match.AllGoogleContactMatches[m];
try
{
Outlook.ContactItem item = sync.OutlookContacts.Find("[" + sync.OutlookPropertyNameId + "] = \"" + entry.Id.Uri.Content + "\"") as Outlook.ContactItem;
//Outlook.ContactItem item = sync.OutlookContacts.Find("[myTest] = \"value\"") as Outlook.ContactItem;
if (item != null)
{
//do something
}
}
catch (Exception)
{
//TODO: should not get here.
}
}
//TODO: add info to Outlook contact from extra Google contacts before deleting extra Google contacts.
for (int m = 1; m < match.AllGoogleContactMatches.Count; m++)
{
match.AllGoogleContactMatches[m].Delete();
}
}
//determine if this contact pair were syncronized
//DateTime? lastUpdated = GetOutlookPropertyValueDateTime(match.OutlookContact, sync.OutlookPropertyNameUpdated);
DateTime? lastSynced = GetOutlookPropertyValueDateTime(match.OutlookContact, sync.OutlookPropertyNameSynced);
if (lastSynced.HasValue)
{
//contact pair was syncronysed before.
//determine if google contact was updated since last sync
//lastSynced is stored without seconds. take that into account.
DateTime lastUpdatedOutlook = match.OutlookContact.LastModificationTime.AddSeconds(-match.OutlookContact.LastModificationTime.Second);
DateTime lastUpdatedGoogle = match.GoogleContact.Updated.AddSeconds(-match.GoogleContact.Updated.Second);
//check if both outlok and google contacts where updated sync last sync
if (lastUpdatedOutlook.Subtract(lastSynced.Value).TotalSeconds >= TimeTolerance
&& lastUpdatedGoogle.Subtract(lastSynced.Value).TotalSeconds >= TimeTolerance)
{
//both contacts were updated.
//options: 1) ignore 2) loose one based on SyncOption
//throw new Exception("Both contacts were updated!");
switch (sync.SyncOption)
{
case SyncOption.MergeOutlookWins:
//overwrite google contact
ContactSync.MergeContacts(match.OutlookContact, match.GoogleContact);
sync.OverwriteContactGroups(match.OutlookContact, match.GoogleContact);
break;
case SyncOption.MergeGoogleWins:
//overwrite outlook contact
ContactSync.MergeContacts(match.GoogleContact, match.OutlookContact);
sync.OverwriteContactGroups(match.GoogleContact, match.OutlookContact);
break;
case SyncOption.MergePrompt:
//promp for sync option
ConflictResolver r = new ConflictResolver();
ConflictResolution res = r.Resolve(match.OutlookContact, match.GoogleContact);
switch (res)
{
case ConflictResolution.Cancel:
break;
case ConflictResolution.OutlookWins:
//TODO: what about categories/groups?
ContactSync.MergeContacts(match.OutlookContact, match.GoogleContact);
sync.OverwriteContactGroups(match.OutlookContact, match.GoogleContact);
break;
case ConflictResolution.GoogleWins:
//TODO: what about categories/groups?
ContactSync.MergeContacts(match.GoogleContact, match.OutlookContact);
sync.OverwriteContactGroups(match.GoogleContact, match.OutlookContact);
break;
default:
break;
}
break;
case SyncOption.GoogleToOutlookOnly:
ContactSync.MergeContacts(match.GoogleContact, match.OutlookContact);
sync.OverwriteContactGroups(match.GoogleContact, match.OutlookContact);
break;
case SyncOption.OutlookToGoogleOnly:
ContactSync.MergeContacts(match.OutlookContact, match.GoogleContact);
sync.OverwriteContactGroups(match.OutlookContact, match.GoogleContact);
break;
}
return;
}
//check if outlook contact was updated (with X second tolerance)
if (lastUpdatedOutlook.Subtract(lastSynced.Value).TotalSeconds >= TimeTolerance)
{
//outlook contact was changed
//merge contacts.
if (sync.SyncOption != SyncOption.GoogleToOutlookOnly)
{
//TODO: use UpdateContact instead?
ContactSync.MergeContacts(match.OutlookContact, match.GoogleContact);
sync.OverwriteContactGroups(match.OutlookContact, match.GoogleContact);
//at the moment use outlook as "master" source of contacts - in the event of a conflict google contact will be overwritten.
//TODO: control conflict resolution by SyncOption
return;
}
}
//check if google contact was updated (with X second tolerance)
if (lastUpdatedGoogle.Subtract(lastSynced.Value).TotalSeconds >= TimeTolerance)
{
//google contact was updated
//update outlook contact
if (sync.SyncOption != SyncOption.OutlookToGoogleOnly)
{
ContactSync.MergeContacts(match.GoogleContact, match.OutlookContact);
sync.OverwriteContactGroups(match.GoogleContact, match.OutlookContact);
}
}
}
else
{
//contacts were never synced.
//merge contacts.
switch (sync.SyncOption)
{
case SyncOption.MergeOutlookWins:
//overwrite google contact
ContactSync.MergeContacts(match.OutlookContact, match.GoogleContact);
sync.OverwriteContactGroups(match.OutlookContact, match.GoogleContact);
break;
case SyncOption.MergeGoogleWins:
//overwrite outlook contact
ContactSync.MergeContacts(match.GoogleContact, match.OutlookContact);
sync.OverwriteContactGroups(match.GoogleContact, match.OutlookContact);
break;
case SyncOption.MergePrompt:
//promp for sync option
ConflictResolver r = new ConflictResolver();
ConflictResolution res = r.Resolve(match.OutlookContact, match.GoogleContact);
switch (res)
{
case ConflictResolution.Cancel:
break;
case ConflictResolution.OutlookWins:
ContactSync.MergeContacts(match.OutlookContact, match.GoogleContact);
sync.OverwriteContactGroups(match.OutlookContact, match.GoogleContact);
break;
case ConflictResolution.GoogleWins:
ContactSync.MergeContacts(match.GoogleContact, match.OutlookContact);
sync.OverwriteContactGroups(match.GoogleContact, match.OutlookContact);
break;
default:
break;
}
break;
case SyncOption.GoogleToOutlookOnly:
ContactSync.MergeContacts(match.GoogleContact, match.OutlookContact);
sync.OverwriteContactGroups(match.GoogleContact, match.OutlookContact);
break;
case SyncOption.OutlookToGoogleOnly:
ContactSync.MergeContacts(match.OutlookContact, match.GoogleContact);
sync.OverwriteContactGroups(match.OutlookContact, match.GoogleContact);
break;
}
}
}
else
throw new ArgumentNullException("ContactMatch has all peers null.");
}
private static PhoneNumber FindPhone(string number, PhonenumberCollection phones)
{
if (string.IsNullOrEmpty(number))
return null;
foreach (PhoneNumber phone in phones)
{
if (phone.Value.Equals(number, StringComparison.InvariantCultureIgnoreCase))
{
return phone;
}
}
return null;
}
private static EMail FindEmail(string address, EMailCollection emails)
{
if (string.IsNullOrEmpty(address))
return null;
foreach (EMail email in emails)
{
if (address.Equals(email.Address, StringComparison.InvariantCultureIgnoreCase))
{
return email;
}
}
return null;
}
public static DateTime? GetOutlookPropertyValueDateTime(Outlook.ContactItem outlookContact, string propertyName)
{
Outlook.UserProperty prop = outlookContact.UserProperties[propertyName];
if (prop != null)
return (DateTime)prop.Value;
return null;
}
/// <summary>
/// Adds new Google Groups to the Google account.
/// </summary>
/// <param name="sync"></param>
public static void SyncGroups(Syncronizer sync)
{
foreach (ContactMatch match in sync.Contacts)
{
if (match.OutlookContact != null && !string.IsNullOrEmpty(match.OutlookContact.Categories))
{
string[] cats = Utilities.GetOutlookGroups(match.OutlookContact);
GroupEntry g;
foreach (string cat in cats)
{
g = sync.GetGoogleGroupByName(cat);
if (g == null)
{
// create group
if (g == null)
{
g = sync.CreateGroup(cat);
g = sync.SaveGoogleGroup(g);
sync.GoogleGroups.Add(g);
}
}
}
}
}
}
}
internal class ContactMatchList : List<ContactMatch>
{
public ContactMatchList(int capacity) : base(capacity) { }
}
internal class ContactMatch
{
public Outlook.ContactItem OutlookContact;
public ContactEntry GoogleContact;
public readonly List<ContactEntry> AllGoogleContactMatches = new List<ContactEntry>(1);
public ContactEntry LastGoogleContact;
public ContactMatch(Outlook.ContactItem outlookContact, ContactEntry googleContact)
{
OutlookContact = outlookContact;
GoogleContact = googleContact;
}
public void AddGoogleContact(ContactEntry googleContact)
{
if (googleContact == null)
return;
//throw new ArgumentNullException("googleContact must not be null.");
if (GoogleContact == null)
GoogleContact = googleContact;
//this to avoid searching the entire collection.
//if last contact it what we are trying to add the we have already added it earlier
if (LastGoogleContact == googleContact)
return;
if (!AllGoogleContactMatches.Contains(googleContact))
AllGoogleContactMatches.Add(googleContact);
LastGoogleContact = googleContact;
}
public void Delete()
{
if (GoogleContact != null)
GoogleContact.Delete();
if (OutlookContact != null)
OutlookContact.Delete();
}
}
//public class GroupMatchList : List<GroupMatch>
//{
// public GroupMatchList(int capacity) : base(capacity) { }
//}
//public class GroupMatch
//{
// public string OutlookGroup;
// public GroupEntry GoogleGroup;
// public readonly List<GroupEntry> AllGoogleGroupMatches = new List<GroupEntry>(1);
// public GroupEntry LastGoogleGroup;
// public GroupMatch(string outlookGroup, GroupEntry googleGroup)
// {
// OutlookGroup = outlookGroup;
// GoogleGroup = googleGroup;
// }
// public void AddGoogleGroup(GroupEntry googleGroup)
// {
// if (googleGroup == null)
// return;
// //throw new ArgumentNullException("googleContact must not be null.");
// if (GoogleGroup == null)
// GoogleGroup = googleGroup;
// //this to avoid searching the entire collection.
// //if last contact it what we are trying to add the we have already added it earlier
// if (LastGoogleGroup == googleGroup)
// return;
// if (!AllGoogleGroupMatches.Contains(googleGroup))
// AllGoogleGroupMatches.Add(googleGroup);
// LastGoogleGroup = googleGroup;
// }
//}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.