Changeset 54 for trunk/Client/USystem.pas
- Timestamp:
- Oct 12, 2012, 11:43:43 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Client/USystem.pas
r53 r54 12 12 const 13 13 SystemModuleObject = 'SystemModule'; 14 ObjectGroupTable = 'ObjectGroup'; 15 ObjectTable = 'Object'; 14 SystemMenuTable = 'SystemMenu'; 15 SystemActionTable = 'SystemAction'; 16 SystemObjectTable = 'Object'; 16 17 InformationTable = 'Information'; 17 18 PropertyTable = 'Property'; … … 92 93 TChronisModuleList = class(TListObject) // TListObject<TChronisModule> 93 94 Base: TChronisBase; 95 procedure RegisterModule(ModuleClass: TChronisModuleClass); 94 96 procedure UpdateList; 95 97 function IsInstalled: Boolean; … … 109 111 Modules: TChronisModuleList; 110 112 ModuleSystem: TChronisModule; 111 procedure RegisterModule(ModuleClass: TChronisModuleClass);112 113 function AddType(Name, DataType: string; TypeIndex: TDbValueType): Integer; 113 function AddGroup(Name: string; ParentGroupId: Integer = 0): Integer; 114 function AddObject(Name, TableName, Schema: string; GroupId: Integer): Integer; 114 function AddMenu(Name: string; ParentId: Integer = 0; ActionId: Integer = 0): Integer; 115 function AddAction(Name: string; TargetType: string; TargetId: Integer): Integer; 116 function AddObject(Name, TableName, Schema: string): Integer; 115 117 function AddProperty(ObjectId: Integer; Name, ColumnName: string; 116 118 CustomType: Integer; Editable: Boolean): Integer; … … 126 128 function AddPropertyString(ObjectId: Integer; Name, ColumnName: string; 127 129 Editable: Boolean; Default: string = ''; MaxLength: Integer = 255): Integer; 130 function AddPropertyBoolean(ObjectId: Integer; Name, ColumnName: string; 131 Editable: Boolean; Default: Boolean = False): Integer; 128 132 function AddPropertyText(ObjectId: Integer; Name, ColumnName: string; 129 133 Editable: Boolean; Default: string = ''): Integer; … … 132 136 function AddPropertyRelationMany(ObjectId: Integer; Name, ColumnName: string; 133 137 Editable: Boolean; ReferedObjectProperty: Integer): Integer; 134 function AddObjectGroup(Name: string): Integer;135 138 function AddEnumeration(Name: string): Integer; 136 139 function AddEnumerationState(Enum: Integer; Name: string): Integer; 137 function AddModule(Name, Author, Website, Version, Description, License: string): Integer;138 140 procedure LoadTypes; 139 function IsDatabaseEmpty: Boolean;140 141 constructor Create; 141 142 destructor Destroy; override; … … 264 265 end; 265 266 266 procedure TChronis Base.RegisterModule(ModuleClass: TChronisModuleClass);267 begin 268 Modules.AddNew(ModuleClass.Create);269 TChronisModule( Modules.Last).System := TChronisBase(Self);267 procedure TChronisModuleList.RegisterModule(ModuleClass: TChronisModuleClass); 268 begin 269 AddNew(ModuleClass.Create); 270 TChronisModule(Last).System := TChronisBase(Base); 270 271 end; 271 272 272 273 function TChronisBase.AddType(Name, DataType: string; TypeIndex: TDbValueType): Integer; 273 var 274 Proxy: TObjectProxy; 275 begin 276 try 277 Proxy := TObjectProxy.Create; 278 Proxy.Client := Client; 279 Proxy.ObjectName := PropertyTypeTable; 280 Proxy.Id := Integer(TypeIndex); 281 Proxy.Properties.Add('Name', Name); 282 Proxy.Properties.Add('DbType', DataType); 283 Proxy.Save; 284 Result := Proxy.Id; 285 finally 286 Proxy.Free; 287 end; 288 end; 289 290 function TChronisBase.AddGroup(Name: string; ParentGroupId: Integer): Integer; 291 var 292 Proxy: TObjectProxy; 293 begin 294 try 295 Proxy := TObjectProxy.Create; 296 Proxy.Client := Client; 297 Proxy.ObjectName := ObjectGroupTable; 298 Proxy.Properties.Add('Name', Name); 299 Proxy.Properties.Add('Parent', IntToStr(ParentGroupId)); 300 Proxy.Save; 301 Result := Proxy.Id; 302 finally 303 Proxy.Free; 304 end; 305 end; 306 307 function TChronisBase.AddObject(Name, TableName, Schema: string; 308 GroupId: Integer): Integer; 309 var 310 Proxy: TObjectProxy; 311 begin 312 try 313 Proxy := TObjectProxy.Create; 314 Proxy.Client := Client; 315 Proxy.ObjectName := ObjectTable; 274 begin 275 with TObjectProxy.Create do 276 try 277 Client := Self.Client; 278 ObjectName := PropertyTypeTable; 279 Id := Integer(TypeIndex); 280 with Properties do begin 281 Add('Name', Name); 282 Add('DbType', DataType); 283 end; 284 Save; 285 Result := Id; 286 finally 287 Free; 288 end; 289 end; 290 291 function TChronisBase.AddMenu(Name: string; ParentId: Integer = 0; ActionId: Integer = 0): Integer; 292 begin 293 with TObjectProxy.Create do 294 try 295 Client := Self.Client; 296 ObjectName := SystemMenuTable; 297 with Properties do begin 298 Add('Name', Name); 299 Add('Parent', IntToStr(ParentId)); 300 Add('Action', IntToStr(ActionId)); 301 end; 302 Save; 303 Result := Id; 304 finally 305 Free; 306 end; 307 end; 308 309 function TChronisBase.AddAction(Name: string; TargetType: string; 310 TargetId: Integer): Integer; 311 begin 312 313 end; 314 315 function TChronisBase.AddObject(Name, TableName, Schema: string): Integer; 316 var 317 Proxy: TObjectProxy; 318 begin 319 try 320 Proxy := TObjectProxy.Create; 321 Proxy.Client := Client; 322 Proxy.ObjectName := SystemObjectTable; 316 323 with Proxy.Properties do begin 317 324 Add('Name', Name); 318 325 Add('Schema', Schema); 319 326 Add('Table', TableName); 320 Add('Group', IntToStr(GroupId));321 327 Add('PrimaryKey', 'Id'); 322 328 end; … … 471 477 end; 472 478 479 function TChronisBase.AddPropertyBoolean(ObjectId: Integer; Name, 480 ColumnName: string; Editable: Boolean; Default: Boolean): Integer; 481 begin 482 483 end; 484 473 485 function TChronisBase.AddPropertyText(ObjectId: Integer; Name, 474 486 ColumnName: string; Editable: Boolean; Default: string): Integer; … … 556 568 end; 557 569 558 function TChronisBase.AddObjectGroup(Name: string): Integer;559 var560 Proxy: TObjectProxy;561 begin562 try563 Proxy := TObjectProxy.Create;564 Proxy.Client := Client;565 Proxy.ObjectName := ObjectGroupTable;566 Proxy.Properties.Add('Name', Name);567 Proxy.Save;568 Result := Proxy.Id;569 finally570 Proxy.Free;571 end;572 end;573 574 570 function TChronisBase.AddEnumeration(Name: string): Integer; 575 571 var … … 600 596 Proxy.Properties.Add('Name', Name); 601 597 Proxy.Properties.Add('Sequence', '0'); 602 Proxy.Save;603 Result := Proxy.Id;604 finally605 Proxy.Free;606 end;607 end;608 609 function TChronisBase.AddModule(Name, Author, Website, Version, Description,610 License: string): Integer;611 var612 Proxy: TObjectProxy;613 begin614 try615 Proxy := TObjectProxy.Create;616 Proxy.Client := Client;617 Proxy.ObjectName := ModuleTable;618 Proxy.Properties.Add('Name', Name);619 Proxy.Properties.Add('Author', Author);620 Proxy.Properties.Add('Website', Website);621 Proxy.Properties.Add('Version', Version);622 Proxy.Properties.Add('Description', Description);623 Proxy.Properties.Add('License', License);624 598 Proxy.Save; 625 599 Result := Proxy.Id; … … 653 627 end; 654 628 655 function TChronisBase.IsDatabaseEmpty: Boolean;656 var657 Proxy: TListProxy;658 begin659 try660 Proxy := TListProxy.Create;661 Proxy.Client := Client;662 Proxy.Path := 'information_schema';663 Proxy.ObjectName := 'tables';664 Proxy.Condition := 'table_name = "SystemModule" AND table_schema = "' +665 Client.Schema + '"';666 Proxy.Load;667 Result := Proxy.Objects.Count = 0;668 finally669 Proxy.Free;670 end;671 end;672 673 629 constructor TChronisBase.Create; 674 630 begin … … 723 679 List := TListProxy.Create; 724 680 List.Client := Core.System.Client; 725 List.ObjectName := ObjectTable;681 List.ObjectName := SystemObjectTable; 726 682 List.Path := Core.System.Client.Schema; 727 683 List.Condition := 'Id=' + IntToStr(ObjectId); … … 782 738 Add('License', License); 783 739 Add('Creator', Creator); 784 Add('HomePage', HomePage); 740 Add('Website', Website); 741 Add('Description', Description.Text); 785 742 end; 786 743 NewObject.Save; … … 813 770 Name := SystemModuleObject; 814 771 with Properties do begin 815 Add('SysName', 'String'); 816 Add('Name', 'String'); 817 Add('Version', 'String'); 818 Add('License', 'String'); 819 Add('Creator', 'String'); 820 Add('HomePage', 'String'); 821 Add('Installed', 'Boolean'); 772 AddSimple('SysName', 'String'); 773 AddSimple('Name', 'String'); 774 AddSimple('Version', 'String'); 775 AddSimple('License', 'String'); 776 AddSimple('Creator', 'String'); 777 AddSimple('Website', 'String'); 778 AddSimple('Installed', 'Boolean'); 779 AddSimple('Description', 'Text'); 822 780 end; 823 781 Define;
Note:
See TracChangeset
for help on using the changeset viewer.