/// <summary> /// Iterates a directory object and prefixes any folder items with "[+] " /// </summary> /// <param name="directory"></param> /// <returns></returns> List <DirectoryItem> PrefixDirectoryFolderItems(CodecDirectory directory) { var tempDirectoryList = new List <DirectoryItem>(); if (directory.CurrentDirectoryResults.Count > 0) { foreach (var item in directory.CurrentDirectoryResults) { if (item is DirectoryFolder) { var newFolder = new DirectoryFolder(); newFolder = (DirectoryFolder)item.Clone(); string prefixName = "[+] " + newFolder.Name; newFolder.Name = prefixName; tempDirectoryList.Add(newFolder); } else { tempDirectoryList.Add(item); } } } //else //{ // DirectoryItem noResults = new DirectoryItem() { Name = "No Results Found" }; // tempDirectoryList.Add(noResults); //} return(tempDirectoryList); }
/// <summary> /// Extracts the folders with no ParentFolder and returns them sorted alphabetically /// </summary> /// <param name="result"></param> /// <returns></returns> public static List <DirectoryItem> GetRootFoldersFromSearchResult(PhonebookSearchResult result) { var rootFolders = new List <DirectoryItem>(); if (result.Folder.Count == 0) { return(null); } else if (result.Folder.Count > 0) { if (Debug.Level > 0) { Debug.Console(1, "Phonebook Folders:\n"); } foreach (Folder f in result.Folder) { var folder = new DirectoryFolder(); folder.Name = f.Name.Value; folder.FolderId = f.FolderId.Value; if (f.ParentFolderId == null) { rootFolders.Add(folder); } if (Debug.Level > 0) { Debug.Console(1, "+ {0}", folder.Name); } } } rootFolders.OrderBy(f => f.Name); return(rootFolders); }
/// <summary> /// Helper method to retrieve directory folder contents and store last requested folder id /// </summary> /// <param name="folderId"></param> void GetDirectoryFolderContents(DirectoryFolder folder) { (Codec as IHasDirectory).GetDirectoryFolderContents(folder.FolderId); }
/// <summary> /// Converts from zStatus.Contact types to generic directory items /// </summary> /// <returns></returns> public static CodecDirectory ConvertZoomContactsToGeneric(List <Contact> zoomContacts) { var directory = new Codec.CodecDirectory(); var folders = new List <Codec.DirectoryItem>(); var roomFolder = new DirectoryFolder(); var contactFolder = new DirectoryFolder(); var contacts = new List <DirectoryItem>(); // Check if there are any zoom rooms var zoomRooms = zoomContacts.FindAll(c => c.IsZoomRoom); if (zoomRooms.Count > 0) { // If so, setup a rooms and contacts folder and add them. roomFolder.Name = "Rooms"; roomFolder.FolderId = "rooms"; contactFolder.Name = "Contacts"; contactFolder.FolderId = "contacts"; folders.Add(roomFolder); folders.Add(contactFolder); directory.AddFoldersToDirectory(folders); } try { if (zoomContacts.Count > 0) { foreach (Contact c in zoomContacts) { var contact = new ZoomDirectoryContact(); contact.Name = c.ScreenName; contact.ContactId = c.Jid; if (folders.Count > 0) { if (c.IsZoomRoom) { contact.FolderId = roomFolder.FolderId; } else { contact.FolderId = contactFolder.FolderId; } } contacts.Add(contact); } directory.AddContactsToDirectory(contacts); } } catch (Exception e) { Debug.Console(1, "Error converting Zoom Phonebook results to generic: {0}", e); } return(directory); }
/// <summary> /// Converts data returned from a cisco codec to the generic Directory format. /// </summary> /// <param name="result"></param> /// <param name="resultFolder"></param> /// <returns></returns> public static CodecDirectory ConvertCiscoPhonebookToGeneric(PhonebookSearchResult result) { var directory = new Codec.CodecDirectory(); var folders = new List <Codec.DirectoryItem>(); var contacts = new List <Codec.DirectoryItem>(); try { if (result.Folder.Count > 0) { foreach (Folder f in result.Folder) { var folder = new DirectoryFolder(); folder.Name = f.Name.Value; folder.FolderId = f.FolderId.Value; if (f.ParentFolderId != null) { folder.ParentFolderId = f.ParentFolderId.Value; } folders.Add(folder); } folders.OrderBy(f => f.Name); directory.AddFoldersToDirectory(folders); } if (result.Contact.Count > 0) { foreach (Contact c in result.Contact) { var contact = new DirectoryContact(); contact.Name = c.Name.Value; contact.ContactId = c.ContactId.Value; if (!string.IsNullOrEmpty(c.Title.Value)) { contact.Title = c.Title.Value; } if (c.FolderId != null) { contact.FolderId = c.FolderId.Value; } foreach (ContactMethod m in c.ContactMethod) { eContactMethodCallType callType = eContactMethodCallType.Unknown; if (!string.IsNullOrEmpty(m.CallType.Value)) { if (m.CallType.Value.ToLower() == "audio") { callType = eContactMethodCallType.Audio; } else if (m.CallType.Value.ToLower() == "video") { callType = eContactMethodCallType.Video; } } eContactMethodDevice device = eContactMethodDevice.Unknown; if (!string.IsNullOrEmpty(m.Device.Value)) { if (m.Device.Value.ToLower() == "mobile") { device = eContactMethodDevice.Mobile; } else if (m.Device.Value.ToLower() == "telephone") { device = eContactMethodDevice.Telephone; } else if (m.Device.Value.ToLower() == "video") { device = eContactMethodDevice.Video; } else if (m.Device.Value.ToLower() == "other") { device = eContactMethodDevice.Other; } } contact.ContactMethods.Add(new PepperDash.Essentials.Devices.Common.Codec.ContactMethod() { Number = m.Number.Value, ContactMethodId = m.ContactMethodId.Value, CallType = callType, Device = device }); } contacts.Add(contact); } contacts.OrderBy(c => c.Name); directory.AddContactsToDirectory(contacts); } } catch (Exception e) { Debug.Console(1, "Error converting Cisco Phonebook results to generic: {0}", e); } return(directory); }