Exemplo n.º 1
0
        private void lnkApplyCredentials_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string connStr = txtConnStr.Text;

            if (connStr.Contains(StringConstants.MgUsernamePlaceholder) &&
                connStr.Contains(StringConstants.MgPasswordPlaceholder))
            {
                using (var diag = new SetCredentialsDialog(StringConstants.MgUsernamePlaceholder, StringConstants.MgPasswordPlaceholder))
                {
                    if (diag.ShowDialog() == DialogResult.OK)
                    {
                        var fs = (IFeatureSource)_service.GetEditedResource();
                        fs.SetEncryptedCredentials(_service.CurrentConnection, diag.Username, diag.Password);
                        //Bit of a hack as parent does a 64-bit driver check to determine
                        //which NameValueCollection to return from the child, but we can
                        //get away with this because the same NameValueCollection is returned
                        //for both
                        fs.ApplyConnectionProperties(this.ConnectionProperties);
                        _service.SyncSessionCopy();
                        MessageBox.Show("Credentials applied");
                    }
                }
            }
            else
            {
                MessageBox.Show(Strings.OdbcConnStrMissingMgPlaceholders);
            }
        }
Exemplo n.º 2
0
 private void lnkApplyCredentials_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     string connStr = txtConnStr.Text;
     if (connStr.Contains(StringConstants.MgUsernamePlaceholder) &&
         connStr.Contains(StringConstants.MgPasswordPlaceholder))
     {
         using (var diag = new SetCredentialsDialog(StringConstants.MgUsernamePlaceholder, StringConstants.MgPasswordPlaceholder))
         {
             if (diag.ShowDialog() == DialogResult.OK)
             {
                 var fs = (IFeatureSource)_service.GetEditedResource();
                 fs.SetEncryptedCredentials(diag.Username, diag.Password);
                 //Bit of a hack as parent does a 64-bit driver check to determine
                 //which NameValueCollection to return from the child, but we can
                 //get away with this because the same NameValueCollection is returned
                 //for both
                 fs.ApplyConnectionProperties(this.ConnectionProperties);
                 _service.SyncSessionCopy();
                 MessageBox.Show("Credentials applied");
             }
         }
     }
     else
     {
         MessageBox.Show(Strings.OdbcConnStrMissingMgPlaceholders);
     }
 }