Ejemplo n.º 1
0
        List <MetaEV> getValues(DbConnection connection, string sql)
        {
            var result = new List <MetaEV>();

            if (!string.IsNullOrEmpty(sql))
            {
                DataTable table = Helper.GetDataTable(connection, sql);
                if (table.Columns.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        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;
                            result.Add(value);
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the sort value for an enumerated list
        /// </summary>
        public string GetEnumSortValue(string enumValue, bool useDisplayValue)
        {
            string   result = enumValue;
            MetaEnum en     = EnumEL;

            bool   elementSortPosition = (IsSorted && en.UsePosition);
            MetaEV value = null;

            if (useDisplayValue)
            {
                value = en.Values.FirstOrDefault(i => i.DisplayValue == enumValue);
            }
            else
            {
                value = en.Values.FirstOrDefault(i => i.Id == enumValue);
            }

            if (value != null)
            {
                string sortPrefix = elementSortPosition ? string.Format("{0:000000}", en.Values.LastIndexOf(value)) : "";
                result = sortPrefix + Report.EnumDisplayValue(en, value.Id);
            }
            else
            {
                string sortPrefix = elementSortPosition ? "000000" : "";
                result = sortPrefix + result;
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Return the display value from the identifer
        /// </summary>
        public string GetDisplayValue(string id, MetaConnection connection, bool forRestriction = false)
        {
            var    values = ValuesPerConnection ? GetValues(connection) : Values;
            MetaEV value  = values.FirstOrDefault(i => i.Id == id);

            return(value == null ? id : (forRestriction ? value.DisplayRestriction : value.DisplayValue));
        }
Ejemplo n.º 4
0
 void updateFinalCssStyle()
 {
     if (string.IsNullOrEmpty(FinalCssClass) && Element != null && Value != null && Element.IsEnum)
     {
         MetaEV value = Element.EnumEL.Values.FirstOrDefault(i => i.DisplayValue == Value.ToString());
         if (value != null && !string.IsNullOrEmpty(value.Css))
         {
             FinalCssStyle = value.Css;
         }
     }
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 6
0
        public string GetEnumSortValue(string enumValue, bool useDisplayValue)
        {
            string result = enumValue;
            bool   elementSortPosition = (IsSorted && MetaColumn.Enum.UsePosition);
            MetaEV value = null;

            if (useDisplayValue)
            {
                value = MetaColumn.Enum.Values.FirstOrDefault(i => i.Val == enumValue);
            }
            else
            {
                value = MetaColumn.Enum.Values.FirstOrDefault(i => i.Id == enumValue);
            }
            if (value != null)
            {
                string sortPrefix = elementSortPosition ? string.Format("{0:000000}", MetaColumn.Enum.Values.LastIndexOf(value)) : "";
                result = sortPrefix + value.Val;
            }
            return(result);
        }
Ejemplo n.º 7
0
        public string GetDisplayValue(string id, bool forRestriction = false)
        {
            MetaEV value = Values.FirstOrDefault(i => i.Id == id);

            return(value == null ? id : (forRestriction ? value.DisplayRestriction : value.DisplayValue));
        }
Ejemplo n.º 8
0
        public void RefreshEnum(bool checkOnly = false)
        {
            if (_source == null || !IsDynamic) return;

            try
            {
                _error = "";
                _information = "";
                DbConnection connection = _source.GetOpenConnection();
                DataTable table = Helper.GetDataTable(connection, Sql);
                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) ? "" : row[1].ToString()) : value.Id;
                            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();
        }
Ejemplo n.º 9
0
        public string GetDisplayValue(string id)
        {
            MetaEV value = Values.FirstOrDefault(i => i.Id == id);

            return(value == null ? id : value.Val);
        }