|
|
@@ -42,6 +42,7 @@ type
|
|
|
function GetTemplateXlsFileName: string;
|
|
|
function GetBackupFilePath: string;
|
|
|
function GetReportTemplatePath: string;
|
|
|
+ function GetAppTempPath: string;
|
|
|
|
|
|
{Select & Save File Choose}
|
|
|
function GetFilter(AExt: string): string;
|
|
|
@@ -81,7 +82,8 @@ type
|
|
|
function GetTempFileDir: string;
|
|
|
function GetTempFilePath: string;
|
|
|
function GetTempName(ALength: Integer = 8): string;
|
|
|
- function GetTempFileName: string;
|
|
|
+ function GetTempFileName: string; overload;
|
|
|
+ function GetTempFileName(const APath, AExt: string): string; overload;
|
|
|
function GenerateTempFolder(AGeneratePath: string): string;
|
|
|
function GetNewGUIDFileName(const AGeneratePath: string): string;
|
|
|
|
|
|
@@ -102,6 +104,8 @@ type
|
|
|
{Copy By Stream}
|
|
|
procedure CopyFileByStream(const ASourceFile, ADestFile: string);
|
|
|
|
|
|
+ procedure AppendTestLog(const AFileName, ALog: string);
|
|
|
+
|
|
|
// Add by chenshilong, 2014-04-11
|
|
|
function GetVersion(APartCount: Integer = 4): string;
|
|
|
function ExtractFileNameWithoutExt(const AFileName: string): string;
|
|
|
@@ -126,11 +130,10 @@ var
|
|
|
{RoundTo}
|
|
|
function InnerRoundTo(const AValue: Extended; const ADigit: Integer; RoundMode: TRoundMode): Extended;
|
|
|
var
|
|
|
- LFactor, Offset: Extended;
|
|
|
- HFactor: Integer;
|
|
|
+ LFactor, Offset, HFactor: Extended;
|
|
|
begin
|
|
|
LFactor := IntPower(10, ADigit);
|
|
|
- HFactor := Trunc(IntPower(10, abs(ADigit)));
|
|
|
+ HFactor := IntPower(10, abs(ADigit));
|
|
|
Result := AValue;
|
|
|
case RoundMode of
|
|
|
rmNearest:
|
|
|
@@ -179,6 +182,18 @@ begin
|
|
|
Result := CommonRoundTo(AValue, iTotalPriceDigit);
|
|
|
end;
|
|
|
|
|
|
+function GetTrueDigit(AValue: Double): Integer;
|
|
|
+const
|
|
|
+ sFormat12 = '0.############';
|
|
|
+var
|
|
|
+ sValue, sDigitValue: string;
|
|
|
+ iPointPos: Integer;
|
|
|
+begin
|
|
|
+ sValue := FormatFloat(sFormat12, AValue);
|
|
|
+ iPointPos := Pos('.', sValue);
|
|
|
+ Result := Min(0, -(Length(sValue) - iPointPos));
|
|
|
+end;
|
|
|
+
|
|
|
function CommonRoundTo(AValue: Double; ADigit: Integer; RoundMode: TRoundMode = rmNearest): Double;
|
|
|
var
|
|
|
X: Double;
|
|
|
@@ -201,7 +216,10 @@ begin
|
|
|
end;
|
|
|
P := @X;
|
|
|
CopyMemory(P, @Buf[0], SizeOf(X));
|
|
|
- Result := InnerRoundTo(X, ADigit, RoundMode);
|
|
|
+ if (ADigit < 0) and (ADigit < GetTrueDigit(AValue)) then
|
|
|
+ Result := AValue
|
|
|
+ else
|
|
|
+ Result := InnerRoundTo(X, ADigit, RoundMode);
|
|
|
end;
|
|
|
|
|
|
{Interface Control}
|
|
|
@@ -340,6 +358,13 @@ begin
|
|
|
Result := GetAppFilePath + 'ReportTemplates\';
|
|
|
end;
|
|
|
|
|
|
+function GetAppTempPath: string;
|
|
|
+begin
|
|
|
+ Result := GetAppFilePath + 'Temp\';
|
|
|
+ if DirectoryExists(Result) then
|
|
|
+ CreateDirectoryInDeep(Result);
|
|
|
+end;
|
|
|
+
|
|
|
{Select & Save File Choose}
|
|
|
|
|
|
function GetFilter(AExt: string): string;
|
|
|
@@ -869,6 +894,13 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+function GetTempFileName(const APath, AExt: string): string;
|
|
|
+begin
|
|
|
+ Result := APath + GetTempName + AExt;
|
|
|
+ while FileExists(Result) do
|
|
|
+ Result := APath + GetTempName + AExt;
|
|
|
+end;
|
|
|
+
|
|
|
function GenerateTempFolder(AGeneratePath: string): string;
|
|
|
begin
|
|
|
Result := AGeneratePath + GetTempName;
|
|
|
@@ -929,7 +961,7 @@ var
|
|
|
iSize1, iSize2: Integer;
|
|
|
begin
|
|
|
iSize1 := FileSizeByName(AFileName);
|
|
|
- Sleep(200);
|
|
|
+ Sleep(300);
|
|
|
iSize2 := FileSizeByName(AFileName);
|
|
|
Result := (iSize1 = iSize2);
|
|
|
if ACheckMode = 0 then
|
|
|
@@ -1023,6 +1055,28 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
+procedure AppendTestLog(const AFileName, ALog: string);
|
|
|
+var
|
|
|
+ f: TextFile;
|
|
|
+begin
|
|
|
+ try
|
|
|
+ if FileExists(AFileName) then
|
|
|
+ begin
|
|
|
+ AssignFile(f, AFileName);
|
|
|
+ Append(f);
|
|
|
+ Writeln(f, ALog);
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ AssignFile(f, AFileName);
|
|
|
+ Rewrite(f);
|
|
|
+ Writeln(f, ALog);
|
|
|
+ end;
|
|
|
+ finally
|
|
|
+ CloseFile(f);
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
function GetVersion(APartCount: Integer = 4): string;
|
|
|
var
|
|
|
V1, V2, V3, V4: Word;
|