public bool Equals(IAccountSettings accountToCompare)
 {
     if (accountToCompare is DatabaseAccountSettings)
     {
         DatabaseAccountSettings DBAccountToCompere = (DatabaseAccountSettings)accountToCompare;
         return(this.ID == DBAccountToCompere.ID && this.AccountVersion == DBAccountToCompere.AccountVersion);
     }
     return(false);
 }
        public IAdapter GetAdapter(IAccountSettings account)
        {
            DatabaseAccountSettings dbAccount = (DatabaseAccountSettings)account;

            allTokensInAccount = dbAccount.Tokens;
            foreach (var token in allTokensInAccount)
            {
                allFactories.GetSessionFactory(token);
            }
            adapterLastUpdate = DateTime.MinValue;
            MinUpdateTime     = account.MinUpdateTime;
            return(this);
        }
        public IAccountSettings TestAccount(IAccountSettings accountnForTest)
        {
            DatabaseAccountSettings accountForTestDB = (DatabaseAccountSettings)accountnForTest;
            DatabaseAccountToken    tokenForTest     = accountForTestDB.Tokens.FirstOrDefault();
            Boolean result = false;

            if (tokenForTest != null)
            {
                if (tokenForTest.Mapping == null)
                {
                    result = ClientNHibernateSessionFactory.TestAccount(tokenForTest);
                }
                else
                {
                    result = ClientNHibernateSessionFactory.TestAccount(tokenForTest, true);
                }
            }
            accountForTestDB.TestResult = result;
            return(accountForTestDB);
        }
        public IAccountSettings Convert(ServiceAccount serviceAccount)
        {
            DatabaseAccountSettings target = new DatabaseAccountSettings();
            target.ID = serviceAccount.ServiceAccountId;
            target.Name = serviceAccount.ServiceAccountName;
            target.Source = serviceAccount.Source;
            target.MinUpdateTime = serviceAccount.MinUpdateTime * 60000;
            target.AccountVersion = serviceAccount.AccountVersion;
            target.Tokens = new List<DatabaseAccountToken>();

            if (serviceAccount.Tokens.Count > 0)
            {
                foreach (Token token in serviceAccount.Tokens)
                {
                    DatabaseAccountToken targetToken = new DatabaseAccountToken();
                    targetToken = (DatabaseAccountToken)targetToken.Convert(token);
                    target.Tokens.Add(targetToken);
                }
            }
            return target;
        }
        public IAccountSettings Convert(ServiceAccount serviceAccount)
        {
            DatabaseAccountSettings target = new DatabaseAccountSettings();

            target.ID             = serviceAccount.ServiceAccountId;
            target.Name           = serviceAccount.ServiceAccountName;
            target.Source         = serviceAccount.Source;
            target.MinUpdateTime  = serviceAccount.MinUpdateTime * 60000;
            target.AccountVersion = serviceAccount.AccountVersion;
            target.Tokens         = new List <DatabaseAccountToken>();

            if (serviceAccount.Tokens.Count > 0)
            {
                foreach (Token token in serviceAccount.Tokens)
                {
                    DatabaseAccountToken targetToken = new DatabaseAccountToken();
                    targetToken = (DatabaseAccountToken)targetToken.Convert(token);
                    target.Tokens.Add(targetToken);
                }
            }
            return(target);
        }
        public ServiceAccount Convert(IAccountSettings service)
        {
            ServiceAccount          target         = new ServiceAccount();
            DatabaseAccountSettings serviceAccount = (DatabaseAccountSettings)service;

            target.ServiceAccountId   = serviceAccount.ID;
            target.ServiceAccountName = serviceAccount.Name;
            target.Source             = serviceAccount.Source;
            target.TestResult         = serviceAccount.TestResult;
            target.MinUpdateTime      = serviceAccount.MinUpdateTime / 60000;
            target.AccountVersion     = serviceAccount.AccountVersion;
            target.Tokens             = new List <Token>();

            if (serviceAccount.Tokens.Count > 0)
            {
                foreach (DatabaseAccountToken token in serviceAccount.Tokens)
                {
                    Token targetToken = new Token();
                    targetToken = token.Convert(token);
                    target.Tokens.Add(targetToken);
                }
            }
            return(target);
        }