private void ShowCalls(bool displayAllCalls) { _displayAllCalls = displayAllCalls; char[] chars = CallsTextBox.Text.ToCharArray(); if (chars.Length == 0 && displayAllCalls) { chars = new Charsets().Chars["ASCII"]; } var codes = chars.Select(x => (uint)x).ToArray(); var callItems = new List <CallItem>(); var call = GetCurrentCall(); if (call != null) { Settings.Default.CallNameComboBox = call.CallName; //HelpTextBox.Text = call.CallName + ": " + call.CallDescription; for (uint i = 0; i < codes.Length; i++) { CallItem c = call.Keys.ContainsKey(codes[i]) ? call.Keys[codes[i]].Clone() : new CallItem() { Code = codes[i], Name = ((char)codes[i]).ToString() }; c.Index = i + 1; callItems.Add(c); } } CallsDataGridView.DataSource = callItems; }
private AbstractItem CreateAppointment(string outlookId, string crmId, Outlook.OlMeetingStatus status) { AbstractItem result; Outlook.NameSpace session = Globals.ThisAddIn.GetOutlookSession(); if (session != null) { Outlook.AppointmentItem legacy = null; Outlook.MAPIFolder folder = session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); if (!string.IsNullOrEmpty(outlookId)) { legacy = folder.Items.Add(Outlook.OlItemType.olAppointmentItem); legacy.MeetingStatus = status; result = new CallItem(legacy); result.CrmEntryId = crmId; this.ByCrmId[crmId] = result; this.ByOutlookId[legacy.EntryID] = result; } else { result = FindExistingAppointmentItem(outlookId, crmId, folder); } } else { throw new ShouldNotHappenException("No Outlook session!"); } return(result); }
/// <summary> /// Find an existing appointment item in the connected Outlook instance which matches these /// parameters. /// </summary> /// <remarks>You can't type parameterise this because Outlook types are not classes.</remarks> /// <param name="outlookId">The Outlook id sought, if known, else null.</param> /// <param name="crmId">The CRM id sought, if known, else null.</param> /// <param name="folder">The folder to search.</param> /// <returns>An abstract item wrapping the Outlook item sought.</returns> private AbstractItem FindExistingAppointmentItem(string outlookId, string crmId, Outlook.MAPIFolder folder) { AbstractItem result; Outlook.AppointmentItem legacy = null; foreach (object obj in folder.Items) { Outlook.AppointmentItem olItem = obj as Outlook.AppointmentItem; if (olItem != null && olItem.EntryID == outlookId) { legacy = olItem; break; } // TODO: CRM id. } if (legacy != null) { if (legacy.MeetingStatus == Outlook.OlMeetingStatus.olNonMeeting) { result = new CallItem(legacy); } else { result = new Wrappers.MeetingItem(legacy); } this.ByOutlookId[legacy.EntryID] = result; if (!string.IsNullOrEmpty(crmId)) { this.ByCrmId[crmId] = result; } } else { throw new ItemNotFoundException(); } return(result); }
public static TimeSpan GetDuration(this CallItem callItem) { return(callItem.TimeEnd - callItem.TimeStart); }