Changeset 44
- Timestamp:
- Mar 9, 2012, 3:02:00 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Application/Clients/UChronisClientMySQL.pas
r43 r44 16 16 procedure InitSystemTypes; override; 17 17 function GetConnected: Boolean; override; 18 procedure Init; override; 18 19 public 19 20 Database: TSqlDatabase; 20 21 procedure ObjectLoad(AObject: TObjectProxy); override; 21 22 procedure ObjectSave(AObject: TObjectProxy); override; 22 procedure ObjectAdd(AObject: TObjectProxy); override;23 23 procedure ObjectDelete(AObject: TObjectProxy); override; 24 24 procedure ListLoad(AList: TListProxy); override; … … 64 64 65 65 procedure TChronisClientMySQL.ObjectLoad(AObject: TObjectProxy); 66 begin 67 66 var 67 DbRows: TDbRows; 68 NewObject: TObjectProxy; 69 Table: string; 70 begin 71 try 72 DbRows := TDbRows.Create; 73 Table := '`' + AObject.ObjectName + '`'; 74 if AObject.SchemaName <> '' then Table := '`' + AObject.SchemaName + '`.' + Table; 75 Database.Query(DbRows, 'SELECT * FROM ' + Table + 76 ' WHERE `Id`=' + IntToStr(AObject.Id)); 77 AObject.Properties.Assign(TDictionaryStringString(DbRows[0])); 78 finally 79 DbRows.Free; 80 end; 68 81 end; 69 82 70 83 procedure TChronisClientMySQL.ObjectSave(AObject: TObjectProxy); 71 begin 72 inherited ObjectSave(AObject); 73 end; 74 75 procedure TChronisClientMySQL.ObjectAdd(AObject: TObjectProxy); 76 begin 77 inherited ObjectAdd(AObject); 84 var 85 DbRows: TDbRows; 86 NewObject: TObjectProxy; 87 Table: string; 88 begin 89 try 90 DbRows := TDbRows.Create; 91 Database.Replace(AObject.ObjectName, AObject.Properties, AObject.SchemaName); 92 if AObject.Id = 0 then AObject.Id := Database.LastInsertId; 93 finally 94 DbRows.Free; 95 end; 78 96 end; 79 97 80 98 procedure TChronisClientMySQL.ObjectDelete(AObject: TObjectProxy); 81 99 begin 82 inherited ObjectDelete(AObject); 100 Database.Delete(AObject.ObjectName, 'Id=' + IntToStr(AObject.Id), 101 AObject.SchemaName); 83 102 end; 84 103 … … 143 162 raise Exception.Create(Format(SMissingBaseType, [RefType.Name])); 144 163 145 Query := Query + '`' + Items[I].Key + '` ' + RefType.DbType + ' N OT NULL,';164 Query := Query + '`' + Items[I].Key + '` ' + RefType.DbType + ' NULL,'; 146 165 end; 147 166 Query := Query + 'PRIMARY KEY (`Id`)' + … … 177 196 end; 178 197 198 procedure TChronisClientMySQL.Init; 199 begin 200 inherited; 201 end; 202 179 203 constructor TChronisClientMySQL.Create; 180 204 begin … … 197 221 Database.Database := Schema; 198 222 Database.Connect; 223 Init; 199 224 end; 200 225 -
trunk/Application/Clients/UChronisClientXMLRPC.pas
r43 r44 9 9 10 10 type 11 12 { TChronisClientXMLRPC } 13 11 14 TChronisClientXMLRPC = class(TChronisClient) 12 15 end; … … 14 17 implementation 15 18 19 16 20 end. 17 21 -
trunk/Application/UChronisClient.pas
r43 r44 7 7 uses 8 8 Classes, SysUtils, SpecializedList, SpecializedDictionary; 9 10 const 11 SystemVersionObject = 'SystemVersion'; 9 12 10 13 type … … 26 29 procedure Save; 27 30 procedure Delete; 28 procedure Add;29 31 constructor Create; 30 32 destructor Destroy; override; … … 81 83 protected 82 84 procedure InitSystemTypes; virtual; 85 procedure Init; virtual; 83 86 function GetConnected: Boolean; virtual; 84 87 public … … 89 92 Password: string; 90 93 Types: TChronisTypeList; 94 Version: string; 91 95 procedure ObjectLoad(AObject: TObjectProxy); virtual; abstract; 92 96 procedure ObjectSave(AObject: TObjectProxy); virtual; abstract; 93 procedure ObjectAdd(AObject: TObjectProxy); virtual; abstract;94 97 procedure ObjectDelete(AObject: TObjectProxy); virtual; abstract; 95 98 procedure ListLoad(AList: TListProxy); virtual; abstract; … … 98 101 procedure TypeUndefine(AType: TChronisType); virtual; abstract; 99 102 procedure CheckTypes; 103 function TypeExists(Name: string): Boolean; virtual; abstract; 100 104 constructor Create; virtual; 101 105 destructor Destroy; override; 102 procedure Connect; virtual; abstract; 103 procedure Disconnect; virtual; abstract; 106 procedure Connect; virtual; 107 procedure Disconnect; virtual; 108 procedure Install; virtual; 109 procedure Uninstall; virtual; 110 procedure Update; virtual; 104 111 property Connected: Boolean read GetConnected; 105 112 end; … … 110 117 resourcestring 111 118 SClientNotSet = 'Client not set'; 119 SNotSupported = 'Not supported'; 120 SVersionMismatch = 'Version mismatch, client: %0:s, server: %1:s. Please upgrade database.'; 121 112 122 113 123 { TChronisTypeList } … … 174 184 end; 175 185 176 procedure TObjectProxy.Add;177 begin178 if Assigned(Client) then Client.ObjectAdd(Self)179 else raise EClientNotSet.Create(SClientNotSet);180 end;181 182 186 constructor TObjectProxy.Create; 183 187 begin … … 230 234 procedure TChronisClient.InitSystemTypes; 231 235 begin 236 end; 237 238 procedure TChronisClient.Init; 239 var 240 NewProxy: TListProxy; 241 NewType: TChronisType; 242 NewObject: TObjectProxy; 243 DbVersion: string; 244 begin 245 NewProxy := TListProxy.Create; 246 NewProxy.Client := Self; 247 NewProxy.SchemaName := 'information_schema'; 248 NewProxy.ObjectName := 'TABLES'; 249 NewProxy.Condition := '(TABLE_SCHEMA = "' + Schema + 250 '") AND (TABLE_NAME = "' + SystemVersionObject + '")'; 251 NewProxy.Load; 252 if NewProxy.Objects.Count > 0 then begin 253 DbVersion := TObjectProxy(NewProxy.Objects[0]).Properties.Values['Version']; 254 if Version <> DbVersion then 255 raise Exception.Create(Format(SVersionMismatch, [Version, DbVersion])); 256 end else begin 257 NewType := TChronisType.Create; 258 NewType.Client := Self; 259 NewType.Name := SystemVersionObject; 260 NewType.Properties.Add('Version', 'String'); 261 NewType.Properties.Add('Time', 'DateTime'); 262 NewType.Define; 263 264 NewObject := TObjectProxy.Create; 265 NewObject.Client := Self; 266 NewObject.SchemaName := Schema; 267 NewObject.ObjectName := SystemVersionObject; 268 NewObject.Properties.Add('Version', Version); 269 NewObject.Properties.Add('Time', 'NOW()'); 270 NewObject.Save; 271 272 Install; 273 end; 232 274 end; 233 275 … … 287 329 end; 288 330 331 procedure TChronisClient.Connect; 332 begin 333 raise Exception.Create(SNotSupported); 334 end; 335 336 procedure TChronisClient.Disconnect; 337 begin 338 raise Exception.Create(SNotSupported); 339 end; 340 341 procedure TChronisClient.Install; 342 begin 343 344 end; 345 346 procedure TChronisClient.Uninstall; 347 begin 348 349 end; 350 351 procedure TChronisClient.Update; 352 begin 353 354 end; 355 289 356 end. 290 357 -
trunk/Forms/UFormLoginProfile.pas
r43 r44 68 68 procedure SpinEditPortChange(Sender: TObject); 69 69 private 70 SelectedProfile: TConnectProfile; 70 71 ProfileList: TProfileList; 71 72 public 72 73 73 end; 74 74 … … 128 128 procedure TLoginProfileForm.ComboBoxProtocolChange(Sender: TObject); 129 129 begin 130 if ListBoxProfiles.ItemIndex <> - 1then131 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).Protocol :=130 if Assigned(SelectedProfile) then 131 SelectedProfile.Protocol := 132 132 TConnectProtocol(ComboBoxProtocol.Items.Objects[ComboBoxProtocol.ItemIndex]); 133 133 end; … … 135 135 procedure TLoginProfileForm.EditNameChange(Sender: TObject); 136 136 begin 137 if ListBoxProfiles.ItemIndex <> - 1then begin138 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).Name := EditName.Text;137 if Assigned(SelectedProfile) then begin 138 SelectedProfile.Name := EditName.Text; 139 139 ListBoxProfiles.Items[ListBoxProfiles.ItemIndex] := EditName.Text; 140 140 end; … … 143 143 procedure TLoginProfileForm.EditDatabaseChange(Sender: TObject); 144 144 begin 145 if ListBoxProfiles.ItemIndex <> - 1then146 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).Database := EditDatabase.Text;145 if Assigned(SelectedProfile) then 146 SelectedProfile.Database := EditDatabase.Text; 147 147 end; 148 148 149 149 procedure TLoginProfileForm.EditServerChange(Sender: TObject); 150 150 begin 151 if ListBoxProfiles.ItemIndex <> - 1then152 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).HostName := EditServer.Text;151 if Assigned(SelectedProfile) then 152 SelectedProfile.HostName := EditServer.Text; 153 153 end; 154 154 … … 202 202 if ListBoxProfiles.ItemIndex <> -1 then 203 203 with TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]) do begin 204 SelectedProfile := nil; 204 205 EditServer.Text := HostName; 205 206 EditDatabase.Text := Database; … … 207 208 SpinEditPort.Value := Port; 208 209 EditName.Text := Name; 210 SelectedProfile := TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]); 209 211 end; 210 212 end; … … 212 214 procedure TLoginProfileForm.SpinEditPortChange(Sender: TObject); 213 215 begin 214 if ListBoxProfiles.ItemIndex <> - 1then215 TConnectProfile(ProfileList[ListBoxProfiles.ItemIndex]).Port := SpinEditPort.Value;216 if Assigned(SelectedProfile) then 217 SelectedProfile.Port := SpinEditPort.Value; 216 218 end; 217 219 -
trunk/Forms/UFormMain.pas
r43 r44 307 307 Core.System.Types.Clear; 308 308 FreeAndNil(Core.Client); 309 UpdateInterface; 310 end; 309 Core.System.Client := Core.Client; 310 end; 311 UpdateInterface; 311 312 end; 312 313 -
trunk/Languages/chronis.cs.po
r43 r44 415 415 msgstr "Nenastaven klient" 416 416 417 #: uchronisclient.snotsupported 418 msgid "Not supported" 419 msgstr "" 420 421 #: uchronisclient.sversionmismatch 422 msgid "Version mismatch, client: %0:s, server: %1:s. Please upgrade database." 423 msgstr "" 424 417 425 #: uchronisclientmysql.smissingbasetype 418 426 msgid "Missing base typ for %s" -
trunk/Languages/chronis.po
r43 r44 393 393 msgstr "" 394 394 395 #: uchronisclient.snotsupported 396 msgid "Not supported" 397 msgstr "" 398 399 #: uchronisclient.sversionmismatch 400 msgid "Version mismatch, client: %0:s, server: %1:s. Please upgrade database." 401 msgstr "" 402 395 403 #: uchronisclientmysql.smissingbasetype 396 404 msgid "Missing base typ for %s" -
trunk/USystem.pas
r43 r44 316 316 Proxy.Client := Client; 317 317 Proxy.ObjectName := ObjectTable; 318 Proxy.Properties.Add('Name', Name); 319 Proxy.Properties.Add('Schema', Schema); 320 Proxy.Properties.Add('Table', TableName); 321 Proxy.Properties.Add('Group', IntToStr(GroupId)); 318 with Proxy.Properties do begin 319 Add('Name', Name); 320 Add('Schema', Schema); 321 Add('Table', TableName); 322 Add('Group', IntToStr(GroupId)); 323 Add('PrimaryKey', 'Id'); 324 end; 322 325 Proxy.Save; 323 326 Result := Proxy.Id; … … 360 363 Proxy.ObjectName := CustomTypeTableName; 361 364 Proxy.Properties.Add('Type', IntToStr(Integer(vtInteger))); 365 Proxy.Save; 362 366 CustomTypeId := Proxy.Id; 363 367 368 Proxy.Id := 0; 364 369 Proxy.ObjectName := TypeNumber; 365 370 Proxy.Properties.Clear; … … 389 394 Proxy.ObjectName := CustomTypeTableName; 390 395 Proxy.Properties.Add('Type', IntToStr(Integer(vtFloat))); 396 Proxy.Save; 391 397 CustomTypeId := Proxy.Id; 392 398 399 Proxy.Id := 0; 393 400 Proxy.ObjectName := TypeFloat; 394 401 Proxy.Properties.Clear; … … 421 428 CustomTypeId := Proxy.Id; 422 429 430 Proxy.Id := 0; 423 431 Proxy.ObjectName := TypeDateTime; 424 432 Proxy.Properties.Clear; … … 450 458 CustomTypeId := Proxy.Id; 451 459 460 Proxy.Id := 0; 452 461 Proxy.ObjectName := TypeString; 453 462 Proxy.Properties.Clear; … … 478 487 CustomTypeId := Proxy.Id; 479 488 489 Proxy.Id := 0; 480 490 Proxy.ObjectName := TypeString; 481 491 Proxy.Properties.Clear; … … 505 515 CustomTypeId := Proxy.Id; 506 516 517 Proxy.Id := 0; 507 518 Proxy.ObjectName := TypeRelationOne; 508 519 Proxy.Properties.Clear; … … 528 539 Proxy.Client := Client; 529 540 Proxy.ObjectName := CustomTypeTableName; 530 531 541 Proxy.Properties.Clear; 532 542 Proxy.Properties.Add('Type', IntToStr(Integer(vtRelationMany))); … … 534 544 CustomTypeId := Proxy.Id; 535 545 546 Proxy.Id := 0; 536 547 Proxy.ObjectName := TypeRelationMany; 537 548 Proxy.Properties.Clear; … … 590 601 Proxy.Properties.Add('Enumeration', IntToStr(Enum)); 591 602 Proxy.Properties.Add('Name', Name); 603 Proxy.Properties.Add('Sequence', '0'); 592 604 Proxy.Save; 593 605 Result := Proxy.Id; -
trunk/chronis.lpi
r43 r44 105 105 </Item6> 106 106 </RequiredPackages> 107 <Units Count="2 6">107 <Units Count="27"> 108 108 <Unit0> 109 109 <Filename Value="chronis.lpr"/> … … 263 263 <UnitName Value="URemote"/> 264 264 </Unit25> 265 <Unit26> 266 <Filename Value="Module/UModuleUser.pas"/> 267 <IsPartOfProject Value="True"/> 268 <UnitName Value="UModuleUser"/> 269 </Unit26> 265 270 </Units> 266 271 </ProjectOptions> -
trunk/chronis.lpr
r42 r44 15 15 UModuleSystem, 16 16 UFormItemList, LDockTree, UChronisClientXMLRPC, UChronisClientMySQL, 17 URemote 17 URemote, UModuleUser 18 18 { you can add units after this }; 19 19
Note:
See TracChangeset
for help on using the changeset viewer.