public void TestAppointmentOwnership() { Appointment appt = new Appointment(); Assert.IsFalse(this.ValidateOwnership(appt)); this.AssignOwnership(appt); Assert.IsTrue(this.ValidateOwnership(appt)); }
public static void WriteAppointment( string email, DateTime appointmentStart ) { DateTime appointmentEnd = appointmentStart.AddHours( 1 ); ExchangeService gw = new ExchangeService( ConfigCache.ExchangeServerUrl, ConfigCache.ExchangeAdminLogin, ConfigCache.ExchangeAdminPassword ); ExchangeUserDict users = gw.QueryActiveDirectory( string.Format("mail={0}", email )); if (users.Count != 0) { foreach (ExchangeUser user in users.Values) { Appointment appt = new Appointment(); appt.Subject = "GCalExchangeSync test appt"; appt.Location = "test"; appt.StartDate = appointmentStart; appt.EndDate = appointmentEnd; appt.MeetingStatus = MeetingStatus.Confirmed; appt.Created = DateUtil.NowUtc; appt.InstanceType = InstanceType.Single; List<Appointment> list = new List<Appointment>(); list.Add(appt); gw.Appointments.WriteAppointments(user, list); } } else { string msg = string.Format("User {0} not found", email); throw new Exception(msg); } }
private void AddFreeBusyBlock( FreeBusyCollection result, DateTimeRange eventRange, bool existingEvent) { FreeBusyTimeBlock block = new FreeBusyTimeBlock(eventRange); Appointment appt = new Appointment(); appt.StartDate = eventRange.Start; appt.EndDate = eventRange.End; appt.BusyStatus = BusyStatus.Busy; if (existingEvent) { AssignOwnership(appt); } block.Appointments.Add(appt); result.Appointments.Add(appt); result[eventRange.Start] = block; }
private List<Appointment> ParseAppointmentResultSetXml(XmlDocument doc) { List<Appointment> result = new List<Appointment>(); XPathNavigator nav = doc.CreateNavigator(); bool active = nav.MoveToFirstChild(); XmlNamespaceManager ns = new XmlNamespaceManager( doc.NameTable ); ns.AddNamespace("dav", "DAV:"); ns.AddNamespace("cal", "urn:schemas:calendar:"); ns.AddNamespace("mail", "urn:schemas:mailheader:"); ns.AddNamespace("f", "http://schemas.microsoft.com/mapi/proptag/"); ns.AddNamespace("g", "http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/"); ns.AddNamespace("h", "http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/"); XmlNodeList nodes = doc.SelectNodes( "//dav:response", ns ); foreach ( XmlNode node in nodes ) { Appointment appt = new Appointment(); appt.HRef = node.SelectSingleNode("dav:href", ns).InnerXml; XmlNode prop = node.SelectSingleNode("dav:propstat[1]/dav:prop", ns); appt.AllDayEvent = GetPropertyAsBool(prop, "cal:alldayevent", ns); appt.Body = GetPropertyAsXML(prop, "f:x1000001e", ns); appt.BusyStatus = ConversionsUtil.ParseBusyStatus( GetPropertyAsString(prop, "cal:busystatus", appt.BusyStatus.ToString(), ns)); appt.Comment = GetPropertyAsString(prop, "dav:comment", ns); appt.Created = GetPropertyAsDateTime(prop, "dav:creationdate", ns); appt.StartDate = GetPropertyAsDateTime(prop, "cal:dtstart", ns); appt.EndDate = GetPropertyAsDateTime(prop, "cal:dtend", ns); appt.InstanceType = (InstanceType)Enum.Parse( typeof(InstanceType), GetPropertyAsString(prop, "cal:instancetype", appt.InstanceType.ToString(), ns), true); appt.IsPrivate = GetPropertyAsBool(prop, "g:x8506", ns); appt.Location = GetPropertyAsString(prop, "cal:location", ns); appt.MeetingStatus = (MeetingStatus)Enum.Parse( typeof(MeetingStatus), GetPropertyAsString(prop, "cal:meetingstatus", appt.MeetingStatus.ToString(), ns), true); appt.Organizer = GetPropertyAsString(prop, "cal:organizer", ns); appt.ResponseStatus = (ResponseStatus)GetPropertyAsInt(prop, "h:x8218", (int)appt.ResponseStatus, ns); appt.Subject = GetPropertyAsString(prop, "mail:subject", ns); result.Add(appt); } return result; }
/// <summary> /// Create a mailbox appointment /// </summary> /// <param name="mailboxUrl">The mailbox URL to create the appointment at</param> /// <param name="appointment">The appointment to create</param> /// <returns>The URL of the created appointment</returns> public string CreateAppointment( string mailboxUrl, Appointment appointment ) { string body = WebDavXmlResources.GetText( WebDavXmlResources.CreateAppointment, appointment.Subject, appointment.Body, appointment.Comment, appointment.IsPrivate ? "1" : "0", appointment.AllDayEvent ? "1" : "0", DateUtil.FormatDateForExchange( appointment.EndDate ), DateUtil.FormatDateForExchange( appointment.StartDate ), Convert.ToInt32( appointment.InstanceType ), appointment.Location, appointment.MeetingStatus.ToString(), appointment.ResponseStatus.ToString(), appointment.Organizer, appointment.BusyStatus.ToString() ); if ( !mailboxUrl.EndsWith( "/" ) ) mailboxUrl += "/"; string appointmentUrl = string.Format( "{0}{{{1}}}.eml", mailboxUrl, Guid.NewGuid().ToString() ); IssueRequestIgnoreResponse(appointmentUrl, Method.PROPPATCH, body); appointment.HRef = appointmentUrl; return appointmentUrl; }
/// <summary> /// Update an existing appointment /// </summary> /// <param name="mailboxUrl">The URL of the appointment in the mailbox</param> /// <param name="appointment">The Update Appointment value</param> /// <returns>The appointment URL</returns> public string UpdateAppointment( string mailboxUrl, Appointment appointment ) { string body = WebDavXmlResources.GetText( WebDavXmlResources.CreateAppointment, appointment.Subject, appointment.Body, appointment.Comment, appointment.IsPrivate ? "1" : "0", appointment.AllDayEvent ? "1" : "0", DateUtil.FormatDateForExchange( appointment.EndDate ), DateUtil.FormatDateForExchange( appointment.StartDate ), Convert.ToInt32( appointment.InstanceType ), appointment.Location, appointment.MeetingStatus.ToString(), appointment.ResponseStatus.ToString(), appointment.Organizer, appointment.BusyStatus.ToString() ); IssueRequestIgnoreResponse(appointment.HRef, Method.PROPPATCH, body); return appointment.HRef; }
/// <summary> /// Validates that the appointment passed in was created through a GCalExchange sync /// </summary> /// <param name="appt">The appointment to validate ownership for</param> /// <returns>true if the event was written by AppointmentWriter</returns> protected bool ValidateOwnership( Appointment appt ) { return ( appt.Comment == GCalenderTag ); }
/// <summary> /// Tags an appointment with a ownership flag so that the appointment can be validated /// against /// </summary> /// <param name="appt">The appointment to set ownership for</param> protected void AssignOwnership( Appointment appt ) { appt.Comment = GCalenderTag; }
/// <summary> /// Updates appointment information between appointments /// </summary> /// <param name="existingAppt">The existing appointment to update</param> /// <param name="newAppt">Appointment information to update from</param> /// <returns></returns> private Appointment UpdateAppointmentInfo( Appointment existingAppt, Appointment newAppt ) { existingAppt.Body = newAppt.Body; existingAppt.Subject = newAppt.Subject; existingAppt.StartDate = newAppt.StartDate; existingAppt.EndDate = newAppt.EndDate; existingAppt.AllDayEvent = newAppt.AllDayEvent; existingAppt.MeetingStatus = newAppt.MeetingStatus; existingAppt.Location = newAppt.Location; existingAppt.InstanceType = newAppt.InstanceType; existingAppt.Comment = newAppt.Comment; existingAppt.BusyStatus = newAppt.BusyStatus; return existingAppt; }
private void CreateAppointment( IntervalTree<Appointment> result, ExchangeUser user, OlsonTimeZone srcTimeZone, EventEntry googleAppsEvent) { Appointment appt = new Appointment(); if ( googleAppsEvent.Times != null && googleAppsEvent.Times.Count > 0 ) { When eventTime = googleAppsEvent.Times[0]; appt.StartDate = DateTime.SpecifyKind(eventTime.StartTime.ToUniversalTime(), DateTimeKind.Unspecified); appt.EndDate = DateTime.SpecifyKind(eventTime.EndTime.ToUniversalTime(), DateTimeKind.Unspecified); log.DebugFormat("Create - [{0}] {1}", appt.Range, appt.Range.Start.Kind); appt.AllDayEvent = googleAppsEvent.Times[0].AllDay; } if (ConfigCache.SyncAppointmentDetails && googleAppsEvent.Locations != null && googleAppsEvent.Locations.Count > 0 ) { appt.Location = googleAppsEvent.Locations[0].ValueString ?? string.Empty; } else { appt.Location = String.Empty; } string subject = ConfigCache.PlaceHolderMessage; if (ConfigCache.SyncAppointmentDetails) { subject += ": " + ConversionsUtil.SafeGetText(googleAppsEvent.Title); if (subject.Length > 255) { subject = subject.Remove(255); } } appt.Subject = subject; if (ConfigCache.SyncAppointmentDetails) { appt.Body = ConversionsUtil.SafeGetContent(googleAppsEvent.Content); } appt.MeetingStatus = ConversionsUtil.ConvertGoogleEventStatus(googleAppsEvent.Status); appt.BusyStatus = ConversionsUtil.GetUserStatusForEvent(user, googleAppsEvent); appt.Created = DateUtil.NowUtc; appt.InstanceType = InstanceType.Single; AssignOwnership( appt ); result.Insert(appt.Range, appt); }
private Appointment createAppointment(DateTime start, DateTime end, bool isAllDay) { Appointment result = new Appointment(); result.StartDate = start; result.Created = DateUtil.NowUtc; result.BusyStatus = BusyStatus.Busy; result.EndDate = end; result.AllDayEvent = isAllDay; return result; }
private List <Appointment> ParseAppointmentResultSetXml(XmlDocument doc) { List <Appointment> result = new List <Appointment>(); XPathNavigator nav = doc.CreateNavigator(); bool active = nav.MoveToFirstChild(); XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("dav", "DAV:"); ns.AddNamespace("cal", "urn:schemas:calendar:"); ns.AddNamespace("mail", "urn:schemas:mailheader:"); ns.AddNamespace("f", "http://schemas.microsoft.com/mapi/proptag/"); ns.AddNamespace("g", "http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/"); ns.AddNamespace("h", "http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/"); XmlNodeList nodes = doc.SelectNodes("//dav:response", ns); foreach (XmlNode node in nodes) { Appointment appt = new Appointment(); appt.HRef = node.SelectSingleNode("dav:href", ns).InnerXml; XmlNode prop = node.SelectSingleNode("dav:propstat[1]/dav:prop", ns); appt.AllDayEvent = GetPropertyAsBool(prop, "cal:alldayevent", ns); appt.Body = GetPropertyAsXML(prop, "f:x1000001e", ns); appt.BusyStatus = ConversionsUtil.ParseBusyStatus( GetPropertyAsString(prop, "cal:busystatus", appt.BusyStatus.ToString(), ns)); appt.Comment = GetPropertyAsString(prop, "dav:comment", ns); appt.Created = GetPropertyAsDateTime(prop, "dav:creationdate", ns); appt.StartDate = GetPropertyAsDateTime(prop, "cal:dtstart", ns); appt.EndDate = GetPropertyAsDateTime(prop, "cal:dtend", ns); appt.InstanceType = (InstanceType)Enum.Parse( typeof(InstanceType), GetPropertyAsString(prop, "cal:instancetype", appt.InstanceType.ToString(), ns), true); appt.IsPrivate = GetPropertyAsBool(prop, "g:x8506", ns); appt.Location = GetPropertyAsString(prop, "cal:location", ns); appt.MeetingStatus = (MeetingStatus)Enum.Parse( typeof(MeetingStatus), GetPropertyAsString(prop, "cal:meetingstatus", appt.MeetingStatus.ToString(), ns), true); appt.Organizer = GetPropertyAsString(prop, "cal:organizer", ns); appt.ResponseStatus = (ResponseStatus)GetPropertyAsInt(prop, "h:x8218", (int)appt.ResponseStatus, ns); appt.Subject = GetPropertyAsString(prop, "mail:subject", ns); result.Add(appt); } return(result); }
private static int CompareAppointmentsByRanges( Appointment x, Appointment y) { if ((x == null) && (y == null)) { // If x is null and y is null, they are equal. return 0; } if (x == null) { // If x is null and y is not null, y is greater. return -1; } if (y == null) { // If x is not null and y is null, x is greater. return 1; } return FreeBusyConverter.CompareRangesByStartThenEnd(x.Range, y.Range); }