diff --git a/Code4DGeraClasses.dproj b/Code4DGeraClasses.dproj index 382add4..fb0a5c3 100644 --- a/Code4DGeraClasses.dproj +++ b/Code4DGeraClasses.dproj @@ -1,7 +1,7 @@  {25167C24-4D80-48BA-AB70-9CFE33544A2A} - 18.8 + 19.5 VCL Code4DGeraClasses.dpr True @@ -120,10 +120,6 @@ - - Cfg_2 - Base - Base @@ -131,6 +127,10 @@ Cfg_1 Base + + Cfg_2 + Base + Delphi.Personality.12 @@ -145,13 +145,8 @@ Microsoft Office XP Sample Automation Server Wrapper Components - - - - Code4DGeraClasses.exe - true - - + + 1 @@ -164,14 +159,14 @@ 0 - + classes - 1 + 64 classes - 1 + 64 @@ -292,6 +287,16 @@ 1 + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + res\drawable-ldpi @@ -455,6 +460,11 @@ 1 .framework + + Contents\MacOS + 1 + .framework + 0 @@ -468,7 +478,7 @@ 1 .dylib - + 1 .dylib @@ -482,6 +492,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .dll;.bpl @@ -496,7 +511,7 @@ 1 .dylib - + 1 .dylib @@ -510,6 +525,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .bpl @@ -528,7 +548,7 @@ 0 - + 0 @@ -539,445 +559,417 @@ Contents\Resources\StartUp\ 0 + + Contents\Resources\StartUp\ + 0 + 0 - - - 1 - - + + 1 - + 1 - - - 1 - - + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - - + + + ..\ 1 - + + ..\ 1 - + + ..\ 1 - - + + + Contents 1 - + + Contents 1 - + + Contents 1 - - + + + Contents\Resources 1 - + + Contents\Resources 1 - + + Contents\Resources 1 - - - 1 - - + + + library\lib\armeabi-v7a 1 - + + library\lib\arm64-v8a 1 - - 1 1 - - 1 - - - - + 1 - + 1 - + + Contents\MacOS 1 - - - + + Contents\MacOS 1 - + + Contents\MacOS 1 - - 1 + + 0 - - + + + library\lib\armeabi-v7a 1 - + + + 1 - + 1 - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - + + ..\ 1 + ..\ 1 - + + ..\ 1 - + 1 1 - + 1 - - - 1 - + - 1 + ..\$(PROJECTNAME).launchscreen + 64 - - 1 + + ..\$(PROJECTNAME).launchscreen + 64 - + 1 1 - + 1 - - - 1 - - + + + Assets 1 - + + Assets 1 - - - 1 - - + + + Assets 1 - + + Assets 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - + - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - - 1 - - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - ..\ - 1 - + - ..\ + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - - - ..\ + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - ..\ + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - Contents + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - Contents + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - Contents\Resources + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Contents\Resources + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - library\lib\armeabi-v7a - 1 - - - library\lib\arm64-v8a - 1 - - - 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - 1 - - - Contents\MacOS - 1 - - - Contents\MacOS + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - 0 - - - - - library\lib\armeabi-v7a + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - Assets + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Assets + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - Assets + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Assets + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - + + + + + - - - - + + + True diff --git a/Postgress/lib32/pgenlist.pdb b/Postgress/lib32/pgenlist.pdb new file mode 100644 index 0000000..c0b7e70 Binary files /dev/null and b/Postgress/lib32/pgenlist.pdb differ diff --git a/Postgress/lib32/pgenlista.pdb b/Postgress/lib32/pgenlista.pdb new file mode 100644 index 0000000..51e1916 Binary files /dev/null and b/Postgress/lib32/pgenlista.pdb differ diff --git a/Postgress/lib32/psqlodbc30a.pdb b/Postgress/lib32/psqlodbc30a.pdb new file mode 100644 index 0000000..797e17b Binary files /dev/null and b/Postgress/lib32/psqlodbc30a.pdb differ diff --git a/Postgress/lib32/psqlodbc35w.pdb b/Postgress/lib32/psqlodbc35w.pdb new file mode 100644 index 0000000..193e420 Binary files /dev/null and b/Postgress/lib32/psqlodbc35w.pdb differ diff --git a/Postgress/lib64/pgenlist.pdb b/Postgress/lib64/pgenlist.pdb new file mode 100644 index 0000000..2fc14da Binary files /dev/null and b/Postgress/lib64/pgenlist.pdb differ diff --git a/Postgress/lib64/pgenlista.pdb b/Postgress/lib64/pgenlista.pdb new file mode 100644 index 0000000..ee0d011 Binary files /dev/null and b/Postgress/lib64/pgenlista.pdb differ diff --git a/Postgress/lib64/psqlodbc30a.pdb b/Postgress/lib64/psqlodbc30a.pdb new file mode 100644 index 0000000..fb5712c Binary files /dev/null and b/Postgress/lib64/psqlodbc30a.pdb differ diff --git a/Postgress/lib64/psqlodbc35w.pdb b/Postgress/lib64/psqlodbc35w.pdb new file mode 100644 index 0000000..72004b2 Binary files /dev/null and b/Postgress/lib64/psqlodbc35w.pdb differ diff --git a/README.md b/README.md index 11c3d6b..38da890 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,11 @@

Geração de classes de entidades. Com opções para o SimpleORM. - +Instrunção para Postgres SQL + + - Pegue na pasta postgres, a lib que corresponde a versão instalada em sua máquina. + Copie e cole na pasta que o executável Code4DelphiGeraClasses está, renome deixando somente a pasta lib, + pois a aplicação buscará por essa pasta. ## 📞 Contacts diff --git a/Src/Model/DM/Model.DM1.dfm b/Src/Model/DM/Model.DM1.dfm index 23268db..ddcccb6 100644 --- a/Src/Model/DM/Model.DM1.dfm +++ b/Src/Model/DM/Model.DM1.dfm @@ -1,5 +1,4 @@ object DM: TDM - OldCreateOrder = False OnCreate = DataModuleCreate Height = 468 Width = 843 @@ -74,8 +73,8 @@ object DM: TDM end object DS_FDMemTableTabelas: TDataSource DataSet = FDMemTableTabelas - Left = 328 - Top = 80 + Left = 464 + Top = 216 end object FDMetaInfoQueryFIelds: TFDMetaInfoQuery Connection = FDConnection1 @@ -141,4 +140,12 @@ object DM: TDM Left = 464 Top = 16 end + object FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink + Left = 464 + Top = 88 + end + object FDPhysPgDriverLink1: TFDPhysPgDriverLink + Left = 464 + Top = 152 + end end diff --git a/Src/Model/DM/Model.DM1.pas b/Src/Model/DM/Model.DM1.pas index 19b8297..21c7e37 100644 --- a/Src/Model/DM/Model.DM1.pas +++ b/Src/Model/DM/Model.DM1.pas @@ -3,30 +3,36 @@ interface uses - System.Classes, - System.SysUtils, Data.DB, + FireDAC.Comp.Client, FireDAC.Comp.DataSet, - FireDAC.Stan.Intf, - FireDAC.Stan.Option, - FireDAC.Stan.Error, - FireDAC.Stan.Def, - FireDAC.Stan.Pool, - FireDAC.Stan.Async, - FireDAC.Stan.Param, - FireDAC.Phys.Intf, + FireDAC.DApt, + FireDAC.DApt.Intf, + FireDAC.DatS, FireDAC.Phys, + FireDAC.Phys.FB, + FireDAC.Phys.FBDef, + FireDAC.Phys.IBBase, + FireDAC.Phys.Intf, FireDAC.Phys.MySQL, FireDAC.Phys.MySQLDef, + FireDAC.Phys.SQLite, + FireDAC.Phys.SQLiteDef, + FireDAC.Phys.SQLiteWrapper.Stat, + FireDAC.Stan.Async, + FireDAC.Stan.Def, + FireDAC.Stan.Error, + FireDAC.Stan.ExprFuncs, + FireDAC.Stan.Intf, + FireDAC.Stan.Option, + FireDAC.Stan.Param, + FireDAC.Stan.Pool, FireDAC.UI.Intf, FireDAC.VCLUI.Wait, - FireDAC.DatS, - FireDAC.DApt.Intf, - FireDAC.DApt, - FireDAC.Phys.FBDef, - FireDAC.Phys.IBBase, - FireDAC.Phys.FB; + + System.Classes, + System.SysUtils, FireDAC.Phys.PGDef, FireDAC.Phys.PG; type TDM = class(TDataModule) @@ -57,6 +63,8 @@ TDM = class(TDataModule) FDMetaInfoQueryFIeldsCOLUMN_SCALE: TIntegerField; FDMetaInfoQueryFIeldsCOLUMN_LENGTH: TIntegerField; FDPhysFBDriverLink1: TFDPhysFBDriverLink; + FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink; + FDPhysPgDriverLink1: TFDPhysPgDriverLink; procedure DataModuleCreate(Sender: TObject); private @@ -75,6 +83,7 @@ implementation procedure TDM.DataModuleCreate(Sender: TObject); begin + FDPhysPgDriverLink1.VendorHome := '.\'; FDConnection1.Connected := False; end; diff --git a/Src/Types/Types.pas b/Src/Types/Types.pas index a0580e4..97e4cbc 100644 --- a/Src/Types/Types.pas +++ b/Src/Types/Types.pas @@ -4,7 +4,7 @@ interface type {$SCOPEDENUMS ON} - TFormaAcesso = (PropertyDireto, PropertyGetSet, GetSet, FluentInterface); + TFormaAcesso = (PropertyDireto, PropertyGetSet, GetSet, FluentInterface, OrientadoInterface); TORM = (None, SimpleORM); {$SCOPEDENUMS OFF} diff --git a/Src/Utils/Utils.pas b/Src/Utils/Utils.pas index 8974e14..a319f20 100644 --- a/Src/Utils/Utils.pas +++ b/Src/Utils/Utils.pas @@ -147,6 +147,7 @@ class function TUtils.GerarCabecalhoArquivo: string; begin Result := '{'+ StringOfChar('*', 78) + '}' + sLineBreak + '{'+ CompD('Code4D - Gerador de classes: ' + FormatDateTime('dd/mm/yyyy hh:nn:ss', Now), 78) +'}' + sLineBreak + + '{'+ CompD('Contribuição - Tiago Robson - Delphiando - @Tiagoadvir ' + '', 78) +'}' + sLineBreak + '{'+ StringOfChar('*', 78) + '}' + sLineBreak; {Result := '//'+ StringOfChar('*', 78) + sLineBreak + @@ -181,6 +182,9 @@ class function TUtils.GetFieldType(ATypeName: string; AExibirMsgSeTipoDesconheci else if(ATypeName = 'DOUBLE')or(ATypeName = 'FLOAT')or(ATypeName = 'DECIMAL')or(ATypeName = 'NUMERIC')then Result := C_DOUBLE else + if(ATypeName = 'DOUBLE PRECISION')or(ATypeName = 'FLOAT')or(ATypeName = 'DECIMAL')or(ATypeName = 'NUMERIC')then + Result := C_DOUBLE + else begin Application.MessageBox(PChar('Tipo de dado não conhecido: ' + ATypeName + ' (tipo string será utilizado)'), 'Tipo desconhecido', MB_OK + MB_ICONEXCLAMATION); Result := C_STRING+ ' {'+ ATypeName +'}'; diff --git a/Src/View/View.Main.dfm b/Src/View/View.Main.dfm index 8096457..336cdb7 100644 --- a/Src/View/View.Main.dfm +++ b/Src/View/View.Main.dfm @@ -1,4 +1,4 @@ -object ViewMain: TViewMain +object ViewMain: TViewMain Left = 0 Top = 0 Caption = 'Code4D - Gerador de classes' @@ -10,13 +10,11 @@ object ViewMain: TViewMain Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] - OldCreateOrder = False Position = poScreenCenter WindowState = wsMaximized OnCreate = FormCreate OnDestroy = FormDestroy OnShow = FormShow - PixelsPerInch = 96 TextHeight = 13 object pnRodape: TPanel Left = 0 @@ -29,6 +27,8 @@ object ViewMain: TViewMain Padding.Left = 3 ParentBackground = False TabOrder = 0 + ExplicitTop = 619 + ExplicitWidth = 1031 object imgLogo: TImage Left = 3 Top = 0 @@ -249,7 +249,6 @@ object ViewMain: TViewMain ParentFont = False Layout = tlCenter OnClick = imgLogoClick - ExplicitLeft = 83 ExplicitWidth = 255 ExplicitHeight = 33 end @@ -259,9 +258,11 @@ object ViewMain: TViewMain Top = 0 Width = 1035 Height = 620 - ActivePage = tabConexao + ActivePage = tabGerador Align = alClient TabOrder = 1 + ExplicitWidth = 1031 + ExplicitHeight = 619 object tabConexao: TTabSheet Caption = 'Conex'#227'o' object pnConexao: TPanel @@ -359,13 +360,13 @@ object ViewMain: TViewMain Width = 650 Height = 21 Style = csDropDownList - ItemIndex = 0 TabOrder = 0 - Text = 'MySQL' OnChange = cBoxDriverChange Items.Strings = ( 'MySQL' - 'Firebird') + 'Firebird' + 'SQLite' + 'Postgres') end object edtDatabase: TEdit Left = 24 @@ -467,6 +468,26 @@ object ViewMain: TViewMain Caption = 'Salvar senha para pr'#243'ximos acessos' TabOrder = 11 end + object btnPreencherComDadosSQLite: TButton + Left = 693 + Top = 80 + Width = 218 + Height = 25 + Cursor = crHandPoint + Caption = 'Preencher com dados b'#225'sicos do SQLite' + TabOrder = 12 + OnClick = btnPreencherComDadosSQLiteClick + end + object btnPreencherComDadosPostgres: TButton + Left = 693 + Top = 111 + Width = 218 + Height = 25 + Cursor = crHandPoint + Caption = 'Preencher com dados b'#225'sicos do Postgres' + TabOrder = 13 + OnClick = btnPreencherComDadosPostgresClick + end end end object tabGerador: TTabSheet @@ -481,6 +502,8 @@ object ViewMain: TViewMain BevelOuter = bvNone ParentBackground = False TabOrder = 0 + ExplicitWidth = 1023 + ExplicitHeight = 591 object Splitter1: TSplitter Left = 297 Top = 0 @@ -498,6 +521,7 @@ object ViewMain: TViewMain BevelOuter = bvNone ParentBackground = False TabOrder = 0 + ExplicitHeight = 591 object Panel6: TPanel AlignWithMargins = True Left = 0 @@ -656,6 +680,8 @@ object ViewMain: TViewMain BevelOuter = bvNone ParentBackground = False TabOrder = 1 + ExplicitWidth = 723 + ExplicitHeight = 591 object mmLog: TMemo Left = 0 Top = 297 @@ -670,6 +696,8 @@ object ViewMain: TViewMain ParentFont = False ScrollBars = ssVertical TabOrder = 0 + ExplicitWidth = 723 + ExplicitHeight = 261 end object Panel7: TPanel Left = 0 @@ -684,6 +712,7 @@ object ViewMain: TViewMain BevelOuter = bvNone ParentBackground = False TabOrder = 1 + ExplicitWidth = 723 object Panel1: TPanel Left = 0 Top = 0 @@ -691,6 +720,7 @@ object ViewMain: TViewMain Height = 59 Align = alTop TabOrder = 0 + ExplicitWidth = 723 object Label8: TLabel Left = 7 Top = 0 @@ -725,14 +755,14 @@ object ViewMain: TViewMain object ckGravarArquivosPasta: TCheckBox Left = 7 Top = 38 - Width = 139 + Width = 149 Height = 17 Cursor = crHandPoint Caption = 'Gravar arquivos na pasta' TabOrder = 2 end object ckAbrirPastaAposGravar: TCheckBox - Left = 154 + Left = 162 Top = 38 Width = 147 Height = 17 @@ -787,8 +817,10 @@ object ViewMain: TViewMain 'Property acesso direto' 'Property acesso Get e Set' 'Func'#245'es com prefixo Get e Set' - 'Fun'#231#245'es fluent interface (overload)') + 'Fun'#231#245'es fluent interface (overload)' + 'Orientado a Interfaces') TabOrder = 1 + OnClick = rdGroupFormaAcessoEntitiesClick end end object GroupBox2: TGroupBox @@ -893,6 +925,21 @@ object ViewMain: TViewMain State = cbChecked TabOrder = 6 end + object ckGerarsaídadedadosinterface: TCheckBox + AlignWithMargins = True + Left = 5 + Top = 155 + Width = 234 + Height = 17 + Cursor = crHandPoint + Margins.Top = 0 + Align = alTop + Caption = 'Gerar sa'#237'da de dados interface' + TabOrder = 7 + Visible = False + ExplicitLeft = 3 + ExplicitTop = 167 + end end object Panel2: TPanel Left = 468 @@ -1029,6 +1076,8 @@ object ViewMain: TViewMain Padding.Bottom = 3 ParentBackground = False TabOrder = 2 + ExplicitTop = 558 + ExplicitWidth = 723 object btnLogLimpar: TButton Left = 3 Top = 3 diff --git a/Src/View/View.Main.pas b/Src/View/View.Main.pas index c0e746c..901e41c 100644 --- a/Src/View/View.Main.pas +++ b/Src/View/View.Main.pas @@ -99,6 +99,9 @@ TViewMain = class(TForm) edtLocalizarNomeTabela: TEdit; Label10: TLabel; btnVerSenha: TSpeedButton; + btnPreencherComDadosSQLite: TButton; + btnPreencherComDadosPostgres: TButton; + ckGerarsaídadedadosinterface: TCheckBox; procedure btnConectarOnOFFClick(Sender: TObject); procedure btnListarTabelasDoBancoClick(Sender: TObject); procedure FormCreate(Sender: TObject); @@ -124,6 +127,9 @@ TViewMain = class(TForm) procedure edtLocalizarNomeTabelaKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure btnVerSenhaMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure btnVerSenhaMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure btnPreencherComDadosSQLiteClick(Sender: TObject); + procedure btnPreencherComDadosPostgresClick(Sender: TObject); + procedure rdGroupFormaAcessoEntitiesClick(Sender: TObject); private FStrGeral: TStrings; FStrMetodosPrivate: TStrings; @@ -135,6 +141,7 @@ TViewMain = class(TForm) FClasseNome: string; FUnitNome: string; FTabelaLB: string; + FInterfaceGerada : Boolean; FFormaAcesso: TFormaAcesso; FORM: TORM; procedure ConfSGBD; @@ -157,6 +164,14 @@ TViewMain = class(TForm) procedure ConfFormSimpleORM; procedure ProcessaGetSetImplementacao(AFieldNameLB, AFieldTipo: string); procedure FiltraTabela; + procedure GerarInterface(AtableName: string); + procedure GeraTopoInterface; + procedure ProcessarContratoInterface(AFieldNameLB: string; AFieldTipo: string); + procedure GerarImplementacaodaClasseInterface(AtableName: string); + procedure GeraTopoClasseInterface; + procedure ProcessaOrientacaoInterface(AFieldNameLB, AFieldTipo: string); + procedure GeraDestructor; + procedure InstanciaFactoryMethod; public end; @@ -299,6 +314,24 @@ procedure TViewMain.btnPreencherComDadosMySQLClick(Sender: TObject); edtUsuario.Text := 'root'; edtHost.Text := 'localhost'; edtPorta.Text := '3306'; + edtUsuario.Enabled := True; + edtSenha.Enabled := True; + edtPorta.Enabled := True; + Self.ConfSGBD; +end; + +procedure TViewMain.btnPreencherComDadosPostgresClick(Sender: TObject); +begin + if(dm.FDConnection1.Connected)then + btnConectarOnOFF.Click; + cBoxDriver.ItemIndex := 3; + edtUsuario.Text := 'postgres'; + edtSenha.Text := 'postgres'; + edtHost.Text := 'localhost'; + edtUsuario.Enabled := True; + edtSenha.Enabled := True; + edtPorta.Enabled := True; + edtPorta.Text := '5432'; Self.ConfSGBD; end; @@ -310,25 +343,51 @@ procedure TViewMain.btnPreencherComDadosFirebirdClick(Sender: TObject); edtUsuario.Text := 'sysdba'; edtSenha.Text := 'masterkey'; edtHost.Text := 'localhost'; + edtUsuario.Enabled := True; + edtSenha.Enabled := True; + edtPorta.Enabled := True; + edtPorta.Text := ''; + Self.ConfSGBD; +end; + +procedure TViewMain.btnPreencherComDadosSQLiteClick(Sender: TObject); +begin + if(dm.FDConnection1.Connected)then + btnConectarOnOFF.Click; + cBoxDriver.ItemIndex := 2; + edtUsuario.Text := ''; edtPorta.Text := ''; + edtSenha.Text := ''; + edtUsuario.Enabled := False; + edtSenha.Enabled := False; + edtPorta.Enabled := False; Self.ConfSGBD; end; procedure TViewMain.btnConectarOnOFFClick(Sender: TObject); begin - if(not dm.FDConnection1.Connected)then - begin - Self.ConectarBanco; - dm.FDMemTableTabelas.Open; - tabGerador.Show; - end - else - begin - dm.FDMemTableTabelas.Close; - dm.FDConnection1.Connected := False; - end; - btnConectarOnOFF.Caption := IfThen(dm.FDConnection1.Connected, 'Desconectar', 'Conectar'); - pnGerador.Enabled := dm.FDConnection1.Connected; + try + if(not dm.FDConnection1.Connected)then + begin + Self.ConectarBanco; + dm.FDMemTableTabelas.Open; + tabGerador.Show; + end + else + begin + dm.FDMemTableTabelas.Close; + dm.FDConnection1.Connected := False; + end; + btnConectarOnOFF.Caption := IfThen(dm.FDConnection1.Connected, 'Desconectar', 'Conectar'); + pnGerador.Enabled := dm.FDConnection1.Connected; + Except on ex:exception do + begin + if AnsiContainsstr(ex.Message, 'password authentication failed') then + begin + showMessage('Erro de Autenticação para o usuário ' + edtUsuario.Text); + end; + end; + end; end; procedure TViewMain.ConectarBanco; @@ -339,6 +398,8 @@ procedure TViewMain.ConectarBanco; case(cBoxDriver.ItemIndex)of 0: dm.FDConnection1.Params.DriverID := 'MySQL'; 1: dm.FDConnection1.Params.DriverID := 'FB'; + 2: dm.FDConnection1.Params.DriverID := 'SQLite'; + 3: dm.FDConnection1.Params.DriverID := 'PG'; end; dm.FDConnection1.Params.Database := edtDatabase.Text; dm.FDConnection1.Params.UserName := edtUsuario.Text; @@ -496,7 +557,7 @@ procedure TViewMain.btnBuscarArquivoBancoClick(Sender: TObject); try LOpenDialog.Title := 'Selecione o arquivo desejado'; LOpenDialog.DefaulText := '*.FDB'; - LOpenDialog.Filter := 'Arquivos FDB (*.FDB)|*.FDB|Arquivos GDB (*.GDB)|*.GDB|Todos os Arquivos (*.*)|*.*'; + LOpenDialog.Filter := 'Arquivos FDB (*.FDB)|*.FDB|Arquivos GDB (*.GDB)|*.GDB|Arquivos DB (*.DB)|*.DB|Todos os Arquivos (*.*)|*.*'; LOpenDialog.InitialDir := ExtractFileDir(LOpenDialog.FileName); if(not LOpenDialog.Execute)then Exit; @@ -533,6 +594,11 @@ procedure TViewMain.ProcessaDirSalvar; end; end; +procedure TViewMain.rdGroupFormaAcessoEntitiesClick(Sender: TObject); +begin + ckGerarsaídadedadosinterface.Visible := rdGroupFormaAcessoEntities.ItemIndex = 4; +end; + procedure TViewMain.rdGroupORMClick(Sender: TObject); begin if(rdGroupORM.ItemIndex = 1)then @@ -559,7 +625,10 @@ procedure TViewMain.ConfFormSimpleORM; procedure TViewMain.ConfSGBD; begin - btnBuscarArquivoBanco.Enabled := cBoxDriver.ItemIndex = 1; + case cBoxDriver.ItemIndex of + 1: btnBuscarArquivoBanco.Enabled := True; + 2: btnBuscarArquivoBanco.Enabled := True; + end; end; procedure TViewMain.btnGerarClassEntitiesSelecionadosClick(Sender: TObject); @@ -577,7 +646,12 @@ procedure TViewMain.btnGerarClassEntitiesSelecionadosClick(Sender: TObject); while(not dm.FDMemTableTabelas.Eof)do begin if(dm.FDMemTableTabelasmarcado.AsString = 'S')then - Self.GerarClassesTabela(dm.FDMemTableTabelasnome_tabela.AsString); + begin + if rdGroupFormaAcessoEntities.ItemIndex = 4 then + Self.GerarInterface(dm.FDMemTableTabelasnome_tabela.AsString) + else + Self.GerarClassesTabela(dm.FDMemTableTabelasnome_tabela.AsString); + end; dm.FDMemTableTabelas.Next; end; finally @@ -590,6 +664,89 @@ procedure TViewMain.btnGerarClassEntitiesSelecionadosClick(Sender: TObject); ShellExecute(Application.Handle, 'open', PChar(ExtractFilePath(FDirSalvar)), nil, nil, SW_SHOWNORMAL); end; +procedure TViewMain.GerarInterface(AtableName: string); +begin + FTabelaName := AtableName; + FStrGeral.Clear; + if(ckLimparMemoACadaUnit.Checked)then + mmLog.Lines.Clear; + dm.FDMetaInfoQueryFIelds.Close; + dm.FDMetaInfoQueryFIelds.ObjectName := AtableName; + dm.FDMetaInfoQueryFIelds.Open; + + FTabelaLB := AtableName; + if(ckUpperCamelCaseInTables.Checked)then + FTabelaLB := TUtils.FormataNome(FTabelaLB); + + FUnitNome := StringReplace(edtNomeEntities.Text, '', FTabelaLB, [rfReplaceAll, rfIgnoreCase]); + FClasseNome := TUtils.RemovePontos(FUnitNome); + + Self.GeraTopoInterface; + Self.LacoEmFields; + FInterfaceGerada := True; + Self.GeraPublic; + FStrGeral.Add('implementation'); + FStrGeral.Add('end.'); + mmLog.Lines.Add(FStrGeral.Text.TrimRight); + + if(ckGravarArquivosPasta.Checked)then + FStrGeral.SaveToFile(FDirSalvar + 'i' + FUnitNome + '_.pas'); + + Self.GerarImplementacaodaClasseInterface(AtableName); + +end; + +procedure TViewMain.GerarImplementacaodaClasseInterface(AtableName: string); +begin + FTabelaName := AtableName; + FStrGeral.Clear; + if(ckLimparMemoACadaUnit.Checked) and not (rdGroupFormaAcessoEntities.ItemIndex = 4 ) then + mmLog.Lines.Clear; + dm.FDMetaInfoQueryFIelds.Close; + dm.FDMetaInfoQueryFIelds.ObjectName := AtableName; + dm.FDMetaInfoQueryFIelds.Open; + + FTabelaLB := AtableName; + if(ckUpperCamelCaseInTables.Checked)then + FTabelaLB := TUtils.FormataNome(FTabelaLB); + FUnitNome := StringReplace(edtNomeEntities.Text, '', FTabelaLB, [rfReplaceAll, rfIgnoreCase]); + FClasseNome := 'T' + TUtils.RemovePontos(FUnitNome); + + Self.GeraTopoClasseInterface; + Self.LacoEmFields; + Self.GeraPrivate; + FInterfaceGerada := False; + Self.GeraPublic; + FStrGeral.Add('implementation'); + Self.InstanciaFactoryMethod; + Self.GeraConstructor; + Self.GeraDestructor; + Self.ProcessaFuncoesAcesso; + FStrGeral.Add('end.'); + mmLog.Lines.Add(FStrGeral.Text.TrimRight); + + if(ckGravarArquivosPasta.Checked)then + FStrGeral.SaveToFile(FDirSalvar + FUnitNome + '.pas'); + +end; + +procedure TViewMain.GeraTopoClasseInterface; +begin + if(ckAddCabecalho.Checked)then + FStrGeral.Add(TUtils.GerarCabecalhoArquivo); + + FStrGeral.Add('unit ' + FUnitNome + ';'); + FStrGeral.Add(''); + FStrGeral.Add('interface'); + FStrGeral.Add(''); + FStrGeral.Add('Uses'); + FStrGeral.Add('i'+ FUnitNome +'_;'); + FStrGeral.Add(''); + FStrGeral.Add(''); + FStrGeral.Add('type'); + FStrGeral.Add(' '+ FClasseNome +' = class ( TInterfacedObject, i' + FUnitNome + ' )'); +end; + procedure TViewMain.GerarClassesTabela(AtableName: string); begin FTabelaName := AtableName; @@ -643,9 +800,24 @@ procedure TViewMain.GeraTopo; TORM.SimpleORM: FStrGeral.Add(' [Tabela('+ QuotedStr(FTabelaName) +')]'); end; + FStrGeral.Add(' '+ FClasseNome +' = class'); end; +procedure TViewMain.GeraTopoInterface; +begin + if(ckAddCabecalho.Checked)then + FStrGeral.Add(TUtils.GerarCabecalhoArquivo); + + FStrGeral.Add('unit i' + FUnitNome + '_;'); + FStrGeral.Add(''); + FStrGeral.Add('interface'); + FStrGeral.Add(''); + FStrGeral.Add('type'); + FStrGeral.Add(' i'+ FClasseNome +' = interface ' ); + FstrGeral.Add('['''+GUIDToString(TGuid.NewGuid)+''']'); +end; + procedure TViewMain.LacoEmFields; var LFieldName: string; @@ -674,12 +846,19 @@ procedure TViewMain.LacoEmFields; //METODO ACESSO case(FFormaAcesso)of TFormaAcesso.PropertyDireto, - TFormaAcesso.PropertyGetSet: - Self.ProcessaProperty(LFieldName, LFieldNameLB, LFieldTipo); + TFormaAcesso.PropertyGetSet: + Self.ProcessaProperty(LFieldName, LFieldNameLB, LFieldTipo); TFormaAcesso.GetSet: - Self.ProcessaGetSet(LFieldNameLB, LFieldTipo); + Self.ProcessaGetSet(LFieldNameLB, LFieldTipo); TFormaAcesso.FluentInterface: - Self.ProcessaFluentInterface(LFieldNameLB, LFieldTipo); + Self.ProcessaFluentInterface(LFieldNameLB, LFieldTipo); + TFormaAcesso.OrientadoInterface: + begin + if not FInterfaceGerada then + Self.ProcessarContratoInterface( LFieldNameLB, LFieldTipo); + if FInterfaceGerada then + Self.ProcessaOrientacaoInterface(LFieldNameLB, LFieldTipo); + end; end; dm.FDMetaInfoQueryFIelds.Next; end; @@ -752,6 +931,19 @@ procedure TViewMain.ProcessaGetSetImplementacao(AFieldNameLB: string; AFieldTipo FStrAcessoImpl.Add(''); end; +procedure TViewMain.ProcessarContratoInterface(AFieldNameLB: string; AFieldTipo: string); +begin + if ckGerarsaídadedadosinterface.Checked then + begin + FStrAcessoDeclaracoes.Add(' function '+ AFieldNameLB + ':' + AFieldTipo + '; overload;'); + FStrAcessoDeclaracoes.Add(' function '+ AFieldNameLB +'(Value: '+ AFieldTipo +'): i' + FUnitNome +'; overload;'); + end + else + begin + FStrAcessoDeclaracoes.Add(' function '+ AFieldNameLB +'(Value: '+ AFieldTipo +'): i' + FUnitNome +';'); + end; +end; + procedure TViewMain.ProcessaFluentInterface(AFieldNameLB: string; AFieldTipo: string); begin FStrAcessoDeclaracoes.Add(' function '+ AFieldNameLB +': '+ AFieldTipo +'; overload;'); @@ -770,6 +962,38 @@ procedure TViewMain.ProcessaFluentInterface(AFieldNameLB: string; AFieldTipo: st FStrAcessoImpl.Add(''); end; +procedure TViewMain.ProcessaOrientacaoInterface(AFieldNameLB: string; AFieldTipo: string); +begin + if ckGerarsaídadedadosinterface.Checked then + begin + FStrAcessoDeclaracoes.Add(' function '+ AFieldNameLB +': '+ AFieldTipo +'; overload;'); + FStrAcessoDeclaracoes.Add(' function '+ AFieldNameLB +'(Value: '+ AFieldTipo +'): i' + FUnitNome +'; overload;'); + + FStrAcessoImpl.Add('function '+ FClasseNome + '.' + AFieldNameLB +': '+ AFieldTipo +';'); + FStrAcessoImpl.Add('begin'); + FStrAcessoImpl.Add(' Result := F'+ AFieldNameLB +';'); + FStrAcessoImpl.Add('end;'); + FStrAcessoImpl.Add(''); + FStrAcessoImpl.Add('function '+ FClasseNome +'.'+ AFieldNameLB +'(Value: '+ AFieldTipo +'): i'+ FUnitNome +';'); + FStrAcessoImpl.Add('begin'); + FStrAcessoImpl.Add(' Result := Self;'); + FStrAcessoImpl.Add(' F'+ AFieldNameLB +' := Value;'); + FStrAcessoImpl.Add('end;'); + FStrAcessoImpl.Add(''); + end + else + begin + FStrAcessoDeclaracoes.Add(' function '+ AFieldNameLB +'(Value: '+ AFieldTipo +'): i' + FUnitNome +';'); + + FStrAcessoImpl.Add('function '+ FClasseNome +'.'+ AFieldNameLB +'(Value: '+ AFieldTipo +'): i'+ FUnitNome +';'); + FStrAcessoImpl.Add('begin'); + FStrAcessoImpl.Add(' Result := Self;'); + FStrAcessoImpl.Add(' F'+ AFieldNameLB +' := Value;'); + FStrAcessoImpl.Add('end;'); + FStrAcessoImpl.Add(''); + end; +end; + procedure TViewMain.GeraPrivate; begin FStrGeral.Add(' private'); @@ -780,10 +1004,35 @@ procedure TViewMain.GeraPrivate; procedure TViewMain.GeraPublic; begin - FStrGeral.Add(' public'); - FStrGeral.Add(' constructor Create;'); - FStrGeral.Add(FStrAcessoDeclaracoes.Text.TrimRight); - FStrGeral.Add(' end;'); + if rdGroupFormaAcessoEntities.ItemIndex = 4 then + begin + if not FInterfaceGerada then + begin + FStrGeral.Add(' public'); + FStrGeral.Add(' constructor Create;'); + FStrGeral.Add(' destructor destroy ; Override;'); + FStrGeral.Add(' class function new: i' + FUnitNome + ';' ); + end; + + FStrGeral.Add(FStrAcessoDeclaracoes.Text.TrimRight); + FStrGeral.Add(' end;'); + FStrGeral.Add(''); + end + else + begin + FStrGeral.Add(FStrAcessoDeclaracoes.Text.TrimRight); + FStrGeral.Add(' end;'); + FStrGeral.Add(''); + end; +end; + +procedure TViewMain.InstanciaFactoryMethod; +begin + FStrGeral.Add(''); + FStrGeral.Add('class function '+ FClasseNome + '.new: i' + FUnitNome + ';'); + FStrGeral.Add('begin'); + FStrGeral.Add(' Result := ' + FClasseNome + '.Create;'); + FStrGeral.Add('end;'); FStrGeral.Add(''); end; @@ -797,12 +1046,27 @@ procedure TViewMain.GeraConstructor; FStrGeral.Add(''); end; +procedure TViewMain.GeraDestructor; +begin + FStrGeral.Add(''); + FStrGeral.Add('Destructor '+ FClasseNome + '.Destroy;'); + FStrGeral.Add('begin'); + FStrGeral.Add(' inherited;'); + FStrGeral.Add('end;'); + FStrGeral.Add(''); +end; + procedure TViewMain.ProcessaFuncoesAcesso; begin case(FFormaAcesso)of TFormaAcesso.PropertyGetSet, - TFormaAcesso.GetSet, - TFormaAcesso.FluentInterface: + TFormaAcesso.GetSet, + TFormaAcesso.FluentInterface: + begin + FStrGeral.Add(FStrAcessoImpl.Text.TrimRight); + FStrGeral.Add(''); + end; + TFormaAcesso.OrientadoInterface: begin FStrGeral.Add(FStrAcessoImpl.Text.TrimRight); FStrGeral.Add(''); diff --git a/Win32/Debug/Code4DGeraClasses.ini b/Win32/Debug/Code4DGeraClasses.ini new file mode 100644 index 0000000..6855bc8 --- /dev/null +++ b/Win32/Debug/Code4DGeraClasses.ini @@ -0,0 +1,28 @@ +[Gerador] +ckConectarAutoAoAcessar=1 +cBoxDriver=2 +edtDatabase=F:\PROJETOS PESSOAIS\FORÇA DE VENDAS DELPHI 11\FastPed_Mobile\db\fastped.db +edtUsuario= +edtHost=localhost +edtPorta= +ckSalvarSenhaBancoProxAcesso=1 +edtSenha= +edtPastaDestino=F:\PROJETOS PESSOAIS\FORÇA DE VENDAS DELPHI 11\FastPed_Mobile\Classes +ckGravarArquivosPasta=0 +ckAbrirPastaAposGravar=0 +ckAddCabecalho=1 +ckLimparMemoACadaUnit=1 +edtNomeEntities=Notificacao +rdGroupFormaAcessoEntities=4 +ckAddComentarioNomeTabela=0 +ckAddComentarioNomeField=0 +ckExibirMsgSeTipoDesconhecido=1 +edtLocalizarNomeTabela= +ckUpperCamelCaseInTables=1 +ckUpperCamelCaseInFields=1 +rdGroupORM=0 +cBoxSimpleORMAtributoCampo=0 +ckAddAtributoPK=1 +edtAddAtributoPKCampo= +ckAddAtributoAutoInc=1 +edtAddAtributoAutoIncCampo= diff --git a/Win32/Debug/lib/pgenlist.pdb b/Win32/Debug/lib/pgenlist.pdb new file mode 100644 index 0000000..c0b7e70 Binary files /dev/null and b/Win32/Debug/lib/pgenlist.pdb differ diff --git a/Win32/Debug/lib/pgenlista.pdb b/Win32/Debug/lib/pgenlista.pdb new file mode 100644 index 0000000..51e1916 Binary files /dev/null and b/Win32/Debug/lib/pgenlista.pdb differ diff --git a/Win32/Debug/lib/psqlodbc30a.pdb b/Win32/Debug/lib/psqlodbc30a.pdb new file mode 100644 index 0000000..797e17b Binary files /dev/null and b/Win32/Debug/lib/psqlodbc30a.pdb differ diff --git a/Win32/Debug/lib/psqlodbc35w.pdb b/Win32/Debug/lib/psqlodbc35w.pdb new file mode 100644 index 0000000..193e420 Binary files /dev/null and b/Win32/Debug/lib/psqlodbc35w.pdb differ