private void ProcessNewMeetingItem(Outlook.MeetingItem meetingItem) { string vCalId = meetingItem.GetVCalId(); if (CrmId.IsValid(vCalId) && RestAPIWrapper.GetEntry(MeetingsSynchroniser.DefaultCrmModule, vCalId, new string[] { "id" }) != null) { meetingItem.GetAssociatedAppointment(false).SetCrmId(CrmId.Get(vCalId)); } }
/// <summary> /// AsNameValues is used in transmission to CRM as well as for comparison, so it should NOT /// access our cache of recipient addresses. /// </summary> /// <returns>A set of name/value pairs suitable for transmitting to CRM.</returns> public override NameValueCollection AsNameValues() { string statusString; string name; switch (this.Status) { case Outlook.OlMeetingStatus.olMeetingCanceled: statusString = "Not Held"; name = this.subject.StartsWith(CancelledPrefix) ? this.subject : $"{CancelledPrefix}: {this.subject}"; break; default: statusString = this.start < DateTime.Now ? "Held" : "Planned"; name = this.subject; break; } NameValueCollection data = new NameValueCollection { RestAPIWrapper.SetNameValuePair("name", name), RestAPIWrapper.SetNameValuePair("description", this.body), RestAPIWrapper.SetNameValuePair("location", this.location), RestAPIWrapper.SetNameValuePair("date_start", string.Format("{0:yyyy-MM-dd HH:mm:ss}", this.start.ToUniversalTime())), RestAPIWrapper.SetNameValuePair("date_end", string.Format("{0:yyyy-MM-dd HH:mm:ss}", this.end.ToUniversalTime())), RestAPIWrapper.SetNameValuePair("duration_minutes", (this.duration % 60).ToString()), RestAPIWrapper.SetNameValuePair("duration_hours", (this.duration / 60).ToString()), RestAPIWrapper.SetNameValuePair("outlook_id", this.globalId), RestAPIWrapper.SetNameValuePair("status", statusString) }; if (CrmId.IsValid(this.organiser)) { data.Add(RestAPIWrapper.SetNameValuePair("assigned_user_id", this.organiser.ToString())); } if (CrmId.IsInvalid(CrmEntryId)) { /* A Guid can be constructed from a 32 digit hex string. The globalId is a * 112 digit hex string. It appears from inspection that the least significant * bytes are those that vary between examples, with the most significant bytes * being invariant in the samples we have to hand. */ CrmEntryId = CrmId.Get(new Guid(this.globalId.Substring(this.globalId.Length - 32))); data.Add(RestAPIWrapper.SetNameValuePair("new_with_id", true)); } data.Add(RestAPIWrapper.SetNameValuePair("id", CrmEntryId.ToString())); return(data); }
/// <summary> /// Construct a name value list (to be serialised as JSON) representing this task. /// </summary> /// <returns>a name value list representing this task</returns> public override NameValueCollection AsNameValues() { return(new NameValueCollection { RestAPIWrapper.SetNameValuePair("name", this.subject), RestAPIWrapper.SetNameValuePair("description", this.description), RestAPIWrapper.SetNameValuePair("status", this.taskStatus), RestAPIWrapper.SetNameValuePair("date_due", this.dateDue), RestAPIWrapper.SetNameValuePair("date_start", this.dateStart), RestAPIWrapper.SetNameValuePair("priority", this.priority), CrmId.IsValid(crmEntryId) ? RestAPIWrapper.SetNameValuePair("id", crmEntryId.ToString()) : RestAPIWrapper.SetNameValuePair("assigned_user_id", RestAPIWrapper.GetUserId()) }); }