Ejemplo n.º 1
0
        public Database(AssemblyWizModel model)
        {
            this.connectionString = model.ConnectionString;
            this.connectionType   = model.ConnectionType;
            this.ownerName        = model.OwnerName;
            this.xmlSchemaFile    = model.XmlSchemaFile;
            this.isXmlSchema      = model.IsXmlSchema;
            try
            {
                if (this.isXmlSchema)
                {
                    XsdAnalyzer analyzer = new XsdAnalyzer();
                    this.dataSet = analyzer.Analyze(this.xmlSchemaFile);
                    if (analyzer.ValidationMessages.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder();
                        foreach (string s in analyzer.ValidationMessages)
                        {
                            sb.Append(s);
                            sb.Append("\r\n");
                        }
                        new ShowWarningsDlg(sb.ToString()).ShowDialog();
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(this.connectionString))
                    {
                        this.dataSet = new DataSet();
                    }
                    else
                    {
                        IProvider provider = NDOProviderFactory.Instance[this.connectionType];
                        if (provider == null)
                        {
                            throw new Exception("Can't find NDO provider '" + this.connectionType + "'");
                        }

                        IDbConnection conn = provider.NewConnection(this.connectionString);
                        conn.Open();
                        try
                        {
                            this.dataSet = provider.GetDatabaseStructure(conn, null);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                        finally
                        {
                            conn.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can't convert the schema into a dataset. Error Message: " + ex.ToString());
            }
        }
Ejemplo n.º 2
0
 public AssemblyWiz3(IModel model)
 {
     // Dieser Aufruf ist für den Windows Form-Designer erforderlich.
     InitializeComponent();
     this.cbTargetLanguage.DataSource = Enum.GetNames(typeof(TargetLanguage));
     this.model = (AssemblyWizModel)model;
 }
Ejemplo n.º 3
0
 public void Setup()
 {
     allObjects.Nodes.Clear();
     model = new AssemblyWizModel();
     model.ConnectionType   = "SqlServer";
     model.ConnectionString = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=NOTEBOOKZERO";
     model.ProjectDirectory = @"c:\MyNw";
     if (!Directory.Exists(model.ProjectDirectory))
     {
         Directory.CreateDirectory(model.ProjectDirectory);
     }
     else
     {
         foreach (string s in Directory.GetFiles(model.ProjectDirectory))
         {
             if (!s.EndsWith(".sln"))
             {
                 File.Delete(s);
             }
         }
     }
     model.ProjectName      = "Northwind";
     model.DefaultNamespace = "Northwind.Reverse";
     FillNodes();
 }
Ejemplo n.º 4
0
 private void FakeXmlAssembly()
 {
     allObjects.Nodes.Clear();
     model = new AssemblyWizModel();
     model.ConnectionType   = "Access";
     model.ConnectionString = "Replace this string with your Connection String";
     model.ProjectDirectory = @"C:\MyXmlReverseClasses\NDO";
     model.ProjectName      = "NDO.Mapping.Reverse";
     model.DefaultNamespace = "NDO.Mapping.Reverse";
     model.IsXmlSchema      = true;
     model.XmlSchemaFile    = @"C:\Projekte\NDO\NDODLL\NDOMapping.xsd";
     model.TargetLanguage   = TargetLanguage.VB;
     FillNodes();
 }
Ejemplo n.º 5
0
        private void FakeMySqlAssembly()
        {
            allObjects.Nodes.Clear();
            model = new AssemblyWizModel();
            model.ConnectionType    = "MySql";
            model.ConnectionString  = "Database=NDOShop;Data Source=localhost;User Id=root;";
            model.ProjectDirectory  = @"c:\MyNw\MySql";
            model.ProjectName       = "NDOShop";
            model.DefaultNamespace  = "NDOShop";
            model.MapStringsAsGuids = false;
            model.UseClassField     = true;
            FillNodes();
            DatabaseNode dbn = (DatabaseNode)allObjects.Nodes[0];

            //			allObjects.Nodes[0].ForeColor = System.Drawing.Color.LightGray;
        }
Ejemplo n.º 6
0
        public AssemblyWizModel ReCreateModel()
        {
            AssemblyWizModel model = new AssemblyWizModel();
            Database         db    = this.databaseNode.Database;

            model.ConnectionString = db.ConnectionString;
            model.ConnectionType   = db.ConnectionType;
            model.IsXmlSchema      = db.IsXmlSchema;
            model.OwnerName        = db.OwnerName;
            model.XmlSchemaFile    = db.XmlSchemaFile;

            Assembly ass = this.assemblyNode.Assembly;

            model.DefaultNamespace = ass.RootNamespace;
            model.ProjectDirectory = ass.TargetDir;
            model.ProjectName      = ass.ProjectName;
            model.TargetLanguage   = ass.TargetLanguage;
            model.UseClassField    = ass.UseClassField;
            return(model);
        }
Ejemplo n.º 7
0
        private void FakeOracleAssembly()
        {
            allObjects.Nodes.Clear();
            model = new AssemblyWizModel();
            model.ConnectionType    = "Oracle";
            model.ConnectionString  = "Password=manager;User ID=SYSTEM;Data Source=maty;Persist Security Info=True";
            model.ProjectDirectory  = @"c:\MyNw\Scott";
            model.ProjectName       = "Scott";
            model.DefaultNamespace  = "Scott.Reverse";
            model.MapStringsAsGuids = false;
            model.UseClassField     = true;
            model.OwnerName         = "SCOTT";
            FillNodes();
            DatabaseNode dbn = (DatabaseNode)allObjects.Nodes[0];
            TableNode    tn  = (TableNode)dbn.FindNode("EMP");

            tn.MapClass(null, EventArgs.Empty);

            //			allObjects.Nodes[0].ForeColor = System.Drawing.Color.LightGray;
        }
Ejemplo n.º 8
0
        private void menuLoad_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter     = "Class Generator Files (*.clgen)|*.clgen";
            ofd.DefaultExt = "clgen";
            DialogResult r = ofd.ShowDialog();

            if (r == DialogResult.OK)
            {
                this.fileName = ofd.FileName;
                XmlDocument doc = new XmlDocument();
                doc.Load(this.fileName);
                allObjects.Nodes.Clear();
                this.model = new AssemblyWizModel(doc.SelectSingleNode("ClassGeneratorData"));
                FillNodes();
#if MaskedOut
                this.fileName = ofd.FileName;
                NodeListSerializer nls = new NodeListSerializer(fileName, null);
                allObjects.Nodes.Clear();


                nls.Deserialize(allObjects.Nodes);
                foreach (NDOTreeNode trn in allObjects.Nodes)
                {
                    DatabaseNode dn = trn as DatabaseNode;
                    if (dn != null)
                    {
                        ApplicationController.Instance.DatabaseNode = dn;
                    }
                    AssemblyNode an = trn as AssemblyNode;
                    if (an != null)
                    {
                        ApplicationController.Instance.AssemblyNode = an;
                    }
                }
#endif
            }
        }
Ejemplo n.º 9
0
        private void NewAssembly()
        {
//            MessageBox.Show("Note: This tool is in an unstable beta state. There are known issues with saving and restoring the .ndogen files.", "Class Generator", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            allObjects.Nodes.Clear();
            model = new AssemblyWizModel();
            if (this.defaultDir != null)
            {
                model.ProjectDirectory = this.defaultDir;
            }
            IWizardController controller = new GenericController("AssemblyWiz", this.GetType().Assembly, "Generate Assembly Wizard");
            //controller.FrameSize = new Size(528, 380);
            DialogResult r = controller.Run(model);

            if (r == DialogResult.OK)
            {
                FillNodes();
            }
            if (r == DialogResult.Ignore)
            {
                this.menuLoad_Click(null, EventArgs.Empty);
            }
        }
Ejemplo n.º 10
0
 public AssemblyWiz4(IModel model)
 {
     // Dieser Aufruf ist für den Windows Form-Designer erforderlich.
     InitializeComponent();
     this.model = (AssemblyWizModel)model;
 }
Ejemplo n.º 11
0
 public DatabaseNode(AssemblyWizModel model) : base("Database", null)
 {
     this.myObject = new Database(model);
     Init();
 }
Ejemplo n.º 12
0
 public AssemblyNode(AssemblyWizModel model) : base("Assembly", null)
 {
     this.myObject = new Assembly(model.ProjectName, model.DefaultNamespace, model.ProjectDirectory, model.UseClassField, model.MapStringsAsGuids, model.TargetLanguage);
     CalculateIndex();
 }