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

            var classBuilderThead = string.Empty;
            var classBuilderTbody = string.Empty;

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

                    var itemForm          = string.Empty;
                    var textTemplateThead = string.Empty;
                    var textTemplateTbody = string.Empty;

                    var fieldInBlackListCreate = FieldInBlackListSave(tableInfo, item.PropertyName);
                    if (fieldInBlackListCreate)
                    {
                        continue;
                    }

                    if (item.IsKey == 1 && !IsPropertyNavigationTypeInstance(tableInfo, item.PropertyName))
                    {
                        var pathTemplateThead = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTheadId(tableInfo));
                        textTemplateThead = Read.AllText(tableInfo, pathTemplateThead, this._defineTemplateFolder);
                        var pathTemplateTbody = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTbodyString(tableInfo));
                        textTemplateTbody = Read.AllText(tableInfo, pathTemplateTbody, this._defineTemplateFolder);
                    }

                    else if (item.Type == "string")
                    {
                        var pathTemplateThead = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTheadFields(tableInfo));
                        textTemplateThead = Read.AllText(tableInfo, pathTemplateThead, this._defineTemplateFolder);
                        var pathTemplateTbody = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTbodyString(tableInfo));
                        textTemplateTbody = Read.AllText(tableInfo, pathTemplateTbody, this._defineTemplateFolder);
                    }

                    else if (item.Type == "DateTime" || item.Type == "DateTime?")
                    {
                        var pathTemplateThead = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTheadFields(tableInfo));
                        textTemplateThead = Read.AllText(tableInfo, pathTemplateThead, this._defineTemplateFolder);
                        var pathTemplateTbody = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTbodyDate(tableInfo));
                        textTemplateTbody = Read.AllText(tableInfo, pathTemplateTbody, this._defineTemplateFolder);
                    }
                    else if (item.Type == "bool" || item.Type == "bool?")
                    {
                        var pathTemplateThead = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTheadFields(tableInfo));
                        textTemplateThead = Read.AllText(tableInfo, pathTemplateThead, this._defineTemplateFolder);
                        var pathTemplateTbody = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTbodyBoolean(tableInfo));
                        textTemplateTbody = Read.AllText(tableInfo, pathTemplateTbody, this._defineTemplateFolder);
                    }

                    else if (item.Type == "decimal" || item.Type == "decimal?" || item.Type == "float" || item.Type == "float?")
                    {
                        var pathTemplateThead = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTheadFields(tableInfo));
                        textTemplateThead = Read.AllText(tableInfo, pathTemplateThead, this._defineTemplateFolder);
                        var pathTemplateTbody = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTbodyNumber(tableInfo));
                        textTemplateTbody = Read.AllText(tableInfo, pathTemplateTbody, this._defineTemplateFolder);
                    }

                    else
                    {
                        if (!IsPropertyNavigationTypeInstance(tableInfo, item.PropertyName))
                        {
                            var pathTemplateThead = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTheadId(tableInfo));
                            textTemplateThead = Read.AllText(tableInfo, pathTemplateThead, this._defineTemplateFolder);
                            var pathTemplateTbody = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularTbodyString(tableInfo));
                            textTemplateTbody = Read.AllText(tableInfo, pathTemplateTbody, this._defineTemplateFolder);
                        }
                        else
                        {
                            continue;
                        }
                    }

                    textTemplateThead = textTemplateThead
                                        .Replace("<#propertyName#>", item.PropertyName)
                                        .Replace("<#className#>", tableInfo.ClassName)
                                        .Replace("<#isRequired#>", item.IsNullable == 0 ? "required" : "")
                                        .Replace("<#ReletedClass#>", PropertyNavigationTypeInstance(tableInfo, item.PropertyName));

                    textTemplateTbody = textTemplateTbody
                                        .Replace("<#propertyName#>", item.PropertyName)
                                        .Replace("<#className#>", tableInfo.ClassName)
                                        .Replace("<#isRequired#>", item.IsNullable == 0 ? "required" : "")
                                        .Replace("<#ReletedClass#>", PropertyNavigationTypeInstance(tableInfo, item.PropertyName));

                    classBuilderThead += string.Format("{0}{1}", textTemplateThead, System.Environment.NewLine);
                    classBuilderTbody += string.Format("{0}{1}", textTemplateTbody, System.Environment.NewLine);
                }
            }

            classBuilder = classBuilder
                           .Replace("<#theadFields#>", classBuilderThead)
                           .Replace("<#tbodyFields#>", classBuilderTbody);
            return(classBuilder);
        }