Menu

[r228]: / trunk / GoogleContactsSync / ConflictResolver.cs  Maximize  Restore  History

Download this file

89 lines (76 with data), 3.2 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
using System;
using System.Collections.Generic;
using System.Text;
using Google.Contacts;
using Google.Documents;
namespace GoContactSyncMod
{
class ConflictResolver : IConflictResolver
{
private ConflictResolverForm _form;
public ConflictResolver()
{
_form = new ConflictResolverForm();
}
public ConflictResolver(ConflictResolverForm form)
{
_form = form;
}
#region IConflictResolver Members
public ConflictResolution Resolve(Microsoft.Office.Interop.Outlook.ContactItem outlookContact, Contact googleContact)
{
string name = googleContact.Title;
if (string.IsNullOrEmpty(name))
name = googleContact.Name.FullName;
if (string.IsNullOrEmpty(name) && googleContact.Organizations.Count > 0)
name = googleContact.Organizations[0].Name;
if (string.IsNullOrEmpty(name) && googleContact.Emails.Count > 0)
name = googleContact.Emails[0].Address;
_form.messageLabel.Text =
"Both the outlook contact and the google contact \"" + name +
"\" have been changed. Choose which you would like to keep.";
switch (_form.ShowDialog())
{
case System.Windows.Forms.DialogResult.Ignore:
// skip
return ConflictResolution.Skip;
case System.Windows.Forms.DialogResult.Cancel:
// cancel
return ConflictResolution.Cancel;
case System.Windows.Forms.DialogResult.No:
// google wins
return ConflictResolution.GoogleWins;
case System.Windows.Forms.DialogResult.Yes:
// outlook wins
return ConflictResolution.OutlookWins;
default:
throw new Exception();
}
}
public ConflictResolution Resolve(Microsoft.Office.Interop.Outlook.NoteItem outlookNote, Document googleNote)
{
string name = googleNote.Title;
_form.messageLabel.Text =
"Both the outlook note and the google note \"" + name +
"\" have been changed. Choose which you would like to keep.";
switch (_form.ShowDialog())
{
case System.Windows.Forms.DialogResult.Ignore:
// skip
return ConflictResolution.Skip;
case System.Windows.Forms.DialogResult.Cancel:
// cancel
return ConflictResolution.Cancel;
case System.Windows.Forms.DialogResult.No:
// google wins
return ConflictResolution.GoogleWins;
case System.Windows.Forms.DialogResult.Yes:
// outlook wins
return ConflictResolution.OutlookWins;
default:
throw new Exception();
}
}
#endregion
}
}
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.