示例#1
0
 private bool?IsActive(BiRCompany biRCompany)
 {
     if (biRCompany.CompanyType == BiRCompanyType.Prawna)
     {
         if (biRCompany.ZawieszeniaDate == DateTime.MinValue && biRCompany.ZakonczeniaDzialalnosciDate == DateTime.MinValue && biRCompany.SkresleniaRegonDate == DateTime.MinValue && biRCompany.OrzeczenieOUpadlosciDate == DateTime.MinValue && biRCompany.ZakonczeniePostepowaniaUpadlosiowegoDate == DateTime.MinValue)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else // Os. Fizyczna
     {
         if (biRCompany.ZawieszeniaDate == DateTime.MinValue && biRCompany.ZakonczeniaDzialalnosciDate == DateTime.MinValue && biRCompany.SkresleniaRegonDate == DateTime.MinValue && biRCompany.OrzeczenieOUpadlosciDate == DateTime.MinValue && biRCompany.ZakonczeniePostepowaniaUpadlosiowegoDate == DateTime.MinValue)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
示例#2
0
        internal static BiRCompany GetCompanyFromDaneSzukajPodmiotyResponse(string response)
        {
            if (string.IsNullOrEmpty(response))
            {
                throw new ArgumentOutOfRangeException(response, "Odpowiedź jest null lub pusta od klienta BiR.");
            }

            BiRCompany company = new BiRCompany();
            XElement   root    = XElement.Parse(response);

            company.Regon          = root.Descendants().First(d => d.Name == _regonElName).Value.Trim();
            company.NIP            = root.Descendants().First(d => d.Name == _nipElName).Value.Trim();
            company.NipStatus      = root.Descendants().First(d => d.Name == _statusNipElName).Value.Trim();
            company.Name           = root.Descendants().First(d => d.Name == _nameElName).Value.Trim();
            company.Wojewodztwo    = root.Descendants().First(d => d.Name == _wojewodztwoElName).Value.Trim();
            company.Powiat         = root.Descendants().First(d => d.Name == _powiatElName).Value.Trim();
            company.Gmina          = root.Descendants().First(d => d.Name == _gminaElName).Value.Trim();
            company.Town           = root.Descendants().First(d => d.Name == _townElName).Value.Trim();
            company.PostalCode     = root.Descendants().First(d => d.Name == _postalCodeElName).Value.Trim();
            company.Street         = GetValueFrom(root, _streetElName);
            company.BuildingNumber = root.Descendants().First(d => d.Name == _buildingNumElName).Value.Trim();
            company.LocalNumber    = root.Descendants().First(d => d.Name == _apartmentNumElName).Value.Trim();

            company.Type    = root.Descendants().First(d => d.Name == _typeElName).Value.Trim();
            company.SilosID = root.Descendants().First(d => d.Name == _silosIDElName).Value.Trim();
            string dateInStr = root.Descendants().First(d => d.Name == _finishDateElName).Value.Trim();

            company.ZakonczeniaDzialalnosciDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);

            company.CompanyType = (company.Type == "P") ? BiRCompanyType.Prawna : BiRCompanyType.FizycznaProwadzacaDzialalnoscGosp;

            return(company);
        }
示例#3
0
        private string GetMessageWithDetailedData(BiRVerifyResult result, BiRCompany biRCompany)
        {
            string fullMessage = result.Message;

            if (biRCompany.ZawieszeniaDate != DateTime.MinValue)
            {
                fullMessage = string.Concat(fullMessage, $" Data zawieszenia działaności: {biRCompany.ZawieszeniaDate.ToShortDateString()}.");
            }
            if (biRCompany.ZakonczeniaDzialalnosciDate != DateTime.MinValue)
            {
                fullMessage = string.Concat(fullMessage, $" Data zakończenia: {biRCompany.ZakonczeniaDzialalnosciDate.ToShortDateString()}.");
            }
            if (biRCompany.SkresleniaRegonDate != DateTime.MinValue)
            {
                fullMessage = string.Concat(fullMessage, $" Data skreślenia z Regon: {biRCompany.SkresleniaRegonDate.ToShortDateString()}.");
            }
            if (biRCompany.OrzeczenieOUpadlosciDate != DateTime.MinValue)
            {
                fullMessage = string.Concat(fullMessage, $" Data orzeczenia o upadłości: {biRCompany.OrzeczenieOUpadlosciDate.ToShortDateString()}.");
            }
            if (biRCompany.ZakonczeniePostepowaniaUpadlosiowegoDate != DateTime.MinValue)
            {
                fullMessage = string.Concat(fullMessage, $" Data zakończenia postępowania upadłościowego: {biRCompany.ZakonczeniePostepowaniaUpadlosiowegoDate.ToShortDateString()}.");
            }

            return(fullMessage);
        }
示例#4
0
        private BiRVerifyResult IsCompanyActive(string nip)
        {
            if (string.IsNullOrEmpty(nip))
            {
                return(new BiRVerifyResult(BiRVerifyStatus.NipIncorrect));
            }

            string     nipPure    = nip.Replace(_dash, string.Empty).Replace(_space, string.Empty).Trim();
            BiRCompany biRCompany = _client.GetCompany(nipPure);

            if (biRCompany == null)
            {
                return(new BiRVerifyResult(_client.GetLastErrorStatus()));
            }

            if (IsActive(biRCompany) ?? true)
            {
                return(new BiRVerifyResult(BiRVerifyStatus.IsActive));
            }
            else
            {
                BiRVerifyResult result = new BiRVerifyResult(BiRVerifyStatus.IsNotActive);
                result.Message = GetMessageWithDetailedData(result, biRCompany);
                return(result);
            }
        }
示例#5
0
        public static void AddDanePrawna(ref BiRCompany company, string result)
        {
            XElement root = XElement.Parse(result);

            company.RodzajRejestruEwidencji = root.Descendants().First(d => d.Name == _praw_RodzajRejEwidNazwaElName).Value.Trim();
            company.NumWRejestrzeEwidencji  = root.Descendants().First(d => d.Name == _praw_NumerWRejEwidElName).Value.Trim();
            company.OrganZalozycielski      = root.Descendants().First(d => d.Name == _praw_OrganZalozyNazwaElName).Value.Trim();
            company.OrganRejestrowy         = root.Descendants().First(d => d.Name == _praw_OrganRejestrowyNazwaElName).Value.Trim();
            company.FormaWlasnosci          = root.Descendants().First(d => d.Name == _praw_FormaWlanosciNazwaElName).Value.Trim();
            company.FormaFinansowania       = root.Descendants().First(d => d.Name == _praw_FormaFinansowaniaNazwaElName).Value.Trim();
            company.SzczegolnaFormaPrawna   = root.Descendants().First(d => d.Name == _praw_SzczegolnaFormaPrawnaNazwaElName).Value.Trim();
            company.PodstawowaFormaPrawna   = root.Descendants().First(d => d.Name == _praw_PodstaowaFormaPrawnaNazwaElName).Value.Trim();
            company.NameShort = root.Descendants().First(d => d.Name == _praw_NazwaSkroconaElName).Value.Trim();


            string dateInStr = string.Empty;

            dateInStr            = root.Descendants().First(d => d.Name == _praw_DataPowstaniaElName).Value.Trim();
            company.CreationDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);
            dateInStr            = root.Descendants().First(d => d.Name == _praw_DataRozpoczeciaDzialElName).Value.Trim();
            company.StartRunDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);

            dateInStr         = root.Descendants().First(d => d.Name == _praw_DataWpisuDoRegonElName).Value.Trim();
            company.RegonDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);

            dateInStr = root.Descendants().First(d => d.Name == _praw_DataWpisuDoRejestruEwidencjiElName).Value.Trim();
            company.WpisDoRejestruEwidencjiDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);

            dateInStr = root.Descendants().First(d => d.Name == _praw_DataZawieszeniaDzialanosciElName).Value.Trim();
            company.ZawieszeniaDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);
            dateInStr = root.Descendants().First(d => d.Name == _praw_DataWaznosiDzialnosciElName).Value.Trim();
            company.WziowieniaDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);
            dateInStr = root.Descendants().First(d => d.Name == _praw_DataZaistnieniaZmianyElName).Value.Trim();
            company.ZaistnieniaZmianyDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);
            dateInStr = root.Descendants().First(d => d.Name == _praw_DataZakonczeniaDzialalnosciElName).Value.Trim();
            company.ZakonczeniaDzialalnosciDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);
            dateInStr = root.Descendants().First(d => d.Name == _praw_DataSkresleniaZRegonElName).Value.Trim();
            company.SkresleniaRegonDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);

            dateInStr = root.Descendants().First(d => d.Name == _praw_DataOrzeczeniaOUpadlosciElName).Value.Trim();
            company.OrzeczenieOUpadlosciDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);

            dateInStr = root.Descendants().First(d => d.Name == _praw_DataZakoczeniaPostepUpadlElName).Value.Trim();
            company.ZakonczeniePostepowaniaUpadlosiowegoDate = string.IsNullOrEmpty(dateInStr) ? DateTime.MinValue : DateTime.Parse(dateInStr);

            company.SiedzibaNietypoweMiejsceLokalizacji = root.Descendants().First(d => d.Name == _praw_AdresNietypowejLokalizajiElName).Value.Trim();
            company.NumerTelefonu = root.Descendants().First(d => d.Name == _praw_NumerTelefonuElName).Value.Trim();
            company.NumerFaksu    = root.Descendants().First(d => d.Name == _praw_NumerFaksuElName).Value.Trim();
            company.Email         = root.Descendants().First(d => d.Name == _praw_AdresEmailElName).Value.Trim();
            company.WWW           = root.Descendants().First(d => d.Name == _praw_AdresStronyInterElName).Value.Trim();
        }
示例#6
0
        public static void AddDaneFizycznaCedig(ref BiRCompany company, string result)
        {
            XElement root = XElement.Parse(result);

            company.RodzajRejestruEwidencji = root.Descendants().First(d => d.Name == _fiz_RodzajRejestruNazwaElName).Value.Trim();
            company.NumWRejestrzeEwidencji  = root.Descendants().First(d => d.Name == _fiz_NumerWRejEwidencjiElName).Value.Trim();
            company.OrganRejestrowy         = root.Descendants().First(d => d.Name == _fiz_OrganRejestrowyNazwaElName).Value.Trim();

            company.NameShort = root.Descendants().First(d => d.Name == _fiz_NazwaSkroconaElName).Value.Trim();

            string dateInString = string.Empty;

            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataPowstaniaElName).Value.Trim();
            company.CreationDate                 = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataRozpDzialanElName).Value.Trim();
            company.StartRunDate                 = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataWpisuDzialnDoRegonElName).Value.Trim();
            company.RegonDate                    = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataZawieszeniaDzialElName).Value.Trim();
            company.ZawieszeniaDate              = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataWznowieniaDzialElName).Value.Trim();
            company.WziowieniaDate               = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataZaistnieniaZmianyDzialElName).Value.Trim();
            company.ZaistnieniaZmianyDate        = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataZakonczeniaDzialElName).Value.Trim();
            company.ZakonczeniaDzialalnosciDate  = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataSkreleniaDzialnosciZRegonElName).Value.Trim();
            company.SkresleniaRegonDate          = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataWpisuDoRejestruEwidencjiElName).Value.Trim();
            company.WpisuDoRejestruEwidencji     = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);
            dateInString                         = root.Descendants().First(d => d.Name == _fiz_DataSkresleniaZRejestruEwidencjiElName).Value.Trim();
            company.SkresleniaZRejestruEwidencji = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);

            dateInString = root.Descendants().First(d => d.Name == _fiz_DataOrzeczeniaoOUpadlosciElName).Value.Trim();
            company.OrzeczenieOUpadlosciDate = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);

            dateInString = root.Descendants().First(d => d.Name == _fiz_DataZakonczeniaPstepowaniaUpadlElName).Value.Trim();
            company.ZakonczeniePostepowaniaUpadlosiowegoDate = string.IsNullOrEmpty(dateInString) ? DateTime.MinValue : DateTime.Parse(dateInString);

            string boolStr = root.Descendants().First(d => d.Name == _fiz_NiePodjetoDzialansociElName).Value;

            company.NiePodjetoDzialanosci = string.IsNullOrEmpty(boolStr) ? false : bool.Parse(boolStr);


            company.SiedzibaNietypoweMiejsceLokalizacji = root.Descendants().First(d => d.Name == _fiz_AdSiedzNietypoweMiejsceLokazlizacjiElName).Value;
            company.NumerTelefonu = root.Descendants().First(d => d.Name == _fiz_NumerTelefonuElName).Value;
            company.NumerFaksu    = root.Descendants().First(d => d.Name == _fiz_NumberFaksuElName).Value;
            company.Email         = root.Descendants().First(d => d.Name == _fiz_AdresEmailElName).Value;
            company.WWW           = root.Descendants().First(d => d.Name == _fiz_AdresStronyInternetowejElName).Value;
        }
示例#7
0
        public BiRCompany GetCompany(string nip)
        {
            try
            {
                _lastVerifyStatus = BiRVerifyStatus.NoSearchYet;

                var paramse = new ParametryWyszukiwania();
                paramse.Nip = nip;


                string errorCode;
                if (couter == 24)
                {
                    Init();
                    couter = 0;
                }
                string result = _client.DaneSzukajPodmioty(paramse);
                couter++;


                if (BiRResponseXMLParser.IsResponseEmpty(result) || BiRResponseXMLParser.ContainsError(result))
                {
                    errorCode = _client.GetValue(_codeOfMessageFromService);
                    Console.WriteLine(errorCode);
                    if (string.IsNullOrEmpty(errorCode) || errorCode.Equals(_errCodeForNoSession))
                    {
                        LogIn(false);
                        result = _client.DaneSzukajPodmioty(paramse);
                        if (BiRResponseXMLParser.IsResponseEmpty(result) || BiRResponseXMLParser.ContainsError(result))
                        {
                            errorCode = _client.GetValue(_codeOfMessageFromService);
                        }
                    }

                    if (!errorCode.Equals(_errCodeForEverythingOK))
                    {
                        _lastVerifyStatus = GetStatusFromErrorCode(errorCode, result);
                        return(null);
                    }
                }

                BiRCompany company = BiRResponseXMLParser.GetCompanyFromDaneSzukajPodmiotyResponse(result);

                // "P" = Typ podmiotu  rejestru REGON:  jednostka prawna(= osoba  prawna lub  jednostka organizacyjna
                // nieposiadająca osobowości prawnej, np.spółka cywilna)
                if (company.Type == _prawnaCompanyType)
                {
                    company.CompanyType = BiRCompanyType.Prawna;
                    result = _client.DanePobierzPelnyRaport(company.Regon, _raportOsPrawnaName);
                    if (BiRResponseXMLParser.IsResponseEmpty(result) || BiRResponseXMLParser.ContainsError(result))
                    {
                        errorCode = _client.GetValue(_codeOfMessageFromService);
                        if (string.IsNullOrEmpty(errorCode) || errorCode.Equals(_errCodeForNoSession))
                        {
                            LogIn(false);
                            result = _client.DanePobierzPelnyRaport(company.Regon, _raportOsPrawnaName);
                            if (BiRResponseXMLParser.IsResponseEmpty(result) || BiRResponseXMLParser.ContainsError(result))
                            {
                                errorCode = _client.GetValue(_codeOfMessageFromService);
                            }
                        }
                        if (!errorCode.Equals(_errCodeForEverythingOK))
                        {
                            _lastVerifyStatus = GetStatusFromErrorCode(errorCode, result);
                            return(null);
                        }
                    }

                    BiRResponseXMLParser.AddDanePrawna(ref company, result);
                }
                // Typ podmiotu rejestru REGON: jedn. fizyczna (= os. fizyczna prowadząca działalność gospodarczą)
                else if (company.Type == _osFizycznaCompanyType && company.SilosID == _dzialnoscWpisanaDoCedigSilosType)
                {
                    company.CompanyType = BiRCompanyType.FizycznaProwadzacaDzialalnoscGosp;
                    result = _client.DanePobierzPelnyRaport(company.Regon, _raportOsFizCedigName);
                    if (BiRResponseXMLParser.IsResponseEmpty(result) || BiRResponseXMLParser.ContainsError(result))
                    {
                        errorCode = _client.GetValue(_codeOfMessageFromService);
                        if (string.IsNullOrEmpty(errorCode) || errorCode.Equals(_errCodeForNoSession))
                        {
                            LogIn(false);
                            result = _client.DanePobierzPelnyRaport(company.Regon, _raportOsFizCedigName);
                            if (BiRResponseXMLParser.IsResponseEmpty(result) || BiRResponseXMLParser.ContainsError(result))
                            {
                                errorCode = _client.GetValue(_codeOfMessageFromService);
                            }
                        }
                        if (!errorCode.Equals(_errCodeForEverythingOK))
                        {
                            _lastVerifyStatus = GetStatusFromErrorCode(errorCode, result);
                            return(null);
                        }
                    }
                    BiRResponseXMLParser.AddDaneFizycznaCedig(ref company, result);
                }
                else
                {
                    // inaczej może być jeszcze LP i LF, czyli jednostek lokalnych
                    throw new ArgumentOutOfRangeException(result, "Zapytanie zwróciło nieobsługiwany typ podmiotu tj. typ = " + company.Type + " , silos = " + company.SilosID);
                }
                return(company);
            } catch (Exception e)
            {
            }

            return(null);
        }