Esempio n. 1
0
        public static void RegenerateExtensionFiles(string extensionNumber, Domain domain)
        {
            if (!IsDomainDeployed(domain.Name))
            {
                Log.Trace("Creating domain " + domain.Name + " to produce an extension");
                RegenerateDomainFile(domain);
            }
            Extension ext = Extension.Load(extensionNumber, domain);

            if (ext == null)
            {
                Lock();
                List <sDeployedExtension> exts = extensions;
                for (int x = 0; x < exts.Count; x++)
                {
                    if ((exts[x].Number == extensionNumber) || (exts[x].DomainName == domain.Name))
                    {
                        exts.RemoveAt(x);
                        break;
                    }
                }
                extensions = exts;
                UnLock();
                _deployer.DestroyExtension(domain.Name, extensionNumber);
                EventController.TriggerEvent(new ExtensionDestroyedEvent(extensionNumber, domain.Name));
            }
            else
            {
                sDeployedExtension sext = new sDeployedExtension(ext);
                Lock();
                List <sDeployedExtension> exts = extensions;
                bool add = true;
                for (int x = 0; x < exts.Count; x++)
                {
                    if ((exts[x].Number == extensionNumber) && (exts[x].DomainName == domain.Name))
                    {
                        exts[x] = sext;
                        add     = false;
                        break;
                    }
                }
                if (add)
                {
                    exts.Add(sext);
                }
                extensions = exts;
                UnLock();
                _deployer.DeployExtension(sext);
                EventController.TriggerEvent(new ExtensionDeploymentEvent(sext));
                Log.Trace("Config file for extension " + extensionNumber + " has been successfully created");
                Extension ex = Extension.Load(extensionNumber, domain);
                VoiceMail vm = VoiceMail.Load(ex.Number, ex.Context);
                if ((vm != null) && vm.ResetVMPassword)
                {
                    vm.ResetVMPassword = false;
                    vm.Update();
                }
            }
        }
Esempio n. 2
0
 public sDeployedExtension(Extension ext)
 {
     _domainName           = ext.Domain.Name;
     _number               = ext.Number;
     _password             = ext.Password;
     _vm                   = null;
     _context              = ext.Context.Name;
     _internalCallerID     = ext.InternalCallerID;
     _internalCallerIDName = ext.InternalCallerIDName;
     _externalCallerID     = ext.ExternalCallerID;
     _externalCallerIDName = ext.ExternalCallerIDName;
     _voicemailTimeout     = ext.VoicemailTimeout;
     if (ext.HasVoicemail)
     {
         _vm = new sDeployedVoicemail(VoiceMail.Load(ext.Number, ext.Context), Number, DomainName);
     }
 }