Home arrow Delphi-Kylix arrow Page 3 - Constructing the Interface for an Internet Access Control Application
DELPHI-KYLIX

Constructing the Interface for an Internet Access Control Application


In this third part to a six-part article that shows how to build an application for Internet access control, such as you might find in an Internet cafe, we will mainly be dealing with the functionality of the main server application. This is the application that will provide us with both the interface and capability to manage client sessions.

Author Info:
By: David Web
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
September 02, 2008
TABLE OF CONTENTS:
  1. · Constructing the Interface for an Internet Access Control Application
  2. · The Main Server Application
  3. · Code continued
  4. · Still More Code
  5. · Code Concluded

print this article
SEARCH DEVARTICLES

Constructing the Interface for an Internet Access Control Application - Code continued
(Page 3 of 5 )


procedure TForm1.timing(theStation,charge,thetime:string);

var

List: TList;

I:integer;

Context: TMyContext;

td,et,ab:tdatetime;

li:tlistitem;

begin

ab:=time;

longTimeFormat:='hh:nn';

et:=IncMinute(ab,strtoint(thetime));

form1.endtime:=et;


td:=now;

// tAll:=thetime;

//Search for workstation name in lv list

//if the name is there, then just add the allocated time and charge etc.

li:=lv.FindCaption(0,theStation,true,true,true);

if li <> nil then begin

memo1.lines.add(theStation+'...found...');

form1.li.ImageIndex:=8;

li.SubItems.Strings[0]:=formatdatetime('hh:mm:ss',et);

li.SubItems.Strings[1]:=timetostr(et);

li.SubItems.Strings[2]:=thetime + ' minutes';

li.SubItems.Strings[3]:='N$'+charge;

li.SubItems.Strings[4]:='Busy';


end

else begin

//the computer name is not on the listview, so add it!

memo1.lines.add('Timing...Caption does not exists.');

//update the lview

form1.li:=form1.lv.Items.Add;

form1.li.ImageIndex:=8;

form1.li.Caption:=theStation;

form1.li.SubItems.Add(formatdatetime('hh:mm:ss',et));

form1.li.SubItems.Add(timetostr(et));

form1.li.SubItems.Add(thetime + ' minutes');

form1.li.SubItems.Add('N$'+charge);

form1.li.SubItems.Add('Busy');

end;


List := form1.ts.Contexts.LockList;

try

for I := 0 to List.Count-1 do

begin

Context :=TMyContext(List[I]);

if Context.compname = theStation then

begin

try

Context.Connection.IOHandler.WriteLn('activate:'+theStation+'@'+thetime);

except

end;

Exit;

end;

end;

finally

form1.ts.Contexts.UnlockList;

end;

form1.memo1.Lines.add('error.');

end;







function ParseString(s : string; var Token1,Token2,Token3: string) :

boolean;

var

P1,P2 : integer;

begin

P1 := Pos(':',s);

P2 := Pos('@',s);

//Test if both delimiters are present, in the right order and

//at least 1 char apart

if ((P1 > 0) and (P2 > 0) and (P2 > P1) and (Abs(P2-P1) > 1))

then begin

Token1 := Copy(s,1,P1-1);

Token2 := Copy(s,P1+1,P2-P1-1);

Token3 := Copy(s,P2+1,Length(s)-P2);

Result := True; //valid string

end

else Result := False; //invalid string

end;


function parse4(s : string; var Token1,Token2,Token3,Token4: string) :

boolean;

var

P1,P2,P3 : integer;

begin

P1 := Pos(':',s);

P2 := Pos('@',s);

P3 := Pos(';',s);

//Test if both delimiters are present, in the right order and

//at least 1 char apart

if ((P1 > 0) and (P2 > 0) and (P3 > 0) and (P2 > P1) and (P3 > P2) and (Abs(P3-P2) > 1) and (Abs(P2-P1) > 1))

then begin

Token1 := Copy(s,1,P1-1);

Token2 := Copy(s,P1+1,P2-P1-1);

Token3 := Copy(s,P2+1,P3-P2-1);

Token4 := Copy(s,P3+1,Length(s)-P3);

Result := True; //valid string

end

else Result := False; //invalid string

end;



constructor TLog.Create(const AMsg: String);

begin

FMsg := AMsg;

inherited Create;

end;


procedure TLog.DoSynchronize;

begin

//GetComputername+'||free|plchldr'

form1.Memo1.Lines.Append(FMsg);

end;



class procedure TLog.AddMsg(const AMsg: String);

begin

with Create(AMsg) do try

Synchronize;

finally

Free;

end;

end;


constructor TForm1.Create(AOwner: TComponent);

begin

inherited Create(AOwner);

ts.ContextClass := TMyContext;

end;



blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials