Changeset 33


Ignore:
Timestamp:
Nov 24, 2011, 1:45:12 PM (12 years ago)
Author:
chronos
Message:
  • Modified: ChronisClient now use concept of object proxies. Methods of TObjectProxy and TListProxy is directed through TChronisClient and descendands implementing different protocols and access methods.
Location:
trunk
Files:
1 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/UChronisClient.pas

    r28 r33  
    1313  TOrderDirection = (odNone, odAscending, odDescending);
    1414
    15   { TQuery }
     15  { TObjectProxy }
    1616
    17   TQuery = class
     17  TObjectProxy = class
     18    Id: Integer;
     19    Properties: TDictionaryStringString;
     20    Client: TChronisClient;
     21    procedure Load;
     22    procedure Save;
     23    procedure Delete;
     24    procedure Add;
     25    constructor Create;
     26    destructor Destroy; override;
     27  end;
     28
     29  { TListProxy }
     30
     31  TListProxy = class
    1832    Client: TChronisClient;
    1933    OrderColumn: string;
     
    2539    ColumnsFilter: TListString;
    2640    ColummsFilterUse: Boolean;
     41    ConditionColumn: string;
     42    ConditionValue: string;
     43    ConditionUse: Boolean;
     44    ObjectName: string;
     45    Objects: TListObject; // TListObject<TObjectProxy>
     46    procedure Clear;
    2747    constructor Create;
    2848    destructor Destroy; override;
    29     procedure Execute; virtual;
    30   end;
    31 
    32   TItemList = class(TListObject) // TListObject<TDictionaryStringString>
    33 
     49    procedure Load; virtual;
     50    procedure Save; virtual;
    3451  end;
    3552
     
    3754
    3855  TChronisClient = class
    39     //procedure GetItemList(Model: string; Condition: TCondition; ItemList: TItemList); virtual; abstract;
    40     //procedure SetItemList(Model: string; Condition: TCondition; ItemList: TItemList); virtual; abstract;
     56    Host: string;
     57    Port: Word;
     58    Schema: string;
     59    User: string;
     60    Password: string;
     61    procedure ObjectLoad(AObject: TObjectProxy); virtual; abstract;
     62    procedure ObjectSave(AObject: TObjectProxy); virtual; abstract;
     63    procedure ObjectAdd(AObject: TObjectProxy); virtual; abstract;
     64    procedure ObjectDelete(AObject: TObjectProxy); virtual; abstract;
     65    procedure ListLoad(AList: TListProxy); virtual; abstract;
     66    procedure ListSave(AList: TListProxy); virtual; abstract;
    4167    constructor Create; virtual;
    4268  end;
     
    4470implementation
    4571
    46 { TQuery }
     72{ TObjectProxy }
    4773
    48 constructor TQuery.Create;
     74procedure TObjectProxy.Load;
    4975begin
    50 
     76  Client.ObjectLoad(Self);
    5177end;
    5278
    53 destructor TQuery.Destroy;
     79procedure TObjectProxy.Save;
    5480begin
     81  Client.ObjectSave(Self);
     82end;
     83
     84procedure TObjectProxy.Delete;
     85begin
     86  Client.ObjectDelete(Self);
     87end;
     88
     89procedure TObjectProxy.Add;
     90begin
     91  Client.ObjectAdd(Self);
     92end;
     93
     94constructor TObjectProxy.Create;
     95begin
     96  Properties := TDictionaryStringString.Create;
     97end;
     98
     99destructor TObjectProxy.Destroy;
     100begin
     101  Properties.Free;
    55102  inherited Destroy;
    56103end;
    57104
    58 procedure TQuery.Execute;
     105{ TListProxy }
     106
     107procedure TListProxy.Clear;
    59108begin
     109  ConditionUse := False;
     110  PageUse := False;
     111  ColummsFilterUse := False;
     112  OrderUse := False;
     113  Objects.Free;
     114end;
    60115
     116constructor TListProxy.Create;
     117begin
     118  ColumnsFilter := TListString.Create;
     119  Objects := TListObject.Create;
     120end;
     121
     122destructor TListProxy.Destroy;
     123begin
     124  Objects.Free;
     125  ColumnsFilter.Free;
     126  inherited Destroy;
     127end;
     128
     129procedure TListProxy.Load;
     130begin
     131  Client.ListLoad(Self);
     132end;
     133
     134procedure TListProxy.Save;
     135begin
     136  Client.ListSave(Self);
    61137end;
    62138
  • trunk/UCore.pas

    r29 r33  
    4343
    4444uses
    45   UApplicationInfo, UChronisClientDirect;
     45  UApplicationInfo, UChronisClientDirect, UChronisClientMySQL;
    4646
    4747{ TCore }
     
    5656  System := TChronisBase.Create;
    5757  System.Database := SqlDatabase1;
    58   System.Client := TChronisClientDirect.Create;
     58  System.Client := TChronisClientMySQL.Create;
     59  TChronisClientMySQL(System.Client).Database := SqlDatabase1;
    5960  System.RegisterModule(TModuleSystem);
    6061  System.ModuleSystem := TModuleSystem(System.Modules.Last);
  • trunk/USystem.pas

    r31 r33  
    6060  TReport = class(TListObject)
    6161    Base: TChronisBase;
    62     Columns: TListObject;
     62    Columns: TListObject; // TListObject<TReportColumn>
    6363    constructor Create;
    6464    destructor Destroy; override;
     
    7171  end;
    7272
    73   { TChronisObject }
     73  { TObjectProxy }
    7474
    7575  TChronisObject = class
  • trunk/chronis.lpi

    r32 r33  
    105105      </Item6>
    106106    </RequiredPackages>
    107     <Units Count="58">
     107    <Units Count="59">
    108108      <Unit0>
    109109        <Filename Value="chronis.lpr"/>
     
    153153        <IsPartOfProject Value="True"/>
    154154        <UnitName Value="UPersistentForm"/>
    155         <EditorIndex Value="6"/>
    156155        <WindowIndex Value="0"/>
    157156        <TopLine Value="21"/>
    158157        <CursorPos X="63" Y="37"/>
    159158        <UsageCount Value="264"/>
    160         <Loaded Value="True"/>
    161159        <DefaultSyntaxHighlighter Value="Delphi"/>
    162160      </Unit4>
     
    217215        <ResourceBaseClass Value="Form"/>
    218216        <UnitName Value="ULoginForm"/>
    219         <EditorIndex Value="11"/>
    220217        <WindowIndex Value="0"/>
    221218        <TopLine Value="43"/>
    222219        <CursorPos X="24" Y="64"/>
    223220        <UsageCount Value="317"/>
    224         <Loaded Value="True"/>
    225         <LoadedDesigner Value="True"/>
    226221        <DefaultSyntaxHighlighter Value="Delphi"/>
    227222      </Unit9>
     
    260255        <EditorIndex Value="3"/>
    261256        <WindowIndex Value="0"/>
    262         <TopLine Value="14"/>
     257        <TopLine Value="34"/>
    263258        <CursorPos X="29" Y="31"/>
    264259        <UsageCount Value="313"/>
     
    271266        <IsPartOfProject Value="True"/>
    272267        <UnitName Value="USystem"/>
    273         <EditorIndex Value="14"/>
    274         <WindowIndex Value="0"/>
    275         <TopLine Value="70"/>
    276         <CursorPos X="9" Y="91"/>
     268        <IsVisibleTab Value="True"/>
     269        <EditorIndex Value="8"/>
     270        <WindowIndex Value="0"/>
     271        <TopLine Value="190"/>
     272        <CursorPos X="1" Y="203"/>
    277273        <UsageCount Value="200"/>
    278274        <Loaded Value="True"/>
     
    285281        <ResourceBaseClass Value="DataModule"/>
    286282        <UnitName Value="UCore"/>
    287         <EditorIndex Value="13"/>
    288         <WindowIndex Value="0"/>
    289         <TopLine Value="42"/>
    290         <CursorPos X="60" Y="60"/>
     283        <EditorIndex Value="7"/>
     284        <WindowIndex Value="0"/>
     285        <TopLine Value="41"/>
     286        <CursorPos X="34" Y="58"/>
    291287        <UsageCount Value="230"/>
    292288        <Loaded Value="True"/>
     
    336332        <IsPartOfProject Value="True"/>
    337333        <UnitName Value="UDataTypes"/>
    338         <EditorIndex Value="16"/>
     334        <EditorIndex Value="9"/>
    339335        <WindowIndex Value="0"/>
    340336        <TopLine Value="5"/>
    341         <CursorPos X="15" Y="18"/>
     337        <CursorPos X="23" Y="20"/>
    342338        <UsageCount Value="204"/>
    343339        <Loaded Value="True"/>
     
    368364        <TopLine Value="149"/>
    369365        <CursorPos X="44" Y="164"/>
    370         <UsageCount Value="152"/>
     366        <UsageCount Value="158"/>
    371367        <DefaultSyntaxHighlighter Value="Delphi"/>
    372368      </Unit22>
     
    384380        <TopLine Value="2393"/>
    385381        <CursorPos X="1" Y="2406"/>
    386         <UsageCount Value="25"/>
     382        <UsageCount Value="24"/>
    387383      </Unit24>
    388384      <Unit25>
     
    434430        <TopLine Value="40"/>
    435431        <CursorPos X="29" Y="54"/>
    436         <UsageCount Value="101"/>
     432        <UsageCount Value="107"/>
    437433        <DefaultSyntaxHighlighter Value="Delphi"/>
    438434      </Unit30>
     
    447443      <Unit32>
    448444        <Filename Value="../../../Lazarus/0.9.31_2.5.1/lcl/include/customform.inc"/>
    449         <EditorIndex Value="15"/>
    450445        <WindowIndex Value="0"/>
    451446        <TopLine Value="2102"/>
    452447        <CursorPos X="18" Y="2113"/>
    453         <UsageCount Value="32"/>
    454         <Loaded Value="True"/>
     448        <UsageCount Value="35"/>
    455449      </Unit32>
    456450      <Unit33>
     
    475469        <EditorIndex Value="1"/>
    476470        <WindowIndex Value="0"/>
    477         <TopLine Value="140"/>
    478         <CursorPos X="1" Y="159"/>
    479         <UsageCount Value="20"/>
     471        <TopLine Value="9"/>
     472        <CursorPos X="18" Y="30"/>
     473        <UsageCount Value="23"/>
    480474        <Loaded Value="True"/>
    481475      </Unit35>
     
    489483        <TopLine Value="175"/>
    490484        <CursorPos X="3" Y="183"/>
    491         <UsageCount Value="51"/>
     485        <UsageCount Value="57"/>
    492486        <DefaultSyntaxHighlighter Value="Delphi"/>
    493487      </Unit36>
     
    531525        <TopLine Value="4"/>
    532526        <CursorPos X="33" Y="19"/>
    533         <UsageCount Value="45"/>
     527        <UsageCount Value="51"/>
    534528        <DefaultSyntaxHighlighter Value="Delphi"/>
    535529      </Unit41>
     
    568562        <IsPartOfProject Value="True"/>
    569563        <UnitName Value="UChronisClient"/>
    570         <EditorIndex Value="12"/>
    571         <WindowIndex Value="0"/>
    572         <TopLine Value="11"/>
    573         <CursorPos X="26" Y="40"/>
    574         <UsageCount Value="41"/>
     564        <EditorIndex Value="6"/>
     565        <WindowIndex Value="0"/>
     566        <TopLine Value="20"/>
     567        <CursorPos X="13" Y="31"/>
     568        <UsageCount Value="47"/>
    575569        <Loaded Value="True"/>
    576570        <DefaultSyntaxHighlighter Value="Delphi"/>
     
    580574        <IsPartOfProject Value="True"/>
    581575        <UnitName Value="UChronisServer"/>
    582         <EditorIndex Value="10"/>
    583576        <WindowIndex Value="0"/>
    584577        <TopLine Value="1"/>
    585578        <CursorPos X="1" Y="14"/>
    586         <UsageCount Value="41"/>
    587         <Loaded Value="True"/>
     579        <UsageCount Value="47"/>
    588580        <DefaultSyntaxHighlighter Value="Delphi"/>
    589581      </Unit47>
     
    592584        <IsPartOfProject Value="True"/>
    593585        <UnitName Value="UChronisClientDirect"/>
    594         <IsVisibleTab Value="True"/>
    595         <EditorIndex Value="9"/>
    596586        <WindowIndex Value="0"/>
    597587        <TopLine Value="8"/>
    598         <CursorPos X="53" Y="18"/>
    599         <UsageCount Value="40"/>
    600         <Loaded Value="True"/>
     588        <CursorPos X="35" Y="14"/>
     589        <UsageCount Value="46"/>
    601590        <DefaultSyntaxHighlighter Value="Delphi"/>
    602591      </Unit48>
     
    605594        <IsPartOfProject Value="True"/>
    606595        <UnitName Value="UChronisModule"/>
    607         <EditorIndex Value="17"/>
     596        <EditorIndex Value="10"/>
    608597        <WindowIndex Value="0"/>
    609598        <TopLine Value="1"/>
    610599        <CursorPos X="5" Y="15"/>
    611         <UsageCount Value="31"/>
     600        <UsageCount Value="37"/>
    612601        <Loaded Value="True"/>
    613602        <DefaultSyntaxHighlighter Value="Delphi"/>
     
    617606        <IsPartOfProject Value="True"/>
    618607        <UnitName Value="UModuleSystem"/>
    619         <EditorIndex Value="18"/>
     608        <EditorIndex Value="11"/>
    620609        <WindowIndex Value="0"/>
    621610        <TopLine Value="54"/>
    622611        <CursorPos X="42" Y="66"/>
    623         <UsageCount Value="31"/>
     612        <UsageCount Value="37"/>
    624613        <Loaded Value="True"/>
    625614        <DefaultSyntaxHighlighter Value="Delphi"/>
     
    638627        <TopLine Value="91"/>
    639628        <CursorPos X="1" Y="106"/>
    640         <UsageCount Value="13"/>
     629        <UsageCount Value="12"/>
    641630      </Unit52>
    642631      <Unit53>
     
    645634        <TopLine Value="240"/>
    646635        <CursorPos X="1" Y="253"/>
    647         <UsageCount Value="13"/>
     636        <UsageCount Value="12"/>
    648637      </Unit53>
    649638      <Unit54>
     
    655644        <EditorIndex Value="5"/>
    656645        <WindowIndex Value="0"/>
    657         <TopLine Value="62"/>
    658         <CursorPos X="56" Y="79"/>
    659         <UsageCount Value="23"/>
     646        <TopLine Value="27"/>
     647        <CursorPos X="20" Y="73"/>
     648        <UsageCount Value="30"/>
    660649        <Loaded Value="True"/>
    661650        <LoadedDesigner Value="True"/>
     
    668657        <TopLine Value="735"/>
    669658        <CursorPos X="17" Y="748"/>
    670         <UsageCount Value="10"/>
     659        <UsageCount Value="9"/>
    671660      </Unit55>
    672661      <Unit56>
     
    674663        <IsPartOfProject Value="True"/>
    675664        <UnitName Value="UChronisClientXMLRPC"/>
    676         <EditorIndex Value="7"/>
    677665        <WindowIndex Value="0"/>
    678666        <TopLine Value="1"/>
    679667        <CursorPos X="1" Y="1"/>
    680         <UsageCount Value="20"/>
    681         <Loaded Value="True"/>
     668        <UsageCount Value="27"/>
    682669        <DefaultSyntaxHighlighter Value="Delphi"/>
    683670      </Unit56>
    684671      <Unit57>
    685         <Filename Value="Application/Clients/UChronisMySQL.pas"/>
    686         <IsPartOfProject Value="True"/>
    687         <UnitName Value="UChronisMySQL"/>
    688         <EditorIndex Value="8"/>
     672        <Filename Value="Application/Clients/UChronisClientMySQL.pas"/>
     673        <IsPartOfProject Value="True"/>
     674        <UnitName Value="UChronisClientMySQL"/>
    689675        <WindowIndex Value="0"/>
    690676        <TopLine Value="1"/>
    691         <CursorPos X="1" Y="1"/>
    692         <UsageCount Value="20"/>
    693         <Loaded Value="True"/>
     677        <CursorPos X="31" Y="3"/>
     678        <UsageCount Value="27"/>
    694679        <DefaultSyntaxHighlighter Value="Delphi"/>
    695680      </Unit57>
     681      <Unit58>
     682        <Filename Value="Common/URemote.pas"/>
     683        <IsPartOfProject Value="True"/>
     684        <UnitName Value="URemote"/>
     685        <WindowIndex Value="0"/>
     686        <TopLine Value="63"/>
     687        <CursorPos X="3" Y="74"/>
     688        <UsageCount Value="23"/>
     689        <DefaultSyntaxHighlighter Value="Delphi"/>
     690      </Unit58>
    696691    </Units>
    697     <JumpHistory Count="30" HistoryIndex="29">
     692    <JumpHistory Count="13" HistoryIndex="11">
    698693      <Position1>
    699694        <Filename Value="USystem.pas"/>
    700         <Caret Line="226" Column="28" TopLine="212"/>
     695        <Caret Line="91" Column="9" TopLine="70"/>
    701696      </Position1>
    702697      <Position2>
    703698        <Filename Value="USystem.pas"/>
    704         <Caret Line="223" Column="1" TopLine="197"/>
     699        <Caret Line="40" Column="3" TopLine="29"/>
    705700      </Position2>
    706701      <Position3>
    707         <Filename Value="Forms/UItemView.pas"/>
    708         <Caret Line="143" Column="14" TopLine="131"/>
     702        <Filename Value="Application/UChronisClient.pas"/>
     703        <Caret Line="47" Column="21" TopLine="23"/>
    709704      </Position3>
    710705      <Position4>
    711         <Filename Value="Forms/UItemView.pas"/>
    712         <Caret Line="44" Column="10" TopLine="33"/>
     706        <Filename Value="Application/UChronisClient.pas"/>
     707        <Caret Line="24" Column="18" TopLine="15"/>
    713708      </Position4>
    714709      <Position5>
    715         <Filename Value="USystem.pas"/>
    716         <Caret Line="223" Column="1" TopLine="210"/>
     710        <Filename Value="Application/UChronisClient.pas"/>
     711        <Caret Line="49" Column="28" TopLine="38"/>
    717712      </Position5>
    718713      <Position6>
    719         <Filename Value="Forms/UItemView.pas"/>
    720         <Caret Line="113" Column="1" TopLine="100"/>
     714        <Filename Value="Application/UChronisClient.pas"/>
     715        <Caret Line="59" Column="44" TopLine="39"/>
    721716      </Position6>
    722717      <Position7>
    723         <Filename Value="Forms/UItemView.pas"/>
    724         <Caret Line="143" Column="1" TopLine="130"/>
     718        <Filename Value="Application/UChronisClient.pas"/>
     719        <Caret Line="55" Column="43" TopLine="39"/>
    725720      </Position7>
    726721      <Position8>
    727         <Filename Value="Forms/UItemView.pas"/>
    728         <Caret Line="44" Column="15" TopLine="31"/>
     722        <Filename Value="Application/UChronisClient.pas"/>
     723        <Caret Line="22" Column="17" TopLine="4"/>
    729724      </Position8>
    730725      <Position9>
    731         <Filename Value="USystem.pas"/>
    732         <Caret Line="223" Column="1" TopLine="210"/>
     726        <Filename Value="Application/UChronisClient.pas"/>
     727        <Caret Line="75" Column="18" TopLine="73"/>
    733728      </Position9>
    734729      <Position10>
    735         <Filename Value="Forms/UItemList.pas"/>
    736         <Caret Line="86" Column="33" TopLine="80"/>
     730        <Filename Value="Application/UChronisClient.pas"/>
     731        <Caret Line="44" Column="5" TopLine="23"/>
    737732      </Position10>
    738733      <Position11>
    739         <Filename Value="Forms/UItemView.pas"/>
    740         <Caret Line="42" Column="24" TopLine="29"/>
     734        <Filename Value="Application/UChronisClient.pas"/>
     735        <Caret Line="131" Column="15" TopLine="121"/>
    741736      </Position11>
    742737      <Position12>
    743         <Filename Value="USystem.pas"/>
    744         <Caret Line="84" Column="46" TopLine="62"/>
     738        <Filename Value="UCore.pas"/>
     739        <Caret Line="58" Column="39" TopLine="42"/>
    745740      </Position12>
    746741      <Position13>
    747         <Filename Value="USystem.pas"/>
    748         <Caret Line="91" Column="9" TopLine="70"/>
     742        <Filename Value="UCore.pas"/>
     743        <Caret Line="107" Column="1" TopLine="82"/>
    749744      </Position13>
    750       <Position14>
    751         <Filename Value="Forms/UItemList.pas"/>
    752         <Caret Line="129" Column="30" TopLine="124"/>
    753       </Position14>
    754       <Position15>
    755         <Filename Value="Forms/UItemView.pas"/>
    756         <Caret Line="42" Column="24" TopLine="29"/>
    757       </Position15>
    758       <Position16>
    759         <Filename Value="Forms/UItemEdit.pas"/>
    760         <Caret Line="54" Column="19" TopLine="35"/>
    761       </Position16>
    762       <Position17>
    763         <Filename Value="Forms/UItemAdd.pas"/>
    764         <Caret Line="31" Column="1" TopLine="17"/>
    765       </Position17>
    766       <Position18>
    767         <Filename Value="Forms/UItemAdd.pas"/>
    768         <Caret Line="120" Column="28" TopLine="107"/>
    769       </Position18>
    770       <Position19>
    771         <Filename Value="Forms/UItemEdit.pas"/>
    772         <Caret Line="203" Column="28" TopLine="191"/>
    773       </Position19>
    774       <Position20>
    775         <Filename Value="Forms/UItemEdit.pas"/>
    776         <Caret Line="135" Column="73" TopLine="122"/>
    777       </Position20>
    778       <Position21>
    779         <Filename Value="Forms/UItemEdit.pas"/>
    780         <Caret Line="220" Column="41" TopLine="207"/>
    781       </Position21>
    782       <Position22>
    783         <Filename Value="Forms/UItemEdit.pas"/>
    784         <Caret Line="276" Column="19" TopLine="263"/>
    785       </Position22>
    786       <Position23>
    787         <Filename Value="Forms/UItemView.pas"/>
    788         <Caret Line="112" Column="20" TopLine="104"/>
    789       </Position23>
    790       <Position24>
    791         <Filename Value="Forms/UItemList.pas"/>
    792         <Caret Line="119" Column="15" TopLine="112"/>
    793       </Position24>
    794       <Position25>
    795         <Filename Value="Forms/UItemList.pas"/>
    796         <Caret Line="181" Column="3" TopLine="162"/>
    797       </Position25>
    798       <Position26>
    799         <Filename Value="Forms/UItemList.pas"/>
    800         <Caret Line="110" Column="6" TopLine="108"/>
    801       </Position26>
    802       <Position27>
    803         <Filename Value="Forms/UMainForm.pas"/>
    804         <Caret Line="328" Column="74" TopLine="322"/>
    805       </Position27>
    806       <Position28>
    807         <Filename Value="Forms/UMainForm.pas"/>
    808         <Caret Line="329" Column="94" TopLine="316"/>
    809       </Position28>
    810       <Position29>
    811         <Filename Value="Forms/UItemView.pas"/>
    812         <Caret Line="117" Column="5" TopLine="104"/>
    813       </Position29>
    814       <Position30>
    815         <Filename Value="../../PascalClassLibrary/Network/CoolWeb/Persistence/USqlDatabase.pas"/>
    816         <Caret Line="159" Column="1" TopLine="140"/>
    817       </Position30>
    818745    </JumpHistory>
    819746  </ProjectOptions>
  • trunk/chronis.lpr

    r32 r33  
    1313  UImportStructureForm, UItemSelect, ULoginProfileForm, UAboutForm,
    1414  UChronisClient, UChronisServer, UChronisClientDirect, UChronisModule,
    15   UModuleSystem, UItemList, LDockTree, UChronisClientXMLRPC, UChronisMySQL
     15  UModuleSystem, UItemList, LDockTree, UChronisClientXMLRPC, UChronisClientMySQL,
     16  URemote
    1617  { you can add units after this };
    1718
Note: See TracChangeset for help on using the changeset viewer.