Esempio n. 1
0
        public static void RegisterChangeCall(Type dialPlanType, ADialPlan.sUpdateConfigurationsCall[] configurationCalls, IEvent[] triggerEvents)
        {
            Monitor.Enter(_lock);
            ArrayList changes = _Changes;

            if (changes == null)
            {
                changes = new ArrayList();
            }
            bool add = true;
            RegisteredConfigurationRegenerationCall call = new RegisteredConfigurationRegenerationCall(dialPlanType, configurationCalls, triggerEvents);

            foreach (object obj in changes)
            {
                if (obj is RegisteredConfigurationRegenerationCall)
                {
                    if (call.Equals(obj))
                    {
                        add = false;
                        break;
                    }
                }
            }
            if (add)
            {
                changes.Add(call);
            }
            _Changes = changes;
            Monitor.Exit(_lock);
        }
 public static void RegisterChangeCall(Type dialPlanType, ADialPlan.sUpdateConfigurationsCall[] configurationCalls, IEvent[] triggerEvents)
 {
     Monitor.Enter(_lock);
     ArrayList changes = _Changes;
     if (changes == null)
         changes = new ArrayList();
     bool add = true;
     RegisteredConfigurationRegenerationCall call = new RegisteredConfigurationRegenerationCall(dialPlanType, configurationCalls, triggerEvents);
     foreach (object obj in changes)
     {
         if (obj is RegisteredConfigurationRegenerationCall)
         {
             if (call.Equals(obj))
             {
                 add = false;
                 break;
             }
         }
     }
     if (add)
         changes.Add(call);
     _Changes = changes;
     Monitor.Exit(_lock);
 }
Esempio n. 3
0
        public static void ProcessChanges()
        {
            Monitor.Enter(_lock);
            ArrayList     changes = _Changes;
            List <IEvent> events  = new List <IEvent>();

            if (changes != null)
            {
                foreach (object obj in changes)
                {
                    if (obj is RegisteredConfigurationRegenerationCall)
                    {
                        RegisteredConfigurationRegenerationCall rcgc = (RegisteredConfigurationRegenerationCall)obj;
                        if (rcgc.TriggerEvents != null)
                        {
                            foreach (IEvent ev in rcgc.TriggerEvents)
                            {
                                events.Add(ev);
                            }
                        }
                        foreach (ADialPlan.sUpdateConfigurationsCall ucc in rcgc.ConfigurationCalls)
                        {
                            CallControlManager.UpdateDialPlan(Utility.LocateType(rcgc.DialPlanType), ucc);
                        }
                    }
                    else if (obj is RegisteredExtensionRegenerationCall)
                    {
                        RegisteredExtensionRegenerationCall regc = (RegisteredExtensionRegenerationCall)obj;
                        if (regc.TriggerEvents != null)
                        {
                            foreach (IEvent ev in regc.TriggerEvents)
                            {
                                events.Add(ev);
                            }
                        }
                        foreach (ADialPlan.sUpdateConfigurationsCall ucc in regc.ConfigurationCalls)
                        {
                            CallControlManager.UpdateDialPlan(Utility.LocateType(regc.DialPlanType), ucc);
                        }
                        CoreGenerator.RegenerateExtensionFiles(regc.ExtensionNumber, Domain.Load(regc.Domain));
                    }
                    else if (obj is string)
                    {
                        if (((string)obj).StartsWith(string.Format(_MODULE_FILE_FORMAT, "")))
                        {
                            string mod = ((string)obj).Substring(string.Format(_MODULE_FILE_FORMAT, "").Length);
                            CoreGenerator.RegenerateModuleFile(mod);
                            EventController.TriggerEvent(new FreeswitchModuleRedeployedEvent(mod));
                        }
                        else if (((string)obj).StartsWith(string.Format(_DEPLOY_TRUNK_FORMAT, "")))
                        {
                            string depTrunkName = ((string)obj).Substring(string.Format(_DEPLOY_TRUNK_FORMAT, "").Length);
                            CoreGenerator.GenerateOutgoingSIPTrunkConfiguration(depTrunkName);
                            EventController.TriggerEvent(new GenericEvent("OutgoingSIPTrunkCreated",
                                                                          new NameValuePair[] {
                                new NameValuePair("Name", depTrunkName)
                            }));
                        }
                        else if (((string)obj).StartsWith(string.Format(_DESTROY_TRUNK_FORMAT, "")))
                        {
                            string desTrunkName   = ((string)obj).Substring(string.Format(_DESTROY_TRUNK_FORMAT, "").Length);
                            string desProfileName = desTrunkName.Split('@')[1];
                            desTrunkName = desTrunkName.Substring(0, desTrunkName.IndexOf("@"));
                            CoreGenerator.DestroyOutgoingSIPTrunk(desTrunkName, desProfileName);
                            EventController.TriggerEvent(new GenericEvent("OutgoingSIPTrunkDeleted",
                                                                          new NameValuePair[] {
                                new NameValuePair("Name", desTrunkName),
                                new NameValuePair("ProfileName", desProfileName)
                            }));
                        }
                        else if (((string)obj).StartsWith(string.Format(_DEPLOY_INCOMING_TRUNK_FORMAT, "")))
                        {
                            string depIncomingTrunkName  = ((string)obj).Substring(string.Format(_DEPLOY_INCOMING_TRUNK_FORMAT, "").Length);
                            string depIncomingDomainName = depIncomingTrunkName.Split('@')[1];
                            depIncomingTrunkName = depIncomingTrunkName.Substring(0, depIncomingTrunkName.IndexOf("@"));
                            CoreGenerator.RegenerateIncomingSIPTrunkFile(depIncomingTrunkName, Domain.Load(depIncomingDomainName));
                            EventController.TriggerEvent(new GenericEvent("IncomingSIPTrunkDeployed",
                                                                          new NameValuePair[] {
                                new NameValuePair("Name", depIncomingTrunkName),
                                new NameValuePair("Domain", depIncomingDomainName)
                            }));
                        }
                        else if (((string)obj).StartsWith(string.Format(_DESTROY_INCOMING_TRUNK_FORMAT, "")))
                        {
                            string desIncomingTrunkName  = ((string)obj).Substring(string.Format(_DESTROY_INCOMING_TRUNK_FORMAT, "").Length);
                            string desIncomingDomainName = desIncomingTrunkName.Split('@')[1];
                            desIncomingTrunkName = desIncomingTrunkName.Substring(0, desIncomingTrunkName.IndexOf("@"));
                            CoreGenerator.DestroyIncomingSIPTrunkFile(desIncomingTrunkName, desIncomingDomainName);
                            EventController.TriggerEvent(new GenericEvent("IncomingSIPTrunkDestroyed",
                                                                          new NameValuePair[] {
                                new NameValuePair("Name", desIncomingTrunkName),
                                new NameValuePair("Domain", desIncomingDomainName)
                            }));
                        }
                    }
                }
            }
            _Changes = null;
            if (ModuleController.Current.IsModuleEnabled("ESL"))
            {
                ModuleController.Current.InvokeModuleMethod("ESL", "ReloadConfigs", false);
            }
            else
            {
                _ReloadConfigurations();
            }
            foreach (IEvent ie in events)
            {
                EventController.TriggerEvent(ie);
            }
            Monitor.Exit(_lock);
        }