/// <summary> /// Try to parse the xml (atom) content from the SEC returned from a search on a CIK. /// </summary> /// <param name="xmlContent"></param> /// <param name="srcUri"></param> /// <param name="publicCompany"></param> /// <returns></returns> public static bool TryParseSecEdgarCikSearch(string xmlContent, Uri srcUri, ref PublicCompany publicCompany) { if (String.IsNullOrWhiteSpace(xmlContent)) { return(false); } var myDynData = DynamicDataFactory.GetDataParser(srcUri); var myDynDataRslt = myDynData.ParseContent(xmlContent); if (myDynDataRslt == null || !myDynDataRslt.Any <dynamic>()) { return(false); } var pr = myDynDataRslt.First <dynamic>(); if (publicCompany == null) { publicCompany = new PublicCompany(); } if (!String.IsNullOrWhiteSpace(pr.Name)) { publicCompany.AddName(KindsOfNames.Legal, pr.Name); } publicCompany.CIK = String.IsNullOrWhiteSpace(pr.Cik) ? publicCompany.CIK : new CentralIndexKey { Value = pr.Cik, Src = myDynData.SourceUri.ToString() }; publicCompany.SIC = String.IsNullOrWhiteSpace(pr.Sic) ? publicCompany.SIC : new StandardIndustryClassification { Value = pr.Sic, Src = myDynData.SourceUri.ToString() }; publicCompany.UsStateOfIncorporation = pr.IncorpState; if (publicCompany.SIC != null && !String.IsNullOrWhiteSpace(pr.SicDesc)) { publicCompany.SIC.Description = pr.SicDesc; } var bizAddr = new AddressData(); if (!String.IsNullOrWhiteSpace(pr.BizAddrStreet)) { UsStreetPo temp; if (UsStreetPo.TryParse(pr.BizAddrStreet, out temp)) { bizAddr = temp.GetData(); } } if (!String.IsNullOrWhiteSpace(pr.BizAddrCity)) { bizAddr.Locality = pr.BizAddrCity; } if (!String.IsNullOrWhiteSpace(pr.BizAddrState)) { bizAddr.RegionAbbrev = pr.BizAddrState; } if (!String.IsNullOrWhiteSpace(pr.BizPostalCode)) { bizAddr.PostalCode = pr.BizPostalCode; } publicCompany.BusinessAddress = new PostalAddress { Street = new UsStreetPo(bizAddr) { Src = myDynData.SourceUri.ToString() }, CityArea = new UsCityStateZip(bizAddr) { Src = myDynData.SourceUri.ToString() } }; var mailAddr = new AddressData(); if (!String.IsNullOrWhiteSpace(pr.MailAddrStreet)) { UsStreetPo temp; if (UsStreetPo.TryParse(pr.MailAddrStreet, out temp)) { mailAddr = temp.GetData(); } } if (!String.IsNullOrWhiteSpace(pr.MailAddrCity)) { mailAddr.Locality = pr.MailAddrCity; } if (!String.IsNullOrWhiteSpace(pr.MailAddrState)) { mailAddr.RegionAbbrev = pr.MailAddrState; } if (!String.IsNullOrWhiteSpace(pr.MailPostalCode)) { mailAddr.PostalCode = pr.MailPostalCode; } publicCompany.MailingAddress = new PostalAddress { Street = new UsStreetPo(mailAddr) { Src = myDynData.SourceUri.ToString() }, CityArea = new UsCityStateZip(mailAddr) { Src = myDynData.SourceUri.ToString() } }; NorthAmericanPhone phOut; if (NorthAmericanPhone.TryParse(pr.BizPhone, out phOut) && publicCompany.PhoneNumbers.All(x => !x.Equals(phOut))) { phOut.Src = myDynData.SourceUri.ToString(); publicCompany.AddPhone(phOut); } if (NorthAmericanPhone.TryParse(pr.MailPhone, out phOut) && publicCompany.PhoneNumbers.All(x => !x.Equals(phOut))) { phOut.Src = myDynData.SourceUri.ToString(); publicCompany.AddPhone(phOut); } if (pr.FormerNames != null) { foreach (var fn in pr.FormerNames) { var strFnDt = fn.FormerDate ?? String.Empty; var strFnVal = fn.FormerName ?? String.Empty; publicCompany.AddName(KindsOfNames.Former, $"{strFnVal}[{strFnDt}]"); } } if (pr.FiscalYearEnd != null && pr.FiscalYearEnd.Length == 4) { int fyed; if (TryGetDayOfYearFiscalEnd(pr.FiscalYearEnd, out fyed)) { publicCompany.FiscalYearEndDay = fyed; } } return(true); }
public void TryParseTests() { var testInput = "102 MAIN ST APT. 101"; UsStreetPo testResultOut = null; var testResult = UsStreetPo.TryParse(testInput, out testResultOut); Assert.IsTrue(testResult); Assert.AreEqual("102", testResultOut.PostBox); Assert.AreEqual("MAIN", testResultOut.StreetName); Assert.AreEqual("ST", testResultOut.StreetKind); Assert.AreEqual("APT. 101", testResultOut.Line2); testInput = "1356 EXECUTIVE DR STE 202"; testResult = UsStreetPo.TryParse(testInput, out testResultOut); Assert.IsTrue(testResult); Assert.AreEqual("1356", testResultOut.PostBox); Assert.AreEqual("EXECUTIVE", testResultOut.StreetName); Assert.AreEqual("DR", testResultOut.StreetKind); Assert.AreEqual("STE 202", testResultOut.Line2); testInput = "7227 N. 16th St. #235"; testResult = UsStreetPo.TryParse(testInput, out testResultOut); Assert.IsTrue(testResult); Assert.AreEqual("7227", testResultOut.PostBox); Assert.AreEqual("16th", testResultOut.StreetName); Assert.AreEqual("N", testResultOut.GetData().ThoroughfareDirectional); Assert.AreEqual("St.", testResultOut.StreetKind); Assert.AreEqual("235", testResultOut.Line2); testInput = "250 GLEN ST"; testResult = UsStreetPo.TryParse(testInput, out testResultOut); Assert.IsTrue(testResult); Assert.AreEqual("250", testResultOut.PostBox); Assert.AreEqual("GLEN", testResultOut.StreetName); Assert.AreEqual("ST", testResultOut.StreetKind); testInput = "40 Commerce Street"; testResult = UsStreetPo.TryParse(testInput, out testResultOut); Assert.IsTrue(testResult); Assert.AreEqual("40", testResultOut.PostBox); Assert.AreEqual("Commerce", testResultOut.StreetName); Assert.AreEqual("Street", testResultOut.StreetKind); testInput = "9848 Upper 173rd Ct W"; testResult = UsStreetPo.TryParse(testInput, out testResultOut); Assert.IsFalse(testResult); var oddAddrs = new[] { "115 112th ave NE Apt 103", "117-D PARK CHARLES BLVD. S.", "1503 Anna Ruby Lane NW", "2625 Piedmont rd. STE 56-407", "2834 S 2475 E", "30930 HIGHWAY 431 LOT 13", "3428 S. King Dr.", "40 CEDAR POINTE LOOP", "4004 S 1500 E", "4211 AVENUE R", "44W244 Plato Rd", "5311 Wong Dr #208", "E9805 190TH AVE", "HCR 70 BOX 126", "N75W15375 COLONY RD", "P.O. BOX 1049", "P.O. Box 521653", "PMB 189", }; foreach (var addr in oddAddrs) { testResultOut = null; testResult = UsStreetPo.TryParse(addr, out testResultOut); Assert.IsTrue(testResult); Console.WriteLine($"Original: '{addr}'"); Console.WriteLine($"PostBox: '{testResultOut.PostBox}'"); Console.WriteLine($"StreetName: '{testResultOut.StreetName}'"); Console.WriteLine($"StreetKind: '{testResultOut.StreetKind}'"); Console.WriteLine($"SecondaryUnit: '{testResultOut.Line2}'"); Console.WriteLine($"CountyTownship: '{testResultOut.CountyTownship}'"); } /* * "115 112th ave NE Apt 103", * "117-D PARK CHARLES BLVD. S.", * "1503 Anna Ruby Lane NW", * "2625 Piedmont rd. STE 56-407", * "2834 S 2475 E", * "30930 HIGHWAY 431 LOT 13", * "3428 S. King Dr.", * "40 CEDAR POINTE LOOP", * "4004 S 1500 E", * "4211 AVENUE R", * "44W244 Plato Rd", * "5311 Wong Dr #208", * "E9805 190TH AVE", * "HCR 70 BOX 126", * "N75W15375 COLONY RD", * "P.O. BOX 1049", * "P.O. Box 521653", * "PMB 189", */ }