public ServiceAccountDTO ConvertToDAO(IAccountSettings serviceAccount)
        {
            ServiceAccountDTO       target         = new ServiceAccountDTO();
            DatabaseAccountSettings currentAccount = (DatabaseAccountSettings)serviceAccount;

            target.ServiceAccountId   = currentAccount.ID;
            target.ServiceAccountName = currentAccount.Name;
            target.Source             = Sources.DataBase;
            target.MinUpdateTime      = target.MinUpdateTime;
            target.AccountVersion     = serviceAccount.AccountVersion;


            List <TokenDTO> tok = new List <TokenDTO>();

            if (currentAccount.Tokens != null)
            {
                foreach (DatabaseAccountToken token in currentAccount.Tokens)
                {
                    TokenDTO localtok = token.ConvertToDAO(token);
                    tok.Add(localtok);
                }
                target.Tokens = tok.ToArray();
            }
            return(target);
        }
        public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount)
        {
            GoogleSheetsAccountSettings target = new GoogleSheetsAccountSettings();
            target.ID = serviceAccount.ServiceAccountId;
            target.Name = serviceAccount.ServiceAccountName;
            target.Source = serviceAccount.Source;
            target.Tokens = new List<GoogleSheetsAccountToken>();
            target.Template = new List<GoogleSheetsAccountTemplate>();
            target.MinUpdateTime = serviceAccount.MinUpdateTime;
            target.AccountVersion = serviceAccount.AccountVersion;

            if (serviceAccount.Tokens.Length > 0)
            {
                foreach (TokenDTO token in serviceAccount.Tokens)
                {
                    GoogleSheetsAccountToken targetToken = new GoogleSheetsAccountToken();
                    targetToken = (GoogleSheetsAccountToken)targetToken.ConvertFromDAO(token);
                    target.Tokens.Add(targetToken);
                }
            }
            if (serviceAccount.MappingTemplates.Length > 0)
            {
                foreach (TemplateDTO template in serviceAccount.MappingTemplates)
                {
                    GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate();
                    targetTemplate = (GoogleSheetsAccountTemplate)targetTemplate.ConvertFromDAO(template);
                    target.Template.Add(targetTemplate);
                }
            }
            return target;
        }
Exemplo n.º 3
0
        public ServiceAccountDTO ConvertToDAO(IAccountSettings serviceAccount)
        {
            ServiceAccountDTO           target         = new ServiceAccountDTO();
            GoogleSheetsAccountSettings currentAccount = (GoogleSheetsAccountSettings)serviceAccount;

            target.ServiceAccountId   = currentAccount.ID;
            target.ServiceAccountName = currentAccount.Name;
            target.Source             = Sources.GoogleSheets;
            target.MinUpdateTime      = target.MinUpdateTime;
            target.AccountVersion     = serviceAccount.AccountVersion;

            List <TokenDTO>    tok   = new List <TokenDTO>();
            List <TemplateDTO> templ = new List <TemplateDTO>();

            if (currentAccount.Tokens != null && currentAccount.Tokens.Count > 0)
            {
                foreach (GoogleSheetsAccountToken token in currentAccount.Tokens)
                {
                    TokenDTO localtok = token.ConvertToDAO(token);
                    tok.Add(localtok);
                }
                target.Tokens = tok.ToArray();
            }
            if (currentAccount.Template != null && currentAccount.Template.Count > 0)
            {
                foreach (GoogleSheetsAccountTemplate template in currentAccount.Template)
                {
                    TemplateDTO locTemlate = template.ConvertToDAO(template);
                    templ.Add(locTemlate);
                }
                target.MappingTemplates = templ.ToArray();
            }
            return(target);
        }
Exemplo n.º 4
0
        public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount)
        {
            GoogleSheetsAccountSettings target = new GoogleSheetsAccountSettings();

            target.ID             = serviceAccount.ServiceAccountId;
            target.Name           = serviceAccount.ServiceAccountName;
            target.Source         = serviceAccount.Source;
            target.Tokens         = new List <GoogleSheetsAccountToken>();
            target.Template       = new List <GoogleSheetsAccountTemplate>();
            target.MinUpdateTime  = serviceAccount.MinUpdateTime;
            target.AccountVersion = serviceAccount.AccountVersion;

            if (serviceAccount.Tokens.Length > 0)
            {
                foreach (TokenDTO token in serviceAccount.Tokens)
                {
                    GoogleSheetsAccountToken targetToken = new GoogleSheetsAccountToken();
                    targetToken = (GoogleSheetsAccountToken)targetToken.ConvertFromDAO(token);
                    target.Tokens.Add(targetToken);
                }
            }
            if (serviceAccount.MappingTemplates.Length > 0)
            {
                foreach (TemplateDTO template in serviceAccount.MappingTemplates)
                {
                    GoogleSheetsAccountTemplate targetTemplate = new GoogleSheetsAccountTemplate();
                    targetTemplate = (GoogleSheetsAccountTemplate)targetTemplate.ConvertFromDAO(template);
                    target.Template.Add(targetTemplate);
                }
            }
            return(target);
        }
Exemplo n.º 5
0
        public static Boolean DeleteAccount(this UserProvider.UserDTO currentUser, IAccountSettings accountToDelete, Boolean DeleteForAllUsers)
        {
            Boolean           succeed = false;
            ServiceAccountDTO targetAccountToDelete = accountToDelete.ConvertToDAO(accountToDelete);

            succeed = services.DeleteAccount(currentUser.UserID, targetAccountToDelete, DeleteForAllUsers);
            return(succeed);
        }
Exemplo n.º 6
0
        public static Boolean CreateNewAccount(this UserProvider.UserDTO currentUser, IAccountSettings newAccount)
        {
            Boolean           succeed          = false;
            ServiceAccountDTO targetnewAccount = newAccount.ConvertToDAO(newAccount);

            succeed = services.CreateNewAccount(currentUser.UserID, targetnewAccount);
            return(succeed);
        }
Exemplo n.º 7
0
        public static Boolean SaveOrUpdateAccount(IAccountSettings account)
        {
            Boolean           succeed       = false;
            ServiceAccountDTO targetAccount = account.ConvertToDAO(account);

            succeed = services.SaveOrUdateAccount(targetAccount);
            return(succeed);
        }
Exemplo n.º 8
0
        public static Boolean ShareTheSettingAccount(this UserProvider.UserDTO currentUser, IAccountSettings accountToShare, String shareUserName, Boolean owner)
        {
            Boolean           succeed = false;
            ServiceAccountDTO targetAccountToShare = accountToShare.ConvertToDAO(accountToShare);

            succeed = services.ShareTheSettingAccount(currentUser.UserID, targetAccountToShare, shareUserName, owner);
            return(succeed);
        }
Exemplo n.º 9
0
        public static IAccountSettings GetDetailsForAccount(this UserProvider.UserDTO currentUser, Int32 accountId, Boolean owner = true)
        {
            ServiceAccountDTO serviceAcc = services.GetUserAccountsByUserIDAndAccountId(currentUser.UserID, accountId);
            IAccountSettings  targetAcc  = GetCurrentInstance(serviceAcc);

            targetAcc       = targetAcc.ConvertFromDAO(serviceAcc);
            targetAcc.Owner = owner;
            return(targetAcc);
        }
Exemplo n.º 10
0
        public static Boolean AccountSettingsTest(IAccountSettings accountForTest, Byte[] fileInBytes)
        {
            ServiceAccountDTO account       = accountForTest.ConvertToDAO(accountForTest);
            ServiceAccountDTO resultAccount = services.TestExcelAccount(account, fileInBytes);

            IAccountSettings resultIaccount = GetCurrentInstance(resultAccount);

            resultIaccount = resultIaccount.ConvertFromDAO(resultAccount);
            return(resultAccount.TestResult);
        }
Exemplo n.º 11
0
        public static Boolean AccountSettingsTest(IAccountSettings accountForTest, out IAccountSettings settingResult)
        {
            ServiceAccountDTO account       = accountForTest.ConvertToDAO(accountForTest);
            ServiceAccountDTO resultAccount = services.TestAccount(account);

            IAccountSettings resultIaccount = GetCurrentInstance(resultAccount);

            resultIaccount = resultIaccount.ConvertFromDAO(resultAccount);
            settingResult  = resultIaccount;
            return(resultAccount.TestResult);
        }
Exemplo n.º 12
0
        public static IAccountSettings GetCurrentInstance(ServiceAccountDTO setting)
        {
            switch (setting.Source)
            {
            case Sources.DataBase:
                return(new DatabaseAccountSettings());

            case Sources.Trello:
                return(new TrelloAccountSettings());

            case Sources.Excel:
                return(new ExcelAccountSettings());

            case Sources.GoogleSheets:
                return(new GoogleSheetsAccountSettings());

            default:
                return(null);
            }
        }
        public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount)
        {
            DatabaseAccountSettings target = new DatabaseAccountSettings();

            target.ID             = serviceAccount.ServiceAccountId;
            target.Name           = serviceAccount.ServiceAccountName;
            target.Source         = serviceAccount.Source;
            target.MinUpdateTime  = serviceAccount.MinUpdateTime;
            target.AccountVersion = serviceAccount.AccountVersion;


            if (serviceAccount.Tokens.Length > 0)
            {
                foreach (TokenDTO token in serviceAccount.Tokens)
                {
                    DatabaseAccountToken targetToken = new DatabaseAccountToken();
                    targetToken = (DatabaseAccountToken)targetToken.ConvertFromDAO(token);
                    target.Tokens.Add(targetToken);
                }
            }
            return(target);
        }
Exemplo n.º 14
0
        public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount)
        {
            TrelloAccountSettings target = new TrelloAccountSettings();
            target.ID = serviceAccount.ServiceAccountId;
            target.Name = serviceAccount.ServiceAccountName;
            target.Source = serviceAccount.Source;
            target.MinUpdateTime = serviceAccount.MinUpdateTime;
            target.TestResult = serviceAccount.TestResult;
            target.AccountVersion = serviceAccount.AccountVersion;

            target.Tokens = new List<TrelloAccountToken>();

            if (serviceAccount.Tokens.Length > 0)
            {
                foreach (TokenDTO token in serviceAccount.Tokens)
                {
                    TrelloAccountToken targetToken = new TrelloAccountToken();
                    targetToken = (TrelloAccountToken)targetToken.ConvertFromDAO(token);
                    target.Tokens.Add(targetToken);
                }
            }
            return target;
        }
Exemplo n.º 15
0
        public IAccountSettings ConvertFromDAO(ServiceAccountDTO serviceAccount)
        {
            TrelloAccountSettings target = new TrelloAccountSettings();

            target.ID             = serviceAccount.ServiceAccountId;
            target.Name           = serviceAccount.ServiceAccountName;
            target.Source         = serviceAccount.Source;
            target.MinUpdateTime  = serviceAccount.MinUpdateTime;
            target.TestResult     = serviceAccount.TestResult;
            target.AccountVersion = serviceAccount.AccountVersion;

            target.Tokens = new List <TrelloAccountToken>();

            if (serviceAccount.Tokens.Length > 0)
            {
                foreach (TokenDTO token in serviceAccount.Tokens)
                {
                    TrelloAccountToken targetToken = new TrelloAccountToken();
                    targetToken = (TrelloAccountToken)targetToken.ConvertFromDAO(token);
                    target.Tokens.Add(targetToken);
                }
            }
            return(target);
        }
Exemplo n.º 16
0
        public ServiceAccountDTO ConvertToDAO(IAccountSettings serviceAccount)
        {
            ServiceAccountDTO target = new ServiceAccountDTO();
            TrelloAccountSettings currentAccount = (TrelloAccountSettings)serviceAccount;
            target.TestResult = currentAccount.TestResult;
            target.ServiceAccountId = currentAccount.ID;
            target.ServiceAccountName = currentAccount.Name;
            target.AccountVersion = currentAccount.AccountVersion;

            target.Source = Sources.Trello;
            target.MinUpdateTime = currentAccount.MinUpdateTime;

            List<TokenDTO> tok = new List<TokenDTO>();
            if (currentAccount.Tokens != null)
            {
                foreach (TrelloAccountToken token in currentAccount.Tokens)
                {
                    TokenDTO localtok = token.ConvertToDAO(token);
                    tok.Add(localtok);
                }
                target.Tokens = tok.ToArray();
            }
            return target;
        }
        public ServiceAccountDTO ConvertToDAO(IAccountSettings serviceAccount)
        {
            ServiceAccountDTO target = new ServiceAccountDTO();
            GoogleSheetsAccountSettings currentAccount = (GoogleSheetsAccountSettings)serviceAccount;

            target.ServiceAccountId = currentAccount.ID;
            target.ServiceAccountName = currentAccount.Name;
            target.Source = Sources.GoogleSheets;
            target.MinUpdateTime = target.MinUpdateTime;
            target.AccountVersion = serviceAccount.AccountVersion;

            List<TokenDTO> tok = new List<TokenDTO>();
            List<TemplateDTO> templ = new List<TemplateDTO>();
            if (currentAccount.Tokens != null && currentAccount.Tokens.Count > 0)
            {
                foreach (GoogleSheetsAccountToken token in currentAccount.Tokens)
                {
                    TokenDTO localtok = token.ConvertToDAO(token);
                    tok.Add(localtok);
                }
                target.Tokens = tok.ToArray();
            }
            if (currentAccount.Template != null && currentAccount.Template.Count > 0)
            {
                foreach (GoogleSheetsAccountTemplate template in currentAccount.Template)
                {
                    TemplateDTO locTemlate = template.ConvertToDAO(template);
                    templ.Add(locTemlate);
                }
                target.MappingTemplates = templ.ToArray();
            }
            return target;
        }
Exemplo n.º 18
0
 public static IAccountSettings GetCurrentInstance(ServiceAccountDTO setting)
 {
     switch (setting.Source)
     {
         case Sources.DataBase:
             return new DatabaseAccountSettings();
         case Sources.Trello:
             return new TrelloAccountSettings();
         case Sources.Excel:
             return new ExcelAccountSettings();
         case Sources.GoogleSheets:
             return new GoogleSheetsAccountSettings();
         default:
             return null;
     }
 }