Exemple #1
0
        public static SIPEventDialog Parse(XElement dialogElement)
        {
            XNamespace ns = m_dialogXMLNS;

            SIPEventDialog eventDialog = new SIPEventDialog();

            eventDialog.ID        = dialogElement.Attribute("id").Value;
            eventDialog.CallID    = (dialogElement.Attribute("call-id") != null) ? dialogElement.Attribute("call-id").Value : null;
            eventDialog.LocalTag  = (dialogElement.Attribute("local-tag") != null) ? dialogElement.Attribute("local-tag").Value : null;
            eventDialog.RemoteTag = (dialogElement.Attribute("remote-tag") != null) ? dialogElement.Attribute("remote-tag").Value : null;
            eventDialog.Direction = (dialogElement.Attribute("direction") != null) ? (SIPEventDialogDirectionEnum)Enum.Parse(typeof(SIPEventDialogDirectionEnum), dialogElement.Attribute("direction").Value, true) : SIPEventDialogDirectionEnum.none;

            XElement stateElement = dialogElement.Element(ns + "state");

            eventDialog.State      = stateElement.Value;
            eventDialog.StateCode  = (stateElement.Attribute("code") != null) ? Convert.ToInt32(stateElement.Attribute("code").Value) : 0;
            eventDialog.StateEvent = (stateElement.Attribute("event") != null) ? SIPEventDialogStateEvent.Parse(stateElement.Attribute("event").Value) : SIPEventDialogStateEvent.None;

            eventDialog.Duration = (dialogElement.Element(ns + "duration") != null) ? Convert.ToInt32(dialogElement.Element(ns + "duration").Value) : 0;

            eventDialog.LocalParticipant  = (dialogElement.Element(ns + "local") != null) ? SIPEventDialogParticipant.Parse(dialogElement.Element(ns + "local")) : null;
            eventDialog.RemoteParticipant = (dialogElement.Element(ns + "remote") != null) ? SIPEventDialogParticipant.Parse(dialogElement.Element(ns + "remote")) : null;

            return(eventDialog);
        }
        public override void Load(string dialogInfoXMLStr)
        {
            try
            {
                XNamespace ns             = m_dialogXMLNS;
                XDocument  eventDialogDoc = XDocument.Parse(dialogInfoXMLStr);

                Version = Convert.ToInt32(((XElement)eventDialogDoc.FirstNode).Attribute("version").Value);
                State   = (SIPEventDialogInfoStateEnum)Enum.Parse(typeof(SIPEventDialogInfoStateEnum), ((XElement)eventDialogDoc.FirstNode).Attribute("state").Value, true);
                Entity  = SIPURI.ParseSIPURI(((XElement)eventDialogDoc.FirstNode).Attribute("entity").Value);

                var dialogElements = eventDialogDoc.Root.Elements(ns + "dialog");
                foreach (XElement dialogElement in dialogElements)
                {
                    DialogItems.Add(SIPEventDialog.Parse(dialogElement));
                }
            }
            catch (Exception excp)
            {
                logger.LogError("Exception SIPEventDialogInfo Ctor. " + excp.Message);
                throw;
            }
        }
        public static SIPEventDialog Parse(XElement dialogElement)
        {
            XNamespace ns = m_dialogXMLNS;
            XNamespace ss = m_sipsorceryXMLNS;

            SIPEventDialog eventDialog = new SIPEventDialog();
            eventDialog.ID = dialogElement.Attribute("id").Value;
            eventDialog.CallID = (dialogElement.Attribute("call-id") != null) ? dialogElement.Attribute("call-id").Value : null;
            eventDialog.LocalTag = (dialogElement.Attribute("local-tag") != null) ? dialogElement.Attribute("local-tag").Value : null;
            eventDialog.RemoteTag = (dialogElement.Attribute("remote-tag") != null) ? dialogElement.Attribute("remote-tag").Value : null;
            eventDialog.Direction = (dialogElement.Attribute("direction") != null) ? (SIPEventDialogDirectionEnum)Enum.Parse(typeof(SIPEventDialogDirectionEnum), dialogElement.Attribute("direction").Value, true) : SIPEventDialogDirectionEnum.none;

            XElement stateElement = dialogElement.Element(ns + "state");
            eventDialog.State = stateElement.Value;
            eventDialog.StateCode = (stateElement.Attribute("code") != null) ? Convert.ToInt32(stateElement.Attribute("code").Value) : 0;
            eventDialog.StateEvent = (stateElement.Attribute("event") != null) ? SIPEventDialogStateEvent.Parse(stateElement.Attribute("event").Value) : SIPEventDialogStateEvent.None;

            eventDialog.Duration = (dialogElement.Element(ns + "duration") != null) ? Convert.ToInt32(dialogElement.Element(ns + "duration").Value) : 0;
            eventDialog.BridgeID = (dialogElement.Element(ss + "bridgeid") != null) ? dialogElement.Element(ss + "bridgeid").Value : null;
            eventDialog.SwitchboardOwner = (dialogElement.Element(ss + "switchboardowner") != null) ? dialogElement.Element(ss + "switchboardowner").Value : null;

            eventDialog.LocalParticipant = (dialogElement.Element(ns + "local") != null) ? SIPEventDialogParticipant.Parse(dialogElement.Element(ns + "local")) : null;
            eventDialog.RemoteParticipant = (dialogElement.Element(ns + "remote") != null) ? SIPEventDialogParticipant.Parse(dialogElement.Element(ns + "remote")) : null;

            return eventDialog;
        }