CAConfig.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. unit CAConfig;
  2. interface
  3. uses
  4. superobject, Classes, SysUtils, mybean.core.objects, InterfaceCA;
  5. type
  6. TCAConfig = class(TMyBeanInterfacedObject, ICAConfig)
  7. private
  8. FURL: string;
  9. FAppID: string;
  10. FEnable: Boolean;
  11. FCASubject: string;
  12. // FIsChooseCa: Boolean;
  13. public
  14. procedure Load;
  15. function GetAppID: string; stdcall;
  16. function GetEnable: Boolean; stdcall;
  17. function GetURL: string; stdcall;
  18. function GetCASubject: string; stdcall;
  19. // function GetIsChooseCa: Boolean; stdcall;
  20. // procedure SetIsChooseCa(AValue: Boolean); stdcall;
  21. constructor Create(); override;
  22. property URL: string read GetURL;
  23. property AppID: string read GetAppID;
  24. property Enable: Boolean read GetEnable;
  25. end;
  26. implementation
  27. uses
  28. DataProviderImport, InterfaceDataProvider;
  29. { TCAConfig }
  30. const
  31. CONFIG_FILE: string = 'Config\ca.config';
  32. constructor TCAConfig.Create;
  33. begin
  34. inherited;
  35. Load;
  36. end;
  37. function TCAConfig.GetAppID: string;
  38. begin
  39. Result := FAppID;
  40. end;
  41. function TCAConfig.GetCASubject: string;
  42. begin
  43. Result := FCASubject;
  44. end;
  45. function TCAConfig.GetEnable: Boolean;
  46. begin
  47. Result := FEnable;
  48. end;
  49. //function TCAConfig.GetIsChooseCa: Boolean;
  50. //begin
  51. // Result := FIsChooseCa;
  52. //end;
  53. function TCAConfig.GetURL: string;
  54. begin
  55. Result := FURL;
  56. end;
  57. procedure TCAConfig.Load;
  58. var
  59. AFullFileName: string;
  60. jo, AServer: ISuperObject;
  61. AGroupServerAddresses: TSuperArray;
  62. iLoop: Integer;
  63. CAUIConfig: string;
  64. begin
  65. AFullFileName := ExtractFilePath(ParamStr(0)) + CONFIG_FILE;
  66. if not FileExists(AFullFileName) then
  67. Exit;
  68. jo := TSuperObject.ParseFile(AFullFileName, False);
  69. if jo = nil then
  70. Exit;
  71. FURL := jo.S['url'];
  72. FAppID := jo.S['appid'];
  73. FEnable := jo.B['enable'];
  74. FCASubject := jo.S['casubject'];
  75. // jo := nil;
  76. // CAUIConfig := GetConfigProvider.Find(WideString('caui_v1_0'));
  77. // if (CAUIConfig = '') or (SO(CAUIConfig) = nil)then
  78. // begin
  79. // jo := SO('{}');
  80. // jo.B['isChooseCa'] := false;
  81. // GetConfigProvider.Insert('caui_v1_0', jo.AsJSon());
  82. // end
  83. // else
  84. // jo := SO(CAUIConfig);
  85. //
  86. // FIsChooseCa := jo.B['isChooseCa'];
  87. end;
  88. //procedure TCAConfig.SetIsChooseCa(AValue: Boolean);
  89. //var
  90. // jo: ISuperObject;
  91. //
  92. // CAUIConfig: string;
  93. //begin
  94. // if FIsChooseCa = Avalue then
  95. // Exit;
  96. // FIsChooseCa := AValue;
  97. //
  98. // CAUIConfig := GetConfigProvider.Find(WideString('caui_v1_0'));
  99. // jo := SO(CAUIConfig);
  100. // if (CAUIConfig = '') or (SO(CAUIConfig) = nil)then
  101. // jo := SO('{}')
  102. // else
  103. // jo := SO(CAUIConfig);
  104. // jo.B['isChooseCa'] := FIsChooseCa;
  105. // GetConfigProvider.Insert(WideString('caui_v1_0'), WideString(jo.AsJSon()));
  106. //end;
  107. end.