Пример #1
0
        public void ExecuteScript(IServerProcess process, string script, DAE.Runtime.DataParams paramsValue)
        {
            if (process == null)
            {
                process = DataSession.UtilityProcess;
            }

            DAE.IServerScript localScript = process.PrepareScript(script);
            try
            {
                foreach (DAE.IServerBatch batch in localScript.Batches)
                {
                    if (batch.IsExpression())
                    {
                        DAE.IServerExpressionPlan plan = batch.PrepareExpression(paramsValue);
                        try
                        {
                            ErrorList errors = new ErrorList();
                            errors.AddRange(plan.Messages);
                            ReportErrors(null, errors);

                            if (plan.DataType is DAE.Schema.TableType)
                            {
                                plan.Close(plan.Open(paramsValue));
                            }
                            else
                            {
                                plan.Evaluate(paramsValue).Dispose();
                            }
                        }
                        finally
                        {
                            batch.UnprepareExpression(plan);
                        }
                    }
                    else
                    {
                        DAE.IServerStatementPlan plan = batch.PrepareStatement(paramsValue);
                        try
                        {
                            ErrorList errors = new ErrorList();
                            errors.AddRange(plan.Messages);
                            ReportErrors(null, errors);

                            plan.Execute(paramsValue);
                        }
                        finally
                        {
                            batch.UnprepareStatement(plan);
                        }
                    }
                }
            }
            finally
            {
                process.UnprepareScript(localScript);
            }
        }
Пример #2
0
        public void Execute(IServerProcess process, string statement, DAE.Runtime.DataParams paramsValue)
        {
            if (process == null)
            {
                process = DataSession.UtilityProcess;
            }

            DAE.IServerStatementPlan plan = process.PrepareStatement(statement, paramsValue);
            try
            {
                ErrorList errors = new ErrorList();
                errors.AddRange(plan.Messages);
                ReportErrors(null, errors);

                plan.Execute(paramsValue);
            }
            finally
            {
                process.UnprepareStatement(plan);
            }
        }
Пример #3
0
        // Action

        /// <summary> Runs script on the local server. </summary>
        protected override void InternalExecute(INode sender, EventParams paramsValue)
        {
            DAE.Runtime.DataParams localParamsValue = BaseArgument.CollectArguments(this);

            if (_script != String.Empty)
            {
                Guid enlistWithATID = Guid.Empty;

                if ((_enlistWith != null) && (_enlistWith.DataView != null) && _enlistWith.DataView.Active && (_enlistWith.DataView.ApplicationTransactionServer != null))
                {
                    enlistWithATID = _enlistWith.DataView.ApplicationTransactionServer.ApplicationTransactionID;
                }

                DAE.IServerProcess process = HostNode.Session.DataSession.ServerSession.StartProcess(new DAE.ProcessInfo(HostNode.Session.DataSession.ServerSession.SessionInfo));
                try
                {
                    if (enlistWithATID != Guid.Empty)
                    {
                        process.JoinApplicationTransaction(enlistWithATID, false);
                    }

                    ErrorList errors = new ErrorList();

                    DAE.IServerScript script = process.PrepareScript(_script);
                    try
                    {
                        foreach (DAE.IServerBatch batch in script.Batches)
                        {
                            if (batch.IsExpression())
                            {
                                DAE.IServerExpressionPlan plan = batch.PrepareExpression(localParamsValue);
                                try
                                {
                                    errors.AddRange(plan.Messages);

                                    if (plan.DataType is DAE.Schema.TableType)
                                    {
                                        plan.Close(plan.Open(localParamsValue));
                                    }
                                    else
                                    {
                                        plan.Evaluate(localParamsValue).Dispose();
                                    }
                                }
                                finally
                                {
                                    batch.UnprepareExpression(plan);
                                }
                            }
                            else
                            {
                                DAE.IServerStatementPlan plan = batch.PrepareStatement(localParamsValue);
                                try
                                {
                                    errors.AddRange(plan.Messages);

                                    plan.Execute(localParamsValue);
                                }
                                finally
                                {
                                    batch.UnprepareStatement(plan);
                                }
                            }
                        }
                    }
                    finally
                    {
                        process.UnprepareScript(script);
                    }

                    HostNode.Session.ReportErrors(HostNode, errors);
                }
                finally
                {
                    HostNode.Session.DataSession.ServerSession.StopProcess(process);
                }

                BaseArgument.ApplyArguments(this, localParamsValue);
            }
        }