Beispiel #1
0
 private static void GetParamsFromRow(IRow row, DAE.Runtime.DataParams LParams, string prefix)
 {
     for (int index = 0; index < row.DataType.Columns.Count; index++)
     {
         LParams.Add(new DAE.Runtime.DataParam(prefix + row.DataType.Columns[index].Name, row.DataType.Columns[index].DataType, Modifier.In, row[index]));
     }
 }
Beispiel #2
0
 protected override Alphora.Dataphor.DAE.Runtime.DataParams GetParams()
 {
     DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams();
     paramsValue.Add(DAE.Runtime.DataParam.Create(Dataphoria.UtilityProcess, "AShowGenerated", _showGeneratedObjects));
     paramsValue.Add(DAE.Runtime.DataParam.Create(Dataphoria.UtilityProcess, "AShowSystem", _showSystemObjects));
     paramsValue.Add(DAE.Runtime.DataParam.Create(Dataphoria.UtilityProcess, "ALibraryName", _libraryName));
     return(paramsValue);
 }
Beispiel #3
0
 /// <summary> Populates a given a (non null) DataParams collection with the actual params used by the DataSet. </summary>
 public void GetAllParams(DAE.Runtime.DataParams paramsValue)
 {
     CheckActive();
     foreach (DataSetDataParam param in _cursor.Params)
     {
         paramsValue.Add(param);
     }
 }
Beispiel #4
0
 protected void UnprepareRootPlan()
 {
     if (_rootPlan != null)
     {
         _process.UnprepareExpression(_rootPlan);
         _rootParams = null;
         _rootPlan   = null;
     }
 }
Beispiel #5
0
 protected IServerExpressionPlan PrepareRootPlan()
 {
     if (_rootPlan == null)
     {
         _rootParams = new DAE.Runtime.DataParams();
         Source.DataView.GetAllParams(_rootParams);
         _rootPlan = _process.PrepareExpression(GetExpression(_rootExpression), _rootParams);
     }
     return(_rootPlan);
 }
Beispiel #6
0
 protected void PrepareParams()
 {
     if (_params == null)
     {
         _params = new DAE.Runtime.DataParams();
         foreach (DAE.Schema.OrderColumn orderColumn in Source.DataView.Order.Columns)
         {
             _params.Add(new DAE.Runtime.DataParam("ACurrent" + orderColumn.Column.Name, orderColumn.Column.DataType, Modifier.Const));
         }
     }
 }
Beispiel #7
0
 /// <summary>Constructs a DataParams from the given parameter names and native value arrays.</summary>
 public static DAE.Runtime.DataParams DataParamsFromNativeParams(IServerProcess process, string[] paramNames, object[] paramsValue)
 {
     DAE.Runtime.DataParams localParamsValue = new DAE.Runtime.DataParams();
     for (int i = 0; i < paramsValue.Length; i++)
     {
         object objectValue = paramsValue[i];
         if (objectValue is DBNull)
         {
             objectValue = null;
         }
         if (objectValue is Double)
         {
             objectValue = Convert.ToDecimal((double)objectValue);
         }
         localParamsValue.Add(DAE.Runtime.DataParam.Create(process, paramNames[i], objectValue, ScalarTypeFromNativeType(process, objectValue == null ? null : objectValue.GetType())));
     }
     return(localParamsValue);
 }
Beispiel #8
0
 public void SetLibrary(string libraryName)
 {
     DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams();
     paramsValue.Add(DAE.Runtime.DataParam.Create(Pipe.Process, "ALibraryName", libraryName));
     using
     (
         DAE.Runtime.Data.Scalar nodeTable =
             DataSession.Evaluate
             (
                 LibraryNodeTypesExpression,
                 paramsValue
             )
     )
     {
         NodeTypeTable.Clear();
         NodeTypeTable.LoadFromString(nodeTable.AsString);
     }
     ValidateNodeTypeTable();
 }
Beispiel #9
0
        /// <summary>Executes the given statement using the utility process.</summary>
        public void Execute(IServerProcess process, string statement, DAE.Runtime.DataParams paramsValue)
        {
            CheckActive();

            if (process == null)
            {
                process = UtilityProcess;
            }

            IServerStatementPlan plan = process.PrepareStatement(statement, paramsValue);

            try
            {
                plan.Execute(paramsValue);
            }
            finally
            {
                process.UnprepareStatement(plan);
            }
        }
Beispiel #10
0
 protected override void InternalDelete()
 {
     if (_deleteStatement == String.Empty)
     {
         base.InternalDelete();
     }
     else
     {
         DAE.Runtime.DataParams paramsValue = GetParamsFromRow(_buffer[_activeOffset].Row, "Old.");
         IServerStatementPlan   plan        = _process.PrepareStatement(_deleteStatement, paramsValue);
         try
         {
             plan.Execute(paramsValue);
         }
         finally
         {
             _process.UnprepareStatement(plan);
         }
     }
 }
Beispiel #11
0
        /// <summary>Opens a cursor on the given expression using the given process.</summary>
        public IServerCursor OpenCursor(IServerProcess process, string expression, DAE.Runtime.DataParams paramsValue)
        {
            CheckActive();

            if (process == null)
            {
                process = UtilityProcess;
            }

            IServerExpressionPlan plan = process.PrepareExpression(expression, paramsValue);

            try
            {
                return(plan.Open(paramsValue));
            }
            catch
            {
                process.UnprepareExpression(plan);
                throw;
            }
        }
Beispiel #12
0
 protected override void InternalUpdate(IRow row)
 {
     if (_updateStatement == String.Empty)
     {
         base.InternalUpdate(row);
     }
     else
     {
         DAE.Runtime.DataParams paramsValue = GetParamsFromRow(_originalRow, "Old.");
         GetParamsFromRow(row, paramsValue, "New.");
         IServerStatementPlan plan = _process.PrepareStatement(_updateStatement, paramsValue);
         try
         {
             plan.Execute(paramsValue);
         }
         finally
         {
             _process.UnprepareStatement(plan);
         }
     }
 }
Beispiel #13
0
        /// <summary>Executes the given script using the given process.</summary>
        public void ExecuteScript(IServerProcess process, string script, DAE.Runtime.DataParams paramsValue)
        {
            if (script != String.Empty)
            {
                CheckActive();

                if (process == null)
                {
                    process = UtilityProcess;
                }

                IServerScript localScript = process.PrepareScript(script);
                try
                {
                    localScript.Execute(paramsValue);
                }
                finally
                {
                    process.UnprepareScript(localScript);
                }
            }
        }
Beispiel #14
0
        public static void SequenceChange(Client.Session session, ISource source, bool shouldEnlist, DAE.Runtime.Data.IRow fromRow, DAE.Runtime.Data.IRow toRow, bool above, string script)
        {
            if (!String.IsNullOrEmpty(script) && source != null)
            {
                Guid enlistWithATID = Guid.Empty;

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

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

                    // Prepare arguments
                    DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams();
                    foreach (DAE.Schema.Column column in fromRow.DataType.Columns)
                    {
                        paramsValue.Add(new DAE.Runtime.DataParam("AFromRow." + column.Name, column.DataType, DAE.Language.Modifier.In, fromRow[column.Name]));
                        paramsValue.Add(new DAE.Runtime.DataParam("AToRow." + column.Name, column.DataType, DAE.Language.Modifier.In, toRow[column.Name]));
                    }
                    paramsValue.Add(new DAE.Runtime.DataParam("AAbove", source.DataView.Process.DataTypes.SystemBoolean, DAE.Language.Modifier.In, above));

                    session.ExecuteScript(process, script, paramsValue);
                }
                finally
                {
                    session.DataSession.ServerSession.StopProcess(process);
                }

                source.DataView.Refresh();
            }
        }
        private void InternalSaveData(object data, bool binary)
        {
            if (binary)
            {
                throw new NotSupportedException("InternalSaveData called with ABinary true");
            }

            DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams();
            paramsValue.Add(new DAE.Runtime.DataParam("LibraryName", Dataphoria.UtilityProcess.DataTypes.SystemString, DAE.Language.Modifier.Const, DAE.Schema.Object.EnsureRooted(LibraryName)));
            paramsValue.Add(new DAE.Runtime.DataParam("DocumentName", Dataphoria.UtilityProcess.DataTypes.SystemString, DAE.Language.Modifier.Const, DAE.Schema.Object.EnsureRooted(DocumentName)));
            paramsValue.Add(new DAE.Runtime.DataParam("DocumentType", Dataphoria.UtilityProcess.DataTypes.SystemString, DAE.Language.Modifier.Const, DocumentType));
            paramsValue.Add(new DAE.Runtime.DataParam("Data", Dataphoria.UtilityProcess.DataTypes.SystemString, DAE.Language.Modifier.Const, data));

            DAE.IServerStatementPlan plan = Dataphoria.UtilityProcess.PrepareStatement(".Frontend.CreateAndSave(LibraryName, DocumentName, DocumentType, Data)", paramsValue);
            try
            {
                plan.Execute(paramsValue);
            }
            finally
            {
                Dataphoria.UtilityProcess.UnprepareStatement(plan);
            }
        }
Beispiel #16
0
        /// <summary>Evaluates the given expression using the given process and returns the result.</summary>
        public DAE.Runtime.Data.IDataValue EvaluateRaw(IServerProcess process, string expression, DAE.Runtime.DataParams paramsValue)
        {
            CheckActive();

            if (process == null)
            {
                process = UtilityProcess;
            }

            IServerExpressionPlan plan = process.PrepareExpression(expression, paramsValue);

            try
            {
                return(plan.Evaluate(paramsValue));
            }
            finally
            {
                process.UnprepareExpression(plan);
            }
        }
Beispiel #17
0
 /// <summary>Evaluates the given expression using the utility process and returns the result as a scalar.</summary>
 public DAE.Runtime.Data.Scalar Evaluate(string expression, DAE.Runtime.DataParams paramsValue)
 {
     return((DAE.Runtime.Data.Scalar)EvaluateRaw(expression, paramsValue));
 }
Beispiel #18
0
 private DAE.Runtime.DataParams GetParamsFromRow(IRow row, string prefix)
 {
     DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams();
     GetParamsFromRow(row, paramsValue, prefix);
     return(paramsValue);
 }
Beispiel #19
0
 /// <summary>EvaluateRows the given expression using the utility process and returns the result as a row.</summary>
 public DAE.Runtime.Data.Row EvaluateRow(string expression, DAE.Runtime.DataParams paramsValue)
 {
     return((DAE.Runtime.Data.Row)EvaluateRaw(expression, paramsValue));
 }
Beispiel #20
0
        public override string SetApplication(string applicationID, string clientType)
        {
            // Reset our current settings
            _theme = null;
            DisposeDefaultIcon();
            ClearDocumentCache();
            ClearImageCache();
            int documentCacheSize = CDefaultDocumentCacheSize;
            int imageCacheSize    = CDefaultImageCacheSize;

            // Optimistically load the settings
            try
            {
                DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams();
                paramsValue.Add(DAE.Runtime.DataParam.Create(Pipe.Process, "AApplicationID", applicationID));

                using (DAE.Runtime.Data.Row row = (DAE.Runtime.Data.Row)Evaluate(Pipe.Process, SettingsExpression, paramsValue))
                {
                    if (row != null)
                    {
                        // Load the theme
                        if (row.HasValue("Theme"))
                        {
                            _theme = (Theme) new BOP.Deserializer().Deserialize((string)row["Theme"], null);
                        }

                        // Load the default form icon
                        if (row.HasValue("IconImage"))
                        {
                            using (Stream iconStream = row.GetValue("IconImage").OpenStream())
                            {
                                Bitmap bitmap = System.Drawing.Image.FromStream(iconStream) as Bitmap;
                                if (bitmap != null)
                                {
                                    _defaultIcon = Icon.FromHandle(bitmap.GetHicon());                                          // TODO: Should this bitmap be disposed after this?
                                }
                            }
                        }

                        // Load the document cache size
                        if (row.HasValue("DocumentCacheSize"))
                        {
                            documentCacheSize = (int)row["DocumentCacheSize"];
                        }

                        // Load the image cache size
                        if (row.HasValue("ImageCacheSize"))
                        {
                            imageCacheSize = (int)row["ImageCacheSize"];
                        }

                        // Load the help file
                        if (row.HasValue("HelpDocument"))
                        {
                            string document = (string)row["HelpDocument"];
                            if (document != String.Empty)
                            {
                                LoadHelpDocument(document);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                HandleException(new ClientException(ClientException.Codes.ErrorLoadingSettings, exception));
            }
            finally
            {
                if (_theme == null)
                {
                    _theme = new Theme();
                }
            }

            // Setup the image cache
            try
            {
                if (imageCacheSize > 0)
                {
                    Pipe.ImageCache = new FixedSizeCache <string, byte[]>(imageCacheSize);
                }
            }
            catch (Exception exception)
            {
                HandleException(exception);                     // Don't fail, just warn
            }

            // Set up the client-side document cache
            try
            {
                if (documentCacheSize > 0)
                {
                    Pipe.Cache =
                        new DocumentCache
                        (
                            Path.Combine
                            (
                                Path.Combine(System.IO.Path.GetTempPath(), CCachePath),
                                @"App" + applicationID.ToString()
                            ),
                            documentCacheSize
                        );
                }
            }
                        #if DEBUG
            catch (Exception exception)
                        #else
            catch
                        #endif
            {
                                #if DEBUG
                HandleException(exception);                     // Don't fail if we can't do this and only show something if under debug
                                #endif
            }

            return(base.SetApplication(applicationID, clientType));
        }
Beispiel #21
0
 /// <summary>EvaluateLists the given expression using the utility process and returns the result as a list.</summary>
 public DAE.Runtime.Data.ListValue EvaluateList(string expression, DAE.Runtime.DataParams paramsValue)
 {
     return((DAE.Runtime.Data.ListValue)EvaluateRaw(expression, paramsValue));
 }
Beispiel #22
0
 /// <summary>Executes the given statement using the utility process.</summary>
 public void Execute(string statement, DAE.Runtime.DataParams paramsValue)
 {
     Execute(null, statement, paramsValue);
 }
Beispiel #23
0
 /// <summary>EvaluateTables the given expression using the utility process and returns the result as a table.</summary>
 public DAE.Runtime.Data.Table EvaluateTable(string expression, DAE.Runtime.DataParams paramsValue)
 {
     return((DAE.Runtime.Data.Table)EvaluateRaw(expression, paramsValue));
 }
Beispiel #24
0
 /// <summary>Executes the given script using the utility process.</summary>
 public void ExecuteScript(string script, DAE.Runtime.DataParams paramsValue)
 {
     ExecuteScript(null, script, paramsValue);
 }
Beispiel #25
0
 /// <summary>EvaluateTables the given expression using the given process and returns the result as a table.</summary>
 public DAE.Runtime.Data.Table EvaluateTable(IServerProcess process, string expression, DAE.Runtime.DataParams paramsValue)
 {
     return((DAE.Runtime.Data.Table)EvaluateRaw(process, expression, paramsValue));
 }
Beispiel #26
0
 /// <summary>Opens a cursor on the given expression using the utility process.</summary>
 public IServerCursor OpenCursor(string expression, DAE.Runtime.DataParams paramsValue)
 {
     return(OpenCursor(null, expression, paramsValue));
 }
Beispiel #27
0
 /// <summary>Evaluates the given expression using the utility process and returns the result.</summary>
 public DAE.Runtime.Data.IDataValue EvaluateRaw(string expression, DAE.Runtime.DataParams paramsValue)
 {
     return(EvaluateRaw(null, expression, paramsValue));
 }
 protected override Alphora.Dataphor.DAE.Runtime.DataParams GetParams()
 {
     DAE.Runtime.DataParams paramsValue = new DAE.Runtime.DataParams();
     paramsValue.Add(DAE.Runtime.DataParam.Create(Dataphoria.UtilityProcess, "ALibraryName", LibraryName));
     return(paramsValue);
 }