示例#1
0
        private ConnectionSettings LoadSettingsFromArgs(string[] args)
        {
            ConnectionSettings conSettings = null;
            CommandLineParams  cmdLine     = new CommandLineParams(args);

            if (cmdLine["cn"] != null)
            {
                if (serverList.IndexOf(cmdLine["cn"]) >= 0)
                {
                    conSettings = serverList.Items[serverList.IndexOf(cmdLine["CN"])];
                    return(conSettings);
                }
            }
            else if (cmdLine["s"] != null)
            {
                conSettings           = new ConnectionSettings();
                conSettings.Type      = ConnectionSettings.ConnectionType.SqlConnection;
                conSettings.SqlServer = cmdLine["s"];
            }
            else if (cmdLine["os"] != null)
            {
                conSettings                  = new ConnectionSettings();
                conSettings.Type             = ConnectionSettings.ConnectionType.Oracle;
                conSettings.OracleDataSource = cmdLine["os"];
            }

            if (conSettings != null)
            {
                if (cmdLine["e"] != null)
                {
                    conSettings.Trusted = true;
                }
                else
                {
                    if (cmdLine["u"] != null)
                    {
                        conSettings.LoginName = cmdLine["u"];
                    }

                    if (cmdLine["p"] != null)
                    {
                        conSettings.Password = cmdLine["p"];
                    }
                }

                if (cmdLine["d"] != null)
                {
                    conSettings.SqlDatabase = cmdLine["d"];
                }
            }
            return(conSettings);
        }