Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="namespaceName"></param>
        /// <param name="path"></param>
        /// <param name="selectedLanguage"></param>
        private void GeneratePersistent(string namespaceName, string path, Language selectedLanguage)
        {
            IDataAccessObjectGenerator generator = null;

            try
            {
                //initialize the generator based on the language

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


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

                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;
                        tableNames[current] = Utilies.RemoveEmptySpaces(Context.databaseTables[i].EntityName);
                    }
                }


                string currentFilePath = string.Empty;

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

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

                    currentFilePath = path + tableNames[i] + "DataAccess";


                    generator.GeneratePersistentObject(tableNames[i], namespaceName, currentFilePath);
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
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 GenerateDataAccessEntities(string namespaceName, string path, Language selectedLanguage, List <string> listTables, List <string> listEntities)
        {
            IDataAccessObjectGenerator generator = null;

            try
            {
                //initialize the generator based on the language

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


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

                //string[] tableNames = new string[listView.CheckedItems.Count];
                ArrayList alColumns        = new ArrayList();
                ArrayList alTableRelations = new ArrayList();

                string currentFilePath = string.Empty;

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

                    alColumns.Add(GeneratorContext.CurrentDatabaseTables[i].Columns);
                    alTableRelations.Add(GeneratorContext.CurrentDatabaseTables[i].Relations);

                    currentFilePath = path + listEntities[i] + "DataAccess";


                    generator.GenerateDataAccessObjects(listEntities[i], namespaceName, currentFilePath);
                }
            }
            catch
            {
                throw;
            }
        }