private static void ConvertSettings(string fileNameAndFilePath) { esSettings2010 settings2010 = new esSettings2010(); settings2010.Load(fileNameAndFilePath); esSettings settings = settings2010.To2011(); esSettingsDriverInfo info = new esSettingsDriverInfo(); info.ConnectionString = settings2010.ConnectionString; info.Driver = settings2010.Driver; settings.DriverInfoCollection.Add(info); try { AdjustPathsBasedOnPriorVersions(settings, @"Software\EntitySpaces 2009", "ES2009", false); AdjustPathsBasedOnPriorVersions(settings, @"Software\EntitySpaces 2010", "ES2010", false); AdjustPathsBasedOnPriorVersions(settings, @"Software\EntitySpaces 2011", "ES2011", false); AdjustPathsBasedOnPriorVersions(settings, @"Software\EntitySpaces 2011", "ES2012", true); } catch { } FileInfo fileInfo = new FileInfo(fileNameAndFilePath); string backup = fileInfo.Name.Replace(fileInfo.Extension, ""); backup += "_original" + fileInfo.Extension; backup = fileInfo.DirectoryName + "\\" + backup; File.Copy(fileNameAndFilePath, backup, true); settings.Save(fileNameAndFilePath); }
public esSettingsDriverInfo FindDriverInfoCollection(string driver) { esSettingsDriverInfo info = null; foreach (esSettingsDriverInfo driverInfo in DriverInfoCollection) { if (driverInfo.Driver == driver) { info = driverInfo; break; } } return(info); }
/// <summary> /// This can be called to embed the settings in an existing XmlDocument /// </summary> /// <param name="xwriter"></param> public void Save(XmlTextWriter xwriter) { // Save a copy off List <esSettingsDriverInfo> driverCollection = DriverInfoCollection; try { // We only want the connection for this settings file DriverInfoCollection = new List <esSettingsDriverInfo>(); if (driverCollection != null && driverCollection.Count > 0) { foreach (esSettingsDriverInfo info in driverCollection) { if (info.Driver == Driver) { DriverInfoCollection.Add(info); break; } } } else { esSettingsDriverInfo info = new esSettingsDriverInfo(); info.ConnectionString = ConnectionString; info.Driver = Driver; DriverInfoCollection.Add(info); } XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); XmlSerializer serializer = new XmlSerializer(typeof(esSettings)); serializer.Serialize(xwriter, this, ns); } finally { DriverInfoCollection = driverCollection; } }
/// <summary> /// This can be called to embed the settings in an existing XmlDocument /// </summary> /// <param name="xwriter"></param> public void Save(XmlTextWriter xwriter) { // Save a copy off List<esSettingsDriverInfo> driverCollection = DriverInfoCollection; try { // We only want the connection for this settings file DriverInfoCollection = new List<esSettingsDriverInfo>(); if (driverCollection != null && driverCollection.Count > 0) { foreach (esSettingsDriverInfo info in driverCollection) { if (info.Driver == Driver) { DriverInfoCollection.Add(info); break; } } } else { esSettingsDriverInfo info = new esSettingsDriverInfo(); info.ConnectionString = ConnectionString; info.Driver = Driver; DriverInfoCollection.Add(info); } XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("", ""); XmlSerializer serializer = new XmlSerializer(typeof(esSettings)); serializer.Serialize(xwriter, this, ns); } finally { DriverInfoCollection = driverCollection; } }
private void comboBoxDriver_SelectedIndexChanged(object sender, EventArgs e) { try { HideErrorOrStatusMessage(); if (comboBoxDriver.SelectedIndex != -1) { DictionaryEntry de = (DictionaryEntry)comboBoxDriver.SelectedItem; string driver = (string)de.Value; lblSelectedDriver.Text = driver; esSettingsDriverInfo driverInfo = Settings.FindDriverInfoCollection(driver); if (driverInfo == null) { // There is no entry fro this driver driverInfo = new esSettingsDriverInfo(); driverInfo.HasConnected = false; driverInfo.Driver = driver; Settings.DriverInfoCollection.Add(driverInfo); textBoxConnectionString.Text = esSettings.GetDefaultConnectionString(driver); // DateAdded chkDateAddedEnabled.Checked = false; txtDateAddedColumnName.Text = "DateAdded"; txtDateAddedServerSideText.Text = string.Empty; chkDateAddedClientSideEnabled.Checked = true; chkDateAddedClientSideEnabled.Checked = false; rdoDateAddedClientSideNow.Checked = true; // DateModified chkDateModifiedEnabled.Checked = false; txtDateModifiedColumnName.Text = "DateModified"; txtDateModifiedServerSideText.Text = string.Empty; chkDateModifiedServerSideEnabled.Checked = true; chkDateModifiedClientSideEnabled.Checked = false; rdoDateModifiedClientSideNow.Checked = true; txtConcurrencyColumnName.Text = string.Empty; } else { // Let's pull thier previous information textBoxConnectionString.Text = driverInfo.ConnectionString; // DateAdded chkDateAddedEnabled.Checked = driverInfo.DateAdded.IsEnabled; txtDateAddedColumnName.Text = driverInfo.DateAdded.ColumnName; txtDateAddedServerSideText.Text = driverInfo.DateAdded.ServerSideText; chkDateAddedClientSideEnabled.Checked = driverInfo.DateAdded.Type == esSettingsDriverInfo.DateType.ServerSide ? true : false; chkDateAddedClientSideEnabled.Checked = driverInfo.DateAdded.Type == esSettingsDriverInfo.DateType.ServerSide ? false : true; rdoDateAddedClientSideNow.Checked = driverInfo.DateAdded.ClientType == esSettingsDriverInfo.ClientType.Now ? true : false; rdoDateAddedClientSideUtcNow.Checked = driverInfo.DateAdded.ClientType == esSettingsDriverInfo.ClientType.Now ? false : true; // DateModified chkDateModifiedEnabled.Checked = driverInfo.DateModified.IsEnabled; txtDateModifiedColumnName.Text = driverInfo.DateModified.ColumnName; txtDateModifiedServerSideText.Text = driverInfo.DateModified.ServerSideText; chkDateModifiedServerSideEnabled.Checked = driverInfo.DateModified.Type == esSettingsDriverInfo.DateType.ServerSide ? true : false; chkDateModifiedClientSideEnabled.Checked = driverInfo.DateModified.Type == esSettingsDriverInfo.DateType.ServerSide ? false : true; rdoDateModifiedClientSideNow.Checked = driverInfo.DateModified.ClientType == esSettingsDriverInfo.ClientType.Now ? true : false; rdoDateModifiedClientSideUtcNow.Checked = driverInfo.DateModified.ClientType == esSettingsDriverInfo.ClientType.Now ? false : true; chkAddedByEnabled.Checked = driverInfo.AddedBy.IsEnabled; chkAddedByEventHandler.Checked = driverInfo.AddedBy.UseEventHandler; txtAddedByColumnName.Text = driverInfo.AddedBy.ColumnName; txtAddedByServerSideText.Text = driverInfo.AddedBy.ServerSideText; chkModifiedByEnabled.Checked = driverInfo.ModifiedBy.IsEnabled; chkModifiedByEventHandler.Checked = driverInfo.ModifiedBy.UseEventHandler; txtModifiedByColumnName.Text = driverInfo.ModifiedBy.ColumnName; txtModifiedByServerSideText.Text = driverInfo.ModifiedBy.ServerSideText; chkConcurrencyColumn.Checked = driverInfo.ConcurrencyColumnEnabled; txtConcurrencyColumnName.Text = driverInfo.ConcurrencyColumn; } textBoxConnectionString.Focus(); SetOleDbButton(); textBoxConnectionHelp.Text = ""; if (String.IsNullOrEmpty(driver)) { textBoxConnectionHelp.Text = "Select a driver from the dropdown above."; } else { switch (driver.ToLower()) { case "access": textBoxConnectionHelp.Text = "EntitySpaces uses OLEDB to pull the metadata from your database during the code generation process. You do not use OLEDB in your EntitySpaces application."; textBoxConnectionHelp.Text += " If you encounter ADODB errors with the EntitySpaces Visual Studio Add-In, use the EntitySpaces StandAlone code generator instead."; textBoxConnectionHelp.Text += " You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "sql": case "oracle": textBoxConnectionHelp.Text = "EntitySpaces uses OLEDB to pull the metadata from your database during the code generation process. You do not use OLEDB in your EntitySpaces application. You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "sqlazure": textBoxConnectionHelp.Text = "EntitySpaces uses SqlClient to pull the metadata from your Azure database during the code generation process. You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "sqlce": textBoxConnectionHelp.Text = "Because there are so many versions of the SqlCe ADO.NET provider, the EntitySpaces metadata engine requires you to build the version into the connection string (as shown below). You can determine the version by looking in your Global Assembly Cache (GAC)."; textBoxConnectionHelp.Text += "\r\n\r\nSqlCe 3.0 - Version=\"9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91\""; textBoxConnectionHelp.Text += "\r\nSqlCe 3.5 - Version=\"3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91\""; textBoxConnectionHelp.Text += " You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "postgresql": textBoxConnectionHelp.Text = "The EntitySpaces Metadata Engine uses reflection to load Npgsql, you can either install a copy in the GAC or in the '" + Settings.InstallPath + "CodeGeneration\\Bin' folder. You must have a version in the GAC to use the Visual Studio Plugin, otherwise you will have to run the StandAlone application located on your Start -> Programs menu. You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "mysql": textBoxConnectionHelp.Text = "The EntitySpaces Metadata Engine uses reflection to load the MySQL Connector/NET provider. You can either install a copy in the GAC or in the '" + Settings.InstallPath + "CodeGeneration\\Bin' folder. You must have a version in the GAC to use the Visual Studio Plugin, otherwise you will have to run the StandAlone application located on your Start -> Programs menu. You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "sqlite": textBoxConnectionHelp.Text = "You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "sybase": textBoxConnectionHelp.Text = "You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "effiprozdb": textBoxConnectionHelp.Text = "You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "vistadb": textBoxConnectionHelp.Text = "The EntitySpaces MetadataEngine PlugIn for VistaDB is bound to VistaDB version '3.5.1.84'."; textBoxConnectionHelp.Text += " You can recompile the PlugIn if you are using a different version. It is located in your '" + Settings.InstallPath + "CodeGeneration\\EntitySpaces.MetadataEngine.VistaDB' folder. After you recompile it put the assembly in the '" + Settings.InstallPath + "CodeGeneration\\Bin' folder."; textBoxConnectionHelp.Text += " You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; case "vistadb4": textBoxConnectionHelp.Text = "The EntitySpaces MetadataEngine PlugIn for VistaDB is bound to VistaDB version '4.0.0.0'."; textBoxConnectionHelp.Text += " You can recompile the PlugIn if you are using a different version. It is located in your '" + Settings.InstallPath + "CodeGeneration\\EntitySpaces.MetadataEngine.VistaDB4' folder. After you recompile it put the assembly in the '" + Settings.InstallPath + "CodeGeneration\\Bin' folder."; textBoxConnectionHelp.Text += " You can save your settings as the default by clicking the 'Save Default Settings' icon on the toolbar."; break; default: textBoxConnectionHelp.Text = "Select a driver from the dropdown above."; break; } } } } catch (Exception ex) { this.ShowError(ex); } }
public void PopulateSettings() { try { // Connection DictionaryEntry de = (DictionaryEntry)comboBoxDriver.SelectedItem; Settings.Driver = (string)de.Value; Settings.ConnectionString = textBoxConnectionString.Text; esSettingsDriverInfo driverInfo = Settings.FindDriverInfoCollection(Settings.Driver); if (driverInfo == null) { driverInfo = new esSettingsDriverInfo(); driverInfo.Driver = Settings.Driver; Settings.DriverInfoCollection.Add(driverInfo); } // Let's pull thier previous information driverInfo.ConnectionString = Settings.ConnectionString; driverInfo.DateAdded.IsEnabled = chkDateAddedEnabled.Checked; driverInfo.DateAdded.ColumnName = txtDateAddedColumnName.Text; driverInfo.DateAdded.ServerSideText = txtDateAddedServerSideText.Text; driverInfo.DateAdded.Type = chkDateAddedClientSideEnabled.Checked ? esSettingsDriverInfo.DateType.ClientSide : esSettingsDriverInfo.DateType.ServerSide; driverInfo.DateAdded.ClientType = rdoDateAddedClientSideNow.Checked ? esSettingsDriverInfo.ClientType.Now : esSettingsDriverInfo.ClientType.UtcNow; driverInfo.DateModified.IsEnabled = chkDateModifiedEnabled.Checked; driverInfo.DateModified.ColumnName = txtDateModifiedColumnName.Text; driverInfo.DateModified.ServerSideText = txtDateModifiedServerSideText.Text; driverInfo.DateModified.Type = chkDateModifiedClientSideEnabled.Checked ? esSettingsDriverInfo.DateType.ClientSide : esSettingsDriverInfo.DateType.ServerSide; driverInfo.DateModified.ClientType = rdoDateModifiedClientSideNow.Checked ? esSettingsDriverInfo.ClientType.Now : esSettingsDriverInfo.ClientType.UtcNow; driverInfo.AddedBy.IsEnabled = chkAddedByEnabled.Checked; driverInfo.AddedBy.UseEventHandler = chkAddedByEventHandler.Checked; driverInfo.AddedBy.ColumnName = txtAddedByColumnName.Text; driverInfo.AddedBy.ServerSideText = txtAddedByServerSideText.Text; driverInfo.ModifiedBy.IsEnabled = chkModifiedByEnabled.Checked; driverInfo.ModifiedBy.UseEventHandler = chkModifiedByEventHandler.Checked; driverInfo.ModifiedBy.ColumnName = txtModifiedByColumnName.Text; driverInfo.ModifiedBy.ServerSideText = txtModifiedByServerSideText.Text; driverInfo.ConcurrencyColumnEnabled = chkConcurrencyColumn.Checked; driverInfo.ConcurrencyColumn = txtConcurrencyColumnName.Text; // File Locations Settings.TemplatePath = textBoxTemplatePath.Text; Settings.OutputPath = textBoxOutputPath.Text; Settings.UIAssemblyPath = textBoxUIAssemblyPath.Text; Settings.CompilerAssemblyPath = textBoxCompilerAssemblyPath.Text; Settings.LanguageMappingFile = textBoxLanguageMap.Text; Settings.UserMetadataFile = textBoxUserMetadata.Text; // Class Names Settings.AbstractPrefix = textBoxAbstractPrefix.Text; Settings.EntitySuffix = textBoxEntitySuffix.Text; Settings.CollectionSuffix = textBoxCollectionSuffix.Text; Settings.QuerySuffix = textBoxQuerySuffix.Text; Settings.MetadataSuffix = textBoxMetadataSuffix.Text; Settings.ProxyStubSuffix = textBoxProxyStubSuffix.Text; // Stored Procedure Names Settings.ProcPrefix = textBoxProcPrefix.Text; Settings.ProcInsert = textBoxProcInsert.Text; Settings.ProcUpdate = textBoxProcUpdate.Text; Settings.ProcDelete = textBoxProcDelete.Text; Settings.ProcLoadAll = textBoxProcLoadAll.Text; Settings.ProcLoadByPK = textBoxProcLoadByPK.Text; Settings.ProcSuffix = textBoxProcSuffix.Text; Settings.ProcVerbFirst = checkBoxProcVerbFirst.Checked; Settings.PrefixWithSchema = checkboxPrefixWithSchema.Checked; // Hierarchical Names Settings.OnePrefix = textBoxOnePrefix.Text; Settings.OneSeparator = textBoxOneSeparator.Text; Settings.OneSuffix = textBoxOneSuffix.Text; Settings.ManyPrefix = textBoxManyPrefix.Text; Settings.ManySeparator = textBoxManySeparator.Text; Settings.ManySuffix = textBoxManySuffix.Text; Settings.SelfOnly = checkBoxSelfOnly.Checked; Settings.SwapNames = checkBoxSwapNames.Checked; Settings.UseAssociativeName = checkBoxUseAssociativeName.Checked; Settings.UseUpToPrefix = checkBoxUseUpToPrefix.Checked; // Miscellaneous Settings.PreserveUnderscores = checkBoxPreserveUnderscores.Checked; Settings.UseRawNames = checkBoxUseRawNames.Checked; // Other Settings.UseNullableTypesAlways = checkBoxUseNullableTypes.Checked; Settings.TurnOffDateTimeInClassHeaders = checkBoxNoDatesInHeader.Checked; if (radioButtonEditTemplate.Checked) Settings.DefaultTemplateDoubleClickAction = "Edit"; if (radioButtonExecute.Checked) Settings.DefaultTemplateDoubleClickAction = "Execute"; if (radioButtonExecuteWithLastSettings.Checked) Settings.DefaultTemplateDoubleClickAction = "ExecuteWithLastSettings"; } catch (Exception ex) { this.ShowError(ex); } }