private bool ValidateInput(MetadataSource metadataSource)
        {
            if (metadataSource == MetadataSource.Grpc)
            {
                try
                {
                    var kProtoFile = metadataSource == MetadataSource.Grpc ? _protoToKProtoConverter.Convert("zzz", _protoFileView.ProtoFileText) : null;

                    if (kProtoFile == null || kProtoFile.GeneratedProtoFile == null || kProtoFile.GeneratedProtoFile.ProtoMessage.Count == 0)
                    {
                        _messageBoxDisplayService.Show("Invalid proto");
                        return(false);
                    }
                }
                catch (ProtoCompileException ex)
                {
                    _messageBoxDisplayService.Show(ex.Message);
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        public KSolution BuildSolution(KickstartWizardModel kickstartWizardModel)
        {
            var solution = new KSolution()
            {
                CompanyName = kickstartWizardModel.CompanyName, SolutionName = kickstartWizardModel.SolutionName
            };

            KProtoFile kProtoFile = null;

            if (kickstartWizardModel.MetadataSource == MetadataSource.Grpc)
            {
                kProtoFile = kickstartWizardModel.MetadataSource == MetadataSource.Grpc ? _protoToKProtoConverter.Convert("zzz", kickstartWizardModel.ProtoFileText) : null;

                //this will override whatever user typed on first standard VS dialog
                if (kickstartWizardModel.CurrentStep == KickstartWizardModel.Step.ProtoFile)
                {
                    kickstartWizardModel.SolutionName = InferSolutionName(kProtoFile);
                    kickstartWizardModel.ProjectName  = InferProjectName(kProtoFile);
                }
                else
                {
                }

                var databaseProject = BuildDatabaseProject(kickstartWizardModel, kProtoFile);
                solution.Project.Add(databaseProject);

                var databaseTestProject = BuildDatabaseTestProject(kickstartWizardModel, kProtoFile);
                solution.Project.Add(databaseTestProject);

                //_databaseSqlView.Bind(databaseProject);

                //if (_currentStep == Step.GenerationStart)
                {
                    var dataLayerProject = BuildDataLayerProject(kickstartWizardModel, databaseProject);
                    var grpcProject      = BuildGrpcProject(kickstartWizardModel, databaseProject, dataLayerProject, kProtoFile);
                    solution.Project.Add(grpcProject);

                    solution.Project.Add(dataLayerProject);
                }
            }
            else if (kickstartWizardModel.MetadataSource == MetadataSource.SqlScripts)
            {
                var databaseProjectStart = BuildDatabaseProject(kickstartWizardModel, null);

                var connectionString = "Server=localhost;";
                var outputRootPath   = string.Empty;

                var databaseProject = _dbToKSolutionConverter.BuildSqlMeta(connectionString, outputRootPath, databaseProjectStart);

                var dataLayerProject = BuildDataLayerProject(kickstartWizardModel, databaseProject);

                solution.Project.Add(databaseProject);
                solution.Project.Add(dataLayerProject);

                var grpcProject = BuildGrpcProject(kickstartWizardModel, databaseProject, dataLayerProject, null);
                grpcProject.CompanyName = kickstartWizardModel.CompanyName;
                solution.Project.Add(grpcProject);

                var protoFiles = _dataLayerProjectToKProtoFileConverter.Convert(databaseProject, dataLayerProject, grpcProject);
                foreach (var pf in protoFiles)
                {
                    grpcProject.ProtoFile.Add(pf);
                }
                //_databaseSqlStep.Bind(databaseProject);

                var pf3 = protoFiles.FirstOrDefault();
                if (pf3 != null)
                {
                    pf3.ProtoFileText = _protoFileToProtoFileConverter.Convert(pf3.GeneratedProtoFile);
                    // _protoFileView.Bind(pf3);
                }
            }


            if (kickstartWizardModel.CreateGrpcServiceTestClientProject)
            {
                solution.Project.Add(new KGrpcServiceClientTestProject {
                    ProjectName = kickstartWizardModel.ProjectName
                });
            }
            if (kickstartWizardModel.CreateDockerBuildProject)
            {
                solution.Project.Add(new KDockerBuildScriptProject {
                    ProjectName = kickstartWizardModel.ProjectName
                });
            }
            if (kickstartWizardModel.CreateGrpcUnitTestProject)
            {
                solution.Project.Add(new KGrpcServiceUnitTestProject {
                    ProjectName = kickstartWizardModel.ProjectName
                });
            }
            if (kickstartWizardModel.CreateIntegrationTestProject)
            {
                solution.Project.Add(new KGrpcServiceIntegrationTestProject {
                    ProjectName = kickstartWizardModel.ProjectName
                });
            }

            if (kickstartWizardModel.CreateWebAppProject)
            {
                solution.Project.Add(new KWebUIProject {
                    ProjectName = kickstartWizardModel.ProjectName
                });
            }

            if (kickstartWizardModel.CreateDockerComposeProject)
            {
                solution.Project.Add(new KDockerComposeProject()
                {
                    ProjectName = kickstartWizardModel.ProjectName
                });
            }

            if (kickstartWizardModel.CreateGrpcClientProject)
            {
                solution.Project.Add(new KGrpcClientProject()
                {
                    ProjectName = kickstartWizardModel.ProjectName
                });
            }
            return(solution);
        }