public void Load(DataRow row) { SIPDialogue = new SIPDialogue(); SIPDialogue.Id = new Guid(row["id"] as string); SIPDialogue.Owner = row["owner"] as string; SIPDialogue.AdminMemberId = row["adminmemberid"] as string; SIPDialogue.LocalTag = row["localtag"] as string; SIPDialogue.RemoteTag = row["remotetag"] as string; SIPDialogue.LocalUserField = SIPUserField.ParseSIPUserField(row["localuserfield"] as string); SIPDialogue.RemoteUserField = SIPUserField.ParseSIPUserField(row["remoteuserfield"] as string); SIPDialogue.CallId = row["callid"] as string; SIPDialogue.CSeq = Convert.ToInt32(row["cseq"]); SIPDialogue.BridgeId = new Guid(row["bridgeid"] as string); SIPDialogue.RemoteTarget = SIPURI.ParseSIPURI(row["remotetarget"] as string); SIPDialogue.RouteSet = (row["routeset"] != null && row["routeset"] != DBNull.Value && !(row["routeset"] as string).IsNullOrBlank()) ? SIPRouteSet.ParseSIPRouteSet(row["routeset"] as string) : null; SIPDialogue.ProxySendFrom = (row["proxysipsocket"] != null && row["proxysipsocket"] != DBNull.Value) ? row["proxysipsocket"] as string : null; SIPDialogue.CDRId = new Guid(row["cdrid"] as string); SIPDialogue.CallDurationLimit = (row["calldurationlimit"] != null && row["calldurationlimit"] != DBNull.Value) ? Convert.ToInt32(row["calldurationlimit"]) : 0; SIPDialogue.Direction = (row["direction"] != null) ? (SIPCallDirection)Enum.Parse(typeof(SIPCallDirection), row["direction"] as string, true) : SIPCallDirection.None; Inserted = DateTimeOffset.Parse(row["inserted"] as string); TransferMode = row["transfermode"] as string; SDP = row["sdp"] as string; RemoteSDP = row["remotesdp"] as string; //SIPDialogue.SwitchboardCallerDescription = (row["switchboardcallerdescription"] != null && row["switchboardcallerdescription"] != DBNull.Value) ? row["switchboardcallerdescription"] as string : null; //SIPDialogue.SwitchboardDescription = (row["switchboarddescription"] != null && row["switchboarddescription"] != DBNull.Value) ? row["switchboarddescription"] as string : null; SIPDialogue.SwitchboardOwner = (row["switchboardowner"] != null && row["switchboardowner"] != DBNull.Value) ? row["switchboardowner"] as string : null; SIPDialogue.SwitchboardLineName = (row["switchboardlinename"] != null && row["switchboardlinename"] != DBNull.Value) ? row["switchboardlinename"] as string : null; SIPDialogue.CRMPersonName = (row["crmpersonname"] != null && row["crmpersonname"] != DBNull.Value) ? row["crmpersonname"] as string : null; SIPDialogue.CRMCompanyName = (row["crmcompanyname"] != null && row["crmcompanyname"] != DBNull.Value) ? row["crmcompanyname"] as string : null; SIPDialogue.CRMPictureURL = (row["crmpictureurl"] != null && row["crmpictureurl"] != DBNull.Value) ? row["crmpictureurl"] as string : null; }
//public Dictionary<Guid, object> Load(XmlDocument dom) //{ // return SIPAssetXMLPersistor<SIPDialogueAsset>.LoadAssetsFromXMLRecordSet(dom); //} #endif public void Load(XElement dialogueElement) { SIPDialogue = new SIPDialogue(); SIPDialogue.Id = new Guid(dialogueElement.Element("id").Value); SIPDialogue.Owner = dialogueElement.Element("owner").Value; SIPDialogue.AdminMemberId = dialogueElement.Element("adminmemberid").Value; SIPDialogue.LocalTag = dialogueElement.Element("localtag").Value; SIPDialogue.RemoteTag = dialogueElement.Element("remotetag").Value; SIPDialogue.LocalUserField = SIPUserField.ParseSIPUserField(dialogueElement.Element("localuserfield").Value); SIPDialogue.RemoteUserField = SIPUserField.ParseSIPUserField(dialogueElement.Element("remoteuserfield").Value); SIPDialogue.CallId = dialogueElement.Element("callid").Value; SIPDialogue.CSeq = Convert.ToInt32(dialogueElement.Element("cseq").Value); SIPDialogue.BridgeId = new Guid(dialogueElement.Element("bridgeid").Value); SIPDialogue.RemoteTarget = SIPURI.ParseSIPURI(dialogueElement.Element("remotetarget").Value); SIPDialogue.RouteSet = (dialogueElement.Element("routeset") != null && !dialogueElement.Element("routeset").Value.IsNullOrBlank()) ? SIPRouteSet.ParseSIPRouteSet(dialogueElement.Element("routeset").Value) : null; SIPDialogue.ProxySendFrom = (dialogueElement.Element("proxysipsocket") != null) ? dialogueElement.Element("proxysipsocket").Value : null; SIPDialogue.CDRId = new Guid(dialogueElement.Element("cdrid").Value); SIPDialogue.CallDurationLimit = (dialogueElement.Element("calldurationlimit") != null) ? Convert.ToInt32(dialogueElement.Element("calldurationlimit").Value) : 0; SIPDialogue.Direction = (dialogueElement.Element("direction") != null) ? (SIPCallDirection)Enum.Parse(typeof(SIPCallDirection), dialogueElement.Element("direction").Value, true) : SIPCallDirection.None; Inserted = DateTimeOffset.Parse(dialogueElement.Element("inserted").Value); TransferMode = dialogueElement.Element("transfermode").Value; SDP = dialogueElement.Element("sdp").Value; RemoteSDP = dialogueElement.Element("remotesdp").Value; //SIPDialogue.SwitchboardCallerDescription = (dialogueElement.Element("switchboardcallerdescription") != null) ? dialogueElement.Element("switchboardcallerdescription").Value : null; //SIPDialogue.SwitchboardDescription = (dialogueElement.Element("switchboarddescription") != null) ? dialogueElement.Element("switchboarddescription").Value : null; SIPDialogue.SwitchboardOwner = (dialogueElement.Element("switchboardowner") != null) ? dialogueElement.Element("switchboardowner").Value : null; SIPDialogue.SwitchboardLineName = (dialogueElement.Element("switchboardlinename") != null) ? dialogueElement.Element("switchboardlinename").Value : null; SIPDialogue.CRMPersonName = (dialogueElement.Element("crmpersonname") != null) ? dialogueElement.Element("crmpersonname").Value : null; SIPDialogue.CRMCompanyName = (dialogueElement.Element("crmcompanyname") != null) ? dialogueElement.Element("crmcompanyname").Value : null; SIPDialogue.CRMPictureURL = (dialogueElement.Element("crmpictureurl") != null) ? dialogueElement.Element("crmpictureurl").Value : null; }
public void WithDifferentNamesAreEqualUserTest() { Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); SIPContactHeader contactHeader1 = new SIPContactHeader(SIPUserField.ParseSIPUserField("\"Joe Bloggs\" <sip:[email protected]:5060> ;expires=0; param1=value1")); SIPContactHeader contactHeader2 = new SIPContactHeader(SIPUserField.ParseSIPUserField("\"Jane Doe\" <sip:[email protected]:5060>;expires=50;param1=value1")); Assert.IsTrue(SIPContactHeader.AreEqual(contactHeader1, contactHeader2), "The Contact headers were not correctly identified as equal."); }
public void WithExpiresParametersAreEqualUserTest() { logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name); SIPContactHeader contactHeader1 = new SIPContactHeader(SIPUserField.ParseSIPUserField("<sip:[email protected]:5060> ;expires=0; param1=value1")); SIPContactHeader contactHeader2 = new SIPContactHeader(SIPUserField.ParseSIPUserField("<sip:[email protected]:5060>;expires=50;param1=value1")); Assert.True(SIPContactHeader.AreEqual(contactHeader1, contactHeader2), "The Contact headers were not correctly identified as equal."); }
public void ParamsInUserPortionURITest() { Console.WriteLine("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); SIPUserField userField = SIPUserField.ParseSIPUserField("<sip:C=on;[email protected]:5060;lr>"); Assert.IsTrue("C=on;t=DLPAN" == userField.URI.User, "SIP user portion parsed incorrectly."); Assert.IsTrue("10.0.0.1:5060" == userField.URI.Host, "SIP host portion parsed incorrectly."); Console.WriteLine("-----------------------------------------"); }
public void ParamsInUserPortionURITest() { logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name); SIPUserField userField = SIPUserField.ParseSIPUserField("<sip:C=on;[email protected]:5060;lr>"); Assert.True("C=on;t=DLPAN" == userField.URI.User, "SIP user portion parsed incorrectly."); Assert.True("10.0.0.1:5060" == userField.URI.Host, "SIP host portion parsed incorrectly."); logger.LogDebug("-----------------------------------------"); }
public void ParseSIPUserFieldNoAnglesUnitTest() { logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name); var userField = SIPUserField.ParseSIPUserField("sip:[email protected]"); Assert.Null(userField.Name); Assert.Equal(SIPURI.ParseSIPURI("sip:[email protected]"), userField.URI); logger.LogDebug("-----------------------------------------"); }
public void ParseWithHeaderParametersUnitTest() { logger.LogDebug("--> " + System.Reflection.MethodBase.GetCurrentMethod().Name); logger.BeginScope(System.Reflection.MethodBase.GetCurrentMethod().Name); var userField = SIPUserField.ParseSIPUserField("\"Jane Doe\" <sip:[email protected]>p=1;q=2"); Assert.Equal("Jane Doe", userField.Name); Assert.Equal(SIPURI.ParseSIPURI("sip:[email protected]"), userField.URI); Assert.Equal(2, userField.Parameters.Count); Assert.Equal("1", userField.Parameters.Get("p")); Assert.Equal("2", userField.Parameters.Get("q")); logger.LogDebug("-----------------------------------------"); }
public SIPDialogue ToSIPDialogue() { SIPDialogue dialogue = new SIPDialogue(); dialogue.Id = ID; dialogue.CDRId = CDRID.GetValueOrDefault(); dialogue.LocalTag = LocalTag; dialogue.RemoteTag = RemoteTag; dialogue.CallId = CallID; dialogue.CSeq = CSeq; dialogue.BridgeId = BridgeID; dialogue.RemoteTarget = SIPURI.ParseSIPURIRelaxed(RemoteTarget); dialogue.LocalUserField = SIPUserField.ParseSIPUserField(LocalUserField); dialogue.RemoteUserField = SIPUserField.ParseSIPUserField(RemoteUserField); dialogue.ProxySendFrom = ProxySIPSocket; dialogue.RouteSet = string.IsNullOrWhiteSpace(RouteSet) ? null : SIPRouteSet.ParseSIPRouteSet(RouteSet); dialogue.CallDurationLimit = CallDurationLimit.GetValueOrDefault(); dialogue.Direction = Enum.Parse <SIPCallDirection>(Direction, true); dialogue.Inserted = Inserted; return(dialogue); }
public SIPDialogue ToSIPDialogue() { SIPDialogue dialogue = new SIPDialogue(); dialogue.Id = !string.IsNullOrEmpty(ID) ? new Guid(ID) : Guid.Empty; dialogue.CDRId = !string.IsNullOrEmpty(CDRID) ? new Guid(CDRID) : Guid.Empty; dialogue.LocalTag = LocalTag; dialogue.RemoteTag = RemoteTag; dialogue.CallId = CallID; dialogue.CSeq = (int)CSeq; dialogue.BridgeId = !string.IsNullOrEmpty(BridgeID) ? new Guid(BridgeID) : Guid.Empty; dialogue.RemoteTarget = SIPURI.ParseSIPURIRelaxed(RemoteTarget); dialogue.LocalUserField = SIPUserField.ParseSIPUserField(LocalUserField); dialogue.RemoteUserField = SIPUserField.ParseSIPUserField(RemoteUserField); dialogue.ProxySendFrom = ProxySendFrom; dialogue.RouteSet = string.IsNullOrWhiteSpace(RouteSet) ? null : SIPRouteSet.ParseSIPRouteSet(RouteSet); dialogue.CallDurationLimit = (int)CallDurationLimit.GetValueOrDefault(); dialogue.Direction = Enum.Parse <SIPCallDirection>(Direction, true); dialogue.Inserted = DateTime.Parse(Inserted); dialogue.RemoteSIPEndPoint = (RemoteSocket != null) ? SIPEndPoint.ParseSIPEndPoint(RemoteSocket) : null; return(dialogue); }
private SIPRequest GetInviteRequest(SIPCallDescriptor sipCallDescriptor, string branchId, string callId, SIPRouteSet routeSet, string content, string contentType) { SIPRequest inviteRequest = new SIPRequest(SIPMethodsEnum.INVITE, sipCallDescriptor.Uri); SIPHeader inviteHeader = new SIPHeader(sipCallDescriptor.GetFromHeader(), SIPToHeader.ParseToHeader(sipCallDescriptor.To), 1, callId); inviteHeader.From.FromTag = CallProperties.CreateNewTag(); inviteHeader.Contact = new List <SIPContactHeader>() { SIPContactHeader.GetDefaultSIPContactHeader(inviteRequest.URI.Scheme) }; inviteHeader.Contact[0].ContactURI.User = sipCallDescriptor.Username; inviteHeader.CSeqMethod = SIPMethodsEnum.INVITE; inviteHeader.UserAgent = SIPConstants.SipUserAgentVersionString; inviteHeader.Routes = routeSet; inviteHeader.Supported = SIPExtensionHeaders.REPLACES + ", " + SIPExtensionHeaders.NO_REFER_SUB + ((PrackSupported == true) ? ", " + SIPExtensionHeaders.PRACK : ""); inviteRequest.Header = inviteHeader; if (!sipCallDescriptor.ProxySendFrom.IsNullOrBlank()) { inviteHeader.ProxySendFrom = sipCallDescriptor.ProxySendFrom; } SIPViaHeader viaHeader = new SIPViaHeader(new IPEndPoint(IPAddress.Any, 0), branchId); inviteRequest.Header.Vias.PushViaHeader(viaHeader); inviteRequest.Body = content; inviteRequest.Header.ContentLength = (inviteRequest.Body != null) ? inviteRequest.Body.Length : 0; inviteRequest.Header.ContentType = contentType; try { if (sipCallDescriptor.CustomHeaders != null && sipCallDescriptor.CustomHeaders.Count > 0) { foreach (string customHeader in sipCallDescriptor.CustomHeaders) { if (customHeader.IsNullOrBlank()) { continue; } else if (customHeader.Trim().StartsWith(SIPHeaders.SIP_HEADER_USERAGENT)) { inviteRequest.Header.UserAgent = customHeader.Substring(customHeader.IndexOf(":") + 1).Trim(); } else if (customHeader.Trim().StartsWith(SIPHeaders.SIP_HEADER_TO + ":")) { var customToHeader = SIPUserField.ParseSIPUserField(customHeader.Substring(customHeader.IndexOf(":") + 1).Trim()); if (customToHeader != null) { inviteRequest.Header.To.ToUserField = customToHeader; } } else { inviteRequest.Header.UnknownHeaders.Add(customHeader); } } } } catch (Exception excp) { logger.LogError("Exception Parsing CustomHeader for GetInviteRequest. " + excp.Message + sipCallDescriptor.CustomHeaders); } if (AdjustInvite != null) { inviteRequest = AdjustInvite(inviteRequest); } return(inviteRequest); }