Changeset 51 for trunk/Client/USystem.pas
- Timestamp:
- Apr 2, 2012, 3:59:58 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Client/USystem.pas
r46 r51 11 11 12 12 const 13 SystemModuleObject = 'SystemModule'; 13 14 ObjectGroupTable = 'ObjectGroup'; 14 15 ObjectTable = 'Object'; … … 36 37 vtTime, vtDate, vtColor, vtHyperlink, vtRelationOne, vtRelationMany, vtPassword); 37 38 38 TChronisType = class;39 39 TChronisObject = class; 40 40 TChronisBase = class; … … 88 88 end; 89 89 90 TChronisType = class 91 private 92 ParentId: Integer; 93 public 94 Id: Integer; 95 DbType: string; 96 TypeIndex: Integer; 97 end; 98 99 { TChronisTypeList } 100 101 TChronisTypeList = class(TListObject) 102 function FindById(Id: Integer): TChronisType; 103 function FindByTypeIndex(Id: Integer): TChronisType; 90 { TChronisModuleList } 91 92 TChronisModuleList = class(TListObject) // TListObject<TChronisModule> 93 Base: TChronisBase; 94 procedure UpdateList; 95 procedure Install; 96 procedure Uninstall; 104 97 end; 105 98 … … 113 106 Types: TChronisTypeList; 114 107 Client: TChronisClient; 115 Modules: T ListObject; // TListObject<TChronisModule>108 Modules: TChronisModuleList; 116 109 ModuleSystem: TChronisModule; 117 110 procedure RegisterModule(ModuleClass: TChronisModuleClass); … … 168 161 end; 169 162 170 { TChronisTypeList }171 172 function TChronisTypeList.FindById(Id: Integer): TChronisType;173 var174 I: Integer;175 begin176 I := 0;177 while (I < Count) and (TChronisType(Items[I]).Id <> Id) do Inc(I);178 if I < Count then Result := TChronisType(Items[I])179 else Result := nil;180 end;181 182 function TChronisTypeList.FindByTypeIndex(Id: Integer): TChronisType;183 var184 I: Integer;185 begin186 I := 0;187 while (I < Count) and (TChronisType(Items[I]).TypeIndex <> Id) do Inc(I);188 if I < Count then Result := TChronisType(Items[I])189 else Result := nil;190 end;191 192 163 { TReportLine } 193 164 … … 277 248 Client.Connect; 278 249 if Client.Connected then begin 279 if IsDatabaseEmptythen ModuleSystem.Install;250 if not ModuleSystem.IsInstalled then ModuleSystem.Install; 280 251 LoadTypes; 281 252 end else FActive := False; … … 697 668 begin 698 669 Types := TChronisTypeList.Create; 699 Modules := TListObject.Create; 670 Modules := TChronisModuleList.Create; 671 Modules.Base := Self; 700 672 end; 701 673 … … 775 747 end; 776 748 749 { TChronisModuleList } 750 751 procedure TChronisModuleList.UpdateList; 752 var 753 I: Integer; 754 NewObject: TObjectProxy; 755 List: TListProxy; 756 begin 757 List := TListProxy.Create; 758 List.Client := Base.Client; 759 List.SchemaName := Base.Client.Schema; 760 NewObject := TObjectProxy.Create; 761 NewObject.Client := Base.Client; 762 for I := 0 to Count - 1 do 763 with TChronisModule(Items[I]) do begin 764 List.Condition := 'SysName="' + SysName + '"'; 765 List.Load; 766 if List.Objects.Count > 0 then 767 NewObject.Id := StrToInt(TObjectProxy(List.Objects[0]).Properties.Values['Id']) 768 else NewObject.Id := 0; 769 NewObject.SchemaName := Base.Client.Schema; 770 NewObject.ObjectName := SystemModuleObject; 771 NewObject.Properties.Add('SysName', SysName); 772 NewObject.Properties.Add('Name', Name); 773 NewObject.Properties.Add('Version', Version); 774 NewObject.Properties.Add('License', License); 775 NewObject.Properties.Add('Creator', Creator); 776 NewObject.Properties.Add('HomePage', HomePage); 777 NewObject.Save; 778 end; 779 NewObject.Free; 780 List.Free; 781 end; 782 783 procedure TChronisModuleList.Install; 784 var 785 NewType: TChronisType; 786 begin 787 NewType := TChronisType.Create; 788 NewType.Client := Base.Client; 789 NewType.Name := SystemModuleObject; 790 NewType.Properties.Add('SysName', 'String'); 791 NewType.Properties.Add('Name', 'String'); 792 NewType.Properties.Add('Version', 'String'); 793 NewType.Properties.Add('License', 'String'); 794 NewType.Properties.Add('Creator', 'String'); 795 NewType.Properties.Add('HomePage', 'String'); 796 NewType.Properties.Add('Installed', 'Boolean'); 797 NewType.Define; 798 end; 799 800 procedure TChronisModuleList.Uninstall; 801 var 802 NewType: TChronisType; 803 begin 804 NewType := TChronisType.Create; 805 NewType.Client := Base.Client; 806 NewType.Name := SystemModuleObject; 807 NewType.Undefine; 808 end; 809 810 777 811 end. 778 812
Note:
See TracChangeset
for help on using the changeset viewer.