Esempio n. 1
0
        private void ExecuteTemplateContainerPartial(TableInfo tableInfo, Context configContext)
        {
            if (!tableInfo.MakeApi)
            {
                return;
            }

            var pathOutput = PathOutput.PathOutputContainerPartialApi(configContext);

            if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarContainerClassPartialExistentes"]) == false)
            {
                return;
            }

            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ContainerPartial(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);

            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);

            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 2
0
        private void ExecuteTemplateAngularModelFilter(TableInfo tableInfo, Context configContext)
        {
            if (tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (!tableInfo.MakeFront)
            {
                return;
            }

            var pathOutput = PathOutputAngular.PathOutputAngularModelFilter(tableInfo, configContext);

            if (File.Exists(pathOutput))
            {
                return;
            }

            var pathTemplate = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularModelFilter(tableInfo));
            var textTemplate = Read.AllText(tableInfo, pathTemplate, this._defineTemplateFolder);
            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplate);

            using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); }
        }
Esempio n. 3
0
        private void ExecuteTemplateOrderByDomainExtension(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos)
        {
            if (tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (!tableInfo.MakeDomain)
            {
                return;
            }


            var pathOutput = PathOutput.PathOutputInfraOrderByDomainExtension(tableInfo, configContext);

            if (File.Exists(pathOutput))
            {
                return;
            }

            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.EntityOrderByDomainExtension(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var classBuilder      = base.GenericTagsTransformer(tableInfo, configContext, textTemplateClass);

            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 4
0
        private void ExecuteTemplateVueRouter(TableInfo tableInfo, Context configContext)
        {
            if (tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (!tableInfo.MakeFront)
            {
                return;
            }

            var pathOutput = PathOutputVue.PathOutputVueRouterViewComponent(tableInfo, configContext);

            var pathTemplate = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameVue.VueRouterComponent(tableInfo));
            var textTemplate = Read.AllText(tableInfo, pathTemplate, this._defineTemplateFolder);
            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplate);

            var itens = string.Empty;

            foreach (var item in configContext.TableInfo)
            {
                var str = @"    { path: '" + item.ClassName.ToLower() + "', name: '" + (item.ClassNameFormated ?? item.ClassName) + "', component: function (resolve) { require(['@/views/" + item.ClassName.ToLower() + "'], resolve) } },";
                itens += string.Format("{0}{1}", str, System.Environment.NewLine);
            }

            classBuilder = classBuilder.Replace("<#pathsRoute#>", itens);

            using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); }
        }
Esempio n. 5
0
        private void ExecuteTemplateAngularRoutingGenerated(TableInfo tableInfo, Context configContext)
        {
            if (tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (!tableInfo.MakeFront)
            {
                return;
            }

            var pathOutput = PathOutputAngular.PathOutputAngularRoutingGenerated(tableInfo, configContext);

            var pathTemplate = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.RoutingGenerated(tableInfo));
            var textTemplate = Read.AllText(tableInfo, pathTemplate, this._defineTemplateFolder);
            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplate);

            var itens = string.Empty;

            foreach (var item in configContext.TableInfo)
            {
                var str = @"    { path: '" + item.ClassName.ToLower() + "', loadChildren: './views/" + item.ClassName.ToLower() + "/" + item.ClassName.ToLower() + ".module#" + item.ClassName + "Module' },";
                itens += string.Format("{0}{1}", str, System.Environment.NewLine);
            }

            classBuilder = classBuilder.Replace("<#pathsRoute#>", itens);

            using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); }
        }
Esempio n. 6
0
        private void ExecuteTemplateApiStart(TableInfo tableInfo, Context configContext)
        {
            if (!tableInfo.MakeApi)
            {
                return;
            }

            var pathOutput = PathOutput.PathOutputWebApiStart(configContext);

            if (File.Exists(pathOutput))
            {
                return;
            }

            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiStart(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var classBuilder      = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);

            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 7
0
        private void ExecuteTemplateVueIndex(TableInfo tableInfo, Context configContext, UniqueListInfo infos)
        {
            if (tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (!tableInfo.MakeFront)
            {
                return;
            }

            var pathOutput = PathOutputVue.PathOutputVueIndexViewComponent(tableInfo, configContext);

            if (File.Exists(pathOutput))
            {
                return;
            }

            var pathTemplate = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameVue.VueIndexComponent(tableInfo));
            var textTemplate = Read.AllText(tableInfo, pathTemplate, this._defineTemplateFolder);
            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplate);

            classBuilder = this.MakeGridClassBuilder(tableInfo, configContext, infos, classBuilder);

            using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); }
        }
Esempio n. 8
0
        private void ExecuteTemplateApiTests(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos)
        {
            var pathOutput = PathOutput.PathOutputApiTest(tableInfo, configContext);

            if (!tableInfo.MakeTest)
            {
                return;
            }

            if (!tableInfo.MakeApi)
            {
                return;
            }


            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiTest(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var pathTemplateMoqValues = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiTestMoqValues(tableInfo));

            var textTemplateClass     = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var TextTemplateMoqValues = Read.AllText(tableInfo, pathTemplateMoqValues, this._defineTemplateFolder);


            var classBuilder          = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);
            var classBuilderMoqValues = string.Empty;

            foreach (var item in infos)
            {
                if (item.IsKey == 1)
                {
                    continue;
                }

                if (Audit.IsAuditField(item.PropertyName))
                {
                    continue;
                }

                var itemvalue = TextTemplateMoqValues.
                                Replace("<#propertyName#>", item.PropertyName).
                                Replace("<#length#>", item.Type == "string" ? item.Length : string.Empty).
                                Replace("<#moqMethod#>", DefineMoqMethd(item.Type));

                classBuilderMoqValues += string.Format("{0}{1}{2}", Tabs.TabSets(), itemvalue, System.Environment.NewLine);
            }

            classBuilder = classBuilder.Replace("<#moqValuesinsert#>", classBuilderMoqValues);


            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 9
0
        private void ExecuteTemplateEntitysExt(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos)
        {
            if (tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (!tableInfo.MakeDomain)
            {
                return;
            }

            var pathOutput = PathOutput.PathOutputDomainEntitysExt(tableInfo, configContext);

            if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarModelPartialExistentes"]) == false)
            {
                return;
            }

            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.EntityExt(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var pathTemplatePropertys = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.EntityProperty(tableInfo));
            var textTemplateClass     = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var textTemplatePropertys = Read.AllText(tableInfo, pathTemplatePropertys, this._defineTemplateFolder);


            var classBuilder = textTemplateClass;

            classBuilder = classBuilder.Replace("<#classBaseEntity#>", this.InheritEntityBase(infos));
            classBuilder = classBuilder.Replace("<#ctorparametersRequired#>", this.ConstructorParametersRequired(infos));
            classBuilder = classBuilder.Replace("<#ctorparametersRequiredBase#>", this.ConstructorParametersRequiredBase(infos));
            classBuilder = classBuilder.Replace("<#parametersRequired#>", this.ParametersRequired(infos));
            classBuilder = classBuilder.Replace("<#parametersRequiredToBase#>", this.ParametersRequiredToBase(infos));
            classBuilder = classBuilder.Replace("<#property#>", base.BuilderPropertys(infos, textTemplatePropertys, configContext));
            classBuilder = classBuilder.Replace("<#initParametersRequired#>", this.InitParametersRequired(infos));
            classBuilder = classBuilder.Replace("<#methodsSeters#>", this.MethodsSeters(infos, tableInfo));
            classBuilder = classBuilder.Replace("<#parametersRequiredConstruction#>", this.ParametersRequiredConstruction(infos));
            classBuilder = classBuilder.Replace("<#methodsSetersConstruction#>", this.MethodsSetersConstruction(infos));
            classBuilder = base.GenericTagsTransformer(tableInfo, configContext, classBuilder);



            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 10
0
        private void ExecuteTemplateContainer(TableInfo tableInfo, Context configContext)
        {
            if (!tableInfo.MakeApi)
            {
                return;
            }

            var pathOutput = PathOutput.PathOutputContainerApi(configContext);

            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.Container(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var pathTemplateInjections = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ContainerInjections(tableInfo));


            var textTemplateClass      = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var TextTemplateInjections = Read.AllText(tableInfo, pathTemplateInjections, this._defineTemplateFolder);

            if (configContext.Module.IsNullOrEmpty())
            {
                textTemplateClass = textTemplateClass.Replace("<#domainSource#>", configContext.ProjectName);
            }
            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);

            var classBuilderMappers = string.Empty;

            foreach (var item in configContext.TableInfo)
            {
                if (!string.IsNullOrEmpty(item.ClassName))
                {
                    var itemInjections = TextTemplateInjections.
                                         Replace("<#namespace#>", configContext.Namespace).
                                         Replace("<#module#>", configContext.Module.IsNullOrEmpty() ? configContext.ProjectName : configContext.Module).
                                         Replace("<#className#>", item.ClassName).
                                         Replace("<#domainSource#>", configContext.DomainSource.IsNullOrEmpty() ? configContext.ProjectName : configContext.DomainSource).
                                         Replace("<#namespaceDomainSource#>", configContext.NamespaceDomainSource);


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


            classBuilder = classBuilder.Replace("<#injections#>", classBuilderMappers);


            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
        public static void FixContentFile(string projectName, string newFileName)
        {
            Console.WriteLine($"{projectName} >> {new FileInfo(newFileName).Name} >> change content.");
            var contentBody = File.ReadAllText(newFileName);

            contentBody = Regex.Replace(contentBody, "Seed", projectName, RegexOptions.IgnoreCase);
            using (var writer = new HelperStream(newFileName).GetInstance())
            {
                writer.Write(contentBody);
            }
        }
Esempio n. 12
0
        public static void FixContentFile(string termOrigin, string termDestination, string newFileName)
        {
            var contentBody = File.ReadAllText(newFileName);

            contentBody = Regex.Replace(contentBody, termOrigin, termDestination, RegexOptions.None);
            using (var writer = new HelperStream(newFileName).GetInstance())
            {
                writer.Write(contentBody);
            }

            Console.WriteLine($"FixContentFile newFileName {newFileName}");
        }
Esempio n. 13
0
        private void ExecuteTemplateFilter(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos)
        {
            if (tableInfo.MovedBaseClassToShared)
            {
                return;
            }

            var pathOutput            = PathOutput.PathOutputFilterWithFolder(tableInfo, configContext);
            var pathTemplateClass     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.Filter(tableInfo));
            var pathTemplatePropertys = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ModelsProperty(tableInfo));

            var textTemplateClass     = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var TextTemplatePropertys = Read.AllText(tableInfo, pathTemplatePropertys, this._defineTemplateFolder);

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);

            var classBuilderPropertys = string.Empty;

            if (infos.IsAny())
            {
                foreach (var item in infos)
                {
                    classBuilderPropertys = MakeFilterDateRange(TextTemplatePropertys, classBuilderPropertys, item);

                    if (item.Type == "bool")
                    {
                        classBuilderPropertys = AddPropertyFilter(TextTemplatePropertys, classBuilderPropertys, item, item.PropertyName, "bool?");
                    }
                    else
                    {
                        classBuilderPropertys = AddPropertyFilter(TextTemplatePropertys, classBuilderPropertys, item, item.PropertyName, item.Type);
                    }
                }
            }

            classBuilder = classBuilder.Replace("<#property#>", classBuilderPropertys);

            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 14
0
        private void ExecuteTemplateEntityMapBase(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos)
        {
            if (!tableInfo.MakeDomain)
            {
                return;
            }

            if (!tableInfo.Scaffold)
            {
                return;
            }

            var pathOutput        = PathOutput.PathOutputEntityMapBase(tableInfo, configContext);
            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.EntityMapBase(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var pathTemplateLength       = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsLength(tableInfo));
            var pathTemplateRequired     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsRequired(tableInfo));
            var pathTemplateMapper       = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsMapper(tableInfo));
            var pathTemplateManyToMany   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsManyToMany(tableInfo));
            var pathTemplateCompositeKey = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.MapsCompositeKey(tableInfo));

            var textTemplateClass        = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var textTemplateLength       = Read.AllText(tableInfo, pathTemplateLength, this._defineTemplateFolder);
            var textTemplateRequired     = Read.AllText(tableInfo, pathTemplateRequired, this._defineTemplateFolder);
            var textTemplateMapper       = Read.AllText(tableInfo, pathTemplateMapper, this._defineTemplateFolder);
            var textTemplateManyToMany   = Read.AllText(tableInfo, pathTemplateManyToMany, this._defineTemplateFolder);
            var textTemplateCompositeKey = Read.AllText(tableInfo, pathTemplateCompositeKey, this._defineTemplateFolder);

            var classBuilderitemTemplateLength    = string.Empty;
            var classBuilderitemTemplateRequired  = string.Empty;
            var classBuilderitemplateMapper       = string.Empty;
            var classBuilderitemplateMapperKey    = string.Empty;
            var classBuilderitemplateManyToMany   = string.Empty;
            var classBuilderitemplateCompositeKey = string.Empty;

            string classBuilder = base.MakeClassBuilderMapORM(tableInfo, configContext, infos, textTemplateClass, textTemplateLength, textTemplateRequired, textTemplateMapper, textTemplateManyToMany, textTemplateCompositeKey, ref classBuilderitemTemplateLength, ref classBuilderitemTemplateRequired, ref classBuilderitemplateMapper, ref classBuilderitemplateMapperKey, ref classBuilderitemplateManyToMany, ref classBuilderitemplateCompositeKey);

            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 15
0
        private void ExecuteTemplateDbContext(TableInfo tableInfo, Context configContext)
        {
            if (!tableInfo.MakeDomain)
            {
                return;
            }

            var pathOutput        = PathOutput.PathOutputDbContext(configContext);
            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.Context(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var pathTemplateRegister = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ContextMappers(tableInfo));


            var textTemplateClass   = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var TextTemplateMappers = Read.AllText(tableInfo, pathTemplateRegister, this._defineTemplateFolder);

            textTemplateClass = textTemplateClass.Replace("<#module#>", configContext.ContextName);

            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);


            var classBuilderMappers = string.Empty;


            foreach (var item in configContext.TableInfo.Where(_ => _.Scaffold))
            {
                var itemMappaer = TextTemplateMappers.
                                  Replace("<#className#>", item.ClassName);

                classBuilderMappers += string.Format("{0}{1}{2}", Tabs.TabMaps(), itemMappaer, System.Environment.NewLine);
            }

            classBuilder = classBuilder.Replace("<#mappers#>", classBuilderMappers);


            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 16
0
        private void ExecuteTemplateAngularFilterGeneratedComponentHtml(TableInfo tableInfo, Context configContext, UniqueListInfo infos)
        {
            if (tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (!tableInfo.MakeFront)
            {
                return;
            }

            var pathOutput = PathOutputAngular.PathOutputAngularFilterGeneratedComponentHtml(tableInfo, configContext);

            var pathTemplate = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularFilterGeneratedComponentHtml(tableInfo));
            var textTemplate = Read.AllText(tableInfo, pathTemplate, this._defineTemplateFolder);
            var classBuilder = this.MakeFilterClassBuilder(tableInfo, configContext, infos, textTemplate);

            using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilder); }
        }
Esempio n. 17
0
        private void ExecuteTemplateApiMore(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos)
        {
            var pathOutput = PathOutput.PathOutputApiMore(tableInfo, configContext);

            if (!tableInfo.MakeApi)
            {
                return;
            }

            if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarApiExistentes"]) == false)
            {
                return;
            }


            var pathTemplateClass = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiMore(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var textTemplateClass = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);

            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);

            if (!tableInfo.Authorize)
            {
                classBuilder = classBuilder.Replace("[Authorize]", string.Empty);
            }

            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 18
0
        private void ExecuteTemplateAppTestsMoqPartial(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos)
        {
            var pathOutput = PathOutput.PathOutputApplicationTestMoqPartial(tableInfo, configContext);

            if (!tableInfo.MakeApp)
            {
                return;
            }

            if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarMoqClassPartialExistentes"]) == false)
            {
                return;
            }

            var pathTemplateClass         = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.AppTestMoqPartial(tableInfo));
            var pathTemplateReletedValues = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.AppTestReleted(tableInfo));

            var textTemplateClass         = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var TextTemplateReletedValues = Read.AllText(tableInfo, pathTemplateReletedValues, this._defineTemplateFolder);

            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);

            classBuilder = MakeReletedIntanceValues(tableInfo, configContext, TextTemplateReletedValues, classBuilder);

            var classBuilderMoqValues = string.Empty;


            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }
Esempio n. 19
0
        private void ExecuteTemplateAngularModelFilterGenerated(TableInfo tableInfo, Context configContext, UniqueListInfo infos)
        {
            if (tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (!tableInfo.MakeFront)
            {
                return;
            }

            var pathOutput = PathOutputAngular.PathOutputAngularModelFilterGenerated(tableInfo, configContext);

            var pathTemplateModelGenerated = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateNameAngular.AngularModelFilterGenerated(tableInfo));
            var textTemplateModelGenerated = Read.AllText(tableInfo, pathTemplateModelGenerated, this._defineTemplateFolder);
            var classBuilderModelGenerated = GenericTagsTransformer(tableInfo, configContext, textTemplateModelGenerated);

            var classBuilderForm = string.Empty;

            if (infos.IsAny())
            {
                foreach (var item in infos)
                {
                    var itemForm          = string.Empty;
                    var pathTemplateField = string.Empty;
                    var textTemplateField = string.Empty;

                    if (item.Type == "string" || item.Type == "DateTime" || item.Type == "DateTime?" || item.Type == "Guid" || item.Type == "Guid?")
                    {
                        if (item.Type == "DateTime" || item.Type == "DateTime?")
                        {
                            itemForm  = string.Format(@"    public {0}Start: string;{1}", item.PropertyName, System.Environment.NewLine);
                            itemForm += string.Format(@"    public {0}End: string;", item.PropertyName);
                        }
                        else
                        {
                            itemForm = string.Format(@"    public {0}: string;", item.PropertyName);
                        }
                    }

                    else if (item.Type == "bool")
                    {
                        itemForm = string.Format(@"    public {0}: boolean;", item.PropertyName);
                    }

                    else if (item.Type == "bool?")
                    {
                        itemForm = string.Format(@"    public {0}?: boolean;", item.PropertyName);
                    }

                    else if (item.Type == "int" || item.Type == "float" || item.Type == "decimal")
                    {
                        itemForm = string.Format(@"    public {0}: number;", item.PropertyName);
                    }

                    else if (item.Type == "int?" || item.Type == "float?" || item.Type == "decimal?")
                    {
                        itemForm = string.Format(@"    public {0}?: number;", item.PropertyName);
                    }



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

            classBuilderModelGenerated = classBuilderModelGenerated.Replace("<#formFields#>", classBuilderForm);

            using (var stream = new HelperStream(pathOutput).GetInstance()) { stream.Write(classBuilderModelGenerated); }
        }
Esempio n. 20
0
        private void ExecuteTemplateApi(TableInfo tableInfo, Context configContext, IEnumerable <Info> infos)
        {
            var pathOutput = PathOutput.PathOutputApi(tableInfo, configContext);

            if (!tableInfo.MakeApi)
            {
                return;
            }

            if (File.Exists(pathOutput) && tableInfo.CodeCustomImplemented)
            {
                return;
            }

            if (File.Exists(pathOutput) && Convert.ToBoolean(ConfigurationManager.AppSettings["GerarApiExistentes"]) == false)
            {
                return;
            }


            var pathTemplateClass  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiBase(tableInfo));
            var pathTemplateApiGet = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiGet(tableInfo));

            if (!File.Exists(pathTemplateClass))
            {
                return;
            }

            var textTemplateClass  = Read.AllText(tableInfo, pathTemplateClass, this._defineTemplateFolder);
            var TextTemplateApiGet = Read.AllText(tableInfo, pathTemplateApiGet, this._defineTemplateFolder);

            var classBuilder = GenericTagsTransformer(tableInfo, configContext, textTemplateClass);

            var classBuilderApiGet = string.Empty;

            if (!tableInfo.IsCompositeKey && tableInfo.Keys.IsAny())
            {
                classBuilderApiGet = TextTemplateApiGet;
                classBuilderApiGet = classBuilderApiGet.Replace("<#className#>", tableInfo.ClassName);
                classBuilderApiGet = classBuilderApiGet.Replace("<#namespace#>", configContext.Namespace);
                classBuilderApiGet = classBuilderApiGet.Replace("<#inheritClassName#>", tableInfo.InheritClassName);
                classBuilderApiGet = classBuilderApiGet.Replace("<#KeyName#>", tableInfo.Keys.FirstOrDefault());
                classBuilderApiGet = classBuilderApiGet.Replace("<#KeyType#>", tableInfo.KeysTypes.FirstOrDefault());
            }
            classBuilder = classBuilder.Replace("<#ApiGet#>", classBuilderApiGet);

            var pathTemplateCustoMethod = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this._defineTemplateFolder.Define(tableInfo), DefineTemplateName.ApiCustomMethod(tableInfo));

            classBuilder = this.CustomMethods(tableInfo, configContext, classBuilder, pathTemplateCustoMethod);

            if (!tableInfo.Authorize)
            {
                classBuilder = classBuilder.Replace("[Authorize]", string.Empty);
            }


            using (var stream = new HelperStream(pathOutput).GetInstance())
            {
                stream.Write(classBuilder);
            }
        }