private void GenerateButton_Click(object sender, EventArgs e)
        {
            SelectProjectButton.Enabled = false;
            GenerateButton.Enabled      = false;
            JsonSchemaParser.GenerateArraysInstedOfLists = ArrayCollectionsCheckbox.Checked;

            LogTextBox.Text = "Generating...";
            Schema schema;

            try
            {
                schema = JsonSchemaParser.ComposeEndpointSchema(SchemaTextBox.Text);
            }
            catch (Exception ex)
            {
                LogTextBox.Text            += "\r\nError reading endpoint";
                LogTextBox.Text            += "\r\n" + ex.Message;
                GenerateButton.Enabled      = true;
                SelectProjectButton.Enabled = true;
                return;
            }
            LogTextBox.Text += "\r\nEnpoint schema - OK";

            LogTextBox.Text += "\r\nWriting code...";

            SchemaGenerator.WriteCSharp(directoryPath + "\\",
                                        schema,
                                        (_) => LogTextBox.Text += ("\r\n" + _),
                                        "Acumatica." + endpointName.Replace(".", "_"),
                                        pathToProject,
                                        additionalPath);
        }
        private void button2_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button2.Enabled = false;

            textBox2.Text = "Generating...";
            Schema schema;

            try
            {
                schema = JsonSchemaParser.ComposeEndpointSchema(textBox1.Text);
            }
            catch (Exception ex)
            {
                textBox2.Text  += "\r\nError reading endpoint";
                textBox2.Text  += "\r\n" + ex.Message;
                button1.Enabled = true;
                button2.Enabled = true;
                return;
            }
            textBox2.Text += "\r\nEnpoint schema - OK";

            textBox2.Text += "\r\nWriting code...";

            SchemaGenerator.WriteCSharp(directoryPath + "\\", schema, (_) => textBox2.Text += ("\r\n" + _), "Acumatica." + endpointName.Replace(".", "_"), pathToProject, additionalPath);
        }
Example #3
0
        static void Main(string[] args)
        {
            string solutionFolderPath = GetParentDirectory(Directory.GetCurrentDirectory(), 5).ToString();

            foreach (var file in Directory.GetFiles(solutionFolderPath + EndpointSchemaDirectory))
            {
                string       endpoint = file.Replace(solutionFolderPath + EndpointSchemaDirectory, "");
                StreamReader reader   = new StreamReader(file);
                string       input    = reader.ReadToEnd();
                reader.Close();

                Schema schema = JsonSchemaParser.ComposeEndpointSchema(input);

                WriteCSharp(
                    solutionFolderPath + string.Format(OutputDirectoryTemplate, endpoint),
                    endpoint,
                    schema,
                    (_) => Console.WriteLine(_));
            }
        }