Changeset 25 for trunk


Ignore:
Timestamp:
Nov 19, 2012, 2:08:02 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Základní čtení logů z přístupového terminálu.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChronIS.lpr

    r24 r25  
    2323
    2424begin
    25   Application.Title:='ChronIS';
    2625  {$IFDEF DEBUG}
    2726  // Heap trace
  • trunk/Languages/ChronIS.cs.po

    r24 r25  
    472472msgstr "Záznam"
    473473
     474#: umoduleattendance.slogcount
     475msgid "Log count: "
     476msgstr ""
     477
    474478#: umoduleattendance.slogin
    475479msgctxt "umoduleattendance.slogin"
     
    558562
    559563#: umoduleattendance.susersread
    560 msgid "User read: %s"
     564msgid "User read: "
    561565msgstr ""
    562566
  • trunk/Languages/ChronIS.po

    r24 r25  
    450450msgstr ""
    451451
     452#: umoduleattendance.slogcount
     453msgid "Log count: "
     454msgstr ""
     455
    452456#: umoduleattendance.slogin
    453457msgctxt "umoduleattendance.slogin"
     
    536540
    537541#: umoduleattendance.susersread
    538 msgid "User read: %s"
     542msgid "User read: "
    539543msgstr ""
    540544
  • trunk/Modules/Attendance/UAttendance.pas

    r14 r25  
    4444  TUserPassage = class
    4545    Id: Integer;
    46     Terminal: TTerminal;
    47     User: TUser;
     46    Terminal: Integer; //TTerminal;
     47    User: Integer; //TUser;
    4848    Time: TDateTime;
    49     Operation: TOperation;
     49    Operation: Integer; //TOperation;
    5050  end;
    5151
  • trunk/Modules/Attendance/UModuleAttendance.pas

    r24 r25  
    77uses
    88  Classes, SysUtils, FileUtil, UModularSystem, UFormList, UFormEdit, Controls,
    9   SpecializedList, Forms, ActnList, Menus, UDataModel, Dialogs, SpecializedDictionary;
     9  SpecializedList, Forms, ActnList, Menus, UDataModel, Dialogs,
     10  SpecializedDictionary, USqlDatabase;
    1011
    1112type
     
    102103  SHoliday = 'Holiday';
    103104  SLog = 'Log';
    104   SUsersRead = 'User read: %s';
     105  SUsersRead = 'User read: ';
     106  SLogCount = 'Log count: ';
    105107
    106108{ TDataModuleAttendance }
     
    112114  UserCount: Integer;
    113115  UserRec: TUser;
     116  Passage: TUserPassage;
     117  PassageCount: Integer;
    114118  Data: TDictionaryStringString;
    115119  I: Integer;
     
    118122  UserRec := nil;
    119123  AccessControler := nil;
     124  Passage := nil;
    120125  try
    121126    VirtualAccessControler := TVirtualTerminalBF630.Create;
     
    123128    VirtualAccessControler.Active := True;
    124129
     130    Data := TDictionaryStringString.Create;
     131
    125132    AccessControler := TTerminalBF630.Create;
    126133    AccessControler.Active := True;
    127134    UserCount := AccessControler.GetUserCount;
    128 
    129     UserRec := TUser.Create;
    130     Data := TDictionaryStringString.Create;
     135    //ShowMessage(SUsersRead + IntToStr(UserCount));
     136
     137    (*UserRec := TUser.Create;
    131138    for I := 0 to UserCount - 1 do begin
    132139      Data.Clear;
     
    135142      Data.Add('SecondName', UserRec.SecondName);
    136143      Core.Database.Insert('User', Data);
    137     end;
    138     ShowMessage(SUsersRead + IntToStr(UserCount));
     144    end; *)
     145
     146    PassageCount := AccessControler.GetPassageCount;
     147    //ShowMessage(SLogCount + IntToStr(PassageCount));
     148
     149    Passage := TUserPassage.Create;
     150    for I := 0 to PassageCount - 1 do begin
     151      Data.Clear;
     152      AccessControler.GetPassage(I, Passage);
     153      Data.Add('Terminal', IntToStr(Passage.Terminal));
     154      Data.Add('Operation', IntToStr(Passage.Operation));
     155      Data.Add('Time', DateTimeToSQL(Passage.Time));
     156      Data.Add('User', IntToStr(Passage.User));
     157      Core.Database.Insert('Passage', Data);
     158    end;
     159
    139160  finally
    140161    if Assigned(Data) then Data.Free;
    141162    if Assigned(UserRec) then UserRec.Free;
     163    if Assigned(Passage) then Passage.Free;
    142164    if Assigned(AccessControler) then AccessControler.Free;
    143165    VirtualAccessControler.Free;
  • trunk/Modules/ChiyuAccessControlers/UTerminalBF630.pas

    r24 r25  
    8181    function ReadDateTime: TDateTime;
    8282    function GetUserCount: Integer; override;
    83     function GetUser(Id: Integer; User: TUser): Boolean; override;
     83    function GetUser(Index: Integer; User: TUser): Boolean; override;
     84    function GetPassageCount: Integer; override;
     85    function GetPassage(Index: Integer; Passage: TUserPassage): Boolean; override;
    8486    constructor Create; override;
    8587    destructor Destroy; override;
     
    106108  end;
    107109
     110  TVirtualTerminalBF630Passage = class
     111    Id: Integer;
     112    Time: TDateTime;
     113    User: Integer;
     114    Key: Integer;
     115  end;
     116
    108117  { TVirtualTerminalBF630 }
    109118
     
    116125    function CommandGetUserIDList(Request: TListByte; Response: TListByte): Byte;
    117126    function CommandGetUserData(Request: TListByte; Response: TListByte): Byte;
     127    function CommandLogGet(Request: TListByte; Response: TListByte): Byte;
     128    function CommandLogGetCount(Request: TListByte; Response: TListByte): Byte;
    118129    procedure SetActive(AValue: Boolean);
    119130    procedure NewConnection(Sender: TCommTCPServer; Pin: TCommPin);
     
    121132  public
    122133    Users: TListObject; // TListObject<TVirtualTerminalBF630User>
     134    Passages: TListObject; // TListObject<TVirtualTerminalBF630Passage>
    123135    Sessions: TListObject; // TListObject<TVirtualTerminalBF630Session>
    124136    AccessKey: array[0..5] of Byte;
     
    198210        else if Command = Byte(toGetDate) then ResultCode := CommandReadDate(Request, Response)
    199211        else if Command = Byte(toUserDataGet) then ResultCode := CommandGetUserData(Request, Response)
     212        else if Command = Byte(toLogGet) then ResultCode := CommandLogGet(Request, Response)
     213        else if Command = Byte(toLogGetCount) then ResultCode := CommandLogGetCount(Request, Response)
    200214        else ResultCode := ResultCodeUnknownCommand;
    201215
     
    314328end;
    315329
     330function TVirtualTerminalBF630.CommandLogGet(Request: TListByte;
     331  Response: TListByte): Byte;
     332var
     333  UserId: Integer;
     334  RequestSerializer: TBinarySerializer;
     335  ResponseSerializer: TBinarySerializer;
     336  I: Integer;
     337  Day, Month, Year: Word;
     338  MSec, Sec, Min, Hour: Word;
     339  FunctionKey: Integer;
     340begin
     341  try
     342    RequestSerializer := TBinarySerializer.Create;
     343    RequestSerializer.List := Request;
     344    //UserId := RequestSerializer.ReadInteger;
     345
     346    ResponseSerializer := TBinarySerializer.Create;
     347    ResponseSerializer.List := Response;
     348    DecodeDateTime(TVirtualTerminalBF630Passage(Passages[0]).Time,
     349      Year, Month, Day, Hour, Min, Sec, MSec);
     350    with ResponseSerializer do begin
     351      WriteByte(Sec);
     352      WriteByte(Min);
     353      WriteByte(Hour);
     354      WriteByte(Day);
     355      WriteByte(Month);
     356      WriteByte(Year mod 100);
     357      WriteByte(0);
     358      WriteByte(0);
     359      WriteByte(0);
     360      WriteByte(TVirtualTerminalBF630Passage(Passages[0]).Key);
     361      WriteInteger(TVirtualTerminalBF630Passage(Passages[0]).User);
     362      WriteByte(0);
     363      WriteByte(0);
     364    end;
     365  finally
     366    RequestSerializer.Free;
     367    ResponseSerializer.Free;
     368  end;
     369end;
     370
     371function TVirtualTerminalBF630.CommandLogGetCount(Request: TListByte;
     372  Response: TListByte): Byte;
     373var
     374  ResponseSerializer: TBinarySerializer;
     375begin
     376  try
     377    ResponseSerializer := TBinarySerializer.Create;
     378    ResponseSerializer.List := Response;
     379    ResponseSerializer.WriteInteger(Passages.Count);
     380    Result := ResultCodeSuccess;
     381  finally
     382    ResponseSerializer.Free;
     383  end;
     384end;
     385
    316386procedure TVirtualTerminalBF630.SetActive(AValue: Boolean);
    317387begin
     
    356426    SecondName := 'Second ' + IntToStr(Id);
    357427  end;
     428  with TVirtualTerminalBF630Passage(Passages.AddNew(TVirtualTerminalBF630Passage.Create)) do begin
     429    Id := Passages.Count;
     430    Time := Now;
     431    User := 1;
     432    Key := 2;
     433  end;
    358434end;
    359435
     
    362438  Sessions := TListObject.Create;
    363439  Users := TListObject.Create;
     440  Passages := TListObject.Create;
    364441  CommSocket := TCommTCPServer.Create(nil);
    365442  CommSocket.Address := 'localhost';
     
    374451  FreeAndNil(CommSocket);
    375452  FreeAndNil(Users);
     453  FreeAndNil(Passages);
    376454  FreeAndNil(Sessions);
    377455  inherited Destroy;
     
    550628end;
    551629
    552 function TTerminalBF630.GetUser(Id: Integer; User: TUser): Boolean;
     630function TTerminalBF630.GetUser(Index: Integer; User: TUser): Boolean;
    553631var
    554632  Request: TListByte;
     
    564642    RequestSerializer := TBinarySerializer.Create;
    565643    RequestSerializer.List := Request;
    566     RequestSerializer.WriteInteger(Id);
     644    RequestSerializer.WriteInteger(Index);
    567645    SendPacket(toUserDataGet, Request, Response);
    568646    if Response[0] <> Id then raise Exception.Create(SWrongId);
     
    581659
    582660  finally
     661    Request.Free;
     662    RequestSerializer.Free;
     663    Response.Free;
     664  end;
     665end;
     666
     667function TTerminalBF630.GetPassageCount: Integer;
     668var
     669  Response: TListByte;
     670  ResponseSerializer: TBinarySerializer;
     671begin
     672  try
     673    Response := TListByte.Create;
     674    ResponseSerializer := TBinarySerializer.Create;
     675    ResponseSerializer.List := Response;
     676    SendPacket(toLogGetCount, nil, Response);
     677    Result := ResponseSerializer.ReadInteger;
     678  finally
     679    Response.Free;
     680  end;
     681end;
     682
     683function TTerminalBF630.GetPassage(Index: Integer; Passage: TUserPassage): Boolean;
     684var
     685  Request: TListByte;
     686  RequestSerializer: TBinarySerializer;
     687  Response: TListByte;
     688  ResponseSerializer: TBinarySerializer;
     689  I: Integer;
     690  Title: Integer;
     691  Department: Integer;
     692  Sec, Min, Hour: Byte;
     693  Day, Month, Year: Byte;
     694  FunctionKey: BYte;
     695  Verify: Byte;
     696  UserId: Integer;
     697  InOutIndication: Byte;
     698  VerificationSource: Byte;
     699begin
     700  try
     701    Response := TListByte.Create;
     702    ResponseSerializer := TBinarySerializer.Create;
     703    ResponseSerializer.List := Response;
     704    Request := TListByte.Create;
     705    RequestSerializer := TBinarySerializer.Create;
     706    RequestSerializer.List := Request;
     707    //RequestSerializer.WriteInteger(Id);
     708    SendPacket(toLogGet, Request, Response);
     709    with ResponseSerializer do begin
     710      Sec := ReadByte;
     711      Min := ReadByte;
     712      Hour := ReadByte;
     713      Day := ReadByte;
     714      Month := ReadByte;
     715      Year := ReadByte;
     716      InOutIndication := ReadByte;
     717      VerificationSource := ReadByte;
     718      Verify := ReadByte;
     719      FunctionKey := ReadByte;
     720      UserId := ReadInteger;
     721    end;
     722
     723    Passage.Terminal := Id;
     724    Passage.Time := EncodeDateTime(2000 + Year, Month, Day, Hour, Min, Sec, 0);
     725    Passage.Operation := FunctionKey;
     726    Passage.User := UserId;
     727  finally
     728    ResponseSerializer.Free;
    583729    Request.Free;
    584730    RequestSerializer.Free;
Note: See TracChangeset for help on using the changeset viewer.