src/Ares/AresServiceClient.cs
/// <summary>
/// Gets ARES informations of the economic subject specified by <paramref name="companyName"/>.
/// </summary>
/// <param name="companyName">Company name.</param>
/// <returns><see cref="AresInfo"/> of the economic subject specified by <paramref name="companyName"/>, if there was found exactly one subject; otherwise empty <see cref="AresInfo"/>.</returns>
Gets ARES informations of the economic subject specified by .
Gets ARES informations of the economic subject specified by .
public AresInfo GetInfoByCompanyName(string companyName)
        {
            WebClient webClient = new WebClient() { Encoding = Encoding.UTF8 };
            string data = string.Empty;
            try
            {
                data = webClient.DownloadString("http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?obchodni_firma=" + companyName + "&max_pocet=10");
            }
            finally
            {
                webClient.Dispose();
                webClient = null;
            }
            if (string.IsNullOrEmpty(data))
                new AresInfo();
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(data);
            XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xmlDocument.NameTable);
            xmlNamespaceManager.AddNamespace("are", "http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_answer/v_1.0.1");
            xmlNamespaceManager.AddNamespace("dtt", "http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/ares/ares_datatypes/v_1.0.4");
            xmlNamespaceManager.AddNamespace("udt", "http://wwwinfo.mfcr.cz/ares/xml_doc/schemas/uvis_datatypes/v_1.0.1");
            xmlNamespaceManager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            XmlNode recordsCountNode = xmlDocument.SelectSingleNode("/are:Ares_odpovedi/are:Odpoved/are:Pocet_zaznamu", xmlNamespaceManager);
            if (recordsCountNode == null)
                return new AresInfo();
            if (!int.TryParse(recordsCountNode.InnerText, out int recordsCount))
                return new AresInfo();
            if (recordsCount == 0 || recordsCount > 1)
                return new AresInfo();
            var crn = xmlDocument.SelectSingleNode("/are:Ares_odpovedi/are:Odpoved/are:Zaznam/are:ICO", xmlNamespaceManager) == null ? string.Empty : xmlDocument.SelectSingleNode("/are:Ares_odpovedi/are:Odpoved/are:Zaznam/are:ICO", xmlNamespaceManager).InnerText;
            if (string.IsNullOrEmpty(crn))
                return new AresInfo();
            return GetInfoByCrn(crn);
        }
public AresInfo GetInfoByCompanyName ( string companyName ) { WebClient webClient = new WebClient ( ) { Encoding = Encoding . UTF8 } ; string data = string . Empty ; try { data = webClient . DownloadString ( " " + companyName + " " ) ; } finally { webClient . Dispose ( ) ; webClient = null ; } if ( string . IsNullOrEmpty ( data ) ) new AresInfo ( ) ; XmlDocument xmlDocument = new XmlDocument ( ) ; xmlDocument . LoadXml ( data ) ; XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager ( xmlDocument . NameTable ) ; xmlNamespaceManager . AddNamespace ( " " , " " ) ; xmlNamespaceManager . AddNamespace ( " " , " " ) ; xmlNamespaceManager . AddNamespace ( " " , " " ) ; xmlNamespaceManager . AddNamespace ( " " , " " ) ; XmlNode recordsCountNode = xmlDocument . SelectSingleNode ( " " , xmlNamespaceManager ) ; if ( recordsCountNode == null ) return new AresInfo ( ) ; if ( ! int . TryParse ( recordsCountNode . InnerText , out int recordsCount ) ) return new AresInfo ( ) ; if ( recordsCount == 0 || recordsCount > 1 ) return new AresInfo ( ) ; var crn = xmlDocument . SelectSingleNode ( " " , xmlNamespaceManager ) == null ? string . Empty : xmlDocument . SelectSingleNode ( " " , xmlNamespaceManager ) . InnerText ; if ( string . IsNullOrEmpty ( crn ) ) return new AresInfo ( ) ; return GetInfoByCrn ( crn ) ; }
Gets ARES informations of the economic subject specified by .
Gets ARES informations of the economic subject specified by .
of the economic subject specified by , if there was found exactly one subject; otherwise empty .
of the economic subject specified by if there was found exactly one subject ; otherwise empty .
companyName
string
None