Ignore:
Timestamp:
Sep 7, 2012, 8:36:13 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Modulární systém přepracován tak, aby podporoval metody Install, Uninstall a Upgrade použitelné pro persistentní data. Původní metody Install a Uninstall přejmenovýny na Start a Stop.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/User/UModuleUser.pas

    r90 r91  
    1616    constructor Create(Owner: TComponent); override;
    1717    destructor Destroy; override;
     18    procedure Start; override;
     19    procedure Stop; override;
    1820    procedure Install; override;
    1921    procedure Uninstall; override;
    20     procedure Update; override;
     22    procedure Upgrade; override;
    2123  end;
    2224
     25
    2326implementation
     27
     28uses
     29  UCore, UUserControlPage, USqlDatabase;
    2430
    2531{ TModuleUser }
     
    2834begin
    2935  inherited;
     36  Identification := 'User';
     37  Title := 'User management';
     38  Version := '0.1';
     39  License := 'GNU/LGPL v3';
     40  Author := 'Chronosoft';
    3041end;
    3142
     
    3546end;
    3647
    37 procedure TModuleUser.Install;
     48procedure TModuleUser.Start;
    3849begin
     50  Core.Pages.RegisterPage(TUserControlPage, UserControlPage, 'uzivatel');
     51  //RegisterPage(TUserControlPage, UserControlPage, '');
    3952  inherited;
    4053end;
    4154
    42 procedure TModuleUser.Uninstall;
     55procedure TModuleUser.Stop;
    4356begin
    4457  inherited;
     58  Core.Pages.UnregisterPage('uzivatel');
    4559end;
    4660
    47 procedure TModuleUser.Update;
     61procedure TModuleUser.Install;
     62var
     63  DbRows: TDbRows;
     64begin
     65  try
     66    DbRows := TDbRows.Create;
     67    Core.CommonDatabase.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `User` (' +
     68  '`Id` int(11) NOT NULL AUTO_INCREMENT,' +
     69  '`Name` varchar(255) NOT NULL,' +
     70  '`FullName` varchar(255) NOT NULL,' +
     71  '`Password` varchar(255) NOT NULL,' +
     72  '`Salt` varchar(255) NOT NULL,' +
     73  '`Email` varchar(255) NOT NULL,' +
     74  '`RegistrationTime` datetime NOT NULL,' +
     75  'PRIMARY KEY (`Id`)' +
     76  ') ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     77    Core.CommonDatabase.Query(DbRows, 'CREATE TABLE IF NOT EXISTS `UserOnline` (' +
     78  '`Id` int(11) NOT NULL AUTO_INCREMENT,' +
     79  '`User` int(11) NOT NULL DEFAULT ''0'',' +
     80  '`ActivityTime` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',' +
     81  '`LoginTime` datetime NOT NULL DEFAULT ''0000-00-00 00:00:00'',' +
     82  '`SessionId` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
     83  '`IpAddress` varchar(16) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
     84  '`HostName` varchar(255) COLLATE utf8_czech_ci NOT NULL DEFAULT '''',' +
     85  '`ScriptName` varchar(255) COLLATE utf8_czech_ci NOT NULL,' +
     86  'PRIMARY KEY (`Id`),' +
     87  'KEY `User` (`User`)' +
     88  ') ENGINE=MEMORY  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=2 ;');
     89  finally
     90    DbRows.Free;
     91  end;
     92  inherited Install;
     93end;
     94
     95procedure TModuleUser.Uninstall;
     96var
     97  DbRows: TDbRows;
     98begin
     99  inherited Uninstall;
     100  try
     101    DbRows := TDbRows.Create;
     102    Core.CommonDatabase.Query(DbRows, 'DROP TABLE `User`');
     103    Core.CommonDatabase.Query(DbRows, 'DROP TABLE `UserOnline`');
     104  finally
     105    DbRows.Free;
     106  end;
     107end;
     108
     109procedure TModuleUser.Upgrade;
    48110begin
    49111  inherited;
Note: See TracChangeset for help on using the changeset viewer.