public static SIPEventDialogParticipant Parse(XElement participantElement)
        {
            XNamespace ns = m_dialogXMLNS;
            XNamespace ss = m_sipsorceryXMLNS;
            SIPEventDialogParticipant participant = new SIPEventDialogParticipant();

            XElement identityElement = participantElement.Element(ns + "identity");

            if (identityElement != null)
            {
                participant.DisplayName = (identityElement.Attribute("display-name") != null) ? identityElement.Attribute("display-name").Value : null;
                participant.URI         = SIPURI.ParseSIPURI(identityElement.Value);
            }

            XElement targetElement = participantElement.Element(ns + "target");

            if (targetElement != null)
            {
                participant.TargetURI = SIPURI.ParseSIPURI(targetElement.Attribute("uri").Value);
            }

            participant.CSeq = (participantElement.Element(ns + "cseq") != null) ? Convert.ToInt32(participantElement.Element(ns + "cseq").Value) : 0;
            //participant.SwitchboardDescription = (participantElement.Element(ss + "switchboarddescription") != null) ? participantElement.Element(ss + "switchboarddescription").Value : null;
            //participant.SwitchboardCallerDescription = (participantElement.Element(ss + "switchboardcallerdescription") != null) ? participantElement.Element(ss + "switchboardcallerdescription").Value : null;
            participant.SwitchboardLineName = (participantElement.Element(ss + "switchboardlinename") != null) ? participantElement.Element(ss + "switchboardlinename").Value : null;
            participant.CRMPersonName       = (participantElement.Element(ss + "crmpersonname") != null) ? participantElement.Element(ss + "crmpersonname").Value : null;
            participant.CRMCompanyName      = (participantElement.Element(ss + "crmcompanyname") != null) ? participantElement.Element(ss + "crmcompanyname").Value : null;
            participant.CRMPictureURL       = (participantElement.Element(ss + "crmpictureurl") != null) ? participantElement.Element(ss + "crmpictureurl").Value : null;

            return(participant);
        }
Exemplo n.º 2
0
        public SIPEventDialog(string id, string state, SIPDialogue sipDialogue)
        {
            ID    = id;
            State = state;

            if (sipDialogue != null)
            {
                CallID    = sipDialogue.CallId;
                LocalTag  = sipDialogue.LocalTag;
                RemoteTag = sipDialogue.RemoteTag;
                Direction = (sipDialogue.Direction == SIPCallDirection.In) ? SIPEventDialogDirectionEnum.recipient : SIPEventDialogDirectionEnum.initiator;
                Duration  = Convert.ToInt32((DateTimeOffset.UtcNow - sipDialogue.Inserted).TotalSeconds % Int32.MaxValue);
                //LocalParticipant = new SIPEventDialogParticipant(sipDialogue.LocalUserField.Name, sipDialogue.LocalUserField.URI, null, sipDialogue.CSeq, sipDialogue.SDP);
                LocalParticipant = new SIPEventDialogParticipant(sipDialogue.LocalUserField.Name, sipDialogue.LocalUserField.URI, null, sipDialogue.CSeq);
                //RemoteParticipant = new SIPEventDialogParticipant(sipDialogue.RemoteUserField.Name, sipDialogue.RemoteUserField.URI, sipDialogue.RemoteTarget, sipDialogue.CSeq, sipDialogue.RemoteSDP);
                RemoteParticipant = new SIPEventDialogParticipant(sipDialogue.RemoteUserField.Name, sipDialogue.RemoteUserField.URI, sipDialogue.RemoteTarget, sipDialogue.CSeq);
                BridgeID          = (sipDialogue.BridgeId != Guid.Empty) ? sipDialogue.BridgeId.ToString() : null;
                SwitchboardOwner  = (sipDialogue.SwitchboardOwner != null) ? sipDialogue.SwitchboardOwner : null;

                if (sipDialogue.Direction == SIPCallDirection.In)
                {
                    RemoteParticipant.CRMPersonName      = sipDialogue.CRMPersonName;
                    RemoteParticipant.CRMCompanyName     = sipDialogue.CRMCompanyName;
                    RemoteParticipant.CRMPictureURL      = sipDialogue.CRMPictureURL;
                    LocalParticipant.SwitchboardLineName = sipDialogue.SwitchboardLineName;
                }
                else if (sipDialogue.Direction == SIPCallDirection.Out)
                {
                    LocalParticipant.CRMPersonName        = sipDialogue.CRMPersonName;
                    LocalParticipant.CRMCompanyName       = sipDialogue.CRMCompanyName;
                    LocalParticipant.CRMPictureURL        = sipDialogue.CRMPictureURL;
                    RemoteParticipant.SwitchboardLineName = sipDialogue.SwitchboardLineName;
                }
            }
        }
Exemplo n.º 3
0
        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);
        }