ConfigDoc.pas 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. FBatchInsertFrmHeight: Integer;
  21. FBatchInsertFrmWidth: Integer;
  22. procedure LoadSectionOfCustomize;
  23. procedure LoadSectionOfUnitList;
  24. procedure LoadSectionOfStdFile;
  25. procedure LoadSectionOfPath;
  26. procedure LoadSectionOfOptions;
  27. procedure LoadIniFile;
  28. procedure SaveIniFile;
  29. procedure SaveSectionOfStdFile;
  30. procedure SaveSectionOfOptions;
  31. procedure SaveSectionOfCustomize;
  32. function GetStandardGclLib: string;
  33. function GetStandardXmLib: string;
  34. procedure SetStandardGclLib(const Value: string);
  35. procedure SetStandardXmLib(const Value: string);
  36. function GetOutputPath: string;
  37. function GetAuditPath: string;
  38. public
  39. constructor Create(const AIniFile: string);
  40. destructor Destroy; override;
  41. property Units: TStrings read FUnits;
  42. property StandardXmLib: string read GetStandardXmLib write SetStandardXmLib;
  43. property StandardGclLib: string read GetStandardGclLib write SetStandardGclLib;
  44. property IsLog: Boolean read FIsLog;
  45. // Path
  46. property AuditPath: string read GetAuditPath;
  47. property OutputPath: string read GetOutputPath;
  48. // Options
  49. property CompanyName: string read FCompanyName write FCompanyName;
  50. property AutoSave: Boolean read FAutoSave write FAutoSave;
  51. property AutoSaveInterval: Integer read FAutoSaveInterval write FAutoSaveInterval;
  52. property OverRangeType: Integer read FOverRangeType write FOverRangeType;
  53. property ExcelWithMis: Boolean read FExcelWithMis write FExcelWithMis;
  54. // Customize
  55. property BatchInsertFrmHeight: Integer read FBatchInsertFrmHeight write FBatchInsertFrmHeight;
  56. property BatchInsertFrmWidth: Integer read FBatchInsertFrmWidth write FBatchInsertFrmWidth;
  57. end;
  58. implementation
  59. { TConfigInfo }
  60. constructor TConfigInfo.Create(const AIniFile: string);
  61. begin
  62. FIniFile := TIniFile.Create(AIniFile);
  63. FUnits := TStringList.Create;
  64. LoadIniFile;
  65. end;
  66. destructor TConfigInfo.Destroy;
  67. begin
  68. SaveIniFile;
  69. FUnits.Free;
  70. FIniFile.Free;
  71. inherited;
  72. end;
  73. function TConfigInfo.GetAuditPath: string;
  74. begin
  75. Result := GetAppFilePath + FAuditPath;
  76. end;
  77. function TConfigInfo.GetOutputPath: string;
  78. begin
  79. Result := GetAppFilePath + FOutputPath;
  80. end;
  81. function TConfigInfo.GetStandardGclLib: string;
  82. begin
  83. Result := GetAppFilePath + '标准清单\工程量清单\' + FStandardGclLib;
  84. end;
  85. function TConfigInfo.GetStandardXmLib: string;
  86. begin
  87. Result := GetAppFilePath + '标准清单\项目节清单\' + FStandardXmLib;
  88. end;
  89. procedure TConfigInfo.LoadIniFile;
  90. begin
  91. LoadSectionOfUnitList;
  92. LoadSectionOfStdFile;
  93. LoadSectionOfPath;
  94. LoadSectionOfOptions;
  95. LoadSectionOfCustomize;
  96. FIsLog := FIniFile.ReadBool('Other', 'IsLog', True);
  97. end;
  98. procedure TConfigInfo.LoadSectionOfCustomize;
  99. begin
  100. FBatchInsertFrmHeight := FIniFile.ReadInteger('Customize', 'BatchInsertFrmHeight', 382);
  101. FBatchInsertFrmWidth := FIniFile.ReadInteger('Customize', 'BatchInsertFrmWidth', 779);
  102. end;
  103. procedure TConfigInfo.LoadSectionOfOptions;
  104. begin
  105. FCompanyName := FIniFile.ReadString('Options', 'CompanyName', '');
  106. FAutoSave := FIniFile.ReadBool('Options', 'AutoSave', True);
  107. FAutoSaveInterval := FIniFile.ReadInteger('Options', 'AutoSaveInterval', 15);
  108. FOverRangeType := FIniFile.ReadInteger('Options', 'OverRangeType', 0);
  109. FExcelWithMis := FIniFile.ReadBool('Options', 'ExcelWithMis', False);
  110. end;
  111. procedure TConfigInfo.LoadSectionOfPath;
  112. begin
  113. FOutputPath := FIniFile.ReadString('Paths', 'Output', '导出文件\');
  114. FAuditPath := FIniFile.ReadString('Paths', 'AuditPath', '上报批复文件\');
  115. end;
  116. procedure TConfigInfo.LoadSectionOfStdFile;
  117. begin
  118. FStandardXmLib := FIniFile.ReadString('StdFiles', 'XmLib', '');
  119. FStandardGclLib := FIniFile.ReadString('StdFiles', 'GclLib', '');
  120. end;
  121. procedure TConfigInfo.LoadSectionOfUnitList;
  122. var
  123. iIndex: Integer;
  124. begin
  125. if FIniFile.SectionExists('UnitList') then
  126. begin
  127. FIniFile.ReadSection('UnitList', FUnits);
  128. for iIndex := 0 to FUnits.Count - 1 do
  129. FUnits.Strings[iIndex] := FIniFile.ReadString('UnitList', FUnits.Strings[iIndex], '');
  130. end;
  131. end;
  132. procedure TConfigInfo.SaveIniFile;
  133. begin
  134. SaveSectionOfStdFile;
  135. SaveSectionOfOptions;
  136. SaveSectionOfCustomize;
  137. end;
  138. procedure TConfigInfo.SaveSectionOfCustomize;
  139. begin
  140. FIniFile.WriteInteger('Customize', 'BatchInsertFrmHeight', FBatchInsertFrmHeight);
  141. FIniFile.WriteInteger('Customize', 'BatchInsertFrmWidth', FBatchInsertFrmWidth);
  142. end;
  143. procedure TConfigInfo.SaveSectionOfOptions;
  144. begin
  145. FIniFile.WriteString('Options', 'CompanyName', FCompanyName);
  146. FIniFile.WriteBool('Options', 'AutoSave', FAutoSave);
  147. FIniFile.WriteInteger('Options', 'AutoSaveInterval', FAutoSaveInterval);
  148. FIniFile.WriteInteger('Options', 'OverRangeType', FOverRangeType);
  149. FIniFile.WriteBool('Options', 'ExcelWithMis', FExcelWithMis);
  150. end;
  151. procedure TConfigInfo.SaveSectionOfStdFile;
  152. begin
  153. FIniFile.WriteString('StdFiles', 'XmLib', FStandardXmLib);
  154. FIniFile.WriteString('StdFiles', 'GclLib', FStandardGclLib);
  155. end;
  156. procedure TConfigInfo.SetStandardGclLib(const Value: string);
  157. begin
  158. FStandardGclLib := Value;
  159. SaveIniFile;
  160. end;
  161. procedure TConfigInfo.SetStandardXmLib(const Value: string);
  162. begin
  163. FStandardXmLib := Value;
  164. SaveIniFile;
  165. end;
  166. end.