Пример #1
0
        public void GenerateSilverChaliceObjects(string namespaceName, string path, bool generateContentPlaceholder, Language selectedLanguage, List <string> listTables, List <string> listEntities)
        {
            AspnetCodeGenerator c = new AspnetCodeGenerator();


            int index = -1;

            foreach (string table in listTables)
            {
                ++index;

                DatabaseTable tbl = GetTableByName(table);

                if (tbl != null)
                {
                    c.Generate(tbl.Columns, namespaceName, listEntities[index], generateContentPlaceholder, Application.StartupPath + @"\Output", tbl.Relations);
                }
            }
        }
Пример #2
0
        private void AspnetCodeGenerationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AspnetCodeGenerationDialog dialog = null;


            try
            {
                //generate mappings
                menuItemGenerateMappingFiles_Click(null, null);


                //is something selected
                if (listView.CheckedItems.Count != 1)
                {
                    MessageBox.Show("Please choose a single entity to generate ASP.NET code", "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (CheckForPrimaryKeys() == false)
                {
                    return;
                }

                dialog = new AspnetCodeGenerationDialog();

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string entityName = string.Empty;
                    string tableName  = string.Empty;

                    ArrayList       alColumns        = new ArrayList();
                    ArrayList       alTableRelations = new ArrayList();
                    TableRelation[] relations        = new TableRelation[0];


                    int current = -1;


                    //get the entity names
                    for (int i = 0; i < listView.Items.Count; i++)
                    {
                        ++current;

                        if (listView.Items[i].Checked)
                        {
                            entityName = Utilies.RemoveEmptySpaces(Context.databaseTables[i].EntityName);
                            tableName  = Context.databaseTables[i].TableName;
                            relations  = Context.databaseTables[i].Relations;

                            break;
                        }
                    }

                    string currentFilePath = string.Empty;

                    AspnetCodeGenerator c = new AspnetCodeGenerator();
                    c.Generate(Context.databaseTables[current].Columns, dialog.NamespaceName, entityName, dialog.GenerateContentPlaceholder, Application.StartupPath + @"\Output", relations);

                    MessageBox.Show("Files were successfully generated.", "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occurred while generating the files " + "\n" + ex.Message, "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (dialog != null)
                {
                    dialog.Dispose();
                }
            }
        }