Ejemplo n.º 1
0
        protected override void CollectArguments(ref DAE.Runtime.DataParams paramsValue)
        {
            if (!(String.IsNullOrEmpty(_keyName) && String.IsNullOrEmpty(_defaultValue)) && !String.IsNullOrEmpty(_paramName))
            {
                DAE.Schema.IDataType type;
                object value;
                GetTypeAndValue(out type, out value);

                if (type != null)
                {
                    if (paramsValue == null)
                    {
                        paramsValue = new DAE.Runtime.DataParams();
                    }
                    paramsValue.Add
                    (
                        new DAE.Runtime.DataParam
                        (
                            _paramName,
                            type,
                            Modifier,
                            value
                        )
                    );
                }
            }
        }
Ejemplo n.º 2
0
        protected override void CollectArguments(ref DAE.Runtime.DataParams paramsValue)
        {
            if ((Source != null) && (Source.DataView != null) && Source.DataView.Active)
            {
                string[]            paramNames;
                DAE.Schema.Column[] columns;

                GetParams(out paramNames, out columns);

                for (int i = 0; i < columns.Length; i++)
                {
                    // Create the collection when we find the first item to add to it
                    if (paramsValue == null)
                    {
                        paramsValue = new DAE.Runtime.DataParams();
                    }

                    DAE.Schema.Column column = columns[i];
                    DataField         field  = Source.DataView.Fields[column.Name];

                    paramsValue.Add
                    (
                        new DAE.Runtime.DataParam
                        (
                            paramNames[i],
                            column.DataType,
                            Modifier,
                            Source.IsEmpty ? null : (field.HasValue() ? field.AsNative : null)
                        )
                    );
                }
            }
        }
Ejemplo n.º 3
0
        protected override void ApplyArguments(DAE.Runtime.DataParams paramsValue)
        {
            if
            (
                (Modifier == DAE.Language.Modifier.Out || Modifier == DAE.Language.Modifier.Var) &&
                (Source != null) &&
                (Source.DataView != null) &&
                Source.DataView.Active &&
                !Source.DataView.IsReadOnly
            )
            {
                string[]            paramNames;
                DAE.Schema.Column[] columns;

                GetParams(out paramNames, out columns);

                for (int i = 0; i < columns.Length; i++)
                {
                    DAE.Runtime.DataParam param = paramsValue[paramNames[i]];
                    if (((param.Modifier == DAE.Language.Modifier.Out) || (param.Modifier == DAE.Language.Modifier.Var)) && !Source.IsEmpty)
                    {
                        DAE.Schema.Column column = columns[i];
                        DataField         field  = Source.DataView.Fields[column.Name];
                        field.AsNative = param.Value;
                    }
                }
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
 public static void ApplyArguments(INode node, DAE.Runtime.DataParams paramsValue)
 {
     if (node != null)
     {
         foreach (Node localNode in node.Children)
         {
             BaseArgument argument = localNode as BaseArgument;
             if (argument != null)
             {
                 argument.ApplyArguments(paramsValue);
             }
         }
     }
 }
Ejemplo n.º 6
0
 public static DAE.Runtime.DataParams CollectArguments(INode node)
 {
     DAE.Runtime.DataParams paramsValue = null;
     if (node != null)
     {
         foreach (Node localNode in node.Children)
         {
             BaseArgument argument = localNode as BaseArgument;
             if (argument != null)
             {
                 argument.CollectArguments(ref paramsValue);
             }
         }
     }
     return(paramsValue);
 }
Ejemplo n.º 7
0
        protected override void ApplyArguments(DAE.Runtime.DataParams paramsValue)
        {
            if
            (
                (Modifier == DAE.Language.Modifier.Out || Modifier == DAE.Language.Modifier.Var) &&
                !(String.IsNullOrEmpty(_keyName) && String.IsNullOrEmpty(_defaultValue)) &&
                !String.IsNullOrEmpty(_paramName)
            )
            {
                var interfaceValue = FindParent(typeof(IInterface)) as IInterface;
                if (interfaceValue == null || String.IsNullOrEmpty(_keyName) || !interfaceValue.UserState.ContainsKey(_keyName))
                {
                    var       param     = paramsValue[_paramName];
                    TokenType tokenType = TokenType.EOF;
                    if (param.Value == null)
                    {
                        tokenType = TokenType.Nil;
                    }
                    else
                    {
                        switch (param.DataType.Name)
                        {
                        case "System.Boolean": tokenType = TokenType.Boolean; break;

                        case "System.Decimal": tokenType = TokenType.Decimal; break;

                        case "System.Integer": tokenType = TokenType.Integer; break;

                        case "System.Money": tokenType = TokenType.Money; break;

                        case "System.String": tokenType = TokenType.String; break;
                        }
                    }
                    if (tokenType != TokenType.EOF)
                    {
                        var expression = new ValueExpression(param.Value, tokenType);
                        var emitter    = new Alphora.Dataphor.DAE.Language.D4.D4TextEmitter();
                        DefaultValue = emitter.Emit(expression);
                    }
                }
                else
                {
                    interfaceValue.UserState[_keyName] = paramsValue[_paramName].Value;
                }
            }
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
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);
            }
        }
Ejemplo n.º 10
0
 /// <summary>Evaluates the given expression enlisted within the specified application transaction.</summary>
 public DAE.Runtime.Data.Scalar EvaluateScalarWith(IServerProcess process, Guid iD, string expression, DAE.Runtime.DataParams paramsValue)
 {
     if (process == null)
     {
         process = DataSession.UtilityProcess;
     }
     process.JoinApplicationTransaction(iD, false);
     try
     {
         return(EvaluateScalar(process, expression, paramsValue));
     }
     finally
     {
         process.LeaveApplicationTransaction();
     }
 }
Ejemplo n.º 11
0
 public void Execute(string statement, DAE.Runtime.DataParams paramsValue)
 {
     Execute(null, statement, paramsValue);
 }
Ejemplo n.º 12
0
 protected abstract void ApplyArguments(DAE.Runtime.DataParams paramsValue);
Ejemplo n.º 13
0
 protected abstract void CollectArguments(ref DAE.Runtime.DataParams paramsValue);
Ejemplo n.º 14
0
 public DAE.Runtime.Data.IDataValue Evaluate(string expression, DAE.Runtime.DataParams paramsValue)
 {
     return(Evaluate(null, expression, paramsValue));
 }
Ejemplo n.º 15
0
 public void ExecuteScript(string script, DAE.Runtime.DataParams paramsValue)
 {
     DataSession.ExecuteScript(null, script, paramsValue);
 }
Ejemplo n.º 16
0
 public DAE.Runtime.Data.Scalar EvaluateScalar(string expression, DAE.Runtime.DataParams paramsValue)
 {
     return(EvaluateScalar(null, expression, paramsValue));
 }
Ejemplo n.º 17
0
 /// <summary>Evaluates the given expression enlisted within the specified application transaction.</summary>
 public DAE.Runtime.Data.Scalar EvaluateScalarWith(Guid iD, string expression, DAE.Runtime.DataParams paramsValue)
 {
     return(EvaluateScalarWith(null, iD, expression, paramsValue));
 }
Ejemplo n.º 18
0
        public DAE.Runtime.Data.Scalar EvaluateScalar(IServerProcess process, string expression, DAE.Runtime.DataParams paramsValue)
        {
            if (process == null)
            {
                process = DataSession.UtilityProcess;
            }

            DAE.IServerExpressionPlan plan = process.PrepareExpression(expression, paramsValue);
            try
            {
                ErrorList errors = new ErrorList();
                errors.AddRange(plan.Messages);
                ReportErrors(null, errors);

                return((DAE.Runtime.Data.Scalar)plan.Evaluate(paramsValue));
            }
            finally
            {
                process.UnprepareExpression(plan);
            }
        }
Ejemplo n.º 19
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);
            }
        }
Ejemplo n.º 20
0
        /// <summary> Prepares for opening a document in the specified application. </summary>
        /// <returns> The starting document configured for the application. </returns>
        public virtual string SetApplication(string applicationID, string clientType)
        {
            DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams();
            paramsValue.Add(DAE.Runtime.DataParam.Create(Pipe.Process, "AApplicationID", applicationID));
            paramsValue.Add(DAE.Runtime.DataParam.Create(Pipe.Process, "AClientType", clientType));

            // Get the node types table
            using (DAE.Runtime.Data.Scalar nodeTable = DataSession.Evaluate(ApplicationNodeTableExpression, paramsValue))
            {
                NodeTypeTable.Clear();
                NodeTypeTable.LoadFromString(nodeTable.AsString);
            }
            ValidateNodeTypeTable();

            // Prepare the application and get name of the starting document
            string documentString = null;

            using (DAE.Runtime.Data.Scalar startingDocument = DataSession.Evaluate(PrepareApplicationExpression, paramsValue))
            {
                documentString = startingDocument.AsString;
            }

            // Load the files required to register any nodes, if necessary
            if (DataSession.Server is DAE.Server.LocalServer)
            {
                IServerCursor cursor = DataSession.OpenCursor(GetLibraryFilesExpression, paramsValue);
                try
                {
                    using (DAE.Runtime.Data.IRow row = cursor.Plan.RequestRow())
                    {
                                                #if !SILVERLIGHT
                        bool          shouldLoad;
                        List <string> filesToLoad = new List <string>();

                        while (cursor.Next())
                        {
                            cursor.Select(row);
                            string fullFileName =
                                ((DAE.Server.LocalServer)DataSession.Server).GetFile
                                (
                                    (DAE.Server.LocalProcess)cursor.Plan.Process,
                                    (string)row["Library_Name"],
                                    (string)row["Name"],
                                    (DateTime)row["TimeStamp"],
                                    (bool)row["IsDotNetAssembly"],
                                    out shouldLoad
                                );
                            if (shouldLoad)
                            {
                                filesToLoad.Add(fullFileName);
                            }
                        }

                        // Load each file to ensure they can be reached by the assembly resolver hack (see AssemblyUtility)
                        foreach (string fullFileName in filesToLoad)
                        {
                            Assembly.LoadFrom(fullFileName);
                        }
                                                #else
                        while (cursor.Next())
                        {
                            cursor.Select(row);
                            ((DAE.Server.LocalServer)DataSession.Server).LoadAndRegister
                            (
                                (DAE.Server.LocalProcess)cursor.Plan.Process,
                                cursor.Plan.Catalog.ClassLoader,
                                (string)row["Library_Name"],
                                (string)row["Name"],
                                (bool)row["ShouldRegister"]
                            );
                        }
                                                #endif
                    }
                }
                finally
                {
                    DataSession.CloseCursor(cursor);
                }
            }

            return(documentString);
        }