Skip to content

Commit

Permalink
commit, some design changes in EXE prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernikas committed Feb 3, 2013
1 parent b6cf09f commit 199ce64
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 19 deletions.
16 changes: 10 additions & 6 deletions VLib/MainUNT.dfm
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
object frmMain: TfrmMain
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Main'
ClientHeight = 645
ClientWidth = 739
ClientHeight = 298
ClientWidth = 475
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
DesignSize = (
739
645)
475
298)
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Expand Down Expand Up @@ -42,8 +44,8 @@ object frmMain: TfrmMain
object WB1: TEmbeddedWB
Left = 0
Top = 296
Width = 737
Height = 241
Width = 473
Height = 0
Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 1
Silent = False
Expand All @@ -58,6 +60,8 @@ object frmMain: TfrmMain
'<HTML></HTML>')
PrintOptions.Footer = '&u&b&d'
PrintOptions.Orientation = poPortrait
ExplicitWidth = 737
ExplicitHeight = 241
ControlData = {
4C0000002C4C0000452A00000000000000000000000000000000000000000000
000000004C000000000000000000000001000000E0D057007335CF11AE690800
Expand Down
119 changes: 106 additions & 13 deletions VLib/MainUNT.pas
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TfrmMain = class(TForm)
function Proceed1(ACode: String): Boolean;
function Proceed2(ACode: String): Boolean;
function Parse1(ASource: String; ASourceText: String): Boolean;
function Parse2(ASource: String; ASourceText: String): Boolean;
public
{ Public declarations }
end;
Expand Down Expand Up @@ -58,10 +59,10 @@ procedure TfrmMain.Button1Click(Sender: TObject);
WB1.Navigate('about:blank');
WB1.Navigate(gloURL1);

//Padaryti timeout ir su state ir gal kartojima
while WB1.ReadyState < READYSTATE_INTERACTIVE do
Application.ProcessMessages;

// Antra karta paleidus tinka ir gloCount1 ???
while (gloCount < 1) and (ATimeout < 199999999) do
begin
Application.ProcessMessages;
Expand Down Expand Up @@ -127,26 +128,56 @@ function TfrmMain.Parse1(ASource, ASourceText: String): Boolean;
if Pos('Įrašų nerasta', WB1.DocumentSource) > 0 then
begin
memResult.Lines.Add('Įrašų nerasta');
// try parse 2
Proceed2(txtCode.Text);
Exit;
end;

AStart := Pos('Paieškos rezultatai', ASourceText);

AResult := ASourceText;
Delete(AResult, 1, AStart-1);
Delete(AResult, 1, AStart - 1);

AEnd := Pos('Konsultacijos mokesčių klausimais telefonu 1882', AResult);
Delete(AResult, AEnd, length(AResult)-AEnd);
Delete(AResult, AEnd, length(AResult) - AEnd);

memResult.Lines.Text := trim(AResult);

end;

function TfrmMain.Parse2(ASource, ASourceText: String): Boolean;
var
AStart: Integer;
AEnd: Integer;
AResult: String;
begin
Result := False;

memResult.Lines.Text := Trim(AResult);
// Result parse
if Pos('Įrašų nerasta', WB1.DocumentSource) > 0 then
begin
memResult.Lines.Add('Įrašų nerasta');
Exit;
end;

AStart := Pos('Paieškos rezultatai', ASourceText);

AResult := ASourceText;
Delete(AResult, 1, AStart - 1);

AEnd := Pos('Konsultacijos mokesčių klausimais telefonu 1882', AResult);
Delete(AResult, AEnd, length(AResult) - AEnd);

memResult.Lines.Text := trim(AResult);
end;

function TfrmMain.Proceed1(ACode: String): Boolean;
var
aElement: IhtmlElement;
ATimeout: Integer;
begin
Result := False;
ATimeout := 0;

// Recognize person code and select person code radio button
if length(trim(txtCode.Text)) = 11 then
Expand Down Expand Up @@ -184,22 +215,84 @@ function TfrmMain.Proceed1(ACode: String): Boolean;
else
Exit;

// TODO: timeout padaryti
while gloCount < 2 do
Application.ProcessMessages;

// Result parse
// ShowMessage(WB1.DocumentSource);
// ShowMessage(WB1.DocumentSourceText);
// WB1.DocumentSourceText
while (gloCount < 2) and (ATimeout < 199999999) do
begin
Application.ProcessMessages;
Inc(ATimeout);
end;

// memResult.Lines.Text := WB1.DocumentSourceText;
if ATimeout >= 199999999 then
begin
WB1.Stop;
WB1.Navigate('about:blank');
WB1.Navigate(gloURL1);
ShowMessage('TimeOut');
Exit;
end;

Parse1(WB1.DocumentSource, WB1.DocumentSourceText);
end;

function TfrmMain.Proceed2(ACode: String): Boolean;
var
ATimeout: Integer;
aElement: IhtmlElement;
begin
Result := False;

gloCount := 0;
ATimeout := 0;
WB1.Stop;
WB1.Navigate('about:blank');
WB1.Navigate(gloURL2);

while WB1.ReadyState < READYSTATE_INTERACTIVE do
Application.ProcessMessages;

while (gloCount < 1) and (ATimeout < 199999999) do
begin
Application.ProcessMessages;
Inc(ATimeout);
end;

if ATimeout >= 199999999 then
begin
ShowMessage ('Timeout');
Exit;
end;

aElement := WB1.ElementByID['inpCode'];
if aElement <> nil then
begin
aElement.click;
WB1.FillForm('InputByCode', ACode);
WB1.FillFormAndExcecute;
end;

aElement := nil;

aElement := WB1.ElementByID['LNGSubmit'];
if aElement <> nil then
begin
aElement.click;
end
else
Exit;

ATimeout := 0;
while (gloCount < 2) and (ATimeout < 199999999) do
begin
Application.ProcessMessages;
Inc(ATimeout);
end;

if ATimeout >= 199999999 then
begin
ShowMessage ('Timeout');
Exit;
end;

Parse2(WB1.DocumentSource, WB1.DocumentSourceText);

end;

Expand Down
Binary file modified VLib/Win32/Debug/VLib.exe
Binary file not shown.

0 comments on commit 199ce64

Please sign in to comment.