コード例 #1
0
        public override string ToString()
        {
            return("AllData: [nip = " + NIP
                   + ", regon = " + REGON
                   + ", type = " + Type

                   + ", name = " + Name
                   + ", shortName = " + ShortName
                   + ", firstName = " + FirstName
                   + ", secondName = " + SecondName
                   + ", lastName = " + LastName

                   + ", street = " + Street
                   + ", streetCode = " + StreetCode
                   + ", streetNumber = " + StreetNumber
                   + ", houseNumber = " + HouseNumber
                   + ", city = " + City
                   + ", cityCode = " + CityCode
                   + ", community = " + Community
                   + ", communityCode = " + CommunityCode
                   + ", county = " + County
                   + ", countyCode = " + CountyCode
                   + ", state = " + State
                   + ", stateCode = " + StateCode
                   + ", postCode = " + PostCode
                   + ", postCity = " + PostCity

                   + ", phone = " + Phone
                   + ", email = " + Email
                   + ", www = " + WWW

                   + ", creationDate = " + CreationDate
                   + ", startDate = " + StartDate
                   + ", registrationDate = " + RegistrationDate
                   + ", holdDate = " + HoldDate
                   + ", renevalDate = " + RenevalDate
                   + ", lastUpdateDate = " + LastUpdateDate
                   + ", endDate = " + EndDate

                   + ", registryEntityCode = " + RegistryEntityCode
                   + ", registryEntityName = " + RegistryEntityName

                   + ", registryCode = " + RegistryCode
                   + ", registryName = " + RegistryName

                   + ", recordCreationDate = " + RecordCreationDate
                   + ", recordNumber = " + RecordNumber

                   + ", basicLegalFormCode = " + BasicLegalFormCode
                   + ", basicLegalFormName = " + BasicLegalFormName

                   + ", specificLegalFormCode = " + SpecificLegalFormCode
                   + ", specificLegalFormName = " + SpecificLegalFormName

                   + ", ownershipFormCode = " + OwnershipFormCode
                   + ", ownershipFormName = " + OwnershipFormName

                   + ", pkd = [" + string.Join(", ", PKD.ConvertAll(e => Convert.ToString(e)).ToArray()) + "]"
                   + "]");
        }
コード例 #2
0
        /// <summary>
        /// Lista PKD jako ciąg
        /// </summary>
        /// <returns>lista PKD</returns>
        private string GetPKDString()
        {
            string s = "";

            foreach (PKD pkd in PKD)
            {
                if (s.Length > 0)
                {
                    s += ", ";
                }

                s += PKD.ToString();
            }

            return(s);
        }
コード例 #3
0
        /// <summary>
        /// Pobranie szczegółowych danych firmy
        /// </summary>
        /// <param name="type">typ numeru identyfikującego firmę</param>
        /// <param name="number">numer określonego typu</param>
        /// <param name="force">jeżeli true zostanie wymuszone zapytanie do GUS w celu pobrania najświeższych danych (trwa dłużej)</param>
        /// <returns>dane firmy lub null w przypadku błędu</returns>
        public AllData GetAllData(Number type, string number, bool force = false)
        {
            try
            {
                // clear error
                LastError = string.Empty;

                // validate number and construct path
                string suffix = null;

                if ((suffix = GetPathSuffix(type, number)) == null)
                {
                    return(null);
                }

                // prepare url
                Uri url = new Uri(URL + (force ? "/getf" : "/get") + "/all/" + suffix);

                // prepare request
                XPathDocument doc = Get(url);

                if (doc == null)
                {
                    LastError = "Nie udało się nawiązać połączenia z serwisem NIP24";
                    return(null);
                }

                // parse response
                string res = GetString(doc, "/result/error/code", null);

                if (res != null)
                {
                    LastError = GetString(doc, "/result/error/description", null);
                    return(null);
                }

                AllData ad = new AllData();

                ad.UID = GetString(doc, "/result/firm/uid", null);

                ad.NIP   = GetString(doc, "/result/firm/nip", null);
                ad.Type  = GetString(doc, "/result/firm/type", null);
                ad.NIP   = GetString(doc, "/result/firm/nip", null);
                ad.REGON = GetString(doc, "/result/firm/regon", null);

                ad.Name       = GetString(doc, "/result/firm/name", null);
                ad.ShortName  = GetString(doc, "/result/firm/shortname", null);
                ad.FirstName  = GetString(doc, "/result/firm/firstname", null);
                ad.SecondName = GetString(doc, "/result/firm/secondname", null);
                ad.LastName   = GetString(doc, "/result/firm/lastname", null);

                ad.Street        = GetString(doc, "/result/firm/street", null);
                ad.StreetCode    = GetString(doc, "/result/firm/streetCode", null);
                ad.StreetNumber  = GetString(doc, "/result/firm/streetNumber", null);
                ad.HouseNumber   = GetString(doc, "/result/firm/houseNumber", null);
                ad.City          = GetString(doc, "/result/firm/city", null);
                ad.CityCode      = GetString(doc, "/result/firm/cityCode", null);
                ad.Community     = GetString(doc, "/result/firm/community", null);
                ad.CommunityCode = GetString(doc, "/result/firm/communityCode", null);
                ad.County        = GetString(doc, "/result/firm/county", null);
                ad.CountyCode    = GetString(doc, "/result/firm/countyCode", null);
                ad.State         = GetString(doc, "/result/firm/state", null);
                ad.StateCode     = GetString(doc, "/result/firm/stateCode", null);
                ad.PostCode      = GetString(doc, "/result/firm/postCode", null);
                ad.PostCity      = GetString(doc, "/result/firm/postCity", null);

                ad.Phone = GetString(doc, "/result/firm/phone", null);
                ad.Email = GetString(doc, "/result/firm/email", null);
                ad.WWW   = GetString(doc, "/result/firm/www", null);

                ad.CreationDate     = GetDateTime(doc, "/result/firm/creationDate");
                ad.StartDate        = GetDateTime(doc, "/result/firm/startDate");
                ad.RegistrationDate = GetDateTime(doc, "/result/firm/registrationDate");
                ad.HoldDate         = GetDateTime(doc, "/result/firm/holdDate");
                ad.RenevalDate      = GetDateTime(doc, "/result/firm/renevalDate");
                ad.LastUpdateDate   = GetDateTime(doc, "/result/firm/lastUpdateDate");
                ad.EndDate          = GetDateTime(doc, "/result/firm/endDate");

                ad.RegistryEntityCode = GetString(doc, "/result/firm/registryEntity/code", null);
                ad.RegistryEntityName = GetString(doc, "/result/firm/registryEntity/name", null);

                ad.RegistryCode = GetString(doc, "/result/firm/registry/code", null);
                ad.RegistryName = GetString(doc, "/result/firm/registry/name", null);

                ad.RecordCreationDate = GetDateTime(doc, "/result/firm/record/created");
                ad.RecordNumber       = GetString(doc, "/result/firm/record/number", null);

                ad.BasicLegalFormCode = GetString(doc, "/result/firm/basicLegalForm/code", null);
                ad.BasicLegalFormName = GetString(doc, "/result/firm/basicLegalForm/name", null);

                ad.SpecificLegalFormCode = GetString(doc, "/result/firm/specificLegalForm/code", null);
                ad.SpecificLegalFormName = GetString(doc, "/result/firm/specificLegalForm/name", null);

                ad.OwnershipFormCode = GetString(doc, "/result/firm/ownershipForm/code", null);
                ad.OwnershipFormName = GetString(doc, "/result/firm/ownershipForm/name", null);

                for (int i = 1; ; i++)
                {
                    string code = GetString(doc, "/result/firm/PKDs/PKD[" + i + "]/code", null);

                    if (code == null)
                    {
                        break;
                    }

                    string descr = GetString(doc, "/result/firm/PKDs/PKD[" + i + "]/description", null);
                    string pri   = GetString(doc, "/result/firm/PKDs/PKD[" + i + "]/primary", "false");

                    PKD pkd = new PKD();

                    pkd.Code        = code;
                    pkd.Description = descr;
                    pkd.Primary     = pri.Equals("true");

                    ad.PKD.Add(pkd);
                }

                return(ad);
            }
            catch (Exception e)
            {
                LastError = e.Message;
            }

            return(null);
        }