public IAccountSettings TestAccount(IAccountSettings accountnForTest) { TrelloAccountSettings accountForTestTrello = (TrelloAccountSettings)accountnForTest; TrelloAccountToken testToken = accountForTestTrello.Tokens.FirstOrDefault(); accountForTestTrello.Tokens.Clear(); _trello.Authorize(testToken.UserToken); try { accountForTestTrello.TestResult = true; accountForTestTrello.Source = Sources.Trello; var boards = _trello.Boards.ForMe(); foreach (var board in boards) { TrelloAccountToken newToken = new TrelloAccountToken(); newToken.BoardID = board.Id; newToken.TokenName = board.Name; newToken.UserToken = testToken.UserToken; newToken.DateCreation = DateTime.Now; accountForTestTrello.Tokens.Add(newToken); } } catch (Exception) { accountForTestTrello.TestResult = false; } return(accountForTestTrello); }
public IAdapter GetAdapter(IAccountSettings account) { TrelloAccountSettings accountForTestTrello = (TrelloAccountSettings)account; TrelloAccountToken Token = accountForTestTrello.Tokens.FirstOrDefault(); TrelloManager adapter = new TrelloManager(); adapter.UserToken = Token.UserToken; adapter.BoardID = Token.BoardID; adapter.MinUpdateTime = account.MinUpdateTime; adapter.adapterLastUpdate = DateTime.MinValue; adapter.TokenID = Token.TokenId; return(adapter); }
public Token Convert(IAccountToken token) { Token targetToken = new Token(); TrelloAccountToken currentToken = (TrelloAccountToken)token; targetToken.TokenName = currentToken.TokenName; targetToken.TokenId = currentToken.TokenId; targetToken.Tokens.Add("UserToken", currentToken.UserToken); targetToken.Tokens.Add("DateCreation", currentToken.DateCreation.ToString()); targetToken.Tokens.Add("BoardID", currentToken.BoardID); return(targetToken); }
public IAccountToken Convert(Token token) { TrelloAccountToken targetToken = new TrelloAccountToken(); targetToken.TokenId = token.TokenId; targetToken.TokenName = token.TokenName; if (token.Tokens.Count > 0) { targetToken.BoardID = (from tok in token.Tokens where tok.Key == "BoardID" select tok.Value).SingleOrDefault(); DateTime result; var res = DateTime.TryParse((from tok in token.Tokens where tok.Key == "DateCreation" select tok.Value).SingleOrDefault(), out result); targetToken.DateCreation = result; targetToken.UserToken = (from tok in token.Tokens where tok.Key == "UserToken" select tok.Value).SingleOrDefault(); } return(targetToken); }
public IAccountSettings Convert(ServiceAccount serviceAccount) { TrelloAccountSettings target = new TrelloAccountSettings(); target.ID = serviceAccount.ServiceAccountId; target.Name = serviceAccount.ServiceAccountName; target.Source = serviceAccount.Source; target.TestResult = serviceAccount.TestResult; target.MinUpdateTime = serviceAccount.MinUpdateTime; target.AccountVersion = serviceAccount.AccountVersion; target.Tokens = new List <TrelloAccountToken>(); if (serviceAccount.Tokens.Count > 0) { foreach (Token token in serviceAccount.Tokens) { TrelloAccountToken targetToken = new TrelloAccountToken(); targetToken = (TrelloAccountToken)targetToken.Convert(token); target.Tokens.Add(targetToken); } } return(target); }