//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
            {
                ;
            }
        }
예제 #2
0
        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
            {
                ;
            }
        }
예제 #3
0
        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());
            }
        }