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); } }
protected override bool EvaluateCondition() { bool result = false; if (Condition != String.Empty) { DAE.Runtime.DataParams localParamsValue = BaseArgument.CollectArguments(this); DAE.IServerProcess process = HostNode.Session.DataSession.ServerSession.StartProcess(new DAE.ProcessInfo(HostNode.Session.DataSession.ServerSession.SessionInfo)); try { ErrorList errors = new ErrorList(); DAE.IServerScript script = process.PrepareScript(String.Format("select {0}", Condition)); try { DAE.IServerBatch batch = script.Batches[0]; DAE.IServerExpressionPlan plan = batch.PrepareExpression(localParamsValue); try { errors.AddRange(plan.Messages); using (IDataValue dataValue = plan.Evaluate(localParamsValue)) result = dataValue == null ? false : (bool)dataValue.AsNative; } finally { batch.UnprepareExpression(plan); } } finally { process.UnprepareScript(script); } HostNode.Session.ReportErrors(HostNode, errors); } finally { HostNode.Session.DataSession.ServerSession.StopProcess(process); } BaseArgument.ApplyArguments(this, localParamsValue); } return(result); }
// 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); } }