Few comments regarding setStatus.cs.
1. remove call to Refresh() method. It is not necessary and executes expensive procedure which does nothing helpful in the method.
2. The snapshot, which is taken from PhoneSystem.GetDNByNumber(), is used locally. So the snapshot can be disposed right after Save(). better to change code to something started with
try
{
using(var dn=PhoneSystem.Root.GetDNByNumber(extension))
{
///cast to the extension assign new profile, call to save
return true;
}
}
catch
{
}
return false;
3. use try ... catch ... to avoid the unnecessary handling of the exceptions in user code. "upcast" of DN to Extension, usage of First() and the call to DN.Save() method are potentially generate an exceptions which may unexpectedly interrupt script which calls setStatus. I think that it is enough to return true/false to inform caller whether the current status was applied. (see above)