public IAccountSettings Convert(ServiceAccount serviceAccount) { GoogleSheetsAccountSettings target = new GoogleSheetsAccountSettings(); target.ID = serviceAccount.ServiceAccountId; target.Name = serviceAccount.ServiceAccountName; target.Source = serviceAccount.Source; target.Tokens = new List <GoogleSheetsAccountToken>(); target.MinUpdateTime = serviceAccount.MinUpdateTime; target.AccountVersion = serviceAccount.AccountVersion; if (serviceAccount.Tokens.Count > 0) { foreach (Token token in serviceAccount.Tokens) { GoogleSheetsAccountToken targetToken = new GoogleSheetsAccountToken(); targetToken = (GoogleSheetsAccountToken)targetToken.Convert(token); target.Tokens.Add(targetToken); } } if (serviceAccount.MappingTemplates.Count > 0) { foreach (Template template in serviceAccount.MappingTemplates) { GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate(); targetTemplate = (GoogleSheetsAccountTemplate)targetTemplate.Convert(template); if (target.Templates != null) { target.Templates.Add(targetTemplate); } } } return(target); }
/// <summary> /// Convert Domain Object for serialization /// </summary> /// <param name="param">Object for converting</param> /// <param name="IsDetailsNeed">If Tokens and Mapping Templates needs</param> /// <returns></returns> public static ServiceAccount ServiceAccountDAOToDomain(this ServiceAccountDAO param, Boolean IsDetailsNeed = false) { ServiceAccount target = new ServiceAccount(); target.ServiceAccountId = param.ServiceAccountId; target.ServiceAccountName = param.ServiceAccountName; target.Source = param.Source; target.MinUpdateTime = param.MinUpdateTime; target.AccountVersion = param.AccountVersion; if (IsDetailsNeed) { if (param.Tokens != null) { target.Tokens = param.Tokens.Select<TokenDAO, Token>(x => x.TokenDAOToTokenDomain()).ToList(); } else { target.Tokens = null; } if (param.MappingTemplates != null) { target.MappingTemplates = param.MappingTemplates.Select<TemplateDAO, Template>(x => x.TemplateDAOToTemplateDomain()).ToList(); } else { target.MappingTemplates = null; } } return target; }
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); }
/// <summary> /// Convert Domain Object for serialization /// </summary> /// <param name="param">Object for converting</param> /// <param name="IsDetailsNeed">If Tokens and Mapping Templates needs</param> /// <returns></returns> public static ServiceAccount ServiceAccountDAOToDomain(this ServiceAccountDAO param, Boolean IsDetailsNeed = false) { ServiceAccount target = new ServiceAccount(); target.ServiceAccountId = param.ServiceAccountId; target.ServiceAccountName = param.ServiceAccountName; target.Source = param.Source; target.MinUpdateTime = param.MinUpdateTime; target.AccountVersion = param.AccountVersion; if (IsDetailsNeed) { if (param.Tokens != null) { target.Tokens = param.Tokens.Select <TokenDAO, Token>(x => x.TokenDAOToTokenDomain()).ToList(); } else { target.Tokens = null; } if (param.MappingTemplates != null) { target.MappingTemplates = param.MappingTemplates.Select <TemplateDAO, Template>(x => x.TemplateDAOToTemplateDomain()).ToList(); } else { target.MappingTemplates = null; } } return(target); }
public IAccountSettings Convert(ServiceAccount serviceAccount) { ExcelAccountSettings target = new ExcelAccountSettings(); target.ID = serviceAccount.ServiceAccountId; target.Name = serviceAccount.ServiceAccountName; target.Source = serviceAccount.Source; target.TestResult = serviceAccount.TestResult; target.AccountVersion = serviceAccount.AccountVersion; target.MinUpdateTime = serviceAccount.MinUpdateTime; target.Tokens = new List <ExcelAccountToken>(); target.Template = new List <ExcelAccountTemplate>(); if (serviceAccount.Tokens.Count > 0) { foreach (Token token in serviceAccount.Tokens) { ExcelAccountToken targetToken = new ExcelAccountToken(); targetToken = (ExcelAccountToken)targetToken.Convert(token); target.Tokens.Add(targetToken); } } if (serviceAccount.MappingTemplates.Count > 0) { foreach (Template template in serviceAccount.MappingTemplates) { ExcelAccountTemplate targetTemplate = new ExcelAccountTemplate(); targetTemplate = (ExcelAccountTemplate)targetTemplate.Convert(template); target.Template.Add(targetTemplate); } } return(target); }
public ServiceAccount Convert(IAccountSettings serviceAccount) { ServiceAccount target = new ServiceAccount(); ExcelAccountSettings currentAccount = (ExcelAccountSettings)serviceAccount; target.ServiceAccountId = currentAccount.ID; target.ServiceAccountName = currentAccount.Name; target.TestResult = currentAccount.TestResult; target.AccountVersion = serviceAccount.AccountVersion; target.MinUpdateTime = serviceAccount.MinUpdateTime; target.Source = Sources.Excel; List <Token> tok = new List <Token>(); List <Template> templ = new List <Template>(); if (currentAccount.Tokens.Count > 0) { foreach (ExcelAccountToken token in currentAccount.Tokens) { Token localtok = token.Convert(token); tok.Add(localtok); } target.Tokens = tok; } if (currentAccount.Template.Count > 0) { foreach (ExcelAccountTemplate template in currentAccount.Template) { Template localtemp = template.Convert(template); templ.Add(localtemp); } target.MappingTemplates = templ; } return(target); }
public static ServiceAccountDTO ServiceAccountDomainToDTO(this ServiceAccount param) { ServiceAccountDTO target = new ServiceAccountDTO(); target.ServiceAccountId = param.ServiceAccountId; target.ServiceAccountName = param.ServiceAccountName; target.Source = param.Source; target.TestResult = param.TestResult; target.MinUpdateTime = param.MinUpdateTime; target.AccountVersion = param.AccountVersion; if (param.Tokens != null) { target.Tokens = param.Tokens.Select <Token, TokenDTO>(x => x.TokenToTokenDTO()).ToList(); } else { target.Tokens = null; } if (param.MappingTemplates != null) { target.MappingTemplates = param.MappingTemplates.Select <Template, TemplateDTO>(x => x.TemplateToTemplateDTO()).ToList(); } else { target.MappingTemplates = null; } return(target); }
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 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); }
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 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 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); } }
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 ServiceAccountDTO GetUserAccountsByUserIDAndAccountId(Int32 userId, Int32 seviceAccountId) { ServiceAccountDTO UserAccountsDTO; ISessionFactory sessionFactory = NhibernateSessionFactory.GetSessionFactory(NhibernateSessionFactory.SessionFactoryConfiguration.Application); using (ISession session = sessionFactory.OpenSession()) { UserLinkDAO userLink = session.QueryOver <UserLinkDAO>().Where(x => x.UserId == userId).And(x => x.Account.ServiceAccountId == seviceAccountId).SingleOrDefault(); if (userLink != null) { ServiceAccount account = userLink.Account.ServiceAccountDAOToDomain(IsDetailsNeed: true); UserAccountsDTO = account.ServiceAccountDomainToDTO(); } else { UserAccountsDTO = null; } return(UserAccountsDTO); } }
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 ServiceAccount Convert(IAccountSettings serviceAccount) { ServiceAccount target = new ServiceAccount(); TrelloAccountSettings currentAccount = (TrelloAccountSettings)serviceAccount; target.ServiceAccountId = currentAccount.ID; target.ServiceAccountName = currentAccount.Name; target.Source = Sources.Trello; target.TestResult = currentAccount.TestResult; target.AccountVersion = currentAccount.AccountVersion; target.MinUpdateTime = currentAccount.MinUpdateTime; List <Token> tok = new List <Token>(); if (currentAccount.Tokens != null) { foreach (TrelloAccountToken token in currentAccount.Tokens) { Token localtok = token.Convert(token); tok.Add(localtok); } target.Tokens = tok.ToArray(); } return(target); }
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; }
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; } }
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 IAccountSettings Convert(ServiceAccount serviceAccount) { GoogleSheetsAccountSettings target = new GoogleSheetsAccountSettings(); target.ID = serviceAccount.ServiceAccountId; target.Name = serviceAccount.ServiceAccountName; target.Source = serviceAccount.Source; target.Tokens = new List<GoogleSheetsAccountToken>(); target.MinUpdateTime = serviceAccount.MinUpdateTime; target.AccountVersion = serviceAccount.AccountVersion; if (serviceAccount.Tokens.Count > 0) { foreach (Token token in serviceAccount.Tokens) { GoogleSheetsAccountToken targetToken = new GoogleSheetsAccountToken(); targetToken = (GoogleSheetsAccountToken)targetToken.Convert(token); target.Tokens.Add(targetToken); } } if (serviceAccount.MappingTemplates.Count > 0) { foreach (Template template in serviceAccount.MappingTemplates) { GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate(); targetTemplate = (GoogleSheetsAccountTemplate)targetTemplate.Convert(template); if (target.Templates != null) target.Templates.Add(targetTemplate); } } return target; }