public ServiceAccount Convert(IAccountSettings service)
        {
            ServiceAccount target = new ServiceAccount();
            GoogleSheetsAccountSettings serviceAccount = (GoogleSheetsAccountSettings)service;

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

            if (serviceAccount.Tokens != null && serviceAccount.Tokens.Count > 0)
            {
                foreach (GoogleSheetsAccountToken token in serviceAccount.Tokens)
                {
                    Token targetToken = new Token();
                    targetToken = token.Convert(token);
                    target.Tokens.Add(targetToken);
                }
            }
            if (serviceAccount.Templates != null && serviceAccount.Templates.Count > 0)
            {
                foreach (GoogleSheetsAccountTemplate template in serviceAccount.Templates)
                {
                    Template targetTemplate = new Template();
                    targetTemplate = template.Convert(template);
                    target.MappingTemplates.Add(targetTemplate);
                }
            }
            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;
        }
        public Token Convert(IAccountToken token)
        {
            Token targetToken = new Token();
            DatabaseAccountToken paramToken = (DatabaseAccountToken)token;

            targetToken.TokenId = paramToken.TokenId;
            targetToken.TokenName = paramToken.TokenName;
            targetToken.Tokens.Add("ConnectionString", paramToken.ConnectionString);
            targetToken.Tokens.Add("UserName", paramToken.UserName);
            targetToken.Tokens.Add("Password", paramToken.Password);
            targetToken.Tokens.Add("DataSource", paramToken.DataSource);
            targetToken.Tokens.Add("Mapping", paramToken.Mapping);
            targetToken.Tokens.Add("DatabaseDriver", paramToken.DatabaseDriver.ToString());
            targetToken.Tokens.Add("DatabaseDialect", paramToken.DatabaseDialect.ToString());

            return targetToken;
        }
        public IAccountToken Convert(Token token)
        {
            DatabaseAccountToken targetToken = new DatabaseAccountToken();
            targetToken.TokenId = token.TokenId;
            targetToken.TokenName = token.TokenName;
            if (token.Tokens != null)
            {

                targetToken.Mapping = (from tok in token.Tokens
                                       where tok.Key == "Mapping"
                                       select tok.Value).SingleOrDefault();

                targetToken.Password = (from tok in token.Tokens
                                        where tok.Key == "Password"
                                        select tok.Value).SingleOrDefault();

                targetToken.ConnectionString = (from tok in token.Tokens
                                                where tok.Key == "ConnectionString"
                                                select tok.Value).SingleOrDefault();

                targetToken.UserName = (from tok in token.Tokens
                                        where tok.Key == "UserName"
                                        select tok.Value).SingleOrDefault();

                targetToken.DataSource = (from tok in token.Tokens
                                          where tok.Key == "DataSource"
                                          select tok.Value).SingleOrDefault();

                String dialect = (from tok in token.Tokens
                                    where tok.Key == "DatabaseDialect"
                                    select tok.Value).SingleOrDefault();

                DatabaseDialect dbDialect;
                Enum.TryParse(dialect, out dbDialect);
                targetToken.DatabaseDialect = dbDialect;

                String Driver = (from tok in token.Tokens
                                  where tok.Key == "DatabaseDriver"
                                 select tok.Value).SingleOrDefault();

                DatabaseDriver dbDriver;
                Enum.TryParse(Driver, out dbDriver);
                targetToken.DatabaseDriver = dbDriver;
            }

            return targetToken;
        }
        public IAccountToken Convert(Token token)
        {
            GoogleSheetsAccountToken targetToken = new GoogleSheetsAccountToken();
            targetToken.TokenId = token.TokenId;
            targetToken.TokenName = token.TokenName;
            if (token.Tokens.Count > 0)
            {
                targetToken.RefreshToken = (from tok in token.Tokens
                                            where tok.Key == "RefreshToken"
                                            select tok.Value).SingleOrDefault();
            }

            return targetToken;
        }
        public Token Convert(IAccountToken token)
        {
            Token targetToken = new Token();
            GoogleSheetsAccountToken paramToken = (GoogleSheetsAccountToken)token;

            targetToken.TokenId = paramToken.TokenId;
            targetToken.TokenName = paramToken.TokenName;
            targetToken.Tokens.Add("RefreshToken", paramToken.RefreshToken);

            return targetToken;
        }
Пример #7
0
        public static Token TokenDTOToTokenDomain(this TokenDTO param)
        {
            Token target = new Token();

            target.TokenId = param.TokenId;
            target.TokenName = param.TokenName;

            foreach (TokenForSerialization item in param.Tokens)
            {
                if (item.Key != null && item.Value != null)
                {
                    target.Tokens.Add(item.Key, item.Value);
                }

            }

            return target;
        }
Пример #8
0
        public static Token TokenDAOToTokenDomain(this TokenDAO param)
        {
            Token target = new Token();

            target.TokenId = param.TokenId;
            target.TokenName = param.TokenName;
            target.Tokens = param.Token;

            return target;
        }