示例#1
0
        private string MakeFilterClassBuilder(TableInfo tableInfo, Context configContext, UniqueListInfo infos, string textTemplate)
        {
            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplate);

            var classBuilderForm = string.Empty;

            if (infos.IsAny())
            {
                foreach (var item in infos)
                {
                    if (Audit.IsAuditField(item.PropertyName))
                    {
                        continue;
                    }

                    if (item.IsKey == 1 && !IsPropertyNavigationTypeInstance(tableInfo, item.PropertyName))
                    {
                        continue;
                    }

                    var itemForm          = string.Empty;
                    var pathTemplateField = string.Empty;
                    var textTemplateField = string.Empty;

                    var fieldInBlackListFilter = FieldInBlackListFilter(tableInfo, item.PropertyName);
                    if (fieldInBlackListFilter)
                    {
                        continue;
                    }

                    if (item.Type == "string")
                    {
                        pathTemplateField = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularFieldInput(tableInfo));
                        textTemplateField = Read.AllText(tableInfo, pathTemplateField, this._defineTemplateFolder);
                    }

                    else if (item.Type == "DateTime" || item.Type == "DateTime?")
                    {
                        pathTemplateField = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularFieldDate(tableInfo));
                        textTemplateField = Read.AllText(tableInfo, pathTemplateField, this._defineTemplateFolder);

                        itemForm.Replace("<#propertyName#>", string.Format("{0}{1}{2}", item.PropertyName + "Start", System.Environment.NewLine, "<#propertyName#>"));
                        itemForm.Replace("<#propertyName#>", string.Format("{0}", item.PropertyName + "End"));
                    }
                    else if (item.Type == "bool" || item.Type == "bool?")
                    {
                        pathTemplateField = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularFieldRadio(tableInfo));
                        textTemplateField = Read.AllText(tableInfo, pathTemplateField, this._defineTemplateFolder);
                    }

                    else
                    {
                        if (IsPropertyNavigationTypeInstance(tableInfo, item.PropertyName))
                        {
                            pathTemplateField = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularFieldSelect(tableInfo));
                            textTemplateField = Read.AllText(tableInfo, pathTemplateField, this._defineTemplateFolder);
                        }
                        else
                        {
                            pathTemplateField = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularFieldInput(tableInfo));
                            textTemplateField = Read.AllText(tableInfo, pathTemplateField, this._defineTemplateFolder);
                        }
                    }

                    itemForm = FormFieldReplace(configContext, tableInfo, item, textTemplateField);
                    itemForm = itemForm
                               .Replace("<#formType#>", "filter")
                               .Replace("<#propertyName#>", item.PropertyName)
                               .Replace("<#className#>", tableInfo.ClassName)
                               .Replace("<#isRequired#>", "")
                               .Replace("<#ReletedClass#>", PropertyNavigationTypeInstance(tableInfo, item.PropertyName));

                    classBuilderForm += string.Format("{0}{1}", itemForm, System.Environment.NewLine);
                }
            }

            classBuilder = classBuilder.Replace("<#formFields#>", classBuilderForm);
            return(classBuilder);
        }