Esempio n. 1
0
        public override void DefineTemplateByTableInfoFields(Context config, TableInfo tableInfo, UniqueListInfo infos)
        {
            foreach (var item in infos)
            {
                var order = TypeConvertCSharp.OrderByType(item.Type);

                if (tableInfo.FieldsConfig.IsAny())
                {
                    var orderField = tableInfo.FieldsConfig
                                     .Where(_ => _.Name.ToLower() == item.ColumnName.ToString().ToLower())
                                     .SingleOrDefault();

                    if (orderField.IsNotNull() && orderField.Order.IsSent())
                    {
                        order = orderField.Order;
                    }
                }

                item.Order = order;
            }

            base.CastOrdenabledToUniqueListInfo(infos);
        }
        public override void DefineTemplateByTableInfoFields(Context config, TableInfo tableInfo, UniqueListInfo infos)
        {
            foreach (var item in infos)
            {
                var order       = TypeConvertCSharp.OrderByType(item.Type);
                var orderFilter = TypeConvertCSharp.OrderByType(item.Type);

                var group               = default(Group);
                var groupComponents     = default(List <GroupComponent>);
                var ShowFieldIsKey      = false;
                var CameCasingManual    = "";
                var RelationOneToOne    = false;
                var dateTimeComparation = config.DateTimeComparation;
                var htmlComponent       = "";

                if (tableInfo.FieldsConfig.IsAny())
                {
                    var dateTimeComparationConfig = tableInfo.FieldsConfig
                                                    .Where(_ => _.Name.ToLower() == item.PropertyName.ToString().ToLower())
                                                    .SingleOrDefault();

                    if (dateTimeComparationConfig.IsNotNull() && dateTimeComparationConfig.DateTimeComparation.IsSent())
                    {
                        dateTimeComparation = dateTimeComparationConfig.DateTimeComparation;
                    }


                    var orderConfig = tableInfo.FieldsConfig
                                      .Where(_ => _.Name.ToLower() == item.PropertyName.ToString().ToLower())
                                      .SingleOrDefault();

                    if (orderConfig.IsNotNull() && orderConfig.Order.IsSent())
                    {
                        order = orderConfig.Order;
                    }


                    if (orderConfig.IsNotNull() && orderConfig.OrderFilter.IsSent())
                    {
                        orderFilter = orderConfig.OrderFilter;
                    }
                    else
                    {
                        orderFilter = int.MaxValue;
                    }

                    var groupConfig = tableInfo.FieldsConfig
                                      .Where(_ => _.Name.ToLower() == item.PropertyName.ToString().ToLower())
                                      .SingleOrDefault();

                    if (groupConfig.IsNotNull() && groupConfig.Group.IsNotNull())
                    {
                        group = groupConfig.Group;
                    }


                    var groupComponentConfig = tableInfo.FieldsConfig
                                               .Where(_ => _.Name.ToLower() == item.PropertyName.ToString().ToLower())
                                               .SingleOrDefault();

                    if (groupComponentConfig.IsNotNull() && groupComponentConfig.GroupComponents.IsAny())
                    {
                        groupComponents = groupConfig.GroupComponents;
                    }


                    var ShowFieldIsKeyConfig = tableInfo.FieldsConfig
                                               .Where(_ => _.Name.ToLower() == item.PropertyName.ToString().ToLower())
                                               .SingleOrDefault();

                    if (ShowFieldIsKeyConfig.IsNotNull() && ShowFieldIsKeyConfig.ShowFieldIsKey.IsSent())
                    {
                        ShowFieldIsKey = groupConfig.ShowFieldIsKey;
                    }

                    var RelationOneToOneConfig = tableInfo.FieldsConfig
                                                 .Where(_ => _.Name.ToLower() == item.PropertyName.ToString().ToLower())
                                                 .SingleOrDefault();

                    if (RelationOneToOneConfig.IsNotNull() && RelationOneToOneConfig.RelationOneToOne.IsSent())
                    {
                        RelationOneToOne = groupConfig.RelationOneToOne;
                    }


                    var CameCasingManualConfig = tableInfo.FieldsConfig
                                                 .Where(_ => _.Name.ToLower() == item.PropertyName.ToString().ToLower())
                                                 .SingleOrDefault();

                    if (CameCasingManualConfig.IsNotNull() && CameCasingManualConfig.CameCasingManual.IsSent())
                    {
                        CameCasingManual = groupConfig.CameCasingManual;
                    }

                    var textEditor = tableInfo.FieldsConfig
                                     .Where(_ => _.Name.ToLower() == item.PropertyName.ToString().ToLower())
                                     .SingleOrDefault();

                    if (textEditor.IsNotNull() && textEditor.TextEditor.IsSent())
                    {
                        htmlComponent = "TextEditor";
                    }

                    if (textEditor.IsNotNull() && textEditor.Upload.IsSent())
                    {
                        htmlComponent = "Upload";
                    }
                }


                item.Order               = order;
                item.HtmlComponent       = htmlComponent;
                item.OrderFilter         = orderFilter;
                item.DateTimeComparation = dateTimeComparation;
                item.Group               = group;
                item.GroupComponents     = groupComponents;
                item.ShowFieldIsKey      = ShowFieldIsKey;
                item.CameCasingManual    = CameCasingManual;
                item.RelationOneToOne    = RelationOneToOne;
            }

            base.CastOrdenabledToUniqueListInfo(infos);
        }