Beispiel #1
0
        public IDataContent <Company> GetData()
        {
            IDataContent <Company> dataContent = new CompanyContent();

            dataContent.Headers = Headers;

            MatchFactory factory = new MatchFactory();

            NumberBase concreteNumberType = factory.MatchNumber(NumbersToCheck, Number);

            if (concreteNumberType != null && concreteNumberType.IsValid(Number))
            {
                try
                {
                    Number = concreteNumberType.FormatNumber(Number);
                    ISession session = NHibernateManager.BeginSessionTransaction();
                    dataContent.Data = CompanyDAO.Instance.GetCompanyDataByNumber(Number, session);
                    NHibernateManager.CloseSessionTransaction();
                    dataContent.Status = StatusEnum.Valid.ToString();
                    if (dataContent.Data == null)
                    {
                        dataContent.Message = "Brak danych";
                        dataContent.Status  = StatusEnum.Error.ToString();
                    }
                }
                catch (Exception e)
                {
                    NHibernateManager.CloseSessionTransaction();
                    throw new Exception(e.Message);
                }
            }
            else
            {
                dataContent.Message = "Podany numer jest niepoprawny";
                dataContent.Status  = StatusEnum.Error.ToString();
            }
            LogManager log = new LogManager();

            log.LogData(dataContent);

            return(dataContent);
        }