Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="namespaceName"></param>
        /// <param name="mappingFileName"></param>
        /// <param name="persistentFileName"></param>
        /// <param name="persistentObject"></param>
        /// <param name="languageName"></param>
        private void GenerateComplete(string namespaceName, string mappingFileName, string persistentFileName, string persistentObject, Language selectedLanguage)
        {
            ITableMetadataGenerator    generator            = null;
            IDataAccessObjectGenerator persistanceGenerator = null;


            try
            {
                if (selectedLanguage == Language.CSharp)
                {
                    generator            = new CSharpTableMetadataGenerator();
                    persistanceGenerator = new CSharpDataAccessObjectGenerator();
                }
                else if (selectedLanguage == Language.VbNet)
                {
                    generator            = new VBTableMetadataGenerator();
                    persistanceGenerator = new VBDataAccessObjectGenerator();
                }


                string[] entityNames = new string[listView.CheckedItems.Count];
                string[] tableNames  = new string[listView.CheckedItems.Count];

                ArrayList alColumns        = new ArrayList();
                ArrayList alTableRelations = new ArrayList();

                int current = -1;

                for (int i = 0; i < listView.Items.Count; i++)
                {
                    if (listView.Items[i].Checked)
                    {
                        ++current;
                        entityNames[current] = Context.databaseTables[i].EntityName;
                        tableNames[current]  = Context.databaseTables[i].TableName;

                        alColumns.Add(Context.databaseTables[i].Columns);
                        alTableRelations.Add(Context.databaseTables[i].Relations);
                    }
                }

                generator.GenerateTableMetadatata(entityNames, tableNames, alColumns, alTableRelations, mappingFileName, namespaceName);
                persistanceGenerator.GeneratePersistentObject(persistentObject, namespaceName, persistentFileName);
                MessageBox.Show("File sucessfully generated", "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);


                //uncheck items
                for (int i = 0; i < listView.Items.Count; i++)
                {
                    listView.Items[i].Checked = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error occured \n" + ex.Message, "DataBlock Modeler", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void GenerateDomainObjects(string namespaceName, string path, Language selectedLanguage, List <string> listTables, List <string> listEntities)
        {
            ITableMetadataGenerator generator = null;

            //initialize the generator based on the language

            if (selectedLanguage == Language.CSharp)
            {
                generator = new CSharpTableMetadataGenerator();
            }
            else if (selectedLanguage == Language.VbNet)
            {
                generator = new VBTableMetadataGenerator();
            }


            //check path
            if (!path.EndsWith(@"\"))
            {
                path += @"\";
            }


            ArrayList alColumns        = new ArrayList();
            ArrayList alTableRelations = new ArrayList();


            string currentFilePath = string.Empty;

            for (int i = 0; i < listEntities.Count; i++)
            {
                alColumns.Clear();
                alTableRelations.Clear();

                foreach (DatabaseTable var in GeneratorContext.CurrentDatabaseTables)
                {
                    if (var.EntityName == listEntities[i])
                    {
                        alColumns.Add(var.Columns);
                        alTableRelations.Add(var.Relations);
                        break;
                    }
                }


                currentFilePath = path + listEntities[i];

                generator.GenerateTableMetadatata(new string[1] {
                    listEntities[i]
                }, new string[1] {
                    listTables[i]
                }, alColumns, alTableRelations, currentFilePath, namespaceName);
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="namespaceName"></param>
        /// <param name="path"></param>
        /// <param name="selectedLanguage"></param>
        private void GenerateMappings(string namespaceName, string path, Language selectedLanguage)
        {
            ITableMetadataGenerator generator = null;

            try
            {
                //initialize the generator based on the language

                if (selectedLanguage == Language.CSharp)
                {
                    generator = new CSharpTableMetadataGenerator();
                }
                else if (selectedLanguage == Language.VbNet)
                {
                    generator = new VBTableMetadataGenerator();
                }


                //check path
                if (!path.EndsWith(@"\"))
                {
                    path += @"\";
                }


                string[] entityNames = new string[listView.CheckedItems.Count];
                string[] tableNames  = new string[listView.CheckedItems.Count];

                ArrayList alColumns        = new ArrayList();
                ArrayList alTableRelations = new ArrayList();

                int current = -1;


                //get the entity names
                for (int i = 0; i < listView.Items.Count; i++)
                {
                    if (listView.Items[i].Checked)
                    {
                        ++current;
                        entityNames[current] = Utilies.RemoveEmptySpaces(Context.databaseTables[i].EntityName);
                        tableNames[current]  = Context.databaseTables[i].TableName;
                    }
                }


                string currentFilePath = string.Empty;

                for (int i = 0; i < entityNames.Length; i++)
                {
                    alColumns.Clear();
                    alTableRelations.Clear();

                    foreach (DatabaseTable var in Context.databaseTables)
                    {
                        if (var.EntityName == entityNames[i])
                        {
                            alColumns.Add(var.Columns);
                            alTableRelations.Add(var.Relations);
                            break;
                        }
                    }


                    currentFilePath = path + entityNames[i];

                    generator.GenerateTableMetadatata(new string[1] {
                        entityNames[i]
                    }, new string[1] {
                        tableNames[i]
                    }, alColumns, alTableRelations, currentFilePath, namespaceName);
                }
            }
            catch
            {
                throw;
            }
        }