public bool Equals(IAccountToken other) { ExcelAccountToken token = (ExcelAccountToken)other; return(this.TokenId.Equals(token.TokenId) && this.TokenName.Equals(token.TokenName)); }
public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount) { ExcelAccountSettings target = new ExcelAccountSettings(); target.ID = serviceAccount.ServiceAccountId; target.Name = serviceAccount.ServiceAccountName; target.Source = serviceAccount.Source; target.AccountVersion = serviceAccount.AccountVersion; target.MinUpdateTime = serviceAccount.MinUpdateTime; target.Tokens = new List <ExcelAccountToken>(); target.Template = new List <ExcelAccountTemplate>(); if (serviceAccount.Tokens.Length > 0) { foreach (TokenDTO token in serviceAccount.Tokens) { ExcelAccountToken targetToken = new ExcelAccountToken(); targetToken = (ExcelAccountToken)targetToken.ConvertFromDAO(token); target.Tokens.Add(targetToken); } } if (serviceAccount.MappingTemplates.Length > 0) { foreach (TemplateDTO template in serviceAccount.MappingTemplates) { ExcelAccountTemplate targetTemplate = new ExcelAccountTemplate(); targetTemplate = (ExcelAccountTemplate)targetTemplate.ConvertFromDAO(template); target.Template.Add(targetTemplate); } } return(target); }
public override bool Equals(object obj) { if (obj == null) { return(false); } ExcelAccountToken objAsExcelAccountToken = obj as ExcelAccountToken; if (objAsExcelAccountToken == null) { return(false); } else { return(Equals(objAsExcelAccountToken)); } }
public TokenDTO ConvertToDAO(IAccountToken token) { TokenDTO target = new TokenDTO(); ExcelAccountToken currentToken = (ExcelAccountToken)token; target.TokenName = currentToken.TokenName; target.TokenId = currentToken.TokenId; List <TokenForSerialization> tokenList = new List <TokenForSerialization>(); TokenForSerialization lastUpdateTime = new TokenForSerialization(); lastUpdateTime.Key = "LastUpdateTime"; lastUpdateTime.Value = currentToken.LastUpdateTime.ToString(); tokenList.Add(lastUpdateTime); target.Tokens = tokenList.ToArray(); return(target); }
public IAccountToken ConvertFromDAO(TokenDTO token) { ExcelAccountToken targetToken = new ExcelAccountToken(); targetToken.TokenId = token.TokenId; targetToken.TokenName = token.TokenName; LastUpdateTime = DateTime.MinValue; if (token.Tokens.Length > 0) { DateTime dt; DateTime.TryParse((from tok in token.Tokens where tok.Key == "LastUpdateTime" select tok.Value).SingleOrDefault(), out dt); targetToken.LastUpdateTime = dt; } return(targetToken); }
private List <ExcelAccountSettings> FindAcountAndToken(String tokentName, out List <ExcelAccountToken> tokenForChange) { if (NeedUpdateAcountList) { UpdateExcelAccountsList(); } tokenForChange = new List <ExcelAccountToken>(); List <ExcelAccountSettings> accountsList = new List <ExcelAccountSettings>(); foreach (ExcelAccountSettings account in excelAccounts) { String name = tokentName.Trim(new Char[] { '~', '$' }); ExcelAccountToken result = account.Tokens.SingleOrDefault(token => token.TokenName == name); if (result != null) { tokenForChange.Add(result); accountsList.Add(account); } } return(accountsList); }
// Добавление нового токена private void Add_NewTokens(string path) { if (Check_FreshToken(path)) { newToken = new ExcelAccountToken(); newToken.TokenName = path; userExcelFullAccount.Tokens.Add(newToken); if (SettingsManager.SaveOrUpdateAccount(userExcelFullAccount)) { MessageBox.Show("Succesfully!!"); ExcelSynchronizer.UpdateWatchibleFiles(); ReloadAllSettingFromDB(); } else { MessageBox.Show("Error!!"); } } else { MessageBox.Show("This file here!!"); } }