public override NameValueCollection AsNameValues() { return(new NameValueCollection { RestAPIWrapper.SetNameValuePair("email1", Email1Address), RestAPIWrapper.SetNameValuePair("title", JobTitle), RestAPIWrapper.SetNameValuePair("phone_work", BusinessTelephoneNumber), RestAPIWrapper.SetNameValuePair("phone_home", HomeTelephoneNumber), RestAPIWrapper.SetNameValuePair("phone_mobile", MobileTelephoneNumber), RestAPIWrapper.SetNameValuePair("phone_fax", BusinessFaxNumber), RestAPIWrapper.SetNameValuePair("department", Department), RestAPIWrapper.SetNameValuePair("primary_address_city", BusinessAddressCity), RestAPIWrapper.SetNameValuePair("primary_address_state", BusinessAddressState), RestAPIWrapper.SetNameValuePair("primary_address_postalcode", BusinessAddressPostalCode), RestAPIWrapper.SetNameValuePair("primary_address_country", BusinessAddressCountry), RestAPIWrapper.SetNameValuePair("primary_address_street", BusinessAddressStreet), RestAPIWrapper.SetNameValuePair("description", Body), RestAPIWrapper.SetNameValuePair("last_name", LastName), RestAPIWrapper.SetNameValuePair("first_name", FirstName), RestAPIWrapper.SetNameValuePair("account_name", CompanyName), RestAPIWrapper.SetNameValuePair("salutation", Title), CrmId.IsValid(CrmEntryId) ? RestAPIWrapper.SetNameValuePair("id", CrmEntryId.ToString()) : RestAPIWrapper.SetNameValuePair("assigned_user_id", RestAPIWrapper.GetUserId()), RestAPIWrapper.SetNameValuePair("sync_contact", this.isPublic) }); }
/// <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()) }); }
public static void ChangeCrmId(this Outlook.ContactItem olItem, string text) { var crmId = new CrmId(text); var state = SyncStateManager.Instance.GetExistingSyncState(olItem); var userProperty = olItem.UserProperties.Find(SyncStateManager.CrmIdPropertyName) ?? olItem.UserProperties.Add(SyncStateManager.CrmIdPropertyName, Outlook.OlUserPropertyType.olText); userProperty.Value = crmId.ToString(); if (state != null) { state.CrmEntryId = crmId; } olItem.Save(); }
/// <summary> /// Set the CRM id for this item to this value. /// </summary> /// <param name="olItem">The Outlook item under consideration.</param> /// <param name="crmId">The value to set.</param> public static void SetCrmId(this Outlook.AppointmentItem olItem, CrmId crmId) { Outlook.UserProperty property = olItem.UserProperties[SyncStateManager.CrmIdPropertyName]; if (property == null) { property = olItem.UserProperties.Add(SyncStateManager.CrmIdPropertyName, Outlook.OlUserPropertyType.olText); SyncStateManager.Instance.SetByCrmId(crmId, SyncStateManager.Instance.GetOrCreateSyncState(olItem)); } if (CrmId.IsInvalid(crmId)) { property.Delete(); } else { property.Value = crmId.ToString(); } }