コード例 #1
0
 public Main(string tableName)
 {
     this.InitializeComponent();
     IGeneratorService generatorService = new GeneratorService();
     generatorService.ConnectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
     this.Tables.DataSource = generatorService.GetColumns(tableName);
 }
コード例 #2
0
        private void Generate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Tables.SelectedRows.Count > 0)
                {
                    Generate.Enabled = false;
                    IDictionary<string, object> parameters = new Dictionary<string, object>();
                    parameters.Add("database", ConfigurationManager.ConnectionStrings["SQLiteConnectionString"].ProviderName);
                    parameters.Add("namespace", this.Namespace.Text);
                    parameters.Add("nullableType", this.NullableType.Checked ? "?" : "");
                    IList<Table> tables = new List<Table>();
                    foreach (DataGridViewRow row in this.Tables.SelectedRows)
                    {
                        tables.Add((Table) row.DataBoundItem);
                    }
                    IGeneratorService generatorService = new GeneratorService();
                    generatorService.ConnectionString =
                        ConfigurationManager.ConnectionStrings["SQLiteConnectionString"].ConnectionString;
                    generatorService.TemplatePath = Path.Combine(Application.StartupPath,
                                                                 string.Format(@"Templates\{0}",
                                                                               this.Version.SelectedItem));
                    generatorService.OutputPath = Path.Combine(Application.StartupPath, "Outputs");
                    //生成之前清空outputs文件夹
                    DeleteFolder(generatorService.OutputPath);

                    generatorService.Generate(tables, parameters);
                    MessageBox.Show("生成成功");
                    Generate.Enabled = true;
                }
                else
                {
                    MessageBox.Show("请选择数据表");
                }
            }
            catch (Exception ex)
            {

            }
        }
コード例 #3
0
 private void Refresh(string schemaType)
 {
     IGeneratorService generatorService = new GeneratorService();
     generatorService.ConnectionString = ConfigurationManager.ConnectionStrings["SQLiteConnectionString"].ConnectionString;
     this.Tables.DataSource = generatorService.GetTables(schemaType);
 }