quarta-feira, 22 de março de 2006

Good News (Mini ECO Book PT BR)

Hi guys !

This week I was a litle busy here with the service,
so many news are comming, one of then is that Peter Morris allowed me to translate the Mini Eco Book about Eco Services !
Probably until the end of the next week it will be ready !

Another news is that I've missed the day to send my Article to concur an Delphi 2006 from clube delphi magazine, so I will be finishing the text of my article and posting it here, probably it will have 3 parts! In that article I explain how to use expression handles, currency managers, comboboxes, Eco State Machines, some OCL tips and another things.

Keep eye on it ;)
Ps.: Maybe I delay a litle bit becuse I've finished some projects this days but I will try my best to post it all until the end of next week.

Regards,
Diego.

Boas Noticias (Mini Book ECO PT BR)

Oi pessoal tudo bem ?
Bom essa semana andei meio ocupado aqui com o serviço,
muitas novidades estão por vir, uma delas é que o Peter Morris me autorizou a fazer a tradução do Mini livro dele sobre ECO Services ! Então aguardem !
Provavelmente até o fim da semana que vem estará pronto.

Outra novidade é que perdi o dia da entrega da materia que concorria a um Delphi 2006 da clube delphi então estarei terminando o texto da matéria e publicarei aqui provavelmente em umas 3 partes! Nesta materia explico como utilizar, expression handles, currency managers, combobox, State Machine, algumas dicas de OCL entre outros.

Fique de olho ;)

Ps.: Pode ser que eu atraze um pouco devido ao número de projetos que tenho estes dias mas tentarei fazer o maximo possivel para que semana que vem esteja tudo ai.

Abração,
Diego.

quarta-feira, 15 de março de 2006

New Eco website.

Hello guys !
Peter Morris has opened an new eco website, and the good news is that it already has an mini book (we can say) about Eco Services and between us its amazing. I recomend the reading ;)

http://myecospace.net

Regards,
Diego.

Novo site sobre Eco.

I ai galera tudo bem ?
Peter Morris lançou seu novo site sobre eco que por sinal já tem um mini livro pode se dizer, sobre Eco Services muito bom por sinal. Vale a pena conferir.

http://myecospace.net

Abração a todos,
Diego.

terça-feira, 14 de março de 2006

Required Files to deploy an ECO Application (WindowsForms)

Hello guys how have you been ?
I was a litle busy this days solving some problems at the company but everthing is nice now ;)

I will write above an list of required files to deplou an ECO Windows Forms application that uses the Interbase, and I will write with the list some explanation of other DB's.

bdpInt20.dll -> required interbase dll, if you uses another DB take a look for the one that matches your DB in the folder 'C:\Program Files\Borland\BDS\3.0\Bin', here comes an example of some of the dll's: (bdpmss20.dll: MicrosoftSql, bdpora20.dll:Oracle, bdpsyb20.dll: Sybase, and others). To understand the name of the dll is simple, bdp means borland data provider + the short name of the db + bdp version.

Borland.Data.Interbase.dll -> required interbase dll, if you uses another DB take a look for the one that matches your DB in the folder 'C:\Program Files\Common Files\Borland Shared\BDS\Shared Assemblies\3.0' if you are using ECO II or in the folder 'C:\Program Files\Common Files\Borland Shared\BDS\Shared Assemblies\4.0' if you are using ECO III.

Borland.Data.Common.dll
Borland.Data.Provider.dll
Borland.Delphi.dll
Borland.Eco.Core.dll
Borland.Eco.Handles.dll
Borland.Eco.Interfaces.dll
Borland.Eco.Ocl.ParserCore.dll
Borland.Eco.Persistence.dll
Borland.Eco.Windows.Forms.dll
EcoPatches.dll -> Only necessary if you are using ECO II with the ECO Patches.

Attention: it can be some other dlls, it depends the components you are using in your project.

To know what dll your project needs to be deployed has to ways, one is to look at the assembler list of your delphi (references) but sometimes it doesnt have all of the assemblers. The other way is to put it your program in other pc that doesnt have the delphi installed and that have an .net debugger installed, so you can run with the .net debbuger and look at the referenced assemblers called from your program.

In another post I will explain step-by-step how to install an .net debbuger and how to find the required assemblers to be deployed.

I hope you guys have liked ;)

Regards,
Diego.

Arquivos necessarios para fazer deploy de uma aplicação ECO (Windowsforms)

I ai galera tudo bem ?
Andei meio ocupado esses dias resolvendo alguns pepinos aqui na empresa mas tudo tranquilo.

Vou colocar abaixo a lista de arquivos necessarios para fazer deploy de uma aplicação ECO windows forms que utiliza o Interbase e junto a lista de arquivos irei dar uma breve explicação sobre os outros BD's.

bdpInt20.dll -> dll necessaria para o interbase funcionar, caso utilize outro BD, procure a dll equivalente na pasta 'C:\Arquivos de programas\Borland\BDS\3.0\Bin', aqui vai um exemplo de algumas dll's: (bdpmss20.dll: MicrosoftSql, bdpora20.dll:Oracle, bdpsyb20.dll: Sybase, e outros). Para entender o nome da dll é simples bdp de borland data provider + nome do bd abreviado + versão do bdp.

Borland.Data.Interbase.dll -> dll necessaria para o interbase funcionar, caso utilize outro bd procure a dll equivalente na pasta 'C:\Arquivos de programas\Arquivos comuns\Borland Shared\BDS\Shared Assemblies\3.0' se for ECO II ou na pasta 'C:\Arquivos de programas\Arquivos comuns\Borland Shared\BDS\Shared Assemblies\4.0' se for ECO III.

Borland.Data.Common.dll
Borland.Data.Provider.dll
Borland.Delphi.dll
Borland.Eco.Core.dll
Borland.Eco.Handles.dll
Borland.Eco.Interfaces.dll
Borland.Eco.Ocl.ParserCore.dll
Borland.Eco.Persistence.dll
Borland.Eco.Windows.Forms.dll
EcoPatches.dll -> É necessario apenas se você estiver utilizando ECO II com o eco patches.

Atenção poderá existir mais dlls de acordo com os componentes que você utilize em sua aplicação.


Para saber quais dlls são necessarias existem duas maneiras, uma é olhar na lista de assemblers do seu delphi (references) porém as vezes alguns dos assemblers não são exibidos na lista e quando você for fazer seu deploy você tera erros ao executar o programa. A outra forma é de você colocar em um outro computador que não tenha o delphi instalado e que tenha um depurador .net para você acompanhar os processos que seu programa ira executar ao inicia-lo e ver o nome dos respectivos assemblers.

Em um proximo artigo explicarei passo a passo como instalar um depurador .net e acompanhar os passos de um programa a ser feito deploy.

Espero que vocês tenhão gostado ;)

Abraços,
Diego.

segunda-feira, 13 de março de 2006

Creating ECO Reports with 9Rays Report

Well, this time I will show how easy is to make reports using ECO.
Create a new ECO Winform Project, for this, go to File->New->Other select the Delphi Net Projects folder, do a double click in ECO Winforms Application.
Now, go to the tab Model View and expand the first item of the list clicking in the signal ‘+’, expand the Package1 item and perform a double click in the first item of the list.
Now create a model like below:



don’t forget to change the name of the two type ends in the association or the ECO will complain.

Now click in the first tab at the left of the Model View and a double click in the Winform.pas item.
configure the property ECOSpaceType of the component rhRoots to use its Model.
Delete the components EcoAutoFormExtender, ECOListActionExtender and ECOGlobalActions.

Add and component ReportGenerator component and set its OwnerForm property to the current form and change its name for rptECOReport.
* Add in the DataSources property, clicking in the button Add, the name PessoaList and the Value pointing to ehPerson. (this item in design time wouldn’t have to be important, however if you do not fill it you will find problems when trying to have access to the DataSource property when trying to access it by code, therefore it is recommended to fill it).

Add two components ExpressionHandle and a CurrencyManager.
Change the name of one of the ExpressionHandle to ehPerson and the other to ehContact and change the name of the CurrencyManager to cmhPerson.
ehPerson must have the following expression Person.allInstances->select(e expression|e.PersonContact->isEmpty), then set its property *AddDefaultNestings to true and change the property RootHandle to use rhRoot, the ehContact must have its expression self.Contacts and its RootHandle will have to point to cmhPerson.
cmhPerson must have its RootHandle property pointing to ehPerson and its BindingContext property pointing to the TWinForm.
* We change to true the AddDefaulNesting property so that our report understands that our object Contact is a Person and it has the same fields that a Person and allows we to use it, set to false the report would only show the object without attributes, not allowing that the same to be manipulated.

Now, add to two datagrids and three buttons.
Change the DataSource option of one DataGrid to use ehPerson and the other to use the ehContact.
Changes the Text property of one of the buttons to Create Person, with the following code in the Click event:
Person.Create(EcoSpace);

Changes the Text property of the other button to Create Contact, with the following code in the Click event:
var
vContact: Person;
begin
if Assigned(cmhPerson.Element) then
begin
vContact: = Person.Create(EcoSpace);
(cmhPerson.Element.AsObject Person).Contacts.Add(vContact);
end
else
MessageBox.Show(‘ No person to add contacts ');
end;

Add the following namespaces in the section use of your code: NineRays.Reporting.DOM, System.Resources,
NineRays.Reporting.View.

Change the Text property of the other button to Generate Report, with the following code in the Click event:
var
vPreviewForm: PreviewForm;
begin
ehPessoa.EnsureBindingList; //Update the list off Persons so our report keeps updated
ehContato.EnsureBindingList;// Update the list off Contacts so our report keeps updated


rptECOReport.DataSources.Clear; //clean the report DataSources list.

rptECOReport.DataSources.Add('PessoaList', ehPessoa.GetList);//Add our list updated to the DataSource
rptECOReport.DesignTemplate; //This method is used only to draw the report. After Drawn it won’t be used.

rptECOReport.LoadTemplate(Application.ExecutablePath.Trim('EcoReport.exe'.ToCharArray)+'\EcoReport.rst '); //Load the saved report designed by the DesignTemplate method. Attention the name of the report must be the same of the one saved in the DesignTemplate.

vPreviewForm: = PreviewForm.Create(rptECOReport);// we create the form to show the Preview of the Report.
try
try
rptECOReport.Prepare; //Prepare the report.
vPreviewForm.WindowState: = FormWindowState.Maximized; //Set the state of the window to Maximized.
vPreviewForm.ShowDialog; //Show the Preview Form.
except
on ee: Exception of the MessageBox.Show(ee.Message, 'ECO Report ', MessageBoxButtons.OK, MessageBoxIcon.Error); //If occur some error we show it to the user.
end;
finally
vPreviewForm.Dispose; //Free the memory resources.
end;
end;

Now execute the program and click in the button Generate Report and the screen of design will be shown, as below:



go to File menu - > New - > Blank Report and click in Ok.

With our new report opened add a PageHeader in our report, to do this click in the icon then click in the report and put the PageHeader at the top of the page. Go to the DataSources tab and go to the Item Special Fields, you will find fields to identify the page number the description of the document, total page and others, Click and drag the Page Number inside of the PageHeader and put it on the right side. (Attention: Always place the objects inside the one you want to show or the same will not be shown). You can place the title of your Report in the PageHeader if you want to print it in all report pages or you can place a Detail and write inside it, to appear only in the initial page. In our case we go to add a Detail, to do that click in the icon and put it below the pageHeader, after that put a Text inside the Detail using the first item of the left lateral bar, called TextBox, and change its Text property to ECO Report with 9Rays.

Lets start to manipulate the ECO objects.
Add a DataBand clicking in the icon and put it below of the Detail, click in the DataBand and change its DataSource property to PersonList (the Name given in the DataSource of rptEcoReport), attention: to manipulate the data to be shown all the components as Header, Detail and others will have to be placed inside of the main DataBand or the data won’t be shown.
Good, with our DataBand ready lets place a Header inside it, to do that click in the icon and draw it inside of the DataBand. After that, put a TextBox with the Text Name and other with the Text Address inside the Header.
After that, add an Detail inside the DataBand, go to the Data Sources and expand the PersonList item (Exactly name of rptEcoReport) click and drag the item Name inside of the Detail, make the same thing with the Address.
Well, now we go to add another DataBand inside of our Databand to show the Contacts of each Person, add the DataBand and setup its DataSource to point to PeersonList.Contacts.
After that, add a Header and a Detail inside of this DataBand as made in the first one, the only difference is that you will have to catch the fields that is inside the DataSource called PersonList - > Contacts and drag them as done previously.
You can add a pageFooter to if you want.
The final result must be as below:



Save the report with the name EcoReport in the same folder of the executable, now close the program and remove or comment the line:
rptRelatorioECO.DesignTemplate;

Save the Project and run, add some Persons and some Contacts and take a look at the final result ;).

To download 9Rays enter in the site of the company: 9Rays

I hope you liked, see you next week!

Any doubts or comments post it in the blog, after all the blog is setuped to accept comments without having a blog account.

segunda-feira, 6 de março de 2006

Criando Relatórios no ECO com 9Rays Report

Bom desta vez irei mostrar como é fácil fazer relatórios utilizando ECO.
Crie um novo Projeto Eco Winforms, para isso vá em File->New->Other selecione a pasta Delphi for .Net Projects, de um duplo clique em ECO Winforms Application.
Vá agora na aba Model View expanda o primeiro item da lista clicando no sinal ‘+’, expanda o item Package1 e de um duplo clique no primeiro item.
Crie o modelo como abaixo:



Não se esqueça de mudar o nome das duas pontas da associação ou o ECO irá reclamar.

Agora clique na primeira aba do lado do esquerdo da Model View e de um duplo clique no item Winform.pas.
Configure a propriedade ECOSpaceType do componente rhRoot para usar seu Modelo.
Delete os componentes EcoAutoFormExtender, ECOListActionExtender e ECOGlobalActions.

Adicione o componente ReportGenerator e sete sua propriedade OwnerForm para o form atual e mude seu nome para rptRelatorioECO.
* Adicione na propriedade DataSources, clicando no botão Add, o Nome PessoaList e o Value apontando para o ehPessoa. (esse item em tempo de design não deveria ser importante, porém se você não preenche-la você poderá encontrar problemas ao tentar acessar a propriedade DataSource via código, por isso é recomendado preenche-la).

Adicione dois componentes ExpressionHandle e um CurrencyManager.
Mude o nome de um dos ExpressionHandle para ehPessoa e o outro para ehContato e mude o nome do CurrencyManager para cmhPessoa.
O ehPessoa deverá ter a seguinte expressão Pessoa.allInstances->select(e|e.PessoaContato->isEmpty), sete a propriedade *AddDefaultNestings para true e mude a propriedade rootHandle para usar o rhRoot, o ehContato deverá ter está expressão self.Contatos e seu rootHandle deverá apontar para cmhPessoa.
O cmhPessoa deverá ter sua propriedade RootHandle apontando para o ehPessoa e sua propriedade BindingContext apontando para o TWinForm.
*Mudamos para true a propriedade AddDefaulNesting para que nosso relatório entenda que o nosso objeto Contato é uma Pessoa e possui os mesmos campos que uma Pessoa e permita que nós o utilizemos, caso contrario o relatório iria apenas mostrar o objeto sem atributos, não permitindo que o mesmo seja manipulado.

Agora Adicione dois datagrids e três botões.
Mude a opção DataSource de um dos DataGrids para usar o ehPessoa e o outro para usar o ehContato.
Mude a propriedade Text de um dos botões para Criar Pessoa, com o seguinte código no evento Click:
Pessoa.Create(EcoSpace);

Mude a propriedade Text do outro botão para Criar Contato, com o seguinte código no evento Click:
var
vContato: Pessoa;
begin
if Assigned(cmhPessoa.Element) then
begin
vContato := Pessoa.Create(EcoSpace);
(cmhPessoa.Element.AsObject as Pessoa).Contatos.Add(vContato);
end
else
MessageBox.Show('Não Existe nenhuma pessoa para adicionar contatos!');
end;

Adicione os seguintes namespaces na seção uses do seu código: NineRays.Reporting.DOM, System.Resources,
NineRays.Reporting.View.

Mude a propriedade Text do outro botão para Gerar Relatório, com o seguinte código no evento Click:
var
vPreviewForm : PreviewForm;
begin
ehPessoa.EnsureBindingList; //Certificamos que a lista de Pessoas esta atualizada
ehContato.EnsureBindingList; //Certificamos que a lista de Contatos esta atualizada

rptRelatorioECO.DataSources.Clear; //Limpamos a lista de DataSources do Relatorio.

rptRelatorioECO.DataSources.Add('PessoaList',ehPessoa.GetList); //Adicionamos a nossa lista de pessoas atual ao datasource.
rptRelatorioECO.DesignTemplate; //Este método é utilizado apenas para desenharmos o relatorio. Após Desenhado não será mais utilizado.

rptRelatorioECO.LoadTemplate(Application.ExecutablePath.Trim('ExemploRelatoriEco.exe'.ToCharArray)+'\relatorioEco.rst'); //Carregamos o arquivo que iremos salvar após Desenhar o relatório e salvar. Atenção o nome do relatório deve ser o mesmo do que foi salvo no Design dele.

vPreviewForm := PreviewForm.Create(rptRelatorioECO); //Criamos o form de Preview do Relatório.
try
try
rptRelatorioECO.Prepare; //Preparamos o relatorio
vPreviewForm.WindowState := FormWindowState.Maximized; //Setamos o estado da janela para Maximizado.
vPreviewForm.ShowDialog; //Exibimos a tela de Preview.
except
on ee : Exception do MessageBox.Show(ee.Message, 'Relatorio no ECO', MessageBoxButtons.OK, MessageBoxIcon.Error); //Se ocorrer algum erro mostramos o mesmo para o usuário.
end;
finally
vPreviewForm.Dispose; //Liberamos o recurso da memória.
end;
end;

Agora Execute o programa e click no botão Gerar Relatório a tela de design será exibida, como abaixo:



Vá no menu File -> New -> Blank Report e click em Ok.

Com nosso novo relatório criado vamos adicionar um PageHeader (cabeçalho) no nosso relatório, para isso click no ícone depois click no relatório e posicione o pageheader no topo da pagina. Vá na aba DataSources e vá no Item Special Fields, você encontrará campos para identificar o numero da pagina a descrição do documento, total de paginas e outros, Click e arraste o Page Number para dentro do PageHeader e posicione o na lateral direita. (Atenção: Coloque sempre dentro ou o mesmo não será exibido). Você poderá colocar o titulo de seu Relatório dentro do PageHeader caso queira que ele seja exibido em todas as paginas ou colocar um Detail e escrever dentro para ele aparecer apenas na pagina inicial. No nosso caso vamos adicionar um detail, para isso click no ícone
e Posicione o abaixo de seu pageHeader, após fazer adicione um texto dentro do Detail utilizando o primeiro item da barra lateral esquerda, chamado TextBox, e altere sua propriedade Text para Relatório ECO e 9Rays.

Vamos agora começar a manipular os dados do ECO.
Para isso adicione um DataBand clicando no ícone e posicione-o abaixo do Detail, click no DataBand e altere sua propriedade DataSource para PessoaList (O Nome dado no DataSource do rptRelatorioEco), atenção para manipular os dados a serem exibidos todos os componentes como Header, Detail e outros deverão ser colocados dentro do DataBand principal ou os dados não serão exibidos.
Bom com nosso DataBand criado vamos agora colocar um Header dentro dele, para isso click no ícone e desenhe-o dentro do DataBand. (Repeti novamente para que não ocorra nenhum erro). Depois de feito isso adicione dois TextBox um com o Text Nome e o outro Endereço.
Depois de feito isso adicione dentro do DataBand um componente Detail, vá na aba Data Sources e expanda o item PessoaList (Mesmo nome do rptRelatorioEco) click e arraste o item Nome para dentro do Detail, faça a mesma coisa com o Endereço.
Bom agora vamos adicionar um outro DataBand dentro do nosso Databand para exibir os Contatos de cada Pessoa, adicione o DataBand e configure seu DataSource para apontar para PessoaList.Contatos.
Após ter feito isso adicione um Header e um Detail dentro deste DataBand como feito no primeiro porem você deverá pegar os campos da aba DataSource que esta dentro do PessoaList -> Contatos e arrastá-los como feito anteriormente.
Após ter feito isso você poderá adicionar um pageFooter para colocar um rodapé.
O resultado final devera ser como o abaixo:


Salve o relatório com o nome relatorioEco no mesmo diretório do executável e feche o editor de relatórios, feche o programa e remova ou comente a linha:
rptRelatorioECO.DesignTemplate;

Salve seu Projeto e execute o programa, adicione algumas Pessoas e alguns Contatos e veja o resultado final ;).

Para baixar o 9Rays entre no site da empresa: 9Rays

Abraços e espero que tenham gostado e até semana que vem.

Qualquer duvida ou comentários postem no blog afinal está liberada a postagem de comentários sem cadastro no blog.