Menu

[r369]: / branches / calendarsync / GoogleContactsSync / AppointmentSync.cs  Maximize  Restore  History

Download this file

163 lines (133 with data), 7.1 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
using System;
using System.Collections.Generic;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
using Google.GData.Calendar;
using Google.GData.Extensions;
namespace GoContactSyncMod
{
internal static class AppointmentSync
{
//internal static DateTime outlookDateMin = new DateTime(4501, 1, 1);
//internal static DateTime outlookDateMax = new DateTime(4500, 12, 31);
/// <summary>
/// Updates Outlook appointments (calendar) to Google Calendar
/// </summary>
public static void Update(Outlook.AppointmentItem master, EventEntry slave)
{
slave.Title.Text = master.Subject;
////foreach (Outlook.Attachment attachment in master.Attachments)
//// slave.Attachments.Add(master.Attachments);
slave.Content.Content = master.Body;
slave.Status = Google.GData.Calendar.EventEntry.EventStatus.CONFIRMED;
if (master.BusyStatus.Equals(Outlook.OlBusyStatus.olTentative))
slave.Status = Google.GData.Calendar.EventEntry.EventStatus.TENTATIVE;
//slave.Categories = master.Categories;
//slave.Duration = master.Duration;
var location = new Google.GData.Extensions.Where();
location.ValueString = master.Location;
slave.Locations.Clear();
slave.Locations.Add(location);
slave.Times.Clear();
slave.Times.Add(new Google.GData.Extensions.When(master.Start, master.End, master.AllDayEvent));
////slave.StartInStartTimeZone = master.StartInStartTimeZone;
////slave.StartTimeZone = master.StartTimeZone;
////slave.StartUTC = master.StartUTC;
//slave.RequiredAttendees = master.RequiredAttendees;
//slave.OptionalAttendees = master.OptionalAttendees;
slave.Reminder = null;
if (master.ReminderSet)
{
var reminder = new Google.GData.Extensions.Reminder();
reminder.Minutes = master.ReminderMinutesBeforeStart;
reminder.Method = Google.GData.Extensions.Reminder.ReminderMethod.alert;
slave.Reminder = reminder;
}
//slave.Resources = master.Resources;
//slave.RTFBody = master.RTFBody;
//if (master.IsRecurring)
// Update(master.GetRecurrencePattern(), slave.Recurrence);
//else if (slave.Recurrence != null)
// slave.Recurrence = null;
}
/// <summary>
/// Updates Outlook appointments (calendar) to Google Calendar
/// </summary>
public static void Update(EventEntry master, Outlook.AppointmentItem slave)
{
slave.Subject = master.Title.Text;
//foreach (Outlook.Attachment attachment in master.Attachments)
// slave.Attachments.Add(master.Attachments);
slave.Body = master.Content.Content;
slave.BusyStatus = Outlook.OlBusyStatus.olBusy;
if (master.Status.Equals(Google.GData.Calendar.EventEntry.EventStatus.TENTATIVE))
slave.BusyStatus = Outlook.OlBusyStatus.olTentative;
if (master.Status.Equals(Google.GData.Calendar.EventEntry.EventStatus.CANCELED))
slave.BusyStatus = Outlook.OlBusyStatus.olFree;
//slave.Categories = master.Categories;
//slave.Duration = master.Duration;
slave.Location = string.Empty;
if (master.Locations.Count > 0)
slave.Location = master.Locations[0].ValueString;
if (master.Times.Count > 0)
{
slave.AllDayEvent = master.Times[0].AllDay;
slave.Start = master.Times[0].StartTime;
slave.End = master.Times[0].EndTime;
}
//slave.StartInStartTimeZone = master.StartInStartTimeZone;
//slave.StartTimeZone = master.StartTimeZone;
//slave.StartUTC = master.StartUTC;
//slave.RequiredAttendees = master.Participants;
//slave.OptionalAttendees = master.OptionalAttendees;
slave.ReminderSet = false;
if (master.Reminder != null && !master.Reminder.Method.Equals(Google.GData.Extensions.Reminder.ReminderMethod.none) && master.Reminder.AbsoluteTime >= DateTime.Now)
{
slave.ReminderSet = true;
slave.ReminderMinutesBeforeStart = master.Reminder.Minutes;
}
//slave.Resources = master.Resources;
//slave.RTFBody = master.RTFBody;
//if (master.IsRecurring)
// Update(master.GetRecurrencePattern(), slave.GetRecurrencePattern());
//else if (slave.IsRecurring)
// slave.ClearRecurrencePattern();
}
//ToDo: Implement recurrent Patterns
//public static void Update(Outlook.RecurrencePattern master, Recurrence slave)
//{
// try
// {
// //slave.RecurrenceType = master.RecurrenceType;
// if (master.DayOfMonth > 0)
// slave.dDayOfMonth = master.DayOfMonth;
// if (master.MonthOfYear > 0)
// slave.MonthOfYear = master.MonthOfYear;
// if (master.DayOfWeekMask > 0)
// slave.DayOfWeekMask = master.DayOfWeekMask;
// slave.Duration = master.Duration;
// //if (master.StartTime.Date < new DateTime(1900, 1, 1)
// // || master.StartTime.Date > new DateTime(2100, 1, 1))
// slave.StartTime = master.StartTime;
// //if (master.EndTime.Date != new DateTime(1601, 1, 2))
// //if (master.EndTime.Date < new DateTime(1900, 1, 1)
// // || master.EndTime.Date > new DateTime(2100, 1, 1))
// slave.EndTime = master.EndTime;
// slave.NoEndDate = master.NoEndDate;
// //slave.Instance = master.Instance;
// slave.Interval = master.Interval;
// //slave.Occurrences = master.Occurrences;
// //if (master.PatternEndDate.Date != new DateTime(4500, 12, 31))
// if (master.PatternEndDate.Date > new DateTime(1900, 1, 1)
// && master.PatternEndDate.Date < new DateTime(2100, 1, 1))
// slave.PatternEndDate = master.PatternEndDate;
// //if (master.PatternStartDate != new DateTime(4501, 1, 1))
// slave.PatternStartDate = master.PatternStartDate;
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}
}
}
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.