| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- unit UAppCentreConfig;
- interface
- uses
- mybean.core.objects, InterfaceAppCentre, Classes, SysUtils, TypInfo;
- type
- TAppCentreConfig = class(TMyBeanInterfacedObject, IAppCentreConfig)
- private
- FLxtAppKey,
- FLxtAppSecret,
- FLxtAppID: string;
- FIP: string;
- FPort: Integer;
- FClientIP: string;
- FClientPort: Integer;
- FEnable: Boolean;
- FShowType: TAppCentreShowType;
- FProjectType: TAppCentreProjectType;
- FBSLoginout: Boolean;
- FMessageCentreIP: string;
- FMessageCentrePort: Integer;
- FMessageCentreEnable: Boolean;
- FDanDianDengLu: Boolean;
- public
- constructor Create; override;
- function GetClientIP: WideString; stdcall;
- function GetClientPort: Integer; stdcall;
- function GetEnable: Boolean; stdcall;
- function GetIP: WideString; stdcall;
- function GetLxtAppID: WideString; stdcall;
- function GetLxtAppKey: WideString; stdcall;
- function GetLxtAppSecret: WideString; stdcall;
- function GetPort: Integer; stdcall;
- function GetShowType: TAppCentreShowType; stdcall;
- function GetProjectType: TAppCentreProjectType; stdcall;
- function GetBSLoginout: Boolean; stdcall;
- function GetMessageCentreIP: WideString; stdcall;
- function GetMessageCentrePort: Integer; stdcall;
- function GetMessageCentreEnable: Boolean; stdcall;
- function GetDanDianDengLu: Boolean; stdcall;
- procedure Load; stdcall;
- property LxtAppKey: WideString read GetLxtAppKey;
- property LxtAppSecret: WideString read GetLxtAppSecret;
- property LxtAppID: WideString read GetLxtAppID;
- property IP: WideString read GetIP;
- property Port: Integer read GetPort;
- property ClientIP: WideString read GetClientIP;
- property ClientPort: Integer read GetClientPort;
- property BSLoginout: Boolean read GetBSLoginout;
- property Enable: Boolean read GetEnable;
- property MessageCentreIP: WideString read GetMessageCentreIP;
- property MessageCentrePort: Integer read GetMessageCentrePort;
- property MessageCentreEnable: Boolean read GetMessageCentreEnable;
- property DanDianDengLu: Boolean read GetDanDianDengLu;
- end;
- implementation
- uses
- superobject, LoggerImport;
- const
- APPCENTRE_CONFIG: string = 'Config\appCentre.config';
- { TAppCentreConfig }
- constructor TAppCentreConfig.Create;
- begin
- inherited;
- Load;
- end;
- function TAppCentreConfig.GetBSLoginout: Boolean;
- begin
- Result := FBSLoginout;
- end;
- function TAppCentreConfig.GetClientIP: WideString;
- begin
- Result := FClientIP;
- end;
- function TAppCentreConfig.GetClientPort: Integer;
- begin
- Result := FClientPort;
- end;
- function TAppCentreConfig.GetDanDianDengLu: Boolean;
- begin
- Result := FDanDianDengLu;
- end;
- function TAppCentreConfig.GetEnable: Boolean;
- begin
- Result := FEnable;
- end;
- function TAppCentreConfig.GetIP: WideString;
- begin
- Result := FIP;
- end;
- function TAppCentreConfig.GetLxtAppID: WideString;
- begin
- Result := FLxtAppID;
- end;
- function TAppCentreConfig.GetLxtAppKey: WideString;
- begin
- Result := FLxtAppKey;
- end;
- function TAppCentreConfig.GetLxtAppSecret: WideString;
- begin
- Result := FLxtAppSecret;
- end;
- function TAppCentreConfig.GetMessageCentreEnable: Boolean;
- begin
- Result := FMessageCentreEnable;
- end;
- function TAppCentreConfig.GetMessageCentreIP: WideString;
- begin
- Result := FMessageCentreIP;
- end;
- function TAppCentreConfig.GetMessageCentrePort: Integer;
- begin
- Result := FMessageCentrePort;
- end;
- function TAppCentreConfig.GetPort: Integer;
- begin
- Result := FPort;
- end;
- function TAppCentreConfig.GetProjectType: TAppCentreProjectType;
- begin
- Result := FProjectType;
- end;
- function TAppCentreConfig.GetShowType: TAppCentreShowType;
- begin
- Result := FShowType;
- end;
- procedure TAppCentreConfig.Load;
- var
- AFullFileName: string;
- jo, AServer: ISuperObject;
- AGroupServerAddresses: TSuperArray;
- iLoop: Integer;
- begin
- AFullFileName := ExtractFilePath(ParamStr(0)) + APPCENTRE_CONFIG;
- if not FileExists(AFullFileName) then
- Exit;
- try
- jo := TSuperObject.ParseFile(AFullFileName, False);
- if jo.O['lxtAppSecret'] <> nil then
- FLxtAppSecret := jo['lxtAppSecret'].AsString;
- if jo.O['ip'] <> nil then
- FIP := jo['ip'].AsString;
- if jo.O['port'] <> nil then
- FPort := jo['port'].AsInteger;
- if jo.O['clientIP'] <> nil then
- FClientIP := jo['clientIP'].AsString;
- if jo.O['clientPort'] <> nil then
- FClientPort := jo['clientPort'].AsInteger;
- if jo.O['lxtAppKey'] <> nil then
- FLxtAppKey := jo['lxtAppKey'].AsString;
- if jo.O['enable'] <> nil then
- FEnable := jo['enable'].AsBoolean;
- if jo.S['showType'] <> '' then
- FShowType := TAppCentreShowType(GetEnumValue(TypeInfo(TAppCentreShowType), jo.S['showType']))
- else
- FShowType := stForm;
- if jo.S['projectType'] <> '' then
- FProjectType := TAppCentreProjectType(GetEnumValue(TypeInfo(TAppCentreProjectType), jo.S['projectType']))
- else
- FProjectType := ptNormal;
- FMessageCentreIP := jo.S['messageCentreIP'];
- FMessageCentrePort := jo.I['messageCentrePort'];
- FMessageCentreEnable := jo.B['messageCentreEnable'];
- FDanDianDengLu := jo.B['DanDianDengLu'];
- except
- on E: Exception do
- begin
- LoggerImport.Error(E.Message, 'TAppCentreConfig.Load');
- end;
- end;
- end;
- end.
|