Ignore:
Timestamp:
Apr 2, 2012, 3:59:58 PM (13 years ago)
Author:
chronos
Message:
  • Added: Unfinished installable module management.
Location:
trunk/Client/Application
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Client/Application/Clients/UChronisClientMySQL.pas

    r46 r51  
    175175
    176176procedure TChronisClientMySQL.TypeUndefine(AType: TChronisType);
    177 begin
    178 
     177var
     178  DbRows: TDbRows;
     179  I: Integer;
     180  Query: string;
     181  RefType: TChronisType;
     182begin
     183  try
     184    DbRows := TDbRows.Create;
     185    Query := 'DROP TABLE IF EXISTS `' + AType.Name + '`';
     186    Database.Query(DbRows, Query);
     187  finally
     188    DbRows.Free;
     189  end;
    179190end;
    180191
  • trunk/Client/Application/UApplicationInfo.pas

    r49 r51  
    5050  Name := 'ChronIS';
    5151  Identification := 1;
    52   ReleaseDate := EncodeDate(2012, 3, 21);
     52  ReleaseDate := EncodeDate(2012, 4, 2);
    5353  MajorVersion := 0;
    5454  MinorVersion := 1;
  • trunk/Client/Application/UChronisModule.pas

    r29 r51  
    66
    77uses
    8   Classes, SysUtils;
     8  Classes, SysUtils, SpecializedList, UChronisClient;
    99
    1010type
     
    1414  TChronisModule = class
    1515    System: TObject; // TChronisSystem;
     16    SysName: string;
    1617    Name: string;
     18    Version: string;
     19    Creator: string;
     20    License: string;
     21    HomePage: string;
     22    Dependencies: TStringList;
     23    function IsInstalled: Boolean;
    1724    procedure Install; virtual;
    1825    procedure Uninstall; virtual;
    1926    constructor Create; virtual;
     27    destructor Destroy; override;
    2028  end;
    2129
    2230  TChronisModuleClass = class of TChronisModule;
     31
    2332
    2433implementation
     
    2736  USystem;
    2837
     38
    2939{ TChronisModule }
    3040
     41function TChronisModule.IsInstalled: Boolean;
     42var
     43  List: TListProxy;
     44begin
     45  List := TListProxy.Create;
     46  List.Client := TChronisBase(System).Client;
     47  List.SchemaName := TChronisBase(System).Client.Schema;
     48  List.ObjectName := SystemModuleObject;
     49  List.Condition := '(SysName="' + SysName + '") AND (Installed=1)';
     50  List.Load;
     51  Result := List.Objects.Count > 0;
     52  List.Free;
     53end;
     54
    3155procedure TChronisModule.Install;
     56var
     57  NewObject: TObjectProxy;
     58  List: TListProxy;
    3259begin
    33 
     60  List := TListProxy.Create;
     61  List.Client := TChronisBase(System).Client;
     62  List.SchemaName := TChronisBase(System).Client.Schema;
     63  List.ObjectName := SystemModuleObject;
     64  List.Condition := 'SysName="' + SysName + '"';
     65  List.Load;
     66  if List.Objects.Count > 0 then begin
     67    NewObject := TObjectProxy.Create;
     68    NewObject.Id := StrToInt(TObjectProxy(List.Objects[0]).Properties.Values['Id']);
     69    NewObject.Client := TChronisBase(System).Client;
     70    NewObject.SchemaName := TChronisBase(System).Client.Schema;
     71    NewObject.ObjectName := SystemModuleObject;
     72    NewObject.Properties.Add('Installed', '1');
     73    NewObject.Save;
     74    NewObject.Free;
     75  end;
     76  List.Free;
    3477end;
    3578
    3679procedure TChronisModule.Uninstall;
     80var
     81  NewObject: TObjectProxy;
     82  List: TListProxy;
    3783begin
    38 
     84  List := TListProxy.Create;
     85  List.Client := TChronisBase(System).Client;
     86  List.SchemaName := TChronisBase(System).Client.Schema;
     87  List.ObjectName := SystemModuleObject;
     88  List.Condition := 'SysName="' + SysName + '"';
     89  List.Load;
     90  if List.Objects.Count > 0 then begin
     91    NewObject := TObjectProxy.Create;
     92    NewObject.Id := StrToInt(TObjectProxy(List.Objects[0]).Properties.Values['Id']);
     93    NewObject.Client := TChronisBase(System).Client;
     94    NewObject.SchemaName := TChronisBase(System).Client.Schema;
     95    NewObject.ObjectName := SystemModuleObject;
     96    NewObject.Properties.Add('Installed', '0');
     97    NewObject.Save;
     98    NewObject.Free;
     99  end;
     100  List.Free;
    39101end;
    40102
    41103constructor TChronisModule.Create;
    42104begin
     105  Dependencies := TStringList.Create;
     106end;
    43107
     108destructor TChronisModule.Destroy;
     109begin
     110  Dependencies.Free;
     111  inherited Destroy;
    44112end;
    45113
Note: See TracChangeset for help on using the changeset viewer.