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.