Exemple #1
0
 private void GenerateRowCode()
 {
     if (this.ConnectionsCombo.SelectedItem != null &&
         this.TablesCombo.SelectedItem != null &&
         !EntitySingular.IsTrimmedEmpty())
     {
         string table       = (string)this.TablesCombo.SelectedItem;
         string tableSchema = null;
         if (table.IndexOf('.') > 0)
         {
             tableSchema = table.Substring(0, table.IndexOf('.'));
             table       = table.Substring(table.IndexOf('.') + 1);
         }
         try
         {
             using (var connection = CreateConnection((string)this.ConnectionsCombo.SelectedItem))
             {
                 connection.Open();
                 this.GeneratedCode.Text = RowGenerator.Generate(connection, tableSchema, table,
                                                                 Module, Schema, EntitySingular, Permission);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
Exemple #2
0
        private void GenerateCodes_Click(object sender, RoutedEventArgs e)
        {
            if (this.ConnectionsCombo.SelectedItem == null ||
                this.TablesCombo.SelectedItem == null)
            {
                MessageBox.Show("Bir bağlantı ve tablo adı seçmelisiniz!");
                return;
            }

            if (EntitySingular.IsTrimmedEmpty())
            {
                MessageBox.Show("Entity Sınıfı için değer girmelisiniz!");
                return;
            }

            if (Permission.IsTrimmedEmpty())
            {
                MessageBox.Show("Erişim Hakkı için değer girmelisiniz!");
                return;
            }

            string tableName = (string)this.TablesCombo.SelectedItem;

            try
            {
                EntityCodeGenerationModel rowModel;
                using (var connection = CreateConnection((string)this.ConnectionsCombo.SelectedItem))
                {
                    connection.Open();
                    var    table       = (string)this.TablesCombo.SelectedItem;
                    string tableSchema = null;
                    if (table.IndexOf('.') > 0)
                    {
                        tableSchema = table.Substring(0, table.IndexOf('.'));
                        table       = table.Substring(table.IndexOf('.') + 1);
                    }
                    rowModel = RowGenerator.GenerateModel(connection, tableSchema, table,
                                                          Module, Schema, EntitySingular, Permission);
                    new EntityCodeGenerator(rowModel, ProjectRoot).Run();

                    MessageBox.Show("Seçilen tablo için kod üretildi!");

                    GenerateCodeButton.IsEnabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #3
0
        private void GenerateCodes_Click(object sender, RoutedEventArgs e)
        {
            if (this.ConnectionsCombo.SelectedItem == null ||
                this.TablesCombo.SelectedItem == null)
            {
                MessageBox.Show("A connection string and table name must be selected!");
                return;
            }

            if (EntitySingular.IsTrimmedEmpty())
            {
                MessageBox.Show("Entity class identifier must be entered!");
                return;
            }

            if (Permission.IsTrimmedEmpty())
            {
                MessageBox.Show("Permission key must be entered!");
                return;
            }

            string tableName = (string)this.TablesCombo.SelectedItem;

            try
            {
                GenerateCodeFor(tableName);

                MessageBox.Show("Code files for the selected table is generated. Please REBUILD SOLUTION before running application, otherwise you may have script errors!");
                GenerateCodeButton.IsEnabled = false;
                SaveTableInfo(tableName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #4
0
        private void GenerateCodes_Click(object sender, RoutedEventArgs e)
        {
            if (this.ConnectionsCombo.SelectedItem == null ||
                this.TablesCombo.SelectedItem == null)
            {
                MessageBox.Show("A connection string and table name must be selected!");
                return;
            }

            if (EntitySingular.IsTrimmedEmpty())
            {
                MessageBox.Show("Entity class identifier must be entered!");
                return;
            }

            if (Permission.IsTrimmedEmpty())
            {
                MessageBox.Show("Permission key must be entered!");
                return;
            }

            string tableName = (string)this.TablesCombo.SelectedItem;

            try
            {
                EntityCodeGenerationModel rowModel;
                var conn = (GeneratorConfig.Connection) this.ConnectionsCombo.SelectedItem;
                using (var connection = SqlConnections.New(conn.ConnectionString, conn.ProviderName))
                {
                    connection.Open();
                    var    table       = (string)this.TablesCombo.SelectedItem;
                    string tableSchema = null;
                    if (table.IndexOf('.') > 0)
                    {
                        tableSchema = table.Substring(0, table.IndexOf('.'));
                        table       = table.Substring(table.IndexOf('.') + 1);
                    }
                    rowModel = RowGenerator.GenerateModel(connection, tableSchema, table,
                                                          Module, ConnectionKey, EntitySingular, Permission, config);
                    new EntityCodeGenerator(rowModel, config).Run();

                    MessageBox.Show("Code files for the selected table is generated!");

                    GenerateCodeButton.IsEnabled = false;
                }

                var cnn      = this.ConnectionsCombo.SelectedItem as GeneratorConfig.Connection;
                var tableObj = cnn != null?cnn.Tables.FirstOrDefault(x => x.Tablename == tableName) : null;

                if (tableObj == null && cnn != null)
                {
                    tableObj           = new GeneratorConfig.Table();
                    tableObj.Tablename = tableName;
                    cnn.Tables.Add(tableObj);
                }

                if (tableObj != null)
                {
                    tableObj.Identifier    = EntitySingular;
                    tableObj.PermissionKey = Permission;
                    tableObj.Module        = Module;
                    tableObj.ConnectionKey = ConnectionKey;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            File.WriteAllText(GetConfigurationFilePath(), JSON.StringifyIndented(config));
        }