Exemple #1
0
        DataTable GetDefinitionTable(string sql)
        {
            DataTable result   = null;
            var       finalSQL = sql;

            try
            {
                if (IsSQL)
                {
                    DbConnection connection = _source.GetOpenConnection();

                    Helper.ExecutePrePostSQL(connection, Model == null ? ReportModel.ClearCommonRestrictions(PreSQL) : Model.ParseCommonRestrictions(PreSQL), this, IgnorePrePostError);
                    finalSQL = Model == null?ReportModel.ClearCommonRestrictions(sql) : Model.ParseCommonRestrictions(sql);

                    result = Helper.GetDataTable(connection, finalSQL);
                    Helper.ExecutePrePostSQL(connection, Model == null ? ReportModel.ClearCommonRestrictions(PostSQL) : Model.ParseCommonRestrictions(PostSQL), this, IgnorePrePostError);
                    connection.Close();
                }
                else
                {
                    result = BuildNoSQLTable(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + "\r\n" + finalSQL);
            }

            return(result);
        }
Exemple #2
0
        DataTable GetDefinitionTable(string sql)
        {
            DataTable result = null;

            if (IsSQL)
            {
                DbConnection connection = _source.GetOpenConnection();
                Helper.ExecutePrePostSQL(connection, PreSQL, this, IgnorePrePostError);
                result = Helper.GetDataTable(connection, sql);
                Helper.ExecutePrePostSQL(connection, PostSQL, this, IgnorePrePostError);
                connection.Close();
            }
            else
            {
                result = BuildNoSQLTable(false);
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Returns the list of the enum values to display after applying filter and depencies
        /// </summary>
        public List <MetaEV> GetSubSetValues(string filter, Dictionary <MetaEnum, string> dependencies)
        {
            var result = new List <MetaEV>();

            if (!string.IsNullOrEmpty(SqlDisplay))
            {
                DbConnection connection = _source.GetOpenConnection();
                var          finalSQL   = RazorHelper.CompileExecute(SqlDisplay, this);
                if (HasDynamicDisplay)
                {
                    finalSQL = finalSQL.Replace(Repository.EnumFilterKeyword + "}", filter);
                }
                if (HasDynamicDisplay && dependencies != null)
                {
                    foreach (var d in dependencies.Keys)
                    {
                        finalSQL = finalSQL.Replace(Repository.EnumValuesKeyword + d.Name + "}", dependencies[d]);
                    }
                }
                finalSQL = Helper.ClearAllSQLKeywords(finalSQL);
                result   = getValues(connection, finalSQL);
            }

            if (!string.IsNullOrEmpty(ScriptDisplay))
            {
                var finalScript = ScriptDisplay;
                if (HasDynamicDisplay)
                {
                    finalScript = finalScript.Replace(Repository.EnumFilterKeyword + "}", Helper.QuoteDouble(filter));
                }
                if (HasDynamicDisplay && dependencies != null)
                {
                    foreach (var d in dependencies.Keys)
                    {
                        finalScript = finalScript.Replace(Repository.EnumValuesKeyword + d.Name + "}", dependencies[d]);
                    }
                }
                finalScript = Helper.ClearAllLINQKeywords(finalScript);
                RazorHelper.CompileExecute(finalScript, this);
                result = NewValues.ToList();
            }

            return(result);
        }
Exemple #4
0
        public List <MetaEV> GetSubSetValues(string filter, Dictionary <MetaEnum, string> dependencies)
        {
            DbConnection connection = _source.GetOpenConnection();

            var finalSQL = RazorHelper.CompileExecute(SqlDisplay, this);

            if (HasDynamicDisplay)
            {
                finalSQL = finalSQL.Replace(Repository.EnumFilterKeyword + "}", filter);
            }
            if (HasDynamicDisplay && dependencies != null)
            {
                foreach (var d in dependencies.Keys)
                {
                    finalSQL = finalSQL.Replace(Repository.EnumValuesKeyword + d.Name + "}", dependencies[d]);
                }
            }
            finalSQL = Helper.ClearAllSQLKeywords(finalSQL);

            return(getValues(connection, finalSQL));
        }
Exemple #5
0
        public void RefreshEnum(bool checkOnly = false)
        {
            if (_source == null || !IsDynamic)
            {
                return;
            }

            try
            {
                _error       = "";
                _information = "";
                DbConnection connection = _source.GetOpenConnection();
                DataTable    table      = Helper.GetDataTable(connection, RazorHelper.CompileExecute(Sql, this));
                connection.Close();

                if (checkOnly)
                {
                    return;
                }

                Values.Clear();
                foreach (DataRow row in table.Rows)
                {
                    if (table.Columns.Count > 0)
                    {
                        if (!row.IsNull(0))
                        {
                            MetaEV value = new MetaEV();
                            value.Id    = row[0].ToString();
                            value.Val   = table.Columns.Count > 1 ? (row.IsNull(1) ? null : row[1].ToString()) : null;
                            value.ValR  = table.Columns.Count > 2 ? (row.IsNull(2) ? null : row[2].ToString()) : null;
                            value.Css   = table.Columns.Count > 3 ? (row.IsNull(3) ? null : row[3].ToString()) : null;
                            value.Class = table.Columns.Count > 4 ? (row.IsNull(4) ? null : row[4].ToString()) : null;
                            Values.Add(value);
                        }
                    }
                }
                _information = string.Format("List refreshed with {0} value(s).", Values.Count);
            }
            catch (Exception ex)
            {
                _error       = ex.Message;
                _information = "Error got when refreshing the values.";
            }
            _information = Helper.FormatMessage(_information);
            UpdateEditorAttributes();
        }