コード例 #1
0
        override public void Start(Script script, IConnectionSettings cs, AuditProcedure auditProcedure, Dictionary <string, string> variables)
        {
            _script                 = script;
            _script.Success         = true;
            _script.ExecutionStatus = ExecutionStatus.Executed;
            _cs = (OracleConnectionSettings)cs;

            StringComparer sc = new StringComparer();

            _schemas = new List <string>();
            if (!string.IsNullOrWhiteSpace(script.Schema))
            {
                if (_cs.Schema.Contains(script.Schema, sc))
                {
                    _schemas.Add(script.Schema);
                }
                else
                {
                    throw new Exception(string.Format("{0} not found in adapter parameters, possible invalid schema.", script.Schema));
                }
            }
            else
            {
                throw new Exception(string.Format("{0}: Schema required in manifest.", cs.Database));
            }

            base.Start(script, cs, auditProcedure, variables);
        }
コード例 #2
0
        public void RunScript(string script, string schema, bool isFile, IConnectionSettings cs)
        {
            OnStepProgress("RunScript", string.Format("On Schema {0}", schema));
            _currSchema = schema;
            OracleConnectionSettings ocs = (OracleConnectionSettings)cs;

            string cmd = isFile ? string.Format(" @\"{0}\"", script) : string.Empty;

            string connectionMinusPassword = string.Empty;
            string arguments = GetConnectionString(schema, ocs.Instance, ocs.Port, ocs.Database, ref connectionMinusPassword);

            arguments = string.Format("{0}{1}", arguments, cmd);

            _p = ScriptProcessorUtil.CreateProcess(_exe, arguments);
            _p.StartInfo.EnvironmentVariables.Add("SQLPATH", Alphaleonis.Win32.Filesystem.Path.GetShort83Path(PathHelper.CachePath));
            _p.StartInfo.EnvironmentVariables.Add("NLS_LANG", WorkflowParameters.NLS_LANG);

            _p.OutputDataReceived        += p_OutputDataReceived;
            _p.ErrorDataReceived         += p_ErrorDataReceived;
            _p.StartInfo.WorkingDirectory = Path.GetDirectoryName(Properties.Settings.Default.SqlPlusPath);

            if (_script.ShowSqlInOutput)
            {
                string scriptText = script;
                if (isFile)
                {
                    scriptText = File.ReadAllText(script);
                }
                OnStepProgress(string.Empty, scriptText);
            }

            _p.Start();
            if (!isFile)
            {
                _p.StandardInput.WriteLine(script);
            }
            _p.StandardInput.WriteLine("Exit");

            #region read this
            // best practice information on accessing stdout/stderr from mdsn article:
            //  https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput%28v=vs.110%29.aspx
            // Do not wait for the child process to exit before reading to the end of its redirected stream.
            // Do not perform a synchronous read to the end of both redirected streams.
            // string output = p.StandardOutput.ReadToEnd();
            // string error = p.StandardError.ReadToEnd();
            // p.WaitForExit();
            // Use asynchronous read operations on at least one of the streams.
            #endregion
            _p.BeginOutputReadLine();
            _p.BeginErrorReadLine();


            _p.WaitForExit();
        }
コード例 #3
0
        static public ConnectionValidationResult ValidateConnectionSettings(OracleConnectionSettings cs)
        {
            ConnectionValidationResult result = new ConnectionValidationResult(true, string.Empty);

            foreach (string schema in cs.Schema)
            {
                string connectionMinusPassword = string.Empty;
                string arguments = GetConnectionString(schema, cs.Instance, cs.Port, cs.Database, ref connectionMinusPassword);
                arguments = " -l " + arguments;
                ConnectionValidationResult r = ValidateConnectionSettings(arguments);
                result.IsValid &= r.IsValid;
                result.Message += string.Format("\r\n{1}:{0}", r.Message, schema);
            }
            result.Message.Trim();

            return(result);
        }
コード例 #4
0
        public ConnectionSettingsCollection ToOracleConnectionSettings()
        {
            //optimistic initialization (IsValid = true)
            ConnectionSettingsCollection list = new ConnectionSettingsCollection()
            {
                IsValid = true
            };

            foreach (DatabaseInstance i in this.DatabaseInstance)
            {
                foreach (Database db in i.Database)
                {
                    OracleConnectionSettings cs = new OracleConnectionSettings()
                    {
                        Instance = i.Name,
                        Database = db.Name,
                        //Schema = db.Schema.Name,
                        Port = i.PortNumber
                    };
                    foreach (string schema in db.Schema)
                    {
                        cs.Schema.Add(schema);
                    }


                    cs.Validate();
                    if (!cs.IsValid)
                    {
                        list.IsValid = false;
                    }

                    list.Add(cs);
                }
            }

            if (list.Count == 0)
            {
                list.IsValid = false;
            }

            return(list);
        }