/// <summary> /// Update AccDataList with new AccDataList built with new configuration /// Delete and create only accounts with data that has changed, to avoid /// interruption of service if data haven't changed /// </summary> /// <param name="NewAccDataList">list of new configurated params</param> private void SynchronizeAccountsList(List <AccountDataSip> NewAccDataList) { AccountDataSip found = null; List <AccountDataSip> AccDataListCopy = new List <AccountDataSip>(AccDataList); foreach (AccountDataSip data in AccDataListCopy) { found = NewAccDataList.Find(x => data.Equals(x)); if (found == null) { AccDataList.Remove(data); SipAgent.DestroyAccount(data.NumeroAbonado); } else { NewAccDataList.Remove(found); } } foreach (AccountDataSip newData in NewAccDataList) { AccDataList.Add(newData); if ((_ProxyIP == null) || (_ProxyIP.Length == 0)) { SipAgent.CreateAccount(newData.NumeroAbonado); } else { SipAgent.CreateAccountAndRegisterInProxy(newData.NumeroAbonado, _ProxyIP, Settings.Default.ExpireInProxy, newData.NumeroAbonado, newData.NumeroAbonado, newData.IdAgrupacion); } } }