ConfigDoc.pas 6.0 KB

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