/// <summary> /// Log a message regarding this Outlook item, with detail of the item. /// </summary> /// <param name="olItem">The outlook item.</param> /// <param name="message">The message to be logged.</param> internal override void LogItemAction(Outlook.ContactItem olItem, string message) { if (olItem != null && olItem.IsValid()) { try { CrmId crmId = this.IsEnabled() ? olItem.GetCrmId() : CrmId.Empty; if (CrmId.IsInvalid(crmId)) { crmId = CrmId.Empty; } StringBuilder bob = new StringBuilder(); bob.Append($"{message}:\n\tOutlook Id : {olItem.EntryID}") .Append(this.IsEnabled() ? $"\n\tCRM Id : {crmId}" : string.Empty) .Append($"\n\tFull name : '{olItem.FullName}'") .Append($"\n\tSensitivity : {olItem.Sensitivity}") .Append($"\n\tTxState : {SyncStateManager.Instance.GetExistingSyncState(olItem)?.TxState}"); Log.Info(bob.ToString()); } catch (COMException) { // Ignore: happens if the outlook item is already deleted. } } }
/// <summary> /// Check whether there exists a sync state other than this state whose CRM id is /// this CRM id or the CRM id of this state. /// </summary> /// <param name="state">The sync state to be checked.</param> /// <param name="crmId">A candidate CRM id.</param> /// <returns>A better guess at the CRM id.</returns> /// <exception cref="DuplicateSyncStateException">If a duplicate is detected.</exception> private CrmId CheckForDuplicateSyncState(SyncState state, CrmId crmId) { CrmId result = CrmId.IsInvalid(crmId) && state != null ? state.CrmEntryId : crmId; if (result != null) { SyncState byCrmState = this.byCrmId.ContainsKey(crmId) ? this.byCrmId[crmId] : null; if (state != null && byCrmState != null && state != byCrmState) { throw new DuplicateSyncStateException(state); } } return(result); }
internal override CrmId AddOrUpdateItemFromOutlookToCrm(SyncState <Outlook.AppointmentItem> syncState) { CrmId previousCrmId = syncState.CrmEntryId; CrmId result = base.AddOrUpdateItemFromOutlookToCrm(syncState); if (CrmId.IsValid(result)) { if (CrmId.IsInvalid(previousCrmId)) /* i.e., it's new */ { if (syncState.OutlookItem.Recipients != null) { AddMeetingRecipientsFromOutlookToCrm(syncState.OutlookItem, result); } this.AddOrUpdateMeetingAcceptanceFromOutlookToCRM(syncState.OutlookItem); } } return(result); }
/// <summary> /// Log a message regarding this Outlook appointment. /// </summary> /// <param name="olItem">The outlook item.</param> /// <param name="message">The message to be logged.</param> internal override void LogItemAction(Outlook.TaskItem olItem, string message) { try { CrmId crmId = olItem.GetCrmId(); if (CrmId.IsInvalid(crmId)) { crmId = CrmId.Empty; } StringBuilder bob = new StringBuilder(); bob.Append($"{message}:\n\tOutlook Id : {olItem.EntryID}") .Append($"\n\tCRM Id : {crmId}") .Append($"\n\tSubject : '{olItem.Subject}'") .Append($"\n\tStatus : {olItem.Status}") .Append($"\n\tSensitivity : {olItem.Sensitivity}") .Append($"\n\tTxState : {SyncStateManager.Instance.GetExistingSyncState(olItem)?.TxState}"); Log.Info(bob.ToString()); } catch (COMException) { // Ignore: happens if the outlook item is already deleted. } }