source: branches/test1/Client/UCore.pas

Last change on this file was 54, checked in by chronos, 12 years ago
  • Added: ChronisAppServer base project.
  • Modified: Changes in client virtual database layer handling.
File size: 2.8 KB
Line 
1unit UCore;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, UCoolTranslator, UDebugLog, USystem, Registry,
9 USqlDatabase, UFormLoginProfile, URegistry, UPDClient;
10
11type
12
13 { TCore }
14
15 TCore = class(TDataModule)
16 CoolTranslator1: TCoolTranslator;
17 DebugLog1: TDebugLog;
18 procedure CoolTranslator1Translate(Sender: TObject);
19 procedure DataModuleCreate(Sender: TObject);
20 procedure DataModuleDestroy(Sender: TObject);
21 procedure SqlDatabase1LogQuery(Sender: TObject; Text: string);
22 private
23 procedure LoadFromRegistry;
24 procedure SaveToRegistry;
25 { private declarations }
26 public
27 LastUserName: string;
28 LastProfile: Integer;
29 LastPassword: string;
30 RememberPassword: Boolean;
31 Profiles: TProfileList;
32 RegistryKey: string;
33 RegistryRootKey: HKEY;
34 System: TChronisBase;
35 end;
36
37var
38 Core: TCore;
39
40
41implementation
42
43uses
44 UModuleSystem, UModuleUser, UApplicationInfo;
45
46{$R *.lfm}
47
48{ TCore }
49
50procedure TCore.DataModuleCreate(Sender: TObject);
51begin
52 Profiles := TProfileList.Create;
53 RegistryRootKey := HKEY_CURRENT_USER;
54 RegistryKey := '\Software\' + ApplicationInfo.CompanyName + '\' +
55 ApplicationInfo.Name;
56 LoadFromRegistry;
57 System := TChronisBase.Create;
58 //TChronisClientMySQL(System.Client).Database := SqlDatabase1;
59 System.Modules.RegisterModule(TModuleSystem);
60 System.ModuleSystem := TModuleSystem(System.Modules.Last);
61 System.Modules.RegisterModule(TModuleUser);
62
63 {$IFDEF DEBUG}
64 DebugLog1.WriteToFileEnable := True;
65 {$ENDIF}
66end;
67
68procedure TCore.CoolTranslator1Translate(Sender: TObject);
69begin
70 UFormLoginProfile.UpdateTranslation;
71end;
72
73procedure TCore.DataModuleDestroy(Sender: TObject);
74begin
75 SaveToRegistry;
76 FreeAndNil(System);
77 FreeAndNil(Profiles);
78end;
79
80procedure TCore.SqlDatabase1LogQuery(Sender: TObject; Text: string);
81begin
82 DebugLog1.Add('', Text);
83end;
84
85procedure TCore.LoadFromRegistry;
86begin
87 with TRegistryEx.Create do
88 try
89 RootKey := RegistryRootKey;
90 OpenKey(RegistryKey, True);
91 LastProfile := ReadIntegerWithDefault('LastConnectProfile', -1);
92 LastUserName := ReadStringWithDefault('LastUserName', 'admin');
93 LastPassword := ReadStringWithDefault('LastPassword', '');
94 RememberPassword := ReadBoolWithDefault('RememberPassword', False);
95 finally
96 Free;
97 end;
98end;
99
100procedure TCore.SaveToRegistry;
101begin
102 with TRegistryEx.Create do
103 try
104 RootKey := RegistryRootKey;
105 OpenKey(RegistryKey, True);
106 WriteInteger('LastConnectProfile', LastProfile);
107 WriteString('LastUserName', LastUserName);
108 if RememberPassword then WriteString('LastPassword', LastPassword)
109 else WriteString('LastPassword', '');
110 WriteBool('RememberPassword', RememberPassword);
111 finally
112 Free;
113 end;
114end;
115
116
117end.
118
Note: See TracBrowser for help on using the repository browser.