public void LoadFromElement(XmlElement element)
        {
            sDeployedContext context = new sDeployedContext();

            context.LoadFromElement((XmlElement)element.ChildNodes[0]);
            _pars.Add("Context", context);
        }
示例#2
0
        public static void RegenerateContextFile(string contextName)
        {
            Context          ct = Context.LoadByName(contextName);
            sDeployedContext dc = new sDeployedContext(ct);

            Lock();
            bool add = true;
            List <sDeployedContext> conts = contexts;

            for (int x = 0; x < conts.Count; x++)
            {
                if (conts[x].Name == dc.Name)
                {
                    conts[x] = dc;
                    add      = false;
                    break;
                }
            }
            if (add)
            {
                conts.Add(dc);
            }
            contexts = conts;
            UnLock();
            _deployer.DeployContext(dc);
            EventController.TriggerEvent(new ContextDeploymentEvent(dc));
        }
示例#3
0
 public void DeployContext(sDeployedContext context)
 {
     lock (_cachedDialPlans)
     {
         foreach (sDeployedProfile prof in CoreGenerator.Profiles)
         {
             if (prof.ContextName == context.Name)
             {
                 _cachedDialPlans.Remove(prof.Name);
             }
         }
     }
 }
示例#4
0
        public void DeployContext(sDeployedContext context)
        {
            DirectoryInfo di = new DirectoryInfo(Settings.Current[Constants.BASE_PATH_NAME].ToString() + Path.DirectorySeparatorChar + Constants.DEFAULT_CONF_DIR +
                                                 Path.DirectorySeparatorChar + Constants.DEFAULT_DIALPLAN_DIR);

            if (!di.Exists)
            {
                Log.Trace("Creating context directory to deploy context");
                di.Create();
            }
            XmlContextFile cfile = context.ContextFile;
            StreamWriter   sw    = new StreamWriter(di.FullName + Path.DirectorySeparatorChar + context.Name + ".xml");

            sw.Write(cfile.ToXMLContent(false));
            sw.Flush();
            sw.Close();
            di = new DirectoryInfo(di.FullName + Path.DirectorySeparatorChar + context.Name);
            if (!di.Exists)
            {
                Log.Trace("Creating context directory");
                di.Create();
            }
            else
            {
                Log.Trace("Cleaning out files for context directory");
                foreach (FileInfo fi in di.GetFiles())
                {
                    fi.Delete();
                }
            }
            int index = 0;

            foreach (XmlContextFile xcf in cfile.Includes)
            {
                sw = new StreamWriter(di.FullName + Path.DirectorySeparatorChar + index.ToString("00000") + "_" + xcf.FileName + ".xml");
                sw.Write(xcf.ToXMLContent(false));
                sw.Flush();
                sw.Close();
                index++;
            }
        }
示例#5
0
        public static void DestroyContext(string contextName)
        {
            List <string>    spros   = new List <string>();
            sDeployedContext context = null;

            Lock();
            List <sDeployedContext> conts = contexts;

            for (int x = 0; x < conts.Count; x++)
            {
                if (conts[x].Name == contextName)
                {
                    context = conts[x];
                    conts.RemoveAt(x);
                    break;
                }
            }
            contexts = conts;
            List <sDeployedProfile> profs = Profiles;

            for (int x = 0; x < profs.Count; x++)
            {
                if (profs[x].ContextName == contextName)
                {
                    profs.RemoveAt(x);
                    spros.Add(profs[x].Name);
                }
            }
            profiles = profs;
            UnLock();
            foreach (string str in spros)
            {
                DestroySIPProfile(str);
            }
            _deployer.DestroyContext(contextName);
            if (context != null)
            {
                EventController.TriggerEvent(new ContextDestroyedEvent(context));
            }
        }
示例#6
0
        public XmlContextFile GenerateContextFile(sDeployedContext context)
        {
            XmlContextFile ret = new XmlContextFile(context.Name);

            ret.WriteStartElement("context");
            ret.WriteStartAttribute("name");
            ret.WriteValue(context.Name);
            ret.WriteEndAttribute();
            ret.WriteRaw(_UNLOOP_EXTENSION);
            lock (_files)
            {
                if (_files.ContainsKey(context.Name))
                {
                    foreach (XmlContextFile xcf in _files[context.Name])
                    {
                        ret.AddInclude(xcf);
                    }
                }
            }
            ret.WriteEndElement();
            return(ret);
        }
 internal ContextDestroyedEvent(sDeployedContext context)
 {
     _pars.Add("Context", context);
 }
 internal static XmlContextFile GenerateContextFile(sDeployedContext context)
 {
     return(_controller.GenerateContextFile(context));
 }