Ejemplo n.º 1
0
        private void generateMapclass()
        {
            var    Mapclasssettings = new Connection();
            string mapTempPath      = Path.GetTempPath();

            if (mapTempPath.EndsWith(@"\") == false)
            {
                mapTempPath += @"\";
            }
            mapTempPath += @"Mapping\";
            if (Directory.Exists(mapTempPath) == false)
            {
                Directory.CreateDirectory(mapTempPath);
            }
            Mapclasssettings.Domainfolderpath = mapTempPath;

            Mapclasssettings.EntityName = "Entity";
            if ((RecoEngine_BI.Common.iDBType) == (int)Enums.DBType.Oracle)
            {
                Mapclasssettings.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
                Mapclasssettings.Type             = ServerType.Oracle;
            }
            else if ((RecoEngine_BI.Common.iDBType) == (int)Enums.DBType.Mysql)
            {
                Mapclasssettings.ConnectionString = ConfigurationManager.AppSettings["MysqlConnectionString"];
                Mapclasssettings.Type             = ServerType.Mysql;
            }

            //  metadataReader = MetadataFactory.GetReader(Mapclasssettings.Type, Mapclasssettings.ConnectionString);
            var           owners     = metadataReader.GetOwners();
            IList <Table> tblList    = metadataReader.GetTables("RECOUSR");
            int           tableindex = 0;

            for (int i = 0; i < tblList.Count; i++)
            {
                if (tblList[i].Name == "OPPORTUNITY")
                {
                    tableindex = i;
                    break;
                }
            }
            Table table = tblList[tableindex];

            table.PrimaryKey = metadataReader.DeterminePrimaryKeys(table);
            metadataReader.GetTableDetails(table, "RECOUSR");
            var applicationPreferences = GetApplicationPreferences(table, false, Mapclasssettings);

            new ApplicationController(applicationPreferences, table).Generate();
        }
Ejemplo n.º 2
0
        public void GenerateAndDisplayCode(Table table)
        {
            SetCodeControlFormatting(applicationSettings);

            // Refresh the primary key relationships.
            table.PrimaryKey  = metadataReader.DeterminePrimaryKeys(table);
            table.ForeignKeys = metadataReader.DetermineForeignKeyReferences(table);

            // Show map and domain code preview
            ApplicationPreferences applicationPreferences = GetApplicationPreferences(table, false, applicationSettings);
            var applicationController = new ApplicationController(applicationPreferences, table);

            applicationController.Generate(writeToFile: false);
            mapCodeFastColoredTextBox.Text    = applicationController.GeneratedMapCode;
            domainCodeFastColoredTextBox.Text = applicationController.GeneratedDomainCode;
        }