Beispiel #1
0
        //TODO: code this
        public void genTable()
        {
            //gen project
            generateProject(_namespace, _namespace, _directoryName);

            //TODO: remove
            //IList data = database.Table(tables[0].GetType()).Query().Select();
            //Console.WriteLine(tables[0].name + tables[0].schema + tables[0].fields[0].columnName +
            //    tables[0].fields[1].columnName);

            // loop generate table to class model
            // STEP 1: create folder to gen
            // STEP 2: gen into folder with struct
            // STEP 3: gen view main, add, update into folder with struct
            // STEP 4: gen view show all link to form of models

            Console.WriteLine("Database ORM will generated into " + folderName);
            string pathName    = String.Format(@"{0}\{1}\{2}", _directoryName, _namespace, folderName);
            string projectPath = string.Format(@"{0}\{1}", _directoryName, _namespace);

            CommonInclude includeFile = new IncludeFile();
            CommonInclude includeForm = new IncludeForm();
            CommonInclude includeDLL  = new IncludeDLL();

            // STEP 1:
            System.IO.Directory.CreateDirectory(pathName);

            //STEP 2:
            foreach (var table in tables)
            {
                table.generate(new ClassGenerate(pathName), _namespace);
            }

            string pathView = String.Format(@"{0}\{1}\{2}", _directoryName, _namespace, folderView);

            System.IO.Directory.CreateDirectory(pathView);

            // STEP 3

            foreach (var table in tables)
            {
                table.generate(new FormGenerate(_connstring, pathView, tables), _namespace);
            }

            foreach (var table in tables)
            {
                //include add | update
                includeForm.includeProject(folderView, table.name, projectPath, _namespace);
                //include main | form
                includeForm.includeProject(folderView, $"FM{table.name}", projectPath, _namespace);
                //include Model
                includeFile.includeProject(folderName, table.name, projectPath, _namespace);
            }

            //include List
            includeForm.includeProject(folderView, "ListViews", projectPath, _namespace);

            //copy | add reference dll
            string pathLibs = String.Format(@"{0}\{1}\{2}", _directoryName, _namespace, folderLib);

            System.IO.Directory.CreateDirectory(pathLibs);
            copyFile(dll + ".dll", pathLibs);
            includeDLL.includeProject(folderLib, dll, projectPath, _namespace);
        }