public void DeployDomain(sDeployedDomain domain) { DirectoryInfo di = new DirectoryInfo(Settings.Current[Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_CONF_DIR + Path.DirectorySeparatorChar + Constants.DEFAULT_EXTENSIONS_DIRECTORY + Path.DirectorySeparatorChar + domain.Name); if (!di.Exists) { Log.Trace("Creating domain directory " + domain.Name + " for extensions"); di.Create(); } FileInfo fi = new FileInfo(di.FullName + ".xml"); if (fi.Exists) { fi.Delete(); } Log.Trace("Deploying domain configuration file for domain " + domain.Name); string str = Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.DataCore.Generators.resources.BaseConfigurations.domain.st"); Template st = new Template(str); st.SetAttribute("domain", domain); FileStream fs = fi.OpenWrite(); st.WriteToStream(fs); fs.Close(); }
public static void RegenerateDomainFile(Domain domain) { sDeployedDomain dom = new sDeployedDomain(domain); Lock(); List <sDeployedDomain> doms = domains; bool add = true; for (int x = 0; x < doms.Count; x++) { if (doms[x].Name == dom.Name) { doms[x] = dom; add = false; break; } } if (add) { doms.Add(dom); } domains = doms; UnLock(); _deployer.DeployDomain(dom); EventController.TriggerEvent(new DomainDeploymentEvent(dom)); }
public void DeployDomain(sDeployedDomain domain) { lock (_cachedMessageCount) { string[] keys = new string[_cachedMessageCount.Count]; _cachedMessageCount.Keys.CopyTo(keys, 0); foreach (string str in keys) { if (str.EndsWith("@" + domain.Name)) { _cachedMessageCount.Remove(str); } } } }
internal static List <string> GetExtensionNumbersForDomain(sDeployedDomain domain) { List <string> ret = new List <string>(); Lock(); foreach (sDeployedExtension ext in extensions) { if (ext.DomainName == domain.Name) { ret.Add(ext.Number); } } foreach (sDeployedIncomingSIPTrunk ist in itrunks) { if (ist.DomainName == domain.Name) { ret.Add(ist.Number); } } UnLock(); return(ret); }
private void ProcessDirectoryRequest(HttpRequest request) { switch (request.Parameters["Event-Name"]) { case "REQUEST_PARAMS": if (request.Parameters["purpose"] != null) { switch (request.Parameters["purpose"]) { case "gateways": Template st = new Template(Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.UserModules.XmlCurl.resources.domain.st")); CoreGenerator.Lock(); st.SetAttribute("domains", CoreGenerator.Domains); st.SetAttribute("section", request.Parameters["section"]); request.ResponseWriter.Write(st.ToString()); CoreGenerator.UnLock(); break; default: request.ResponseWriter.WriteLine(NOT_FOUND_RESPONSE); break; } } else { sDeployedExtension ext = null; sDeployedDomain dom = null; switch (request.Parameters["action"]) { case "sip_auth": CoreGenerator.Lock(); for (var x = 0; x < CoreGenerator.Extensions.Count; x++) { if ((CoreGenerator.Extensions[x].Number == request.Parameters["user"]) && (CoreGenerator.Extensions[x].DomainName == request.Parameters["domain"])) { ext = CoreGenerator.Extensions[x]; break; } } if (ext != null) { for (int x = 0; x < CoreGenerator.Domains.Count; x++) { if (CoreGenerator.Domains[x].Name == ext.DomainName) { dom = CoreGenerator.Domains[x]; break; } } } CoreGenerator.UnLock(); if (ext == null) { request.ResponseWriter.WriteLine(NOT_FOUND_RESPONSE); } else { Template st = new Template(Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.UserModules.XmlCurl.resources.Extension.st")); st.SetAttribute("ext", ext); st.SetAttribute("domain", dom); st.SetAttribute("section", request.Parameters["section"]); request.ResponseWriter.Write(st.ToString()); } break; case "reverse-auth-lookup": CoreGenerator.Lock(); for (var x = 0; x < CoreGenerator.Extensions.Count; x++) { if ((CoreGenerator.Extensions[x].Number == request.Parameters["user"]) && (CoreGenerator.Extensions[x].DomainName == request.Parameters["domain"])) { ext = CoreGenerator.Extensions[x]; break; } } CoreGenerator.UnLock(); if (ext == null) { request.ResponseWriter.WriteLine(NOT_FOUND_RESPONSE); } else { Template st = new Template(Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.UserModules.XmlCurl.resources.ReverseAuth.st")); st.SetAttribute("extension", ext); st.SetAttribute("section", request.Parameters["section"]); request.ResponseWriter.Write(st.ToString()); } break; default: request.ResponseWriter.WriteLine(NOT_FOUND_RESPONSE); break; } } break; case "GENERAL": if (request.Parameters["action"] == "message-count") { string mcont = VirtualConfigDeployer.GetCachedMessageCount(request.Parameters["user"], request.Parameters["domain"]); if (mcont != null) { request.ResponseWriter.Write(mcont); } else { sDeployedExtension ext = null; sDeployedDomain dom = null; CoreGenerator.Lock(); for (var x = 0; x < CoreGenerator.Extensions.Count; x++) { if ((CoreGenerator.Extensions[x].Number == request.Parameters["user"]) && (CoreGenerator.Extensions[x].DomainName == request.Parameters["domain"])) { ext = CoreGenerator.Extensions[x]; break; } } if (ext != null) { for (int x = 0; x < CoreGenerator.Domains.Count; x++) { if (CoreGenerator.Domains[x].Name == ext.DomainName) { dom = CoreGenerator.Domains[x]; break; } } } CoreGenerator.UnLock(); if (ext == null) { request.ResponseWriter.WriteLine(NOT_FOUND_RESPONSE); } else { Template st = new Template(Utility.ReadEmbeddedResource("Org.Reddragonit.FreeSwitchConfig.UserModules.XmlCurl.resources.MessageCount.st")); st.SetAttribute("ext", ext); st.SetAttribute("domain", dom); st.SetAttribute("section", request.Parameters["section"]); request.ResponseWriter.Write(st.ToString()); VirtualConfigDeployer.CacheMessageCount(ext.Number, dom.Name, st.ToString()); } } } else { request.ResponseWriter.WriteLine(NOT_FOUND_RESPONSE); } break; default: request.ResponseWriter.WriteLine(NOT_FOUND_RESPONSE); break; } }
internal DomainDeploymentEvent(sDeployedDomain domain) { _pars.Add("Domain", domain); }