Ejemplo n.º 1
0
        public static List <IAccountSettings> GetAllAccounts()
        {
            List <IAccountSettings> allUserAccounts = new List <IAccountSettings>();

            using (ISession session = sessionFactory.OpenSession())
            {
                var allUserLinks = session.QueryOver <UserLinkDAO>().List();
                if (allUserLinks != null)
                {
                    List <ServiceAccountDAO> allUserAccountsDAO = allUserLinks.Select <UserLinkDAO, ServiceAccountDAO>(x => x.Account).ToList();
                    List <ServiceAccount>    allUserAc          = SettingsConverter.ServiceAccountDAOCollectionToDomain(allUserAccountsDAO);
                    foreach (ServiceAccount account in allUserAc)
                    {
                        IAccountSettings temp = GetCurrentInstance(account.Source);

                        allUserAccounts.Add(temp.Convert(account));
                    }
                }
                else
                {
                    allUserAccounts = null;
                }

                return(allUserAccounts);
            }
        }
        public ServiceAccountDTO TestExcelAccount(ServiceAccountDTO accountForTest, Byte[] fileForParce)
        {
            IAccountSettings currentAccountForTest = SettingsManager.GetCurrentInstance(accountForTest.Source);

            currentAccountForTest = currentAccountForTest.Convert(accountForTest.ServiceAccountDTOToDomain());
            ExcelAdapter currentAdapter = new ExcelAdapter(currentAccountForTest, fileForParce);

            IAccountSettings testResult   = currentAdapter.TestAccount(currentAccountForTest);
            ServiceAccount   resultDomain = new ServiceAccount();

            resultDomain = testResult.Convert(testResult);
            ServiceAccountDTO result = resultDomain.ServiceAccountDomainToDTO();

            return(result);
        }
Ejemplo n.º 3
0
        public static IAccountSettings GetAccountByTokenID(Int32 id)
        {
            IAccountSettings targetAccount = null;

            using (ISession session = sessionFactory.OpenSession())
            {
                TokenDAO          token         = session.Get <TokenDAO>(id);
                ServiceAccountDAO accountFromDB = session.Query <ServiceAccountDAO>().Where(x => x.Tokens.Contains(token)).SingleOrDefault();
                if (accountFromDB != null)
                {
                    targetAccount = GetCurrentInstance(accountFromDB.Source);
                    if (targetAccount != null)
                    {
                        ServiceAccount accountDomain = accountFromDB.ServiceAccountDAOToDomain(true);
                        targetAccount = targetAccount.Convert(accountDomain);
                    }
                }
                return(targetAccount);
            }
        }
        public ServiceAccountDTO TestAccount(ServiceAccountDTO accountForTest)
        {
            IAdapter currentAdapter = AdapterInstanceFactory.GetCurentAdapterInstance(accountForTest.Source);

            if (currentAdapter != null)
            {
                IAccountSettings currentAccountForTest = SettingsManager.GetCurrentInstance(accountForTest.Source);

                currentAccountForTest = currentAccountForTest.Convert(accountForTest.ServiceAccountDTOToDomain());

                IAccountSettings testResult   = currentAdapter.TestAccount(currentAccountForTest);
                ServiceAccount   resultDomain = new ServiceAccount();
                resultDomain = testResult.Convert(testResult);
                ServiceAccountDTO result = resultDomain.ServiceAccountDomainToDTO();
                return(result);
            }
            else
            {
                accountForTest.TestResult = false;
                return(accountForTest);
            }
        }