예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// Helper to create a MetaEnum for a given MetaColumn
        /// </summary>
        public MetaEnum CreateEnumFromColumn(MetaColumn column)
        {
            MetaEnum result = AddEnum();

            result.IsEditable = true;
            result.Name       = column.DisplayName;
            if (!IsNoSQL)
            {
                result.IsDynamic = true;
                result.Sql       = string.Format("SELECT DISTINCT \r\n{0} \r\nFROM {1} \r\nORDER BY 1", column.Name, column.MetaTable.FullSQLName);
                result.RefreshEnum();
            }
            else
            {
                result.IsDynamic = false;
                column.MetaTable.BuildNoSQLTable(true);
                foreach (DataRow row in column.MetaTable.NoSQLTable.Rows)
                {
                    result.Values.Add(new MetaEV()
                    {
                        Id = row[column.Name].ToString()
                    });
                }
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Add a MetaEnum to the MetaData
        /// </summary>
        public MetaEnum AddEnum()
        {
            MetaEnum result = MetaEnum.Create();

            result.Name = "Enum";
            result.Name = Helper.GetUniqueName(result.Name, (from i in MetaData.Enums select i.Name).ToList());
            MetaData.Enums.Add(result);
            result.Source = this;
            return(result);
        }
예제 #4
0
 /// <summary>
 /// Remove a MetaEnum from the MetaData
 /// </summary>
 public void RemoveEnum(MetaEnum item)
 {
     //Clean up enum references from columns
     foreach (MetaTable table in MetaData.Tables)
     {
         foreach (MetaColumn column in table.Columns.Where(i => i.EnumGUID == item.GUID))
         {
             column.EnumGUID = "";
         }
     }
     MetaData.Enums.Remove(item);
 }
예제 #5
0
 void setContext(ITypeDescriptorContext context)
 {
     _metaConnection = context.Instance as MetaConnection;
     _metaEnum = context.Instance as MetaEnum;
     _metaTable = context.Instance as MetaTable;
     _metaColumn = context.Instance as MetaColumn;
     _metaJoin = context.Instance as MetaJoin;
     _reportView = context.Instance as ReportView;
     _reportOutput = context.Instance as ReportOutput;
     _reportSchedule = context.Instance as ReportSchedule;
     _parameter = context.Instance as Parameter;
     _security = context.Instance as SealSecurity;
     _emailDevice = context.Instance as OutputEmailDevice;
 }
예제 #6
0
        /// <summary>
        /// Helper to create a MetaEnum for a given MetaColumn
        /// </summary>
        public MetaEnum CreateEnumFromColumn(MetaColumn column)
        {
            MetaEnum result = AddEnum();

            result.IsEditable = true;
            result.Name       = column.DisplayName;
            result.IsDynamic  = true;
            if (!IsNoSQL)
            {
                result.Sql = string.Format("SELECT DISTINCT \r\n{0} \r\nFROM {1} \r\nORDER BY 1", column.Name, column.MetaTable.FullSQLName);
            }
            else
            {
                result.Script = @"@using System.Data
@{
    MetaEnum enumList = Model;
    MetaSource source = enumList.Source;
    MetaTable table = source.MetaData.Tables.FirstOrDefault(i => i.Name == TableName);
    if (table != null)
    {
        DataTable dataTable = table.BuildNoSQLTable(true);
        enumList.Values.Clear();
        foreach (DataRow val in dataTable.Rows)
        {
            if (!enumList.Values.Exists(i => i.Id == val[ColumnName].ToString()))
            {
                enumList.Values.Add(new MetaEV() { Id = val[ColumnName].ToString() });
            }
        }
    }
}
";
                result.Script = result.Script.Replace("TableName", Helper.QuoteDouble(column.MetaTable.Name));
                result.Script = result.Script.Replace("ColumnName", Helper.QuoteDouble(column.Name));
            }
            result.RefreshEnum();
            return(result);
        }
예제 #7
0
 public string EnumDisplayValue(MetaEnum instance, string id)
 {
     string result = instance.GetDisplayValue(id);
     if (instance.Translate) result = Repository.RepositoryTranslate(ExecutionView.CultureInfo.TwoLetterISOLanguageName, "Enum", instance.Name, result);
     return result;
 }
예제 #8
0
 public void RemoveEnum(MetaEnum item)
 {
     //Clean up enum references from columns
     foreach (MetaTable table in MetaData.Tables)
     {
         foreach (MetaColumn column in table.Columns.Where(i => i.EnumGUID == item.GUID))
         {
             column.EnumGUID = "";
         }
     }
     MetaData.Enums.Remove(item);
 }