コード例 #1
0
        public TokenDTO ConvertToDAO(IAccountToken token)
        {
            TokenDTO             target       = new TokenDTO();
            DatabaseAccountToken currentToken = (DatabaseAccountToken)token;

            target.TokenName = currentToken.TokenName;
            target.TokenId   = currentToken.TokenId;
            List <TokenForSerialization> tokenList = new List <TokenForSerialization>();

            TokenForSerialization userName = new TokenForSerialization();

            userName.Key   = "UserName";
            userName.Value = currentToken.UserName;
            tokenList.Add(userName);

            TokenForSerialization password = new TokenForSerialization();

            password.Key   = "Password";
            password.Value = currentToken.Password;
            tokenList.Add(password);

            TokenForSerialization mapping = new TokenForSerialization();

            mapping.Key   = "Mapping";
            mapping.Value = currentToken.Mapping;
            tokenList.Add(mapping);

            TokenForSerialization dataSource = new TokenForSerialization();

            dataSource.Key   = "DataSource";
            dataSource.Value = currentToken.DataSource;
            tokenList.Add(dataSource);

            TokenForSerialization databaseDriver = new TokenForSerialization();

            databaseDriver.Key   = "DatabaseDriver";
            databaseDriver.Value = currentToken.DatabaseDriver.ToString();
            tokenList.Add(databaseDriver);

            TokenForSerialization databaseDialect = new TokenForSerialization();

            databaseDialect.Key   = "DatabaseDialect";
            databaseDialect.Value = currentToken.DatabaseDialect.ToString();
            tokenList.Add(databaseDialect);

            TokenForSerialization databaseConnectionString = new TokenForSerialization();

            databaseConnectionString.Key   = "ConnectionString";
            databaseConnectionString.Value = currentToken.ConnectionString;
            tokenList.Add(databaseConnectionString);

            target.Tokens = tokenList.ToArray();
            return(target);
        }
コード例 #2
0
        public IAccountToken ConvertFromDAO(TokenDTO token)
        {
            DatabaseAccountToken targetToken = new DatabaseAccountToken();

            targetToken.TokenId   = token.TokenId;
            targetToken.TokenName = token.TokenName;
            if (token.Tokens.Length > 0)
            {
                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);
        }
コード例 #3
0
        private void btnAddToken_Click(object sender, EventArgs e)
        {
            newToken                 = new DatabaseAccountToken();
            cmbTokens.Enabled        = false;
            btnAddToken.Enabled      = false;
            cmbDBType.Text           = String.Empty;
            cmbDBDialect.Text        = String.Empty;
            txtConnectionString.Text = String.Empty;
            txtPasswrd.Text          = String.Empty;
            txtUserID.Text           = String.Empty;
            txtDataSource.Text       = String.Empty;
            rtxtMapping.Text         = String.Empty;
            txtNewTokenName.Text     = String.Empty;
            label1.Text              = "Choose DB Type";
            label2.Text              = "Choose DB Dialect";
            label4.Text              = "Set a conection string details";
            panelChoseDBProvider.Show();
            btnCancelSaveOrEditingSettings.Show();
            label2.Hide();
            cmbDBDialect.Hide();
            panelConStrDiteils.Hide();
            panelPreviewString.Hide();
            MakeFieldsEnabled();
            groupBoxAccounts.Enabled = false;

            cmbDBType.SelectedIndexChanged    += cmbDBType_SelectedIndexChanged;
            cmbDBDialect.SelectedIndexChanged += cmbDBDialect_SelectedIndexChanged;
            btnApplyConSetDiteils.Click       += btnApplyConSetDiteils_Click;
            btnApplyConSetDiteils.Click       -= btnApplyConSetDiteilsForExistingToken_Click;
            btnSaveSettings.Click             += btnSaveSettings_Click;
            btnSaveSettings.Click             -= btnSaveChangedSettings_Click;
            cmbDBDialect.SelectedIndexChanged -= cmbDBDialect_SelectedIndexChangedForExistingToken;
            cmbDBDialect.SelectedIndexChanged -= cmbDBType_SelectedIndexChangedForExistingToken;
            cmbDBDialect.SelectedIndexChanged += cmbDBType_SelectedIndexChanged;
            cmbDBDialect.SelectedIndexChanged += cmbDBDialect_SelectedIndexChanged;
            btnTestConStr.Click  += btnTestConStr_Click;
            btnTestConStr.Click  -= btnTestConStrChanged_Click;
            btnChekMapping.Click += btnChekMapping_Click;
            btnChekMapping.Click -= btnChekMappingChanged_Click;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 private void cmbTokens_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cmbTokens.SelectedItem != null)
     {
         DatabaseAccountToken selectedToken = userDBFullAccount.Tokens.FirstOrDefault(x => x.TokenName == cmbTokens.SelectedItem.ToString());
         if (selectedToken != null)
         {
             this.selectedToken = selectedToken;
             PrepareForShowingTokenDetails(selectedToken);
             if (userDBFullAccount.Owner)
             {
                 btnDeleteToken.Enabled = true;
                 btnChangeToken.Enabled = true;
             }
             else
             {
                 btnChangeToken.Enabled = false;
                 btnDeleteToken.Enabled = false;
             }
         }
     }
 }
コード例 #6
0
        private void PrepareForShowingTokenDetails(DatabaseAccountToken token)
        {
            cmbDBType.Text    = token.DatabaseDriver.ToString();
            cmbDBDialect.Text = token.DatabaseDialect.ToString();
            panelChoseDBProvider.Show();

            txtUserID.Text     = token.UserName;
            txtPasswrd.Text    = token.Password;
            txtDataSource.Text = token.DataSource;
            panelConStrDiteils.Show();

            txtConnectionString.Text = token.ConnectionString;
            panelPreviewString.Show();

            rtxtMapping.Text = token.Mapping;
            btnApplyConSetDiteils.Hide();
            btnTestConStr.Hide();

            label1.Text = "Database Type";
            label2.Text = "Database Dialect";
            label4.Text = "Conection string details";

            MakeFieldsReadonly();
        }
コード例 #7
0
        private String CreateConString(DatabaseAccountToken token)
        {
            String conStr = String.Format("User ID = '{0}'; Password = {1}; Data Source = {2}", token.UserName, token.Password, token.DataSource);

            return(conStr);
        }