public static void PullExtensions(ManagerConnection ami) { List <string> _siplines = new List <string>(); List <string> retrievedSips = new List <string>(); Dictionary <string, PABXExtensionStatus> pabxStatuses = new Dictionary <string, PABXExtensionStatus>(); //get initial extension list direct from PABX using (HttpClient n = new HttpClient()) { string downloadString = "http://" + PABX.CurrentUser.host + "/if/windows_comms.php?u=" + PABX.CurrentUser.login + "&p=" + PABX.CurrentUser.password + "&extensionstatus=1"; Console.WriteLine(downloadString); try { string json = n.GetStringAsync(downloadString).Result; // use HTTPClient instead of WebClient, avoids crashing with larger PABX's. Result is required as it is a task pabxStatuses = JsonConvert.DeserializeObject <Dictionary <string, PABXExtensionStatus> >(json); } catch { MessageBox.Show("SmartPABX not up to date, please contact system admin.", "PABX Error", MessageBoxButton.OK, MessageBoxImage.Error); } } PABXExtensions.Clear(); pabxStatuses.Keys.ToList().ForEach(e => { Extension ext = new Extension(); ext.Number = Convert.ToInt32(e); ext.Comment = pabxStatuses[e].comment; ext.Status = Convert.ToInt32(pabxStatuses[e].status); ext.GroupId = Convert.ToInt32(pabxStatuses[e].groupid); PABXExtensions.Add(ext); }); DebuggingTools.VarDump(PABXExtensions); }
public static async void LoadContacts() { UserContacts = await PABXFile <Dictionary <string, UserContactData> > .LoadObjectAsync("contacts.json"); DebuggingTools.VarDump(UserContacts); if (UserContacts == null) { UserContacts = new Dictionary <string, UserContactData>(); } }