programa não atualiza tabela quando está aberto na rede

Delphi

11/10/2006

Pessoal, estou com um problema há tempos, tenho um programa que roda em 3 máquinas, as tabelas ficam no servidor (uso PARADOX) e o BDE configurado em rede, tudo fuciona perfeitamente, só que quando 2 pcs estão com o programa aberto, ele não atualiza as alterações feitas por entre eles. os erros que ocorrem são, duplicação de ordens e status. Já procurei no forum um componente para que, ao atualizar algum dado em alguma máquina, atualize automaticamente em todas, o componete que encontrei foi o [b:85bf0b0cba]ShellChangeNotifier[/b:85bf0b0cba], só que não consigo utilizá-lo, marco todas as opções de alteração em [b:85bf0b0cba]Notify Filters[/b:85bf0b0cba] e nada acontece.

Procurei algo sobre ele no forum, so que não encontro uma explicação completa.

E agora, quem poderar me ajudar :?: :?: :?:


Vagner.oliveira

Vagner.oliveira

Curtidas 0

Respostas

Vagner.oliveira

Vagner.oliveira

11/10/2006

sobe


GOSTEI 0
Aloizio Castro

Aloizio Castro

11/10/2006

procedure Tdm.RefreshTables;
var
  i : Integer;
begin
  for i := 0 to Self.ComponentCount-1 do
    begin
      if Components[ i ] is TTable then
        if (Components[ i ] as TTable).Active then
          (Components[ i ] as TTable).Refresh;
    end;
end;

procedure Tdm.FlushTables;
var
  i : Integer;
begin
  for i := 0 to Self.ComponentCount-1 do
    begin
      if Components[ i ] is TTable then
        if (Components[ i ] as TTable).Active then
          begin
            (Components[ i ] as TTable).FlushBuffers;
            DbiSaveChanges((Components[ i ] as TTable).Handle);
          end;
    end;
end;


E no evento de AfterPost de todas as minhas tabelas eu faço o seguinte:
FlushTables;
RefreshTables;


Tente isto, além de é claro, configurar bem o BDE.

Abracos.


GOSTEI 0
Vagner.oliveira

Vagner.oliveira

11/10/2006

Consegui utilizar o [b:3da3ec492c]Shell Change Notify[/b:3da3ec492c] em rede. utilizo os seguintes componentes
- 1 button
- 1 shell change notify
- 1 label

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    ShellChangeNotifier1: TShellChangeNotifier;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Shape1: TShape;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure ShellChangeNotifier1Change;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var arq:TextFile;
begin
\\ aqui eu crio o arquivo troca.txt
        AssignFile(arq, ´B:\´ + ´troca.txt´); { ´b:\´ é a unidade que mapeei }
        ReWrite(Arq);
        Write(Arq, formatdatetime(´mm_ss´, now));
        CloseFile(Arq);
end;

procedure TForm1.ShellChangeNotifier1Change;
var t:textfile;
    texto:string;
begin
\\ quando o arq troca.txt é alterado ele importa o valor para o label
AssignFile(t, ´B:\´ + ´troca.txt´);
reset (t);
read(t, texto);
label1.Caption:=texto;
closefile(t);
end;

procedure TForm1.FormCreate(Sender: TObject);
var t:textfile;
    texto:string;
begin
{ aqui é so um capricho, quando abre o programa ja atualiza o label }
AssignFile(t, ´B:\´ + ´troca.txt´);
reset (t);
read(t, texto);
label1.Caption:=texto;
closefile(t);
end;
end.


[size=18:3da3ec492c][b:3da3ec492c][color=red:3da3ec492c]Detalhes a serem considerados:[/color:3da3ec492c][/b:3da3ec492c][/size:3da3ec492c]
:arrow: este processo foi testado para funcionar em uma rede interna.

:arrow: é necessário mapear uma unidade em TODOS os PCs (inclusive onde está
o arquivo swap, caso ele seja executado no pc).

:arrow: o Shell Change Notify tem que ter o ´root´ com a unidade mapeada

[b:3da3ec492c][size=16:3da3ec492c]Espero que isto ajude bastante a todos e especialmente aos que sempre contribuem para o forum.[/size:3da3ec492c][/b:3da3ec492c] :P


GOSTEI 0
Vagner.oliveira

Vagner.oliveira

11/10/2006

Consegui utilizar o [b:697ba3a55f]Shell Change Notify[/b:697ba3a55f] em rede. utilizo os seguintes componentes
- 1 button
- 1 shell change notify
- 1 label

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ShellCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    ShellChangeNotifier1: TShellChangeNotifier;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Shape1: TShape;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure ShellChangeNotifier1Change;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var arq:TextFile;
begin
\\ aqui eu crio o arquivo troca.txt
        AssignFile(arq, ´B:\´ + ´troca.txt´); { ´b:\´ é a unidade que mapeei }
        ReWrite(Arq);
        Write(Arq, formatdatetime(´mm_ss´, now));
        CloseFile(Arq);
end;

procedure TForm1.ShellChangeNotifier1Change;
var t:textfile;
    texto:string;
begin
\\ quando o arq troca.txt é alterado ele importa o valor para o label
AssignFile(t, ´B:\´ + ´troca.txt´);
reset (t);
read(t, texto);
label1.Caption:=texto;
closefile(t);
end;

procedure TForm1.FormCreate(Sender: TObject);
var t:textfile;
    texto:string;
begin
{ aqui é so um capricho, quando abre o programa ja atualiza o label }
AssignFile(t, ´B:\´ + ´troca.txt´);
reset (t);
read(t, texto);
label1.Caption:=texto;
closefile(t);
end;
end.


[size=18:697ba3a55f][b:697ba3a55f][color=red:697ba3a55f]Detalhes a serem considerados:[/color:697ba3a55f][/b:697ba3a55f][/size:697ba3a55f]
:arrow: este processo foi testado para funcionar em uma rede interna.

:arrow: é necessário mapear uma unidade em TODOS os PCs (inclusive onde está
o arquivo swap, caso ele seja executado no pc).

:arrow: o Shell Change Notify tem que ter o ´root´ com a unidade mapeada

[b:697ba3a55f][size=16:697ba3a55f]Espero que isto ajude bastante a todos e especialmente aos que sempre contribuem para o forum.[/size:697ba3a55f][/b:697ba3a55f] :P


GOSTEI 0
POSTAR