public void TELNotEqualsValueTest() { MARC.Everest.DataTypes.TEL aValue = new MARC.Everest.DataTypes.TEL(), bValue = new MARC.Everest.DataTypes.TEL(); aValue.Value = "0"; aValue.Use = new MARC.Everest.DataTypes.SET<MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse>>(0) { new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse>(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Home) }; aValue.Capabilities = new MARC.Everest.DataTypes.SET<MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationCabability>>(0) { new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationCabability>(MARC.Everest.DataTypes.Interfaces.TelecommunicationCabability.Voice) }; aValue.UseablePeriod = new MARC.Everest.DataTypes.GTS(new MARC.Everest.DataTypes.EIVL<MARC.Everest.DataTypes.TS>(MARC.Everest.DataTypes.DomainTimingEventType.BeforeMeal,new MARC.Everest.DataTypes.IVL<MARC.Everest.DataTypes.PQ>(new MARC.Everest.DataTypes.PQ((decimal)0,"0")))); aValue.NullFlavor = new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.NullFlavor>(MARC.Everest.DataTypes.NullFlavor.AskedUnknown); aValue.UpdateMode = new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.UpdateMode>(MARC.Everest.DataTypes.UpdateMode.Add); aValue.Flavor = "0"; aValue.ValidTimeLow = new MARC.Everest.DataTypes.TS(DateTime.Parse("2011-1-10")); aValue.ValidTimeHigh = new MARC.Everest.DataTypes.TS(DateTime.Parse("2011-1-10")); aValue.ControlActRoot = "0"; aValue.ControlActExt = "0"; bValue.Value = "1"; bValue.Use = new MARC.Everest.DataTypes.SET<MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse>>(0) { new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse>(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Home) }; bValue.Capabilities = new MARC.Everest.DataTypes.SET<MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationCabability>>(0) { new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationCabability>(MARC.Everest.DataTypes.Interfaces.TelecommunicationCabability.Voice) }; bValue.UseablePeriod = new MARC.Everest.DataTypes.GTS(new MARC.Everest.DataTypes.EIVL<MARC.Everest.DataTypes.TS>(MARC.Everest.DataTypes.DomainTimingEventType.BeforeMeal,new MARC.Everest.DataTypes.IVL<MARC.Everest.DataTypes.PQ>(new MARC.Everest.DataTypes.PQ((decimal)0,"0")))); bValue.NullFlavor = new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.NullFlavor>(MARC.Everest.DataTypes.NullFlavor.AskedUnknown); bValue.UpdateMode = new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.UpdateMode>(MARC.Everest.DataTypes.UpdateMode.Add); bValue.Flavor = "0"; bValue.ValidTimeLow = new MARC.Everest.DataTypes.TS(DateTime.Parse("2011-1-10")); bValue.ValidTimeHigh = new MARC.Everest.DataTypes.TS(DateTime.Parse("2011-1-10")); bValue.ControlActRoot = "0"; bValue.ControlActExt = "0"; Assert.AreNotEqual(aValue, bValue); }
public void TELEqualsSerializationTest() { MARC.Everest.DataTypes.TEL aValue = new MARC.Everest.DataTypes.TEL(), bValue = null; aValue.Use = new MARC.Everest.DataTypes.SET<MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse>>(0) { new MARC.Everest.DataTypes.CS<MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse>(MARC.Everest.DataTypes.Interfaces.TelecommunicationAddressUse.Home) }; aValue.UseablePeriod = new MARC.Everest.DataTypes.GTS(new MARC.Everest.DataTypes.IVL<MARC.Everest.DataTypes.TS>(new MARC.Everest.DataTypes.TS(DateTime.Parse("2011-1-10")))); aValue.Value = "0"; aValue.Flavor = "0"; StringWriter sw = new StringWriter(); DatatypeFormatter fmtr = new DatatypeFormatter() { CompatibilityMode = DatatypeFormatterCompatibilityMode.Canadian }; XmlStateWriter xw = new XmlStateWriter(XmlWriter.Create(sw, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8 })); xw.WriteStartElement("test"); fmtr.Graph(xw, aValue); xw.WriteEndElement(); // comp xw.Flush(); StringReader sr = new StringReader(sw.ToString()); XmlStateReader rdr = new XmlStateReader(XmlReader.Create(sr)); rdr.Read(); rdr.Read(); bValue = Util.Convert<MARC.Everest.DataTypes.TEL>(fmtr.Parse(rdr, typeof(MARC.Everest.DataTypes.TEL)).Structure); Assert.AreEqual(aValue, bValue); }
/// <summary> /// XTN from telephone number /// </summary> /// <param name="tel"></param> /// <param name="instance"></param> public static void XTNFromTel(MARC.Everest.DataTypes.TEL tel, NHapi.Model.V25.Datatype.XTN instance) { Regex re = new Regex(@"^(?<s1>(?<s0>[^:/\?#]+):)?(?<a1>//(?<a0>[^/\;#]*))?(?<p0>[^\;#]*)(?<q1>\;(?<q0>[^#]*))?(?<f1>#(?<f0>.*))?"); // Match var match = re.Match(tel.Value); if (match.Groups[1].Value != "tel:") { instance.AnyText.Value = tel.Value; //instance.TelephoneNumber.Value = tel.Value; return; } // Telephone string[] comps = match.Groups[5].Value.Split('-'); StringBuilder sb = new StringBuilder(), phone = new StringBuilder(); for (int i = 0; i < comps.Length; i++) { if (i == 0 && comps[i].Contains("+")) { sb.Append(comps[i]); instance.CountryCode.Value = comps[i]; } else if (sb.Length == 0 && comps.Length == 3 || comps.Length == 4 && i == 1) // area code? { sb.AppendFormat("({0})", comps[i]); instance.AreaCityCode.Value = comps[i]; } else if (i != comps.Length - 1) { sb.AppendFormat("{0}-", comps[i]); phone.AppendFormat("{0}", comps[i]); } else { sb.Append(comps[i]); phone.Append(comps[i]); } } instance.LocalNumber.Value = phone.ToString().Replace("-", ""); // Extension? string[] parms = match.Groups[7].Value.Split(';'); foreach (var parm in parms) { string[] pData = parm.Split('='); if (pData[0] == "extension" || pData[0] == "ext" || pData[0] == "postd") { sb.AppendFormat("X{0}", pData[1]); instance.Extension.Value = pData[1]; } } instance.TelephoneNumber.Value = sb.ToString(); // Tel use if (tel.Use != null) { foreach (var tcu in s_v2TelUseConvert) { if (tcu.Value.Value == tel.Use.First.Code) { instance.TelecommunicationUseCode.Value = tcu.Key; } } } if (tel.Capabilities != null) { String cap = Util.ToWireFormat(tel.Capabilities); if (cap.Contains("sms")) { instance.TelecommunicationEquipmentType.Value = "CP"; } else if (cap.Contains("voice")) { instance.TelecommunicationEquipmentType.Value = "PH"; } } }