/// <summary> /// Get a string representing the values of the distinct fields of this crmItem, /// as a final fallback for identifying an otherwise unidentifiable object. /// </summary> /// <param name="crmItem">An item received from CRM.</param> /// <returns>An identifying string.</returns> /// <see cref="SyncState{ItemType}.IdentifyingFields"/> private string GetDistinctFields(EntryValue crmItem) { string result; switch (crmItem.module_name) { case CallsSynchroniser.CrmModule: result = CallSyncState.GetDistinctFields(crmItem); break; case ContactSynchroniser.CrmModule: result = ContactSyncState.GetDistinctFields(crmItem); break; case MeetingsSynchroniser.CrmModule: result = MeetingSyncState.GetDistinctFields(crmItem); break; case TaskSynchroniser.CrmModule: result = TaskSyncState.GetDistinctFields(crmItem); break; default: this.log.Warn($"Unexpected CRM module name '{crmItem.module_name}'"); result = string.Empty; break; } return(result); }
/// <summary> /// Update this Outlook appointment's start and duration from this CRM object. /// </summary> /// <param name="crmType">The CRM type of the item from which values are to be taken.</param> /// <param name="crmItem">The CRM item from which values are to be taken.</param> /// <param name="date_start">The state date/time of the item, adjusted for timezone.</param> /// <param name="olItem">The outlook item assumed to correspond with the CRM item.</param> private void UpdateOutlookStartAndDuration(string crmType, EntryValue crmItem, DateTime date_start, Outlook.AppointmentItem olItem) { try { olItem.Start = date_start; var minutesString = crmItem.GetValueAsString("duration_minutes"); var hoursString = crmItem.GetValueAsString("duration_hours"); int minutes = string.IsNullOrWhiteSpace(minutesString) ? 0 : int.Parse(minutesString); int hours = string.IsNullOrWhiteSpace(hoursString) ? 0 : int.Parse(hoursString); if (crmType == AppointmentSyncing.CrmModule) { olItem.Location = crmItem.GetValueAsString("location"); olItem.End = olItem.Start; if (hours > 0) { olItem.End.AddHours(hours); } if (minutes > 0) { olItem.End.AddMinutes(minutes); } SetRecipients(olItem, crmItem.GetValueAsString("id"), crmType); } olItem.Duration = minutes + hours * 60; } finally { this.SaveItem(olItem); } }
/// <summary> /// A CRM item is perceived to have changed if its modified date is different from /// that of its Outlook representation, or if its should sync flag is. /// </summary> /// <param name="crmItem">A CRM item.</param> /// <param name="olItem">An Outlook item, assumed to represent the same entity.</param> /// <returns>True if either of these propertyies differ between the representations.</returns> private bool CrmItemChanged(EntryValue crmItem, Outlook.ContactItem olItem) { Outlook.UserProperty dateModifiedProp = olItem.UserProperties[SyncStateManager.ModifiedDatePropertyName]; return(dateModifiedProp.Value != crmItem.GetValueAsString("date_modified") || ShouldSyncFlagChanged(olItem, crmItem)); }
/// <summary> /// Set this outlook item's duration, but also end time and location, from this CRM item. /// </summary> /// <param name="crmType">The type of the CRM item.</param> /// <param name="crmItem">The CRM item.</param> /// <param name="olItem">The Outlook item.</param> private void SetOutlookItemDuration(string crmType, EntryValue crmItem, Outlook.AppointmentItem olItem) { int minutes = 0, hours = 0; try { if (!string.IsNullOrWhiteSpace(crmItem.GetValueAsString("duration_minutes"))) { minutes = int.Parse(crmItem.GetValueAsString("duration_minutes")); } if (!string.IsNullOrWhiteSpace(crmItem.GetValueAsString("duration_hours"))) { hours = int.Parse(crmItem.GetValueAsString("duration_hours")); } int durationMinutes = minutes + hours * 60; if (crmType == AppointmentSyncing.CrmModule) { olItem.Location = crmItem.GetValueAsString("location"); olItem.End = olItem.Start.AddMinutes(durationMinutes); } olItem.Duration = durationMinutes; } catch (Exception any) { Log.Error("AppointmentSyncing.SetOutlookItemDuration", any); } finally { this.SaveItem(olItem); } }
/// <summary> /// Update an existing Outlook item with values taken from a corresponding CRM item. Note that /// this just overwrites all values in the Outlook item. /// </summary> /// <param name="crmItem">The CRM item from which values are to be taken.</param> /// <param name="itemSyncState">The sync state of an outlook item assumed to correspond with the CRM item.</param> /// <returns>An appropriate sync state.</returns> private SyncState <Outlook.ContactItem> UpdateExistingOutlookItemFromCrm(EntryValue crmItem, SyncState <Outlook.ContactItem> itemSyncState) { if (!itemSyncState.IsDeletedInOutlook) { Outlook.ContactItem olItem = itemSyncState.OutlookItem; Outlook.UserProperty dateModifiedProp = olItem.UserProperties[SyncStateManager.ModifiedDatePropertyName]; Outlook.UserProperty shouldSyncProp = olItem.UserProperties["SShouldSync"]; this.LogItemAction(olItem, "ContactSyncing.UpdateExistingOutlookItemFromCrm"); if (CrmItemChanged(crmItem, olItem)) { DateTime crmDate = DateTime.Parse(crmItem.GetValueAsString("date_modified")); DateTime outlookDate = dateModifiedProp == null ? DateTime.MinValue : DateTime.Parse(dateModifiedProp.Value.ToString()); if (crmDate > this.LastRunCompleted && outlookDate > this.LastRunCompleted) { MessageBox.Show( $"Contact {olItem.FirstName} {olItem.LastName} has changed both in Outlook and CRM; please check which is correct", "Update problem", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (crmDate > outlookDate) { this.SetOutlookItemPropertiesFromCrmItem(crmItem, olItem); } } this.LogItemAction(olItem, "ContactSyncing.UpdateExistingOutlookItemFromCrm"); itemSyncState.OModifiedDate = DateTime.ParseExact(crmItem.GetValueAsString("date_modified"), "yyyy-MM-dd HH:mm:ss", null); } return(itemSyncState); }
protected override void OnMouseUp(int x, int y, MouseButton button) { if (button == MouseButton.Left) { EntryValue.OnSelectionEnd(x, y); } }
private static void SetProperties(string value, EntryValue valueInterpretation, ILogEntry result) { switch (valueInterpretation) { case EntryValue.date: // 2015-01-13 var date = value == "-" ? DateTime.MinValue : DateTime.ParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture); result.DateTime = new DateTime(date.Year, date.Month, date.Day, result.DateTime.Hour, result.DateTime.Minute, result.DateTime.Second); break; case EntryValue.time: // 00:32:17 var time = value == "-" ? DateTime.MinValue : DateTime.ParseExact(value, "HH:mm:ss", CultureInfo.InvariantCulture); result.DateTime = new DateTime(result.DateTime.Year, result.DateTime.Month, result.DateTime.Day, time.Hour, time.Minute, time.Second); break; case EntryValue.s_ip: result.SourceIpAddress = IPAddress.Parse(value).ToString(); break; case EntryValue.cs_method: result.Method = value; break; case EntryValue.s_port: result.Port = Int32.Parse(value); break; case EntryValue.c_ip: result.ClientIpAddress = IPAddress.Parse(value).ToString(); break; } }
protected override void UpdateOutlookDetails(string crmType, EntryValue crmItem, DateTime date_start, Outlook.AppointmentItem olItem) { try { olItem.Start = date_start; var minutesString = crmItem.GetValueAsString("duration_minutes"); var hoursString = crmItem.GetValueAsString("duration_hours"); int minutes = string.IsNullOrWhiteSpace(minutesString) ? 0 : int.Parse(minutesString); int hours = string.IsNullOrWhiteSpace(hoursString) ? 0 : int.Parse(hoursString); olItem.Duration = minutes + hours * 60; olItem.Location = crmItem.GetValueAsString("location"); olItem.End = olItem.Start; if (hours > 0) { olItem.End.AddHours(hours); } if (minutes > 0) { olItem.End.AddMinutes(minutes); } SetOutlookRecipientsFromCRM(olItem, crmItem, crmItem.GetValueAsString("id"), crmType); } finally { this.SaveItem(olItem); } }
private void SetOutlookItemPropertiesFromCrmItem(EntryValue crmItem, Outlook.TaskItem olItem) { try { DateTime dateStart = crmItem.GetValueAsDateTime("date_start"); DateTime dateDue = crmItem.GetValueAsDateTime("date_due"); string timeStart = ExtractTime(dateStart); string timeDue = ExtractTime(dateDue); olItem.Subject = crmItem.GetValueAsString("name"); olItem.StartDate = MaybeChangeDate(dateStart, olItem.StartDate, "olItem.StartDate"); olItem.DueDate = MaybeChangeDate(dateDue, olItem.DueDate, "olItem.DueDate"); string body = crmItem.GetValueAsString("description"); olItem.Body = string.Concat(body, "#<", timeStart, "#", timeDue); olItem.Status = GetStatus(crmItem.GetValueAsString("status")); olItem.Importance = GetImportance(crmItem.GetValueAsString("priority")); EnsureSynchronisationPropertiesForOutlookItem(olItem, crmItem.GetValueAsString("date_modified"), DefaultCrmModule, CrmId.Get(crmItem.id)); } finally { this.SaveItem(olItem); } }
/// <summary> /// Update a single appointment in the specified Outlook folder with changes from CRM, but /// only if its start date is fewer than five days in the past. /// </summary> /// <param name="folder">The folder to synchronise into.</param> /// <param name="crmType">The CRM type of the candidate item.</param> /// <param name="crmItem">The candidate item from CRM.</param> /// <returns>The synchronisation state of the item updated (if it was updated).</returns> protected override SyncState <Outlook.AppointmentItem> AddOrUpdateItemFromCrmToOutlook( Outlook.MAPIFolder folder, string crmType, EntryValue crmItem) { SyncState <Outlook.AppointmentItem> result = null; DateTime dateStart = crmItem.GetValueAsDateTime("date_start"); if (dateStart >= GetStartDate()) { /* search for the item among the sync states I already know about */ var syncState = this.GetExistingSyncState(crmItem); if (syncState == null) { /* check for howlaround */ var matches = this.FindMatches(crmItem); if (matches.Count == 0) { /* didn't find it, so add it to Outlook */ result = AddNewItemFromCrmToOutlook(folder, crmType, crmItem, dateStart); } else { this.Log.Warn($"Howlaround detected? Appointment '{crmItem.GetValueAsString("name")}' offered with id {crmItem.GetValueAsString("id")}, expected {matches[0].CrmEntryId}, {matches.Count} duplicates"); } } else { /* found it, so update it from the CRM item */ result = UpdateExistingOutlookItemFromCrm(crmType, crmItem, dateStart, syncState); result?.OutlookItem.Save(); } if (crmItem?.relationships?.link_list != null) { foreach (var list in crmItem.relationships.link_list) { foreach (var record in list.records) { var data = record.data.AsDictionary(); try { this.meetingRecipientsCache[data[AddressResolutionData.EmailAddressFieldName].ToString()] = new AddressResolutionData(list.name, data); Log.Debug($"Successfully cached recipient {data[AddressResolutionData.EmailAddressFieldName]} => {list.name}, {data[AddressResolutionData.ModuleIdFieldName]}."); } catch (KeyNotFoundException kex) { Log.Error($"Key not found while caching meeting recipients.", kex); } } } } } return(result); }
protected override void OnMouseDown(int x, int y, MouseButton button) { if (button == MouseButton.Left) { SetKeyboardFocus(); EntryValue.OnMouseClick(x, y); } }
private bool IsProbablySameItem(EntryValue result, ContactItem contactItem) { string crmIdStr = contactItem.GetCrmId().ToString(); return(result != null && (result.id.Equals(crmIdStr) || result.GetValueAsString("outlook_id").Equals(contactItem.EntryID))); }
/// <summary> /// Replace the content of this entry by a blob. /// </summary> /// <param name="newBlob">The content blob.</param> /// <param name="mode">The mode.</param> /// <exception cref="System.ArgumentNullException">content</exception> public void SetBlob(Blob newBlob, Mode mode = Mode.NonExecutableFile) { if (newBlob == null) { throw new ArgumentNullException("newBlob"); } NewEntryValue = new EntryValue(newBlob, mode); }
/// <summary> /// Add an item existing in CRM but not found in Outlook to Outlook. /// </summary> /// <param name="appointmentsFolder">The Outlook folder in which the item should be stored.</param> /// <param name="crmType">The CRM type of the item from which values are to be taken.</param> /// <param name="crmItem">The CRM item from which values are to be taken.</param> /// <param name="date_start">The state date/time of the item, adjusted for timezone.</param> /// <returns>A sync state object for the new item.</returns> private SyncState <Outlook.AppointmentItem> AddNewItemFromCrmToOutlook( Outlook.MAPIFolder appointmentsFolder, string crmType, EntryValue crmItem, DateTime date_start) { AppointmentSyncState newState = null; Outlook.AppointmentItem olItem = null; try { var crmId = crmItem.GetValueAsString("id"); /* * There's a nasty little bug (#223) where Outlook offers us back in a different thread * the item we're creating, before we're able to set up the sync state which marks it * as already known. By locking on the enqueueing lock here, we should prevent that. */ lock (enqueueingLock) { olItem = appointmentsFolder.Items.Add(Outlook.OlItemType.olAppointmentItem); newState = new AppointmentSyncState(crmType) { OutlookItem = olItem, OModifiedDate = DateTime.ParseExact(crmItem.GetValueAsString("date_modified"), "yyyy-MM-dd HH:mm:ss", null), CrmEntryId = crmId }; ItemsSyncState.Add(newState); olItem.Subject = crmItem.GetValueAsString("name"); olItem.Body = crmItem.GetValueAsString("description"); /* set the SEntryID property quickly, create the sync state and save the item, to reduce howlaround */ EnsureSynchronisationPropertiesForOutlookItem(olItem, crmItem, crmType); this.SaveItem(olItem); } LogItemAction(olItem, "AppointmentSyncing.AddNewItemFromCrmToOutlook"); if (!string.IsNullOrWhiteSpace(crmItem.GetValueAsString("date_start"))) { olItem.Start = date_start; SetOutlookItemDuration(crmType, crmItem, olItem); Log.Info("\tdefault SetRecepients"); SetRecipients(olItem, crmId, crmType); } } finally { if (olItem != null) { this.SaveItem(olItem); } } return(newState); }
protected override bool IsMatch(Outlook.AppointmentItem olItem, EntryValue crmItem) { var crmItemStart = crmItem.GetValueAsDateTime("date_start"); var crmItemName = crmItem.GetValueAsString("name"); var olItemStart = olItem.Start; var subject = olItem.Subject; return(subject == crmItemName && olItemStart == crmItemStart); }
public static string GetValueByKey(EntryValue entry, string key) { string str = string.Empty; foreach (NameValue _value in entry.nameValueList) { if (_value.name == key) { str = _value.value.ToString(); } } return(str); }
/// <summary> /// Specialisation: also set end time and location. /// </summary> /// <param name="crmItem">The CRM item.</param> /// <param name="olItem">The Outlook item.</param> protected override void SetOutlookItemDuration(EntryValue crmItem, Outlook.AppointmentItem olItem) { try { base.SetOutlookItemDuration(crmItem, olItem); olItem.Location = crmItem.GetValueAsString("location"); olItem.End = olItem.Start.AddMinutes(olItem.Duration); } catch (System.Exception any) { ErrorHandler.Handle("Failed while setting Outlook item duration", any); } }
public string GetEntryValueWithCrlf() { if (EntryValue == null) { return(@""); } var rtn = @""; foreach (var line in EntryValue.Split('\n')) { rtn += line + @"\r\n"; } return(rtn); }
public double?GetDoubleValue() { if (EntryValue == null || EntryValue.Equals(@"")) { return(null); } double rtnValue = 0.0; if (double.TryParse(EntryValue, out rtnValue)) { return(rtnValue); } return(null); }
private static void SetNotInGraphCore(Entry entry, object value) { var values = entry.Values; for (int index = 0; index < values.Count; index++) { if (ReferenceEquals(values[index].Value, value)) { var item = values[index]; item = new EntryValue(item.Type, item.Value, false); values[index] = item; return; } } }
private SyncState <Outlook.TaskItem> UpdateExistingOutlookItemFromCrm(EntryValue crmItem, SyncState <Outlook.TaskItem> syncStateForItem) { if (!syncStateForItem.IsDeletedInOutlook) { Outlook.TaskItem olItem = syncStateForItem.OutlookItem; Outlook.UserProperty oProp = olItem.UserProperties[SyncStateManager.ModifiedDatePropertyName]; if (oProp.Value != crmItem.GetValueAsString("date_modified")) { SetOutlookItemPropertiesFromCrmItem(crmItem, olItem); } syncStateForItem.OModifiedDate = DateTime.ParseExact(crmItem.GetValueAsString("date_modified"), "yyyy-MM-dd HH:mm:ss", null); } return(syncStateForItem); }
/// <summary> /// Detect whether the should sync flag value is different between these two representations. /// </summary> /// <param name="olItem">An outlook item.</param> /// <param name="crmItem">A CRM item, presumed to represent the same entity.</param> /// <returns>True if the should sync flag values are different, else false.</returns> private bool ShouldSyncFlagChanged(Outlook.ContactItem olItem, EntryValue crmItem) { bool result = false; Outlook.UserProperty shouldSyncProp = olItem.UserProperties["SShouldSync"]; if (shouldSyncProp != null) { string crmShouldSync = ShouldSyncContact(crmItem).ToString().ToLower(); string olShouldSync = shouldSyncProp.Value.ToLower(); result = crmShouldSync != olShouldSync; } return(result); }
/// <summary> /// Get the existing sync state for this CRM item, if it exists, else null. /// </summary> /// <param name="crmItem">The item.</param> /// <returns>The appropriate sync state, or null if none.</returns> public SyncState GetExistingSyncState(EntryValue crmItem) { SyncState result; string outlookId = crmItem.GetValueAsString("outlook_id"); CrmId crmId = CrmId.Get(crmItem.id); if (this.byCrmId.ContainsKey(crmId)) { result = this.byCrmId[crmId]; } else if (this.byOutlookId.ContainsKey(outlookId)) { result = this.byOutlookId[outlookId]; } else if (this.byGlobalId.ContainsKey(outlookId)) { result = this.byGlobalId[outlookId]; } else { string simulatedGlobalId = SyncStateManager.SimulateGlobalId(crmId); if (this.byGlobalId.ContainsKey(simulatedGlobalId)) { result = this.byGlobalId[simulatedGlobalId]; } else { string distinctFields = GetDistinctFields(crmItem); if (string.IsNullOrEmpty(distinctFields)) { result = null; } else if (this.byDistinctFields.ContainsKey(distinctFields)) { result = this.byDistinctFields[distinctFields]; } else { result = null; } } } return(result); }
/// <summary> /// Find any existing Outlook items which appear to be identical to this CRM item. /// </summary> /// <param name="crmItem">The CRM item to match.</param> /// <returns>A list of matching Outlook items.</returns> protected List <SyncState <OutlookItemType> > FindMatches(EntryValue crmItem) { List <SyncState <OutlookItemType> > result; try { result = ItemsSyncState.Where(a => this.IsMatch(a.OutlookItem, crmItem)) .ToList <SyncState <OutlookItemType> >(); } catch (Exception any) { this.Log.Error("Exception while checking for matches", any); result = new List <SyncState <OutlookItemType> >(); } return(result); }
/// <summary> /// This is a workaround to update owned entities https://github.com/aspnet/EntityFrameworkCore/issues/13890 /// </summary> /// <param name="entry">Top level entry on which to set the values</param> /// <param name="entity">the Values in the form of an object</param> public static void _SetRootValues(EntityEntry entry, object entity, Action <EntityEntry, object> setValuesAction) { setValuesAction(entry, entity); EntryValue entryValue = new EntryValue { Level = 0, Entry = entry, Entity = entity, Reference = null, parentEntity = null }; EntryValue[] entryValues = _GetOwnedEntryValues(entryValue); int[] levels = entryValues.Select(e => e.Level).ToArray(); int maxLvl = levels.Max(); if (maxLvl >= 1) { ILookup <int, EntryValue> entriesLookUp = entryValues.ToLookup(e => e.Level); _SetValuesAtLevel(1, entriesLookUp, maxLvl, setValuesAction); } }
private void SetOutlookItemPropertiesFromCrmItem(EntryValue crmItem, Outlook.TaskItem olItem) { try { DateTime dateStart = crmItem.GetValueAsDateTime("date_start"); DateTime dateDue = crmItem.GetValueAsDateTime("date_due"); string timeStart = ExtractTime(dateStart); string timeDue = ExtractTime(dateDue); olItem.Subject = crmItem.GetValueAsString("name"); try { olItem.StartDate = MaybeChangeDate(dateStart, olItem.StartDate, "syncState.StartDate"); } catch (COMException comx) { #if DEBUG Log.Debug($"COM Exception while trying to set start date of task: '{comx.Message}'. Some otherwise-valid tasks don't support this"); #endif } try { olItem.DueDate = MaybeChangeDate(dateDue, olItem.DueDate, "syncState.DueDate"); } catch (COMException comx) { #if DEBUG Log.Debug($"COM Exception while trying to set start date of task: '{comx.Message}'. Do some otherwise-valid tasks not support this?"); #endif } string body = crmItem.GetValueAsString("description"); olItem.Body = string.Concat(body, "#<", timeStart, "#", timeDue); olItem.Status = GetStatus(crmItem.GetValueAsString("status")); olItem.Importance = GetImportance(crmItem.GetValueAsString("priority")); EnsureSynchronisationPropertiesForOutlookItem(olItem, crmItem.GetValueAsString("date_modified"), DefaultCrmModule, CrmId.Get(crmItem.id)); } finally { this.SaveItem(olItem); } }
private void pckCategory_SelectedIndexChanged(object sender, System.EventArgs e) { if (pckCategory != null && pckCategory.SelectedItem != null && ((string)pckCategory.SelectedItem).Equals("Onibus")) { EntryValue.Text = "4.05"; string carteira = "Carteira"; if (this.pckPaymentType.Items.Any(p => p == carteira)) { this.pckPaymentType.SelectedItem = carteira; } } else { EntryValue.Text = string.Empty; EntryValue.Focus(); } }
public CreateTokenPage() { InitializeComponent(); this.BindingContext = new ViewModel.TokenViewModel(); EntryAlias.TextChanged += (sender, args) => { string _text = EntryAlias.Text; if (_text.Length > 20) { _text = _text.Remove(_text.Length - 1); EntryAlias.Text = _text; } }; EntryBarCode.TextChanged += (sender, args) => { string _text = EntryBarCode.Text; if (_text.Length > 20) { _text = _text.Remove(_text.Length - 1); EntryBarCode.Text = _text; } }; EntryValue.TextChanged += (sender, args) => { string _text = EntryValue.Text; if (_text.Length > 6) { _text = _text.Remove(_text.Length - 1); EntryValue.Text = _text; } }; EntryAlias.Completed += (s, e) => EntryValue.Focus(); EntryValue.Completed += (s, e) => EntryBarCode.Focus(); EntryBarCode.Completed += (s, e) => { var current = this.BindingContext as ViewModel.TokenViewModel; current.CreateCommand.Execute(null); }; }
/// <summary> /// Set all those properties of this outlook item whose values are different from the /// equivalent values on this CRM item. Update the synchronisation properties only if some /// other property has actually changed. /// </summary> /// <param name="crmItem">The CRM item from which to take values.</param> /// <param name="olItem">The Outlook item into which to insert values.</param> /// <returns>true if anything was changed.</returns> private void SetOutlookItemPropertiesFromCrmItem(EntryValue crmItem, Outlook.ContactItem olItem) { try { olItem.FirstName = crmItem.GetValueAsString("first_name"); olItem.LastName = crmItem.GetValueAsString("last_name"); olItem.Email1Address = crmItem.GetValueAsString("email1"); olItem.BusinessTelephoneNumber = crmItem.GetValueAsString("phone_work"); olItem.HomeTelephoneNumber = crmItem.GetValueAsString("phone_home"); olItem.MobileTelephoneNumber = crmItem.GetValueAsString("phone_mobile"); olItem.JobTitle = crmItem.GetValueAsString("title"); olItem.Department = crmItem.GetValueAsString("department"); olItem.BusinessAddressCity = crmItem.GetValueAsString("primary_address_city"); olItem.BusinessAddressCountry = crmItem.GetValueAsString("primary_address_country"); olItem.BusinessAddressPostalCode = crmItem.GetValueAsString("primary_address_postalcode"); olItem.BusinessAddressState = crmItem.GetValueAsString("primary_address_state"); olItem.BusinessAddressStreet = crmItem.GetValueAsString("primary_address_street"); olItem.Body = crmItem.GetValueAsString("description"); if (crmItem.GetValue("account_name") != null) { olItem.Account = crmItem.GetValueAsString("account_name"); olItem.CompanyName = crmItem.GetValueAsString("account_name"); } olItem.BusinessFaxNumber = crmItem.GetValueAsString("phone_fax"); olItem.Title = crmItem.GetValueAsString("salutation"); if (olItem.Sensitivity != Outlook.OlSensitivity.olNormal) { Log.Info($"ContactSyncing.SetOutlookItemPropertiesFromCrmItem: setting sensitivity of contact {crmItem.GetValueAsString("first_name")} {crmItem.GetValueAsString("last_name")} ({crmItem.GetValueAsString("email1")}) to normal"); olItem.Sensitivity = Outlook.OlSensitivity.olNormal; } EnsureSynchronisationPropertiesForOutlookItem( olItem, crmItem.GetValueAsString("date_modified"), crmItem.GetValueAsString("sync_contact"), CrmId.Get(crmItem.id)); } finally { this.SaveItem(olItem); } }
public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks etc, of course :) if (Symbol != null) { hash = hash * 59 + Symbol.GetHashCode(); } hash = hash * 59 + Quantity.GetHashCode(); hash = hash * 59 + AveragePrice.GetHashCode(); hash = hash * 59 + MarketPrice.GetHashCode(); hash = hash * 59 + MarketValue.GetHashCode(); hash = hash * 59 + EntryValue.GetHashCode(); hash = hash * 59 + UpdateTime.GetHashCode(); return(hash); } }
/// <summary> /// Replace the content of this entry by a blob. /// </summary> /// <param name="newBlob">The content blob.</param> /// <param name="mode">The mode.</param> /// <exception cref="System.ArgumentNullException">content</exception> public void SetBlob(Blob newBlob, Mode mode = Mode.NonExecutableFile) { if (newBlob == null) throw new ArgumentNullException("newBlob"); NewEntryValue = new EntryValue(newBlob, mode); }
private static void SetNotInGraphCore(Entry entry, object value) { var values = entry.Values; for (int index = 0; index < values.Count; index++) { var item = values[index]; var candidate = item.Value.Target; if (ReferenceEquals(candidate, value)) { item = new EntryValue(item.Type, item.Value, false); values[index] = item; return; } } }