private void ChangeParent(XmlContextFile parent)
        {
            string tmp     = ToXMLContent(false);
            string newPath = "";

            if (parent == null)
            {
                newPath = "." + Path.DirectorySeparatorChar;
            }
            else
            {
                newPath = parent.BasePath + _fileName + Path.DirectorySeparatorChar;
            }
            foreach (XmlContextFile xcf in _includes)
            {
                tmp = tmp.Replace(string.Format(_INCLUDE_LINE, xcf.BasePath + xcf.FileName + ".xml"),
                                  string.Format(_INCLUDE_LINE, newPath + xcf.FileName + ".xml"));
            }
            _writer.Close();
            _ms     = new MemoryStream();
            _writer = XmlWriter.Create(_ms);
            _writer.WriteRaw(tmp);
            foreach (XmlContextFile xcf in _includes)
            {
                xcf.ChangeParent(this);
            }
        }
Esempio n. 2
0
 public void Start(ADialPlan[] plans)
 {
     _files = new Dictionary <string, List <XmlContextFile> >();
     _plans = new List <string>();
     foreach (ADialPlan plan in plans)
     {
         _plans.Add(plan.Name);
         foreach (sCallContext cont in plan.CallContexts)
         {
             if (!_files.ContainsKey(cont.Name))
             {
                 _files.Add(cont.Name, new List <XmlContextFile>());
             }
             List <XmlContextFile> tfiles = _files[cont.Name];
             XmlContextFile        file   = new XmlContextFile(plan.Name);
             tfiles.Add(file);
             _files.Remove(cont.Name);
             _files.Add(cont.Name, tfiles);
             foreach (sCallExtension ext in cont.Extensions)
             {
                 WriteCallExtension(ext, file);
             }
         }
     }
 }
Esempio n. 3
0
 public void DialplanDeployed(ADialPlan plan, int index)
 {
     lock (_files)
     {
         _plans.Insert(index, plan.Name);
         foreach (sCallContext cont in plan.CallContexts)
         {
             if (!_files.ContainsKey(cont.Name))
             {
                 _files.Add(cont.Name, new List <XmlContextFile>());
             }
             List <XmlContextFile> tfiles = _files[cont.Name];
             XmlContextFile        file   = new XmlContextFile(plan.Name);
             for (int x = 0; x < tfiles.Count; x++)
             {
                 if (_plans.IndexOf(tfiles[x].FileName) > _plans.IndexOf(plan.Name))
                 {
                     tfiles.Insert(x, file);
                     break;
                 }
             }
             _files.Remove(cont.Name);
             _files.Add(cont.Name, tfiles);
             foreach (sCallExtension ext in cont.Extensions)
             {
                 WriteCallExtension(ext, file);
             }
         }
     }
 }
        public XmlContextFile AddInclude(string fileName)
        {
            XmlContextFile ret = new XmlContextFile(fileName, this);

            _includes.Add(ret);
            WriteRaw(string.Format(_INCLUDE_LINE, ret.BasePath + ret._fileName));
            return(ret);
        }
Esempio n. 5
0
 private void _AppendElementAttributes(XmlContextFile file, NameValuePair[] attributes)
 {
     if (attributes != null)
     {
         foreach (NameValuePair nvp in attributes)
         {
             file.WriteStartAttribute(nvp.Name);
             file.WriteValue(nvp.Value);
             file.WriteEndAttribute();
         }
     }
 }
Esempio n. 6
0
 public void DialplanUpdated(ADialPlan plan)
 {
     lock (_files)
     {
         string[] keys = new string[_files.Count];
         _files.Keys.CopyTo(keys, 0);
         foreach (string key in keys)
         {
             List <XmlContextFile> files = _files[key];
             for (int x = 0; x < files.Count; x++)
             {
                 if (files[x].FileName == plan.Name)
                 {
                     files.RemoveAt(x);
                     break;
                 }
             }
             _files.Remove(key);
             _files.Add(key, files);
         }
         foreach (sCallContext cont in plan.CallContexts)
         {
             if (!_files.ContainsKey(cont.Name))
             {
                 _files.Add(cont.Name, new List <XmlContextFile>());
             }
             List <XmlContextFile> tfiles = _files[cont.Name];
             XmlContextFile        file   = new XmlContextFile(plan.Name);
             for (int x = 0; x < tfiles.Count; x++)
             {
                 if (_plans.IndexOf(tfiles[x].FileName) > _plans.IndexOf(plan.Name))
                 {
                     tfiles.Insert(x, file);
                     break;
                 }
             }
             _files.Remove(cont.Name);
             _files.Add(cont.Name, tfiles);
             foreach (sCallExtension ext in cont.Extensions)
             {
                 WriteCallExtension(ext, file);
             }
         }
     }
 }
 private void ChangeParent(XmlContextFile parent)
 {
     string tmp = ToXMLContent(false);
     string newPath = "";
     if (parent == null)
         newPath = "." + Path.DirectorySeparatorChar;
     else
         newPath = parent.BasePath + _fileName + Path.DirectorySeparatorChar;
     foreach (XmlContextFile xcf in _includes)
     {
         tmp = tmp.Replace(string.Format(_INCLUDE_LINE, xcf.BasePath + xcf.FileName + ".xml"),
             string.Format(_INCLUDE_LINE, newPath + xcf.FileName + ".xml"));
     }
     _writer.Close();
     _ms = new MemoryStream();
     _writer = XmlWriter.Create(_ms);
     _writer.WriteRaw(tmp);
     foreach (XmlContextFile xcf in _includes)
         xcf.ChangeParent(this);
 }
 public void Start(ADialPlan[] plans)
 {
     _files = new Dictionary<string, List<XmlContextFile>>();
     _plans = new List<string>();
     foreach (ADialPlan plan in plans)
     {
         _plans.Add(plan.Name);
         foreach (sCallContext cont in plan.CallContexts)
         {
             if (!_files.ContainsKey(cont.Name))
                 _files.Add(cont.Name, new List<XmlContextFile>());
             List<XmlContextFile> tfiles = _files[cont.Name];
             XmlContextFile file = new XmlContextFile(plan.Name);
             tfiles.Add(file);
             _files.Remove(cont.Name);
             _files.Add(cont.Name, tfiles);
             foreach (sCallExtension ext in cont.Extensions)
                 WriteCallExtension(ext, file);
         }
     }
 }
Esempio n. 9
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);
        }
 public XmlContextFile AddInclude(string fileName)
 {
     XmlContextFile ret = new XmlContextFile(fileName, this);
     _includes.Add(ret);
     WriteRaw(string.Format(_INCLUDE_LINE, ret.BasePath + ret._fileName));
     return ret;
 }
 public void DialplanDeployed(ADialPlan plan, int index)
 {
     lock (_files)
     {
         _plans.Insert(index, plan.Name);
         foreach (sCallContext cont in plan.CallContexts)
         {
             if (!_files.ContainsKey(cont.Name))
                 _files.Add(cont.Name, new List<XmlContextFile>());
             List<XmlContextFile> tfiles = _files[cont.Name];
             XmlContextFile file = new XmlContextFile(plan.Name);
             for (int x = 0; x < tfiles.Count; x++)
             {
                 if (_plans.IndexOf(tfiles[x].FileName) > _plans.IndexOf(plan.Name))
                 {
                     tfiles.Insert(x, file);
                     break;
                 }
             }
             _files.Remove(cont.Name);
             _files.Add(cont.Name, tfiles);
             foreach (sCallExtension ext in cont.Extensions)
                 WriteCallExtension(ext, file);
         }
     }
 }
 public void DialplanUpdated(ADialPlan plan)
 {
     lock (_files)
     {
         string[] keys = new string[_files.Count];
         _files.Keys.CopyTo(keys, 0);
         foreach (string key in keys)
         {
             List<XmlContextFile> files = _files[key];
             for (int x = 0; x < files.Count; x++)
             {
                 if (files[x].FileName == plan.Name)
                 {
                     files.RemoveAt(x);
                     break;
                 }
             }
             _files.Remove(key);
             _files.Add(key, files);
         }
         foreach (sCallContext cont in plan.CallContexts)
         {
             if (!_files.ContainsKey(cont.Name))
                 _files.Add(cont.Name, new List<XmlContextFile>());
             List<XmlContextFile> tfiles = _files[cont.Name];
             XmlContextFile file = new XmlContextFile(plan.Name);
             for (int x = 0; x < tfiles.Count; x++)
             {
                 if (_plans.IndexOf(tfiles[x].FileName) > _plans.IndexOf(plan.Name))
                 {
                     tfiles.Insert(x, file);
                     break;
                 }
             }
             _files.Remove(cont.Name);
             _files.Add(cont.Name, tfiles);
             foreach (sCallExtension ext in cont.Extensions)
                 WriteCallExtension(ext, file);
         }
     }
 }
 private void _AppendElementAttributes(XmlContextFile file, NameValuePair[] attributes)
 {
     if (attributes != null)
     {
         foreach (NameValuePair nvp in attributes)
         {
             file.WriteStartAttribute(nvp.Name);
             file.WriteValue(nvp.Value);
             file.WriteEndAttribute();
         }
     }
 }
Esempio n. 14
0
 public void AddInclude(XmlContextFile file)
 {
     _includes.Add(file);
     file.ChangeParent(this);
     WriteRaw(string.Format(_INCLUDE_LINE, file.BasePath + file._fileName));
 }
Esempio n. 15
0
        private void WriteCallExtension(sCallExtension ext, XmlContextFile file)
        {
            file.WriteStartElement("extension");
            file.WriteStartAttribute("name");
            file.WriteValue(ext.Name);
            file.WriteEndAttribute();
            if (ext.Continue)
            {
                file.WriteStartAttribute("continue");
                file.WriteValue("true");
                file.WriteEndAttribute();
            }
            if (ext.Inline)
            {
                file.WriteStartAttribute("inline");
                file.WriteValue("true");
                file.WriteEndAttribute();
            }
            foreach (ICallCondition cond in ext.Conditions)
            {
                file.WriteStartElement("condition");
                _AppendElementAttributes(file, cond.ConditionTagAttributes);
                if (cond.Break.HasValue)
                {
                    file.WriteStartAttribute("break");
                    switch (cond.Break.Value)
                    {
                    case CallConditionBreakTypes.Never:
                        file.WriteValue("never");
                        break;

                    case CallConditionBreakTypes.OnFalse:
                        file.WriteValue("on-false");
                        break;

                    case CallConditionBreakTypes.OnTrue:
                        file.WriteValue("on-true");
                        break;
                    }
                    file.WriteEndAttribute();
                }
                if (cond.PreActionElements != null)
                {
                    foreach (sPreActionsElement pae in cond.PreActionElements)
                    {
                        file.WriteStartElement(pae.Name);
                        _AppendElementAttributes(file, pae.ElementAttributes);
                        file.WriteEndElement();
                    }
                }
                if (cond.Actions != null)
                {
                    foreach (ICallAction act in cond.Actions)
                    {
                        file.WriteStartElement("action");
                        _AppendElementAttributes(file, act.ActionXMLAttributes);
                        file.WriteEndElement();
                    }
                }
                if (cond.AntiActions != null)
                {
                    foreach (ICallAction act in cond.AntiActions)
                    {
                        file.WriteStartElement("anti-action");
                        _AppendElementAttributes(file, act.ActionXMLAttributes);
                        file.WriteEndElement();
                    }
                }
                file.WriteEndElement();
            }
            file.WriteEndElement();
        }
 public void AddInclude(XmlContextFile file)
 {
     _includes.Add(file);
     file.ChangeParent(this);
     WriteRaw(string.Format(_INCLUDE_LINE, file.BasePath + file._fileName));
 }
 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;
 }
 private XmlContextFile(string fileName, XmlContextFile parent)
     : this(fileName)
 {
     _parent = parent;
 }
 private void WriteCallExtension(sCallExtension ext, XmlContextFile file)
 {
     file.WriteStartElement("extension");
     file.WriteStartAttribute("name");
     file.WriteValue(ext.Name);
     file.WriteEndAttribute();
     if (ext.Continue)
     {
         file.WriteStartAttribute("continue");
         file.WriteValue("true");
         file.WriteEndAttribute();
     }
     if (ext.Inline)
     {
         file.WriteStartAttribute("inline");
         file.WriteValue("true");
         file.WriteEndAttribute();
     }
     foreach (ICallCondition cond in ext.Conditions)
     {
         file.WriteStartElement("condition");
         _AppendElementAttributes(file, cond.ConditionTagAttributes);
         if (cond.Break.HasValue)
         {
             file.WriteStartAttribute("break");
             switch (cond.Break.Value)
             {
                 case CallConditionBreakTypes.Never:
                     file.WriteValue("never");
                     break;
                 case CallConditionBreakTypes.OnFalse:
                     file.WriteValue("on-false");
                     break;
                 case CallConditionBreakTypes.OnTrue:
                     file.WriteValue("on-true");
                     break;
             }
             file.WriteEndAttribute();
         }
         if (cond.PreActionElements!=null)
         {
             foreach (sPreActionsElement pae in cond.PreActionElements)
             {
                 file.WriteStartElement(pae.Name);
                 _AppendElementAttributes(file, pae.ElementAttributes);
                 file.WriteEndElement();
             }
         }
         if (cond.Actions != null)
         {
             foreach (ICallAction act in cond.Actions)
             {
                 file.WriteStartElement("action");
                 _AppendElementAttributes(file, act.ActionXMLAttributes);
                 file.WriteEndElement();
             }
         }
         if (cond.AntiActions != null)
         {
             foreach (ICallAction act in cond.AntiActions)
             {
                 file.WriteStartElement("anti-action");
                 _AppendElementAttributes(file, act.ActionXMLAttributes);
                 file.WriteEndElement();
             }
         }
         file.WriteEndElement();
     }
     file.WriteEndElement();
 }
Esempio n. 20
0
 private XmlContextFile(string fileName, XmlContextFile parent)
     : this(fileName)
 {
     _parent = parent;
 }