UAppCentreConfig.pas 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. unit UAppCentreConfig;
  2. interface
  3. uses
  4. mybean.core.objects, InterfaceAppCentre, Classes, SysUtils, TypInfo;
  5. type
  6. TAppCentreConfig = class(TMyBeanInterfacedObject, IAppCentreConfig)
  7. private
  8. FLxtAppKey,
  9. FLxtAppSecret,
  10. FLxtAppID: string;
  11. FIP: string;
  12. FPort: Integer;
  13. FClientIP: string;
  14. FClientPort: Integer;
  15. FEnable: Boolean;
  16. FShowType: TAppCentreShowType;
  17. FProjectType: TAppCentreProjectType;
  18. FBSLoginout: Boolean;
  19. FMessageCentreIP: string;
  20. FMessageCentrePort: Integer;
  21. FMessageCentreEnable: Boolean;
  22. FDanDianDengLu: Boolean;
  23. public
  24. constructor Create; override;
  25. function GetClientIP: WideString; stdcall;
  26. function GetClientPort: Integer; stdcall;
  27. function GetEnable: Boolean; stdcall;
  28. function GetIP: WideString; stdcall;
  29. function GetLxtAppID: WideString; stdcall;
  30. function GetLxtAppKey: WideString; stdcall;
  31. function GetLxtAppSecret: WideString; stdcall;
  32. function GetPort: Integer; stdcall;
  33. function GetShowType: TAppCentreShowType; stdcall;
  34. function GetProjectType: TAppCentreProjectType; stdcall;
  35. function GetBSLoginout: Boolean; stdcall;
  36. function GetMessageCentreIP: WideString; stdcall;
  37. function GetMessageCentrePort: Integer; stdcall;
  38. function GetMessageCentreEnable: Boolean; stdcall;
  39. function GetDanDianDengLu: Boolean; stdcall;
  40. procedure Load; stdcall;
  41. property LxtAppKey: WideString read GetLxtAppKey;
  42. property LxtAppSecret: WideString read GetLxtAppSecret;
  43. property LxtAppID: WideString read GetLxtAppID;
  44. property IP: WideString read GetIP;
  45. property Port: Integer read GetPort;
  46. property ClientIP: WideString read GetClientIP;
  47. property ClientPort: Integer read GetClientPort;
  48. property BSLoginout: Boolean read GetBSLoginout;
  49. property Enable: Boolean read GetEnable;
  50. property MessageCentreIP: WideString read GetMessageCentreIP;
  51. property MessageCentrePort: Integer read GetMessageCentrePort;
  52. property MessageCentreEnable: Boolean read GetMessageCentreEnable;
  53. property DanDianDengLu: Boolean read GetDanDianDengLu;
  54. end;
  55. implementation
  56. uses
  57. superobject, LoggerImport;
  58. const
  59. APPCENTRE_CONFIG: string = 'Config\appCentre.config';
  60. { TAppCentreConfig }
  61. constructor TAppCentreConfig.Create;
  62. begin
  63. inherited;
  64. Load;
  65. end;
  66. function TAppCentreConfig.GetBSLoginout: Boolean;
  67. begin
  68. Result := FBSLoginout;
  69. end;
  70. function TAppCentreConfig.GetClientIP: WideString;
  71. begin
  72. Result := FClientIP;
  73. end;
  74. function TAppCentreConfig.GetClientPort: Integer;
  75. begin
  76. Result := FClientPort;
  77. end;
  78. function TAppCentreConfig.GetDanDianDengLu: Boolean;
  79. begin
  80. Result := FDanDianDengLu;
  81. end;
  82. function TAppCentreConfig.GetEnable: Boolean;
  83. begin
  84. Result := FEnable;
  85. end;
  86. function TAppCentreConfig.GetIP: WideString;
  87. begin
  88. Result := FIP;
  89. end;
  90. function TAppCentreConfig.GetLxtAppID: WideString;
  91. begin
  92. Result := FLxtAppID;
  93. end;
  94. function TAppCentreConfig.GetLxtAppKey: WideString;
  95. begin
  96. Result := FLxtAppKey;
  97. end;
  98. function TAppCentreConfig.GetLxtAppSecret: WideString;
  99. begin
  100. Result := FLxtAppSecret;
  101. end;
  102. function TAppCentreConfig.GetMessageCentreEnable: Boolean;
  103. begin
  104. Result := FMessageCentreEnable;
  105. end;
  106. function TAppCentreConfig.GetMessageCentreIP: WideString;
  107. begin
  108. Result := FMessageCentreIP;
  109. end;
  110. function TAppCentreConfig.GetMessageCentrePort: Integer;
  111. begin
  112. Result := FMessageCentrePort;
  113. end;
  114. function TAppCentreConfig.GetPort: Integer;
  115. begin
  116. Result := FPort;
  117. end;
  118. function TAppCentreConfig.GetProjectType: TAppCentreProjectType;
  119. begin
  120. Result := FProjectType;
  121. end;
  122. function TAppCentreConfig.GetShowType: TAppCentreShowType;
  123. begin
  124. Result := FShowType;
  125. end;
  126. procedure TAppCentreConfig.Load;
  127. var
  128. AFullFileName: string;
  129. jo, AServer: ISuperObject;
  130. AGroupServerAddresses: TSuperArray;
  131. iLoop: Integer;
  132. begin
  133. AFullFileName := ExtractFilePath(ParamStr(0)) + APPCENTRE_CONFIG;
  134. if not FileExists(AFullFileName) then
  135. Exit;
  136. try
  137. jo := TSuperObject.ParseFile(AFullFileName, False);
  138. if jo.O['lxtAppSecret'] <> nil then
  139. FLxtAppSecret := jo['lxtAppSecret'].AsString;
  140. if jo.O['ip'] <> nil then
  141. FIP := jo['ip'].AsString;
  142. if jo.O['port'] <> nil then
  143. FPort := jo['port'].AsInteger;
  144. if jo.O['clientIP'] <> nil then
  145. FClientIP := jo['clientIP'].AsString;
  146. if jo.O['clientPort'] <> nil then
  147. FClientPort := jo['clientPort'].AsInteger;
  148. if jo.O['lxtAppKey'] <> nil then
  149. FLxtAppKey := jo['lxtAppKey'].AsString;
  150. if jo.O['enable'] <> nil then
  151. FEnable := jo['enable'].AsBoolean;
  152. if jo.S['showType'] <> '' then
  153. FShowType := TAppCentreShowType(GetEnumValue(TypeInfo(TAppCentreShowType), jo.S['showType']))
  154. else
  155. FShowType := stForm;
  156. if jo.S['projectType'] <> '' then
  157. FProjectType := TAppCentreProjectType(GetEnumValue(TypeInfo(TAppCentreProjectType), jo.S['projectType']))
  158. else
  159. FProjectType := ptNormal;
  160. FMessageCentreIP := jo.S['messageCentreIP'];
  161. FMessageCentrePort := jo.I['messageCentrePort'];
  162. FMessageCentreEnable := jo.B['messageCentreEnable'];
  163. FDanDianDengLu := jo.B['DanDianDengLu'];
  164. except
  165. on E: Exception do
  166. begin
  167. LoggerImport.Error(E.Message, 'TAppCentreConfig.Load');
  168. end;
  169. end;
  170. end;
  171. end.