public static void Initialize() { if (!Initialized) { mut.WaitOne(); if (!Initialized) { Initialized = true; InitBaseData(); //Org.Reddragonit.FreeSwitchConfig.DataCore.DB.Users.User.Initialize(); ModuleController.Current.LoadModulesFromDirectory(Utility.LocateDirectory("LoadedModules")); foreach (Type t in typeof(Initializer).Assembly.GetTypes()) { if (t.FullName.StartsWith("Org.Reddragonit.FreeSwitchConfig.Site.BaseComponents.DialPlans") && t.IsSubclassOf(typeof(ADialPlan))) { ADialPlan adp = (ADialPlan)t.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); CallControlManager.DeployDialPlan(adp); } } } Log.Trace("Releasing initializer mutex..."); mut.ReleaseMutex(); } }
public string TestDialedNumber(string extensionNumber, string dialedNumber, string pin, DateTime?currentTime) { return(CallControlManager.TestDialNumber(Extension.Load(extensionNumber, Domain.Current), dialedNumber, (pin == "" ? null : pin), currentTime).ToString()); }
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); }