//Application routines private void BuildConnectionString() { PFConnectionManager connMgr = null; DatabasePlatform dbPlat = DatabasePlatform.Unknown; ConnectionStringPrompt cp = null; try { dbPlat = (DatabasePlatform)Enum.Parse(typeof(DatabasePlatform), this.cboDatabaseTypeForOutputTable.Text); connMgr = new PFConnectionManager(); cp = new ConnectionStringPrompt(dbPlat, connMgr); cp.ConnectionString = this.txtConnectionStringForOutputTable.Text; System.Windows.Forms.DialogResult res = cp.ShowConnectionPrompt(); if (res == DialogResult.OK) { this.txtConnectionStringForOutputTable.Text = cp.ConnectionString; } } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); WriteLogMessage(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { ; } }
private void InitDatabaseTypesDropdown() { bool showInstalledDatabaseProvidersOnly = true; PFConnectionManager connMgr = new PFConnectionManager(); PFKeyValueList <string, PFProviderDefinition> provDefs = connMgr.GetListOfProviderDefinitions(); this.cboDatabaseTypeForOutputTables.Items.Clear(); foreach (stKeyValuePair <string, PFProviderDefinition> provDef in provDefs) { if (showInstalledDatabaseProvidersOnly) { if (provDef.Value.InstallationStatus == enProviderInstallationStatus.IsInstalled) { this.cboDatabaseTypeForOutputTables.Items.Add(provDef.Key); } else { ; } } else { this.cboDatabaseTypeForOutputTables.Items.Add(provDef.Key); } } }
public static void UpdateProviderObjects(MainForm frm) { PFConnectionManager connMgr = new PFConnectionManager(); try { _msg.Length = 0; _msg.Append("UpdateProviderObjects started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); //this will get the installation status connMgr.UpdateAllProvidersInstallationStatus(); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { _msg.Length = 0; _msg.Append("\r\n... UpdateProviderObjects finished."); Program._messageLog.WriteLine(_msg.ToString()); } }
public static void CreateConnectionObjects(MainForm frm) { PFConnectionManager connMgr = new PFConnectionManager(); try { _msg.Length = 0; _msg.Append("CreateConnectionObjects started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); connMgr.CreateTestConnectionDefinitions(); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { _msg.Length = 0; _msg.Append("\r\n... CreateConnectionObjects finished."); Program._messageLog.WriteLine(_msg.ToString()); } }
private void InitFormValues() { bool showInstalledDatabaseProvidersOnly = this.ShowInstalledDatabaseProvidersOnly; PFConnectionManager connMgr = new PFConnectionManager(); PFKeyValueList <string, PFProviderDefinition> provDefs = connMgr.GetListOfProviderDefinitions(); if (provDefs.Count == 0) { connMgr.CreateProviderDefinitions(); } else { connMgr.UpdateAllProvidersInstallationStatus(); } provDefs = connMgr.GetListOfProviderDefinitions(); this.cboDatabaseTypeForOutputTable.Items.Clear(); foreach (stKeyValuePair <string, PFProviderDefinition> provDef in provDefs) { if (showInstalledDatabaseProvidersOnly) { if (provDef.Value.InstallationStatus == enProviderInstallationStatus.IsInstalled) { //this.cboDatabaseTypeForOutputTable.Items.Add(provDef.Key); if (provDef.Value.AvailableForSelection) { this.cboDatabaseTypeForOutputTable.Items.Add(provDef.Key); } else { ; } } else { ; } } else { this.cboDatabaseTypeForOutputTable.Items.Add(provDef.Key); } } SetOutputDatabaseProvider(); SetOutputConnectionString(); if (this.cboDatabaseTypeForOutputTable.Text.Trim().Length > 0) { SetOutputTableName(); SetOutputBatchSizeForDbPlatform(); } else { this.txtOutputTableName.Text = string.Empty; this.txtOutputBatchSize.Text = AppConfig.GetStringValueFromConfigFile("DefaultOutputDatabaseBatchSize", "120");; } this.chkReplaceExistingTable.Checked = AppConfig.GetBooleanValueFromConfigFile("ReplaceOutputTableIfExists", "False"); }
private void InitDefaultDatabaseType(ComboBox cboDatabaseType, TextBox txtDefaultDatabseConnectionString) { bool showInstalledDatabaseProvidersOnly = pfDataViewerCP.Properties.Settings.Default.ShowInstalledDatabaseProvidersOnly; PFConnectionManager connMgr = new PFConnectionManager(); PFKeyValueList <string, PFProviderDefinition> provDefs = connMgr.GetListOfProviderDefinitions(); cboDatabaseType.Items.Clear(); foreach (stKeyValuePair <string, PFProviderDefinition> provDef in provDefs) { if (showInstalledDatabaseProvidersOnly) { if (provDef.Value.InstallationStatus == enProviderInstallationStatus.IsInstalled) { if (provDef.Value.AvailableForSelection) { cboDatabaseType.Items.Add(provDef.Key); } else { ; } } else { ; } } else { if (provDef.Value.AvailableForSelection) { cboDatabaseType.Items.Add(provDef.Key); } else { ; } } } if (DatabaseTypeIsInList(cboDatabaseType) == false) { //database type no longer in the list of database types available for use cboDatabaseType.Text = string.Empty; txtDefaultDatabseConnectionString.Text = string.Empty; } else { //database type is still in the list: do nothing ; } }
private void RefreshProviderOption(DatabasePlatform dbPlat, RadioButton opt) { PFConnectionManager connMgr = new PFConnectionManager(); //test //if (this.chkShowInstalledProvidersOnly.Checked) //{ // if (dbPlat == DatabasePlatform.Informix // || dbPlat == DatabasePlatform.SQLAnywhereUltraLite // || dbPlat == DatabasePlatform.SQLServerCE40) // { // opt.Visible = false; // return; // } //} //end test if (connMgr.ProviderDefinitions.Count == 0) { connMgr.CreateProviderDefinitions(); } else { connMgr.UpdateAllProvidersInstallationStatus(); } if (this.chkShowInstalledProvidersOnly.Checked) { for (int i = 0; i < connMgr.ProviderDefinitions.Count; i++) { PFProviderDefinition provDef = connMgr.ProviderDefinitions[i].Value; if (provDef.DbPlatform == dbPlat) { if (provDef.InstallationStatus == enProviderInstallationStatus.IsInstalled) { opt.Visible = true; } else { opt.Visible = false; } break; } }//end for loop } else { opt.Visible = true; } }
private void DefineConnectionString(ComboBox cboDatabaseType, TextBox txtConnectionString) { PFConnectionManager connMgr = null; DatabasePlatform dbPlat = DatabasePlatform.Unknown; ConnectionStringPrompt cp = null; if (cboDatabaseType.Text.Trim().Length == 0) { _msg.Length = 0; _msg.Append("You must specify a database type before defining a connection string."); AppMessages.DisplayWarningMessage(_msg.ToString()); return; } try { dbPlat = (DatabasePlatform)Enum.Parse(typeof(DatabasePlatform), cboDatabaseType.Text); connMgr = new PFConnectionManager(); cp = new ConnectionStringPrompt(dbPlat, connMgr); cp.ConnectionString = txtConnectionString.Text; System.Windows.Forms.DialogResult res = cp.ShowConnectionPrompt(); if (res == DialogResult.OK) { txtConnectionString.Text = cp.ConnectionString; } } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToErrorLog); } finally { ; } }
/// <summary> /// Constructor. /// </summary> public ConnectionStringPrompt(DatabasePlatform dbPlatform, PFConnectionManager connMgr) { _dbPlatform = dbPlatform; _connectionManager = connMgr; }
public static void ShowConnectionPromptForm(MainForm frm) { PFConnectionManager connMgr = null; DatabasePlatform dbPlat = DatabasePlatform.MSSQLServer; bool runTests = false; try { _msg.Length = 0; _msg.Append("ShowConnectionPromptForm started ...\r\n"); Program._messageLog.WriteLine(_msg.ToString()); connMgr = new PFConnectionManager(); ConnectionStringPrompt cp = new ConnectionStringPrompt(dbPlat, connMgr); System.Windows.Forms.DialogResult res = cp.ShowConnectionPrompt(); if (res == System.Windows.Forms.DialogResult.OK) { runTests = true; _msg.Length = 0; _msg.Append("Connection name: "); _msg.Append(cp.ConnectionName); _msg.Append(Environment.NewLine); _msg.Append("Connection string: "); _msg.Append(cp.ConnectionString); _msg.Append(Environment.NewLine); _msg.Append("Connection Definition: "); _msg.Append(Environment.NewLine); if (cp.ConnectionDefinition != null) { _msg.Append(cp.ConnectionDefinition.ToString()); _msg.Append(Environment.NewLine); } Program._messageLog.WriteLine(_msg.ToString()); } else { _msg.Length = 0; _msg.Append("User cancelled connection string request: "); _msg.Append(res.ToString()); Program._messageLog.WriteLine(_msg.ToString()); } if (runTests) { //cp.ConnectionDefinition.SaveToXmlFile(@"c:\temp\TestConnectionDefinition.xml"); //PFConnectionDefinition newCP = PFConnectionDefinition.LoadFromXmlFile(@"c:\temp\TestConnectionDefinition.xml"); //cp.ConnectionDefinition.ConnectionKeyElements.SaveToXmlFile(@"c:\temp\ConnectionKeyElements.xml"); //PFList<stKeyValuePair<string, string>> elementsList = cp.ConnectionDefinition.ConnectionKeyElements.ConvertThisToPFKeyValueListEx(); //elementsList.SaveToXmlFile(@"c:\temp\ConnectionKeyElements_PFList.xml"); //Program._messageLog.WriteLine(Environment.NewLine + "newCP TO STRING:" + Environment.NewLine + newCP.ToString() + Environment.NewLine + "END newCP TO STRING" + Environment.NewLine); //PFKeyValueList<string, string> testlist = PFKeyValueList<string, string>.LoadFromXmlString(cp.ConnectionDefinition.DbPlatformConnectionStringProperties[15].Value); //Program._messageLog.WriteLine(testlist.ToXmlString()); //cp.ConnectionDefinition.DbPlatformConnectionStringProperties.SaveToXmlFile(@"c:\temp\DbPlatformConnectionStringProperties.xml"); //Program._messageLog.WriteLine(Environment.NewLine + "-----------"); //string dumpOutput = PFObjectDumper.Write(cp, 0); //Program._messageLog.WriteLine(dumpOutput); //Program._messageLog.WriteLine(Environment.NewLine + "-----------"); //cp = null; //newCP = null; } } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); Program._messageLog.WriteLine(_msg.ToString()); AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog); } finally { _msg.Length = 0; _msg.Append("\r\n... ShowConnectionPromptForm finished."); Program._messageLog.WriteLine(_msg.ToString()); } }
//Application routines private void ShowConnectionStringForm() { PFConnectionManager connMgr = null; DatabasePlatform dbPlat = DatabasePlatform.Unknown; ConnectionStringPrompt cp = null; try { if (this.optSQLServer.Checked) { dbPlat = DatabasePlatform.MSSQLServer; } else if (this.optSQLServerCE35.Checked) { dbPlat = DatabasePlatform.SQLServerCE35; } else if (this.optSQLServerCE40.Checked) { dbPlat = DatabasePlatform.SQLServerCE40; } else if (this.optMicrosoftAccess.Checked) { dbPlat = DatabasePlatform.MSAccess; } else if (this.optODBC.Checked) { dbPlat = DatabasePlatform.ODBC; } else if (this.optOLEDB.Checked) { dbPlat = DatabasePlatform.OLEDB; } else if (this.optOracleNative.Checked) { dbPlat = DatabasePlatform.OracleNative; } else if (this.optMySQL.Checked) { dbPlat = DatabasePlatform.MySQL; } else if (this.optDB2.Checked) { dbPlat = DatabasePlatform.DB2; } else if (this.optInformix.Checked) { dbPlat = DatabasePlatform.Informix; } else if (this.optSybase.Checked) { dbPlat = DatabasePlatform.Sybase; } else if (this.optSQLAnywhere.Checked) { dbPlat = DatabasePlatform.SQLAnywhere; } else if (this.optSQLAnywhereUL.Checked) { dbPlat = DatabasePlatform.SQLAnywhereUltraLite; } else if (this.optMSOracle.Checked) { dbPlat = DatabasePlatform.MSOracle; } else { dbPlat = DatabasePlatform.SQLServerCE35; } connMgr = new PFConnectionManager(); cp = new ConnectionStringPrompt(dbPlat, connMgr); cp.ConnectionString = string.Empty; System.Windows.Forms.DialogResult res = cp.ShowConnectionPrompt(); } catch (System.Exception ex) { _msg.Length = 0; _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex)); AppMessages.DisplayErrorMessage(_msg.ToString()); } finally { ; } }