Beispiel #1
0
        public ECommerceProcessor(string connectionString)
        {
            env     = connectionString;
            sConfig = ServiceGenerator <ConfigurationService> .GetInstance(ConfigurationConstants.ConfigurationDatabase, env);

            sMember = ServiceGenerator <MembershipService> .GetInstance(ConfigurationConstants.MembershipDatabase, env);

            sOrder = ServiceGenerator <OrderCaptureService> .GetInstance(ConfigurationConstants.OrderCaptureDatabase, env);
        }
Beispiel #2
0
        public GeneralProcessTest()
        {
            env     = ConfigurationManager.AppSettings["MongoConnectionString"];
            sConfig = ServiceGenerator <ConfigurationService> .GetInstance(ConfigurationConstants.ConfigurationDatabase, env);

            sMember = ServiceGenerator <MembershipService> .GetInstance(ConfigurationConstants.MembershipDatabase, env);

            sOrder = ServiceGenerator <OrderCaptureService> .GetInstance(ConfigurationConstants.OrderCaptureDatabase, env);
        }
        public FileResult Post(List <IFormFile> files)
        {
            List <Model> Models = new List <Model>();
            long         size   = files.Sum(f => f.Length);

            try
            {
                var filePath = Path.GetTempFileName();

                foreach (var formFile in files)
                {
                    if (formFile.Length > 0)
                    {
                        using (var reader = new StreamReader(formFile.OpenReadStream()))
                        {
                            string text = reader.ReadToEnd();
                            reader.Dispose();

                            string[] models = text.Split(new string[] { "class" }, StringSplitOptions.None);

                            for (int i = 1; i < models.Length; i++)
                            {
                                Model m = new Model(models[i], "Test");

                                Models.Add(m);
                            }
                        }
                    }
                }

                string fileName = "Project.txt";
                byte[] bytes    = new byte[0];

                MemoryStream ms = new MemoryStream();
                TextWriter   tw = new StreamWriter(ms);

                List <string> downloads = new List <string>();
                foreach (Model m in Models)
                {
                    tw.WriteLine(APIControllerGenerator.Generate(m));
                    tw.WriteLine(RepositoryGenerator.Generate(m));
                    tw.WriteLine(ServiceGenerator.Generate(m));
                    tw.WriteLine(TableGenerator.Generate(m, Models));
                }

                tw.Flush();
                bytes = ms.ToArray();
                ms.Dispose();

                return(File(bytes, "application/x-msdownload", fileName));
            }
            catch (Exception ex)
            {
                return(File("", ""));
            }
        }
        public GeneratedFile GenerateService()
        {
            var dtoFullNamespace     = GetFullNamespace(DTONamespace);
            var cqsFullNamespace     = GetFullNamespace(CQSNamespace);
            var serviceFullNamespace = GetFullNamespace(ServiceNamespace);
            var serviceFullPath      = GetFullPath(ServiceNamespace);
            var serviceGenerator     = new ServiceGenerator(ContractABI, ContractName, ByteCode, serviceFullNamespace, cqsFullNamespace, dtoFullNamespace, CodeGenLanguage);

            return(serviceGenerator.GenerateFileContent(serviceFullPath));
        }
        public async void GetPerson()
        {
            List <Person> persons = new List <Person>();

            for (int i = 0; i < 10; i++)
            {
                persons.Add(await ServiceGenerator.GetService().GetPerson());
            }

            Persons = new ObservableCollection <Person>(persons);
        }
        public void IsValiedShape()
        {
            Shape            shape       = new Shape();
            string           userInput   = "Draw a square with a side length of 200";
            ServiceGenerator service     = new ServiceGenerator();
            string           actualValue = "Square";

            shape = service.ValidateShape(userInput);
            string expectedValue = shape.shapeName;

            Assert.AreEqual(expectedValue, actualValue, true);
        }
        public void CheckEmptyUserInput()
        {
            Shape            shape           = new Shape();
            string           userInput       = "";
            ServiceGenerator service         = new ServiceGenerator();
            string           responceMassage = "Please enter the Shape Description";

            shape = service.ValidateShape(userInput);
            string expectedValue = shape.responceMessage;

            Assert.AreEqual(expectedValue, responceMassage);
        }
        public void IsValiedProperties()
        {
            Shape            shape             = new Shape();
            string           userInput         = "Draw a square with a side length of 200";
            ServiceGenerator service           = new ServiceGenerator();
            bool             isPropertyMatched = true;

            shape = service.ValidateShape(userInput);
            bool expectedValue = shape.isParametersMatched;

            Assert.AreEqual(expectedValue, isPropertyMatched);
        }
        public void IsShapenotCreated()
        {
            Shape            shape           = new Shape();
            string           userInput       = "Draw a  with a side length of 200";
            ServiceGenerator service         = new ServiceGenerator();
            string           responceMassage = "Shape not Created";

            shape = service.ValidateShape(userInput);
            string expectedValue = shape.responceMessage;

            Assert.AreEqual(expectedValue, responceMassage);
        }
Beispiel #10
0
        public GeneratedFile GenerateService(bool singleMessagesFile = false)
        {
            var dtoFullNamespace = GetFullNamespace(DTONamespace);
            var cqsFullNamespace = GetFullNamespace(CQSNamespace);

            dtoFullNamespace = singleMessagesFile ? string.Empty : FullyQualifyNamespaceFromImport(dtoFullNamespace);
            cqsFullNamespace = FullyQualifyNamespaceFromImport(cqsFullNamespace);

            var serviceFullNamespace = GetFullNamespace(ServiceNamespace);
            var serviceFullPath      = GetFullPath(ServiceNamespace);
            var serviceGenerator     = new ServiceGenerator(ContractABI, ContractName, ByteCode, serviceFullNamespace, cqsFullNamespace, dtoFullNamespace, CodeGenLanguage);

            return(serviceGenerator.GenerateFileContent(serviceFullPath));
        }
        public async void TurnOff()
        {
            try
            {
                var light = new Light()
                {
                    Action = 0
                };

                await ServiceGenerator.GetService().Test(light);
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #12
0
        public void ServiceCreation()
        {
            ServiceGenerator access  = new ServiceGenerator();
            List <string>    ingress = access.CreateService("test", "5000");

            Assert.Equal(ingress[0], "apiVersion: v1");
            Assert.Equal(ingress[1], "kind: Service");
            Assert.Equal(ingress[2], "metadata:");
            Assert.Equal(ingress[3], "  name: test-svc");
            Assert.Equal(ingress[4], "spec:");
            Assert.Equal(ingress[5], "  ports:");
            Assert.Equal(ingress[6], "  - port: 80");
            Assert.Equal(ingress[7], "    targetPort: 5000");
            Assert.Equal(ingress[8], "  selector:");
            Assert.Equal(ingress[9], "    run: test-deploy");
            Assert.Equal(ingress[10], "  type: ClusterIP");
        }
        private static void Main()
        {
            var assembly = typeof (IInfusionSoftConfiguration).Assembly;

            var generator = new ServiceGenerator(assembly)
                            {
                                InterfaceDirectory = Path.Combine(Output, ".").Directory(),
                                WrapperDirectory = Path.Combine(Output, "Wrappers").Directory()
                            };

            Service[] services = generator.Generate();

            Console.Out.WriteLine("{0} services created", services.Length);

            Console.Out.WriteLine("done");
            Console.ReadKey();
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            var tableName = "GP_NIVTIN";
            var className = "NivelTinta";

            //GENERATE SQL
            var spGen = new StoreProcedureGenerator(tableName);
            var spMax = spGen.GetMaxStoreProcedure();

            var repositorySp = spGen.GenerateCode();

            Console.Write(repositorySp);
            Console.WriteLine("Code SQL generated!!!");

            Console.WriteLine("");
            Console.WriteLine("");

            //GENERATE REPOSITORY
            var rpGen          = new RepositoryGenerator(tableName, className, spMax);
            var repositoryCode = rpGen.GenerateCode();

            Console.Write(repositoryCode);
            Console.WriteLine("Code Repository generated!!!");

            Console.WriteLine("");
            Console.WriteLine("");

            //GENERATE SERVICE
            var svGen       = new ServiceGenerator(className);
            var serviceCode = svGen.GenerateCode();

            Console.Write(serviceCode);
            Console.WriteLine("Code Service generated!!!");

            Console.WriteLine("");
            Console.WriteLine("");

            //GET PROPERTIES
            foreach (var prop in typeof(ColumnTable).GetProperties())
            {
                Console.WriteLine("{0}={1}", prop.Name, prop.PropertyType);
            }

            Console.ReadLine();
        }
Beispiel #15
0
        private void GenerateServices()
        {
            var         assemblyName    = new AssemblyName("Camstar.ApiService");
            DCTypeStore dCTypeStore     = new DCTypeStore();
            var         assemblyBuilder =
                DefineDynamicAssembly(assemblyName, "ApiBin", "1.0.0.0");
            var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name + Constants.File.DllFileExt,
                                                                    assemblyName.Name + Constants.File.DllFileExt, false);
            var assemblyGenerator = new AssemblyGenerator(moduleBuilder, dCTypeStore,
                                                          "Camstar.WCF.Service", typeof(Camstar.WCF.Service.ServiceBase).Assembly, "Camstar.WCF.Service");

            assemblyGenerator.GenerateCommonTypes();
            ServiceGenerator serviceGenerator = new ServiceGenerator(moduleBuilder, dCTypeStore, "Camstar.WCF.Service");

            foreach (DCType dcType in this._dcTypes)
            {
                assemblyGenerator.AddDC(dcType);
            }
            for (var current = 0; current < this._dcTypes.Count; ++current)
            {
                this.OnStateChanged(GeneratingPhase.DataContract, current, this._dcTypes.Count,
                                    this._dcTypes[current].Name);
                serviceGenerator.AddDC(this._dcTypes[current]);
            }

            for (var current = 0; current < this._ExposedServices.Count; ++current)
            {
                this.OnStateChanged(GeneratingPhase.ServiceContract, current, this._ExposedServices.Count,
                                    this._ExposedServices[current].Name);
                serviceGenerator.AddService(this._ExposedServices[current]);
                if (this._ExposedServices[current].ExposedState != ExposedServiceStateType.Base)
                {
                    ++this._GeneratedServicesCount;
                }
            }

            assemblyBuilder.Save(assemblyName.Name + Constants.File.DllFileExt);
        }
Beispiel #16
0
        static void Main(string[] args)
        {
            var map = new Dictionary<string, string>(StringComparer.Ordinal);
            var key = (string)null;
            foreach (var item in args)
            {
                if (item.Length == 0)
                    continue;
                if (item.StartsWith("-", StringComparison.Ordinal))
                    key = item;
                else if (key != null)
                    map[key] = $"{(map.TryGetValue(key, out var value) ? value + " " : string.Empty)}{item.Trim(' ', '\'', '\"')}";
            }
            if (!map.TryGetValue("-p", out var path) && !map.TryGetValue("--path", out path))
            {
                throw new ArgumentException("Path missing, expect -p|--path path1 path2");
            }
            if (!map.TryGetValue("-o", out var output) && !map.TryGetValue("--out", out output))
            {
                throw new ArgumentException("Out missing, expect -o|--out path1 path2");
            }
            if (!map.TryGetValue("-n", out var nameSpace) && !map.TryGetValue("--namespace", out nameSpace))
            {
                //throw new ArgumentException("Nmaespace missing, expect -n|--namespace Name.Space");
            }
            CodeGeneratorMode mode = CodeGeneratorMode.Controllers;
            if (map.TryGetValue("-m", out var modeText) || map.TryGetValue("--mode", out modeText))
            {
                if (!Enum.TryParse<CodeGeneratorMode>(modeText, out mode))
                    throw new ArgumentException("Mode missing, expect -m|--mode Controllers|,|Logs|,|Invokers");
            }

            var generator = new ServiceGenerator(path, output, nameSpace);
            generator.Mode = mode;
            generator.Generate();
            generator.GetUnits(true);

        }
Beispiel #17
0
 public T GetService()
 {
     return(ServiceGenerator.CreateInterfaceProxyWithoutTarget <T>(ProxyGenerationOptions.Default, Interceptor));
 }
Beispiel #18
0
 public ServiceTestBase(string database)
 {
     env     = ConfigurationConstants.ConnectionStringQA;
     service = ServiceGenerator <TEntity> .GetInstance(database, env);
 }
Beispiel #19
0
        private void btnGenerateCode_Click(object sender, EventArgs e)
        {
            try
            {
                var tableName = this.txtSqlTableName.Text.Trim();
                if (tableName.Length.Equals(0))
                {
                    throw new Exception("Necesita especificar el nombre de la tabla.");
                }

                var className = this.txtClassName.Text.Trim();
                if (className.Length.Equals(0))
                {
                    throw new Exception("Necesita especificar el nombre de la clase.");
                }
                var varName = $"{className.Substring(0, 1).ToLower()}{className.Substring(1, className.Length - 1)}";

                var outputFolder = this.txtOutputFolder.Text.Trim();
                if (outputFolder.Length.Equals(0))
                {
                    throw new Exception("Necesita especificar el folder destino.");
                }

                var sqlFileName        = $"{tableName}.sql";
                var repositoryFileName = $"{className}Repository.cs";
                var interfaceFileName  = $"I{className}Service.cs";
                var serviceFileName    = $"{className}Service.cs";
                var gsFileName         = $"{className}GetAndSet.cs";

                Cursor.Current = Cursors.WaitCursor;

                //GENERATE SQL
                var spGen   = new StoreProcedureGenerator(tableName);
                var sqlCode = spGen.GenerateCode();
                Utilities.WriteFile(sqlCode, outputFolder, sqlFileName);
                //--

                var spMax = spGen.GetMaxStoreProcedure();

                //GENERATE REPOSITORY
                var rpGen          = new RepositoryGenerator(tableName, className, spMax);
                var repositoryCode = rpGen.GenerateCode();
                Utilities.WriteFile(repositoryCode, outputFolder, repositoryFileName);
                //--

                //GENERATE SERVICE
                var svGen         = new ServiceGenerator(className);
                var interfaceCode = svGen.GenerateCodeInterface();
                var serviceCode   = svGen.GenerateCodeService();
                Utilities.WriteFile(interfaceCode, outputFolder, interfaceFileName);
                Utilities.WriteFile(serviceCode, outputFolder, serviceFileName);
                //--

                //GENERATE GET AND SET
                var columns = new List <ColumnTable>();
                for (var i = 0; i < this.dgdData.Rows.Count - 1; i++)
                {
                    var row = this.dgdData.Rows[i];
                    //row.Cells[2].Value = Utilities.GetSapDataType(column.SapDataType, column.SapDataType2);
                    columns.Add(new ColumnTable
                    {
                        Id             = (int)row.Cells[8].Value,
                        SqlTableName   = row.Cells[9].Value?.ToString(),
                        SqlColumnName  = row.Cells[0].Value?.ToString(),
                        SapDescription = row.Cells[10].Value?.ToString(),
                        SqlDataType    = row.Cells[6].Value?.ToString(),
                        SapDataType    = "",
                        SapDataType2   = "",
                        SqlSize        = (int)row.Cells[3].Value,
                        SqlPrecision   = (int)row.Cells[4].Value,
                        NullValue      = (bool)row.Cells[7].Value ? 1 : 0,
                        PropertyName   = row.Cells[5].Value?.ToString(),
                        PropertyType   = row.Cells[6].Value?.ToString()
                    });
                }

                var gsGen  = new GetAndSetGenerator <ColumnTable>(tableName, className, varName, columns);
                var gsCode = gsGen.GenerateCode();
                Utilities.WriteFile(gsCode, outputFolder, gsFileName);
                //--

                Cursor.Current = Cursors.Default;
                MessageBox.Show("Archivos generados", "Info");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Beispiel #20
0
        public static void Main(string[] args)
        {
            #region Welcome
            Console.WriteLine();
            Console.WriteLine(@"__/\\\\\\\\\\\\\\\__/\\\________/\\\__/\\\\\\\\\\\\\\\__/\\\\\\\\\\\\\\\_        ");
            Console.WriteLine(@" _\/\\\///////////__\/\\\_______\/\\\_\////////////\\\__\/\\\///////////__       ");
            Console.WriteLine(@"  _\/\\\_____________\/\\\_______\/\\\___________/\\\/___\/\\\_____________      ");
            Console.WriteLine(@"   _\/\\\\\\\\\\\_____\/\\\_______\/\\\_________/\\\/_____\/\\\\\\\\\\\_____     ");
            Console.WriteLine(@"    _\/\\\///////______\/\\\_______\/\\\_______/\\\/_______\/\\\///////______    ");
            Console.WriteLine(@"     _\/\\\_____________\/\\\_______\/\\\_____/\\\/_________\/\\\_____________   ");
            Console.WriteLine(@"      _\/\\\_____________\//\\\______/\\\____/\\\/___________\/\\\_____________  ");
            Console.WriteLine(@"       _\/\\\______________\///\\\\\\\\\/____/\\\\\\\\\\\\\\\_\/\\\\\\\\\\\\\\\_ ");
            Console.WriteLine(@"        _\///_________________\/////////_____\///////////////__\///////////////__");
            Console.WriteLine();
            Console.WriteLine(@" Joining your app and kubernetes with reduced effort and centralized scaffolding ");
            Console.WriteLine(@"                                                        created with <3 by Clark ");
            Console.WriteLine();
            #endregion

            string        path   = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).FullName);
            SharedMethods access = new SharedMethods();
            var           deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention());
            var           deserializer        = deserializerBuilder.Build();
            var           result = deserializer.Deserialize <FuzeDataModel.K8SettingObject>(File.OpenText(string.Format("{0}/{1}", path, "k8settings.yml")));

            foreach (var thisconfig in result.configs)
            {
                Console.WriteLine(string.Format("Working on config element {0}", thisconfig.name));

                #region Namespace
                string nameSpace = string.Format("{0}-{1}-ns.yml", thisconfig.appName, thisconfig.name);
                Console.WriteLine(string.Format("Generating nameSpace - {0}", nameSpace));
                NameSpaceGenerator namespaceconfig = new NameSpaceGenerator();
                access.WriteOut(namespaceconfig.CreateNamespace(thisconfig.appName, thisconfig.name), string.Format("{0}/{1}", path, nameSpace));
                #endregion

                #region ConfigMap
                string config = string.Format("{0}-{1}-cm.yml", thisconfig.appName, thisconfig.name);
                Console.WriteLine(string.Format("Generating configmap - {0}", config));
                ConfigMapGenerator configmap = new ConfigMapGenerator();
                access.WriteOut(configmap.CreateConfigMap(thisconfig.appName, thisconfig.name, thisconfig.env), string.Format("{0}/{1}", path, config));
                #endregion

                #region Secret
                string secret = string.Format("{0}-{1}-secret.yml", thisconfig.appName, thisconfig.name);
                Console.WriteLine(string.Format("Generating secretmap - {0}", secret));
                SecretMapGenerator secretmap = new SecretMapGenerator();
                access.WriteOut(secretmap.CreateSecretMap(thisconfig.appName, thisconfig.name, thisconfig.secret), string.Format("{0}/{1}", path, secret));
                #endregion

                #region Deployment
                string deploy = string.Format("{0}-{1}-deploy.yml", thisconfig.appName, thisconfig.name);
                Console.WriteLine(string.Format("Generating deployment - {0}", deploy));
                DeploymentGenerator deployment = new DeploymentGenerator();
                access.WriteOut(deployment.CreateDeployment(thisconfig.appName, thisconfig.image, thisconfig.env, thisconfig.name), string.Format("{0}/{1}", path, deploy));
                #endregion

                #region Service
                string svc = string.Format("{0}-{1}-svc.yml", thisconfig.appName, thisconfig.name);
                Console.WriteLine(string.Format("Generating service - {0}", svc));
                ServiceGenerator service = new ServiceGenerator();
                access.WriteOut(service.CreateService(thisconfig.appName), string.Format("{0}/{1}", path, svc));
                #endregion

                #region Ingress
                foreach (var domain in thisconfig.domain)
                {
                    string ing = string.Format("{0}-{1}-{2}-ing.yml", domain, thisconfig.appName, thisconfig.name);;
                    Console.WriteLine(string.Format("Generating ingress - {0}", ing));
                    IngressGenerator ingress = new IngressGenerator();
                    access.WriteOut(ingress.CreateIngress(thisconfig.appName, domain), string.Format("{0}/{1}", path, ing));
                }
                #endregion

                #region Autoscaler
                string hpa = string.Format("{0}-{1}-hpa.yml", thisconfig.appName, thisconfig.name);
                Console.WriteLine(string.Format("Generating autoscaler - {0}", hpa));
                AutoscalerGenerator autoscaler = new AutoscalerGenerator();
                access.WriteOut(autoscaler.CreateAutoscaler(thisconfig.appName, thisconfig.name), string.Format("{0}/{1}", path, hpa));
                #endregion

                Console.WriteLine();
            }
            Console.WriteLine("Finished");
        }