Ejemplo n.º 1
0
        //example:
        //Driver={Adaptive Server Enterprise};server=profastsv2syb;port=5000;schemaRoot=AdventureWorks;uid=SA;Pwd=SA1992;
        private string ConvertSybaseConnectionStringToOdbc(string sybaseConnectionString)
        {
            string        odbcConnectionString = string.Empty;
            PFParseString sqlConnBuilder       = new PFParseString();
            string        val = string.Empty;

            if (_connectionString.Trim().Length > 0)
            {
                sqlConnBuilder.KeyType       = PFParseString.PFArgumentKeyType.NamedKey;
                sqlConnBuilder.Delimiters    = ";";
                sqlConnBuilder.StringToParse = sybaseConnectionString;

                _str.Length = 0;
                _str.Append("Driver={Adaptive Server Enterprise};");

                PFParseString.PFKeyValuePair kv = new PFParseString.PFKeyValuePair();
                kv = sqlConnBuilder.GetFirstKeyValue();
                while (kv.Key != string.Empty)
                {
                    if (kv.Key.ToLower() == "data source")
                    {
                        _str.Append("server=");
                        _str.Append(kv.Value);
                        _str.Append(";");
                    }
                    if (kv.Key.ToLower() == "port")
                    {
                        _str.Append("port=");
                        _str.Append(kv.Value);
                        _str.Append(";");
                    }
                    if (kv.Key.ToLower() == "database")
                    {
                        _str.Append("schemaRoot=");
                        _str.Append(kv.Value);
                        _str.Append(";");
                    }
                    if (kv.Key.ToLower() == "uid")
                    {
                        _str.Append("uid=");
                        _str.Append(kv.Value);
                        _str.Append(";");
                    }
                    if (kv.Key.ToLower() == "pwd")
                    {
                        _str.Append("pwd=");
                        _str.Append(kv.Value);
                        _str.Append(";");
                    }

                    kv = sqlConnBuilder.GetNextKeyValue();
                }
            }

            odbcConnectionString = _str.ToString();

            return(odbcConnectionString);
        }
Ejemplo n.º 2
0
        public static void RunCommandLineParseTest(MainForm frm)
        {
            PFParseString parse = new PFParseString();

            try
            {
                _msg.Length = 0;
                _msg.Append("RunCommandLineParseTest running ...");
                Program._messageLog.WriteLine(_msg.ToString());

                parse.QuotedValues = frm.chkQuotedValues.Checked;
                parse.KeyType      = frm.cboKeyType.Text == "NoKey" ? PFParseString.PFArgumentKeyType.NoKey
                                : frm.cboKeyType.Text == "CharKey" ? PFParseString.PFArgumentKeyType.CharKey
                                : PFParseString.PFArgumentKeyType.NamedKey;
                parse.Delimiters    = frm.txtDelimiters.Text;
                parse.StringToParse = frm.txtCommandLineToParse.Text;

                _msg.Length = 0;
                _msg.Append("Key type: ");
                _msg.Append(parse.KeyType.ToString());
                _msg.Append("\r\n");
                _msg.Append("Delimiters: ");
                _msg.Append(parse.Delimiters);
                _msg.Append("\r\n");
                _msg.Append("QuotedValues: ");
                _msg.Append(parse.QuotedValues.ToString());
                _msg.Append("\r\n");
                _msg.Append("String to parse: ");
                _msg.Append(parse.StringToParse);
                _msg.Append("\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                _msg.Length = 0;

                if (parse.KeyType == PFParseString.PFArgumentKeyType.NoKey)
                {
                    string val = string.Empty;
                    _msg.Append("Show first to last:\r\n");
                    val = parse.GetFirst();
                    while (parse.EOL == false)
                    {
                        _msg.Append(val);
                        _msg.Append("\r\n");
                        val = parse.GetNext();
                    }
                    _msg.Append("Show last to first:\r\n");
                    val = parse.GetLast();
                    while (parse.EOL == false)
                    {
                        _msg.Append(val);
                        _msg.Append("\r\n");
                        val = parse.GetPrev();
                    }
                    Program._messageLog.WriteLine(_msg.ToString());
                }
                else
                {
                    //is either CharKey or NamedKey
                    PFParseString.PFKeyValuePair kv = new PFParseString.PFKeyValuePair();
                    _msg.Append("Show first to last:\r\n");
                    kv = parse.GetFirstKeyValue();
                    while (kv.Key != string.Empty)
                    {
                        _msg.Append("Key = ");
                        _msg.Append(kv.Key);
                        _msg.Append(" Val = ");
                        _msg.Append(kv.Value);
                        _msg.Append("\r\n");
                        kv = parse.GetNextKeyValue();
                    }
                    _msg.Append("Show last to first:\r\n");
                    kv = parse.GetLastKeyValue();
                    while (kv.Key != string.Empty)
                    {
                        _msg.Append("Key = ");
                        _msg.Append(kv.Key);
                        _msg.Append(" Val = ");
                        _msg.Append(kv.Value);
                        _msg.Append("\r\n");
                        kv = parse.GetPrevKeyValue();
                    }
                    Program._messageLog.WriteLine(_msg.ToString());
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                ;
            }
        }