Esempio n. 1
0
        private void BuildConnectionString(string connectionStringWithProvider)
        {
            var connectionSettings = DbSettingsService.ParseConnectionSettings(connectionStringWithProvider);
            var inputValuesWrapper = DbSettingsService.MapToValuesWrapper(connectionSettings);

            var dbSettingsForm = SubmitFormDisplayHelper.LoadSubmitFormByExtensionId(_context.ExtensionManager,
                                                                                     ExtensionCatalog.DbSettings, inputValuesWrapper.CollectIncomeValues());

            dbSettingsForm.WorkCallback = (step, list) =>
            {
                var valuesWrapper = new DbSettingsFormValuesWrapper(list);
                connectionSettings = DbSettingsService.ExtractConnectionSettings(valuesWrapper);

                var dbSettingsService = new DbSettingsService(_context.UnityContainer);
                dbSettingsService.CheckConnectionSettings(connectionSettings);

                connectionStringWithProvider =
                    DbSettingsService.ToConnectionStringWithProvider(connectionSettings);

                return(new Dictionary <string, object>());
            };

            if (DialogResult.OK == dbSettingsForm.ShowDialog(_form))
            {
                var step2 =
                    new RegistrationFormValuesWrapper.Step2
                {
                    Control5ConnectionString = connectionStringWithProvider
                };

                _form.ApplyValues(step2.CollectIncomeValues());
            }
        }
Esempio n. 2
0
        private void Step2(RegistrationFormValuesWrapper.Step2 valuesWrapper)
        {
            SecureString securePassword = null;

            if (!valuesWrapper.Control1LoginWithoutPassword)
            {
                securePassword = new SecureString();

                foreach (char ch in valuesWrapper.Control2Password)
                {
                    securePassword.AppendChar(ch);
                }

                securePassword.MakeReadOnly();
            }

            AuthenticationSettings authenticationSettings;

            if (null != _decryptedKey)
            {
                authenticationSettings = new AuthenticationSettings(_identifier, _decryptedKey);
            }
            else if (null != _lightCertificate)
            {
                authenticationSettings =
                    new AuthenticationSettings(_lightCertificate.Identifier, _lightCertificate.Thumbprint);
            }
            else
            {
                throw new InvalidOperationException();
            }

            var entranceService = _context.UnityContainer.Resolve <IEntranceService>();

            var connectionString = valuesWrapper.Control4ChangeConnectionString
                ? valuesWrapper.Control5ConnectionString
                : entranceService.SuggestConnectionString(_identifier);

            IConnectionSettings connectionSettings = null;

            if (null != connectionString)
            {
                connectionSettings = DbSettingsService.ParseConnectionSettings(connectionString);
            }

            authenticationSettings.ConnectionSettings = connectionSettings;

            entranceService.Register(authenticationSettings, securePassword);
        }