ConfigDoc.pas 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. unit ConfigDoc;
  2. interface
  3. uses
  4. Classes, IniFiles, UtilMethods;
  5. type
  6. TConfigInfo = class
  7. private
  8. FIniFile: TIniFile;
  9. FUnits: TStrings;
  10. FStandardXmLib: string;
  11. FStandardGclLib: string;
  12. FOutputPath: string;
  13. FAuditPath: string;
  14. FCompanyName: string;
  15. FAutoSave: Boolean;
  16. FAutoSaveInterval: Integer;
  17. FOverRangeType: Integer;
  18. FExcelWithMis: Boolean;
  19. procedure LoadSectionOfUnitList;
  20. procedure LoadSectionOfStdFile;
  21. procedure LoadSectionOfPath;
  22. procedure LoadSectionOfOptions;
  23. procedure LoadIniFile;
  24. procedure SaveIniFile;
  25. procedure SaveSectionOfStdFile;
  26. procedure SaveSectionOfOptions;
  27. function GetStandardGclLib: string;
  28. function GetStandardXmLib: string;
  29. procedure SetStandardGclLib(const Value: string);
  30. procedure SetStandardXmLib(const Value: string);
  31. function GetOutputPath: string;
  32. function GetAuditPath: string;
  33. public
  34. constructor Create(const AIniFile: string);
  35. destructor Destroy; override;
  36. property Units: TStrings read FUnits;
  37. property StandardXmLib: string read GetStandardXmLib write SetStandardXmLib;
  38. property StandardGclLib: string read GetStandardGclLib write SetStandardGclLib;
  39. // Path
  40. property AuditPath: string read GetAuditPath;
  41. property OutputPath: string read GetOutputPath;
  42. // Options
  43. property CompanyName: string read FCompanyName write FCompanyName;
  44. property AutoSave: Boolean read FAutoSave write FAutoSave;
  45. property AutoSaveInterval: Integer read FAutoSaveInterval write FAutoSaveInterval;
  46. property OverRangeType: Integer read FOverRangeType write FOverRangeType;
  47. property ExcelWithMis: Boolean read FExcelWithMis write FExcelWithMis;
  48. end;
  49. implementation
  50. { TConfigInfo }
  51. constructor TConfigInfo.Create(const AIniFile: string);
  52. begin
  53. FIniFile := TIniFile.Create(AIniFile);
  54. FUnits := TStringList.Create;
  55. LoadIniFile;
  56. end;
  57. destructor TConfigInfo.Destroy;
  58. begin
  59. SaveIniFile;
  60. FUnits.Free;
  61. FIniFile.Free;
  62. inherited;
  63. end;
  64. function TConfigInfo.GetAuditPath: string;
  65. begin
  66. Result := GetAppFilePath + FAuditPath;
  67. end;
  68. function TConfigInfo.GetOutputPath: string;
  69. begin
  70. Result := GetAppFilePath + FOutputPath;
  71. end;
  72. function TConfigInfo.GetStandardGclLib: string;
  73. begin
  74. Result := GetAppFilePath + '깃硫헌데\묏넋좆헌데\' + FStandardGclLib;
  75. end;
  76. function TConfigInfo.GetStandardXmLib: string;
  77. begin
  78. Result := GetAppFilePath + '깃硫헌데\淃커쌘헌데\' + FStandardXmLib;
  79. end;
  80. procedure TConfigInfo.LoadIniFile;
  81. begin
  82. LoadSectionOfUnitList;
  83. LoadSectionOfStdFile;
  84. LoadSectionOfPath;
  85. LoadSectionOfOptions;
  86. end;
  87. procedure TConfigInfo.LoadSectionOfOptions;
  88. begin
  89. FCompanyName := FIniFile.ReadString('Options', 'CompanyName', '');
  90. FAutoSave := FIniFile.ReadBool('Options', 'AutoSave', True);
  91. FAutoSaveInterval := FIniFile.ReadInteger('Options', 'AutoSaveInterval', 15);
  92. FOverRangeType := FIniFile.ReadInteger('Options', 'OverRangeType', 0);
  93. FExcelWithMis := FIniFile.ReadBool('Options', 'ExcelWithMis', False);
  94. end;
  95. procedure TConfigInfo.LoadSectionOfPath;
  96. begin
  97. FOutputPath := FIniFile.ReadString('Paths', 'Output', '돔놔匡숭\');
  98. FAuditPath := FIniFile.ReadString('Paths', 'AuditPath', '�괩툽릿匡숭\');
  99. end;
  100. procedure TConfigInfo.LoadSectionOfStdFile;
  101. begin
  102. FStandardXmLib := FIniFile.ReadString('StdFiles', 'XmLib', '');
  103. FStandardGclLib := FIniFile.ReadString('StdFiles', 'GclLib', '');
  104. end;
  105. procedure TConfigInfo.LoadSectionOfUnitList;
  106. var
  107. iIndex: Integer;
  108. begin
  109. if FIniFile.SectionExists('UnitList') then
  110. begin
  111. FIniFile.ReadSection('UnitList', FUnits);
  112. for iIndex := 0 to FUnits.Count - 1 do
  113. FUnits.Strings[iIndex] := FIniFile.ReadString('UnitList', FUnits.Strings[iIndex], '');
  114. end;
  115. end;
  116. procedure TConfigInfo.SaveIniFile;
  117. begin
  118. SaveSectionOfStdFile;
  119. SaveSectionOfOptions;
  120. end;
  121. procedure TConfigInfo.SaveSectionOfOptions;
  122. begin
  123. FIniFile.WriteString('Options', 'CompanyName', FCompanyName);
  124. FIniFile.WriteBool('Options', 'AutoSave', FAutoSave);
  125. FIniFile.WriteInteger('Options', 'AutoSaveInterval', FAutoSaveInterval);
  126. FIniFile.WriteInteger('Options', 'OverRangeType', FOverRangeType);
  127. FIniFile.WriteBool('Options', 'ExcelWithMis', FExcelWithMis);
  128. end;
  129. procedure TConfigInfo.SaveSectionOfStdFile;
  130. begin
  131. FIniFile.WriteString('StdFiles', 'XmLib', FStandardXmLib);
  132. FIniFile.WriteString('StdFiles', 'GclLib', FStandardGclLib);
  133. end;
  134. procedure TConfigInfo.SetStandardGclLib(const Value: string);
  135. begin
  136. FStandardGclLib := Value;
  137. SaveIniFile;
  138. end;
  139. procedure TConfigInfo.SetStandardXmLib(const Value: string);
  140. begin
  141. FStandardXmLib := Value;
  142. SaveIniFile;
  143. end;
  144. end.