private void HydrateUiFromSettings(string settingsPath) { try { Settings = EarlyBoundGeneratorConfig.Load(settingsPath); Settings.CrmSvcUtilRealtiveRootPath = Paths.PluginsPath; SettingsMap = new SettingsMap(this, Settings) { SettingsPath = settingsPath }; PropertiesGrid.SelectedObject = SettingsMap; SkipSaveSettings = false; } catch (Exception ex) { TxtOutput.AppendText($"Unable to Load Settings from Config file: {settingsPath}. {ex}"); var result = MessageBox.Show(@"The Settings File is either empty or malformed. Would you like to reset the file to the default settings?", @"Unable to Load Settings!", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { Settings = EarlyBoundGeneratorConfig.GetDefault(); Settings.CrmSvcUtilRealtiveRootPath = Paths.PluginsPath; } else { SkipSaveSettings = true; } } }
private void HydrateUiFromSettings(string settingsPath) { try { Settings = EarlyBoundGeneratorConfig.Load(settingsPath); Settings.CrmSvcUtilRealtiveRootPath = Paths.PluginsPath; SkipSaveSettings = false; } catch (Exception ex) { TxtOutput.AppendText($"Unable to Load Settings from Config file: {settingsPath}. {ex}"); var result = MessageBox.Show(@"The Settings File is either empty or malformed. Would you like to reset the file to the default settings?", @"Unable to Load Settings!", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { Settings = EarlyBoundGeneratorConfig.GetDefault(); Settings.CrmSvcUtilRealtiveRootPath = Paths.PluginsPath; } else { SkipSaveSettings = true; } } ChkAddDebuggerNonUserCode.Checked = Settings.ExtensionConfig.AddDebuggerNonUserCode; ChkAddFilesToProject.Checked = Settings.ExtensionConfig.AddNewFilesToProject; ChkAudibleCompletion.Checked = Settings.AudibleCompletionNotification; ChkCreateOneActionFile.Checked = Settings.ExtensionConfig.CreateOneFilePerAction; ChkCreateOneEntityFile.Checked = Settings.ExtensionConfig.CreateOneFilePerEntity; ChkCreateOneOptionSetFile.Checked = Settings.ExtensionConfig.CreateOneFilePerOptionSet; ChkEditableResponseActions.Checked = Settings.ExtensionConfig.MakeResponseActionsEditable; ChkIncludeCommandLine.Checked = Settings.IncludeCommandLine; ChkMakeReadonlyFieldsEditable.Checked = Settings.ExtensionConfig.MakeReadonlyFieldsEditable; ChkMaskPassword.Checked = Settings.MaskPassword; ChkGenerateActionAttributeNameConsts.Checked = Settings.ExtensionConfig.GenerateActionAttributeNameConsts; ChkGenerateAttributeNameConsts.Checked = Settings.ExtensionConfig.GenerateAttributeNameConsts; ChkGenerateAnonymousTypeConstructor.Checked = Settings.ExtensionConfig.GenerateAnonymousTypeConstructor; ChkGenerateEntityRelationships.Checked = Settings.ExtensionConfig.GenerateEntityRelationships; ChkGenerateOptionSetEnums.Checked = Settings.ExtensionConfig.GenerateEnumProperties; ChkRemoveRuntimeComment.Checked = Settings.ExtensionConfig.RemoveRuntimeVersionComment; ChkUseDeprecatedOptionSetNaming.Checked = Settings.ExtensionConfig.UseDeprecatedOptionSetNaming; ChkUseTFS.Checked = Settings.ExtensionConfig.UseTfsToCheckoutFiles; ChkUseXrmClient.Checked = Settings.ExtensionConfig.UseXrmClient; TxtActionPath.Text = Settings.ActionOutPath; TxtEntityPath.Text = Settings.EntityOutPath; TxtInvalidCSharpNamePrefix.Text = Settings.ExtensionConfig.InvalidCSharpNamePrefix; TxtOptionSetFormat.Text = Settings.ExtensionConfig.LocalOptionSetFormat; TxtLanguageCodeOverride.Text = Settings.ExtensionConfig.OptionSetLanguageCodeOverride + ""; TxtNamespace.Text = Settings.Namespace; TxtOptionSetPath.Text = Settings.OptionSetOutPath; TxtServiceContextName.Text = Settings.ServiceContextName; // Hide or show labels based on checked preferences LblActionsDirectory.Visible = ChkCreateOneActionFile.Checked; LblActionPath.Visible = !LblActionsDirectory.Visible; LblEntitiesDirectory.Visible = ChkCreateOneEntityFile.Checked; LblEntityPath.Visible = !LblEntitiesDirectory.Visible; LblOptionSetsDirectory.Visible = ChkCreateOneOptionSetFile.Checked; LblOptionSetPath.Visible = !LblOptionSetsDirectory.Visible; SetAddFilesToProjectVisibility(); }
// ReSharper disable once InconsistentNaming private void HydrateSettingsFromUI() { if (ConnectionDetail != null) { TxtOutput.AppendText("CRM Authentication Type Detected: " + ConnectionDetail.AuthType + Environment.NewLine); Settings.Domain = GetUserDomain(); Settings.Password = ConnectionDetail.GetUserPassword(); Settings.SupportsActions = ConnectionDetail.OrganizationMajorVersion >= Crm2013; Settings.UseCrmOnline = ConnectionDetail.UseOnline; Settings.UserName = ConnectionDetail.UserName; Settings.Url = ConnectionDetail.GetUrlString(); if (Settings.UseConnectionString && string.IsNullOrWhiteSpace(Settings.Password) && ConnectionDetail.NewAuthType != AuthenticationType.Certificate && ConnectionDetail.NewAuthType != AuthenticationType.ClientSecret && ConnectionDetail.NewAuthType != AuthenticationType.OAuth) { // Fix for https://github.com/daryllabar/DLaB.Xrm.XrmToolBoxTools/issues/43 // Difficulties with Early Bound Generator #43 var askForPassword = new PasswordDialog(this); Settings.Password = askForPassword.ShowDialog(this) == DialogResult.OK ? askForPassword.Password : "******"; } if (ConnectionDetail.AuthType == AuthenticationProviderType.ActiveDirectory && string.IsNullOrWhiteSpace(Settings.UserName)) { Settings.UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; } if (string.IsNullOrWhiteSpace(Settings.ConnectionString)) { // Load any non-username/password situations via connection string #268 Settings.ConnectionString = ConnectionDetail.GetNonUserConnectionString(); if (!string.IsNullOrWhiteSpace(Settings.ConnectionString)) { Settings.UseConnectionString = true; } } } SettingsMap.PushChanges(); Settings.RootPath = Path.GetDirectoryName(Path.GetFullPath(TxtSettingsPath.Text)); if (SettingsMap.UseDeprecatedOptionSetNaming) { Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, @"DLaB.CrmSvcUtilExtensions.OptionSet.CodeWriterFilterService,DLaB.CrmSvcUtilExtensions"); Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, string.Empty); } else { var defaultConfig = EarlyBoundGeneratorConfig.GetDefault(); defaultConfig.CrmSvcUtilRelativeRootPath = Paths.PluginsPath; Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter).Value); Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService).Value); } }
private void EarlyBoundGenerator_Load(object sender, EventArgs e) { if (ConnectionDetail != null) { DisplayActionsIfSupported(false); } try { Settings = EarlyBoundGeneratorConfig.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); } catch (Exception ex) { TxtOutput.AppendText("Unable to Load Settings form Config: " + ex); SkipSaveSettings = true; Settings = EarlyBoundGeneratorConfig.GetDefault(); } ChkAddDebuggerNonUserCode.Checked = Settings.ExtensionConfig.AddDebuggerNonUserCode; ChkAddFilesToProject.Checked = Settings.ExtensionConfig.AddNewFilesToProject; ChkAudibleCompletion.Checked = Settings.AudibleCompletionNotification; ChkCreateOneActionFile.Checked = Settings.ExtensionConfig.CreateOneFilePerAction; ChkCreateOneEntityFile.Checked = Settings.ExtensionConfig.CreateOneFilePerEntity; ChkCreateOneOptionSetFile.Checked = Settings.ExtensionConfig.CreateOneFilePerOptionSet; ChkIncludeCommandLine.Checked = Settings.IncludeCommandLine; ChkMakeReadonlyFieldsEditable.Checked = Settings.ExtensionConfig.MakeReadonlyFieldsEditable; ChkMaskPassword.Checked = Settings.MaskPassword; ChkGenerateAttributeNameConsts.Checked = Settings.ExtensionConfig.GenerateAttributeNameConsts; ChkGenerateAnonymousTypeConstructor.Checked = Settings.ExtensionConfig.GenerateAnonymousTypeConstructor; ChkGenerateEntityRelationships.Checked = Settings.ExtensionConfig.GenerateEntityRelationships; ChkGenerateOptionSetEnums.Checked = Settings.ExtensionConfig.GenerateEnumProperties; ChkRemoveRuntimeComment.Checked = Settings.ExtensionConfig.RemoveRuntimeVersionComment; ChkUseDeprecatedOptionSetNaming.Checked = Settings.ExtensionConfig.UseDeprecatedOptionSetNaming; ChkUseTFS.Checked = Settings.ExtensionConfig.UseTfsToCheckoutFiles; ChkUseXrmClient.Checked = Settings.ExtensionConfig.UseXrmClient; TxtActionPath.Text = Settings.ActionOutPath; TxtEntityPath.Text = Settings.EntityOutPath; TxtInvalidCSharpNamePrefix.Text = Settings.ExtensionConfig.InvalidCSharpNamePrefix; TxtOptionSetFormat.Text = Settings.ExtensionConfig.LocalOptionSetFormat; TxtNamespace.Text = Settings.Namespace; TxtOptionSetPath.Text = Settings.OptionSetOutPath; TxtServiceContextName.Text = Settings.ServiceContextName; // Hide or show labels based on checked preferences LblActionsDirectory.Visible = ChkCreateOneActionFile.Checked; LblActionPath.Visible = !LblActionsDirectory.Visible; LblEntitiesDirectory.Visible = ChkCreateOneEntityFile.Checked; LblEntityPath.Visible = !LblEntitiesDirectory.Visible; LblOptionSetsDirectory.Visible = ChkCreateOneOptionSetFile.Checked; LblOptionSetPath.Visible = !LblOptionSetsDirectory.Visible; SetAddFilesToProjectVisibility(); }
// ReSharper disable once InconsistentNaming private void HydrateSettingsFromUI() { if (ConnectionDetail != null) { TxtOutput.AppendText("CRM Authentication Type Detected: " + ConnectionDetail.AuthType + Environment.NewLine); Settings.AuthType = ConnectionDetail.AuthType; Settings.Domain = GetUserDomain(); Settings.Password = ConnectionDetail.GetUserPassword(); Settings.SupportsActions = ConnectionDetail.OrganizationMajorVersion >= Crm2013; Settings.UseConnectionString = Settings.UseConnectionString; // #151 || Settings.AuthType == AuthenticationProviderType.ActiveDirectory; Settings.UseCrmOnline = ConnectionDetail.UseOnline; Settings.UserName = ConnectionDetail.UserName; Settings.Url = GetUrlString(); if (Settings.UseConnectionString && string.IsNullOrWhiteSpace(Settings.Password)) { // Fix for https://github.com/daryllabar/DLaB.Xrm.XrmToolBoxTools/issues/43 // Difficulties with Early Bound Generator #43 var askForPassowrd = new PasswordDialog(this); Settings.Password = askForPassowrd.ShowDialog(this) == DialogResult.OK ? askForPassowrd.Password : "******"; } if (ConnectionDetail.AuthType == AuthenticationProviderType.ActiveDirectory && string.IsNullOrWhiteSpace(Settings.UserName)) { Settings.UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; } } Settings.ActionOutPath = TxtActionPath.Text; Settings.EntityOutPath = TxtEntityPath.Text; Settings.RootPath = Path.GetDirectoryName(Path.GetFullPath(TxtSettingsPath.Text)); if (ChkUseDeprecatedOptionSetNaming.Checked) { Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, @"DLaB.CrmSvcUtilExtensions.OptionSet.CodeWriterFilterService,DLaB.CrmSvcUtilExtensions"); Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, string.Empty); } else { var defaultConfig = EarlyBoundGeneratorConfig.GetDefault(); Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.CodeWriterFilter).Value); Settings.SetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService, defaultConfig.GetExtensionArgument(CreationType.OptionSets, CrmSrvUtilService.NamingService).Value); } var validLanguageCode = int.TryParse(TxtLanguageCodeOverride.Text, out var languageCode); var extensions = Settings.ExtensionConfig; extensions.AddDebuggerNonUserCode = ChkAddDebuggerNonUserCode.Checked; extensions.AddNewFilesToProject = ChkAddFilesToProject.Checked; extensions.CreateOneFilePerAction = ChkCreateOneActionFile.Checked; extensions.CreateOneFilePerEntity = ChkCreateOneEntityFile.Checked; extensions.CreateOneFilePerOptionSet = ChkCreateOneOptionSetFile.Checked; extensions.GenerateActionAttributeNameConsts = ChkGenerateActionAttributeNameConsts.Checked; extensions.GenerateAttributeNameConsts = ChkGenerateAttributeNameConsts.Checked; extensions.GenerateAnonymousTypeConstructor = ChkGenerateAnonymousTypeConstructor.Checked; extensions.GenerateEntityRelationships = ChkGenerateEntityRelationships.Checked; extensions.GenerateEnumProperties = ChkGenerateOptionSetEnums.Checked; extensions.InvalidCSharpNamePrefix = TxtInvalidCSharpNamePrefix.Text; extensions.MakeReadonlyFieldsEditable = ChkMakeReadonlyFieldsEditable.Checked; extensions.MakeResponseActionsEditable = ChkEditableResponseActions.Checked; extensions.LocalOptionSetFormat = TxtOptionSetFormat.Text; extensions.OptionSetLanguageCodeOverride = validLanguageCode ? languageCode : (int?)null; extensions.RemoveRuntimeVersionComment = ChkRemoveRuntimeComment.Checked; extensions.UseXrmClient = ChkUseXrmClient.Checked; extensions.UseDeprecatedOptionSetNaming = ChkUseDeprecatedOptionSetNaming.Checked; extensions.UseTfsToCheckoutFiles = ChkUseTFS.Checked; Settings.AudibleCompletionNotification = ChkAudibleCompletion.Checked; Settings.IncludeCommandLine = ChkIncludeCommandLine.Checked; Settings.MaskPassword = ChkMaskPassword.Checked; Settings.Namespace = TxtNamespace.Text; Settings.OptionSetOutPath = TxtOptionSetPath.Text; Settings.ServiceContextName = string.IsNullOrWhiteSpace(TxtServiceContextName.Text) ? null : TxtServiceContextName.Text; }