ConfigDoc.pas 4.7 KB

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