private void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                //create entity
                CodeGeneratorSettingsInfo folder = ConfigCtrl.GetCodeGeneratorSettings();
                Collection <TableInfo>    tables = Johnny.CodeGenerator.Core.DatabaseCtrl.GetTables(_connectionstring, _server, _database);
                foreach (TableInfo tb in tables)
                {
                    if (tb.TableName == _table)
                    {
                        string entityFolder = Path.Combine(folder.WorkingFolder, "Temp");
                        entityFolder = Path.Combine(entityFolder, folder.Entity);
                        Generator.GenerateEntityXmlFromTable(tb, entityFolder, txtNameSpacePrefix.Text, txtNameSpaceSuffix.Text);
                        break;
                    }
                }



                richtxtCode.Text = Johnny.CodeGenerator.Core.Generator.GenerateSingle(_connectionstring, _database, _server, GetModelName(_table), cmbTemplateGroup.Items[cmbTemplateGroup.SelectedIndex].ToString(), cmbTemplate.Items[cmbTemplate.SelectedIndex].ToString());

                tabSingleGenerator.SelectedIndex = 1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void GenerateTextXmlClick(object o, EventArgs e)
        {
            TableNode tn = (TableNode)this.SelectedNode;

            if (tn == null)
            {
                return;
            }
            CodeGeneratorSettingsInfo folder = ConfigCtrl.GetCodeGeneratorSettings();

            Generator.GenerateTextXmlFromTable(tn.Table, @"D:\WorkSpace\Projects_GitHub\CodeGenerator\Dev\Src\CodeGenerator\");
        }
Exemplo n.º 3
0
        private void GenerateEntityXmlClick(object o, EventArgs e)
        {
            TableNode tn = (TableNode)this.SelectedNode;

            if (tn == null)
            {
                return;
            }
            CodeGeneratorSettingsInfo folder = ConfigCtrl.GetCodeGeneratorSettings();

            Generator.GenerateEntityXmlFromTable(tn.Table, folder.EntityFullPath, "Johnny.CMS", "Access");
        }
        private void tabSingleGenerator_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabSingleGenerator.SelectedIndex == 2) //Template
            {
                CodeGeneratorSettingsInfo folder = ConfigCtrl.GetCodeGeneratorSettings();

                if (cmbTemplateGroup.SelectedIndex >= 0 && cmbTemplate.SelectedIndex >= 0)
                {
                    string strFile    = DataConvert.GetString(cmbTemplate.Items[cmbTemplate.SelectedIndex]) + ".xslt";
                    string xsltFolder = Path.Combine(folder.Template, DataConvert.GetString(cmbTemplateGroup.Items[cmbTemplateGroup.SelectedIndex]));
                    //xsltFolder = Path.Combine(xsltFolder, DataConvert.GetString(cmbTemplate.Items[cmbTemplate.SelectedIndex]));
                    string xsltFile = Path.Combine(xsltFolder, strFile);
                    txtTemplatePath.Text = xsltFile;
                    using (StreamReader sr = new StreamReader(xsltFile, Encoding.UTF8))
                    {
                        richtxtTemplate.Text = sr.ReadToEnd();
                        sr.Close();
                    }
                }
            }
            else if (tabSingleGenerator.SelectedIndex == 3)
            {
                CodeGeneratorSettingsInfo folder = ConfigCtrl.GetCodeGeneratorSettings();

                string xmlFile = Path.Combine(folder.EntityFullPath, GetModelName(_table) + ".xml");
                txtEntityPath.Text = xmlFile;
                using (StreamReader sr = new StreamReader(xmlFile, Encoding.UTF8))
                {
                    richtxtEntity.Text = sr.ReadToEnd();
                    sr.Close();
                }
            }
            else if (tabSingleGenerator.SelectedIndex == 4)
            {
                CodeGeneratorSettingsInfo folder = ConfigCtrl.GetCodeGeneratorSettings();

                string xmlFolder = @"D:\WorkSpace\Projects_GitHub\CodeGenerator\Dev\Src\CodeGenerator\";
                string xmlFile   = xmlFolder + @"\" + GetModelName(_table) + ".xml";
                using (StreamReader sr = new StreamReader(xmlFile, Encoding.UTF8))
                {
                    richtxtFieldText.Text = sr.ReadToEnd();
                    sr.Close();
                }
            }
        }
        private void DlgSettingsCG_Load(object sender, EventArgs e)
        {
            try
            {
                //load config info
                CodeGeneratorSettingsInfo cgsettings = ConfigCtrl.GetCodeGeneratorSettings();
                if (cgsettings != null)
                {
                    txtWorkingFolder.Text = cgsettings.WorkingFolder;
                    txtTemplate.Text      = cgsettings.Template;
                    txtVsTemplate.Text    = cgsettings.VsTemplate;
                    txtOutput.Text        = cgsettings.Output;
                    txtEntity.Text        = cgsettings.Entity;
                }

                txtWorkingFolder.Select();
                txtOutput.Text = "Output";
                txtEntity.Text = "Entity";
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("DlgSettingsCG.DlgSettingsCG_Load", ex);
            }
        }
        private void btnGenXml_Click(object sender, EventArgs e)
        {
            CodeGeneratorSettingsInfo folder = ConfigCtrl.GetCodeGeneratorSettings();

            Generator.GenerateEntityXml(_connectionstring, _table, "dbo", _server, _database, folder.Entity, txtNameSpacePrefix.Text, txtNameSpaceSuffix.Text);
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtWorkingFolder.Text == string.Empty)
                {
                    txtWorkingFolder.Select();
                    MessageBox.Show("Working folder can't be empty!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!Directory.Exists(txtWorkingFolder.Text))
                {
                    txtWorkingFolder.Select();
                    MessageBox.Show("Invalid path of Working folder!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (txtTemplate.Text == string.Empty)
                {
                    txtTemplate.Select();
                    MessageBox.Show("Template folder can't be empty!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!Directory.Exists(txtTemplate.Text))
                {
                    txtTemplate.Select();
                    MessageBox.Show("Invalid path of Template folder!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (txtVsTemplate.Text == string.Empty)
                {
                    txtVsTemplate.Select();
                    MessageBox.Show("Visual Studio Template folder can't be empty!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!Directory.Exists(txtVsTemplate.Text))
                {
                    txtVsTemplate.Select();
                    MessageBox.Show("Invalid path of Visual Studio Template folder!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (txtOutput.Text == string.Empty)
                {
                    txtOutput.Select();
                    MessageBox.Show("Output folder can't be empty!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!DataValidation.IsValidPathName(txtOutput.Text))
                {
                    txtOutput.Select();
                    MessageBox.Show("Invalid charaters for Output folder name!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (txtEntity.Text == string.Empty)
                {
                    txtEntity.Select();
                    MessageBox.Show("Entity folder name can't be empty!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (!DataValidation.IsValidPathName(txtEntity.Text))
                {
                    txtEntity.Select();
                    MessageBox.Show("Invalid charaters for Entity folder name", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                CodeGeneratorSettingsInfo cgsettings = new CodeGeneratorSettingsInfo();
                cgsettings.WorkingFolder = txtWorkingFolder.Text;
                cgsettings.Template      = txtTemplate.Text;
                cgsettings.VsTemplate    = txtVsTemplate.Text;
                cgsettings.Output        = txtOutput.Text;
                cgsettings.Entity        = txtEntity.Text;

                if (!ConfigCtrl.SetCodeGeneratorSettings(cgsettings))
                {
                    MessageBox.Show("Failed to save!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("DlgWorkingFolderSetting.btnOK_Click", ex);
            }
        }