📄 jvprogramversioncheck.pas
字号:
procedure TJvProgramVersionCheck.ShowProgramVersionsDescription(const AFromVersion, AToVersion: string);
var
ParameterList: TJvParameterList;
Parameter: TJvBaseParameter;
begin
ParameterList := TJvParameterList.Create(Self);
try
ParameterList.Messages.Caption := Format(RsPVCWhatNewInS, [CurrentApplicationName]);
ParameterList.CancelButtonVisible := False;
Parameter := TJvMemoParameter.Create(ParameterList);
with Parameter do
begin
SearchName := SParamNameMemo;
Caption := Format(RsPVCChangesBetween, [AFromVersion, AToVersion]);
Width := 340;
Height := 200;
AsString := RemoteProgramVersionHistory.GetVersionsDescription(AFromVersion, AToVersion);
end;
ParameterList.AddParameter(Parameter);
ParameterList.ShowParameterDialog
finally
ParameterList.Free;
end;
end;
procedure TJvProgramVersionCheck.StoreData;
begin
inherited StoreData;
AppStorage.WriteDateTime(AppStorage.ConcatPaths([AppStoragePath, SLastCheck]), LastCheck);
end;
procedure TJvProgramVersionCheck.StoreRemoteVersionInfoToFile;
begin
FRemoteAppStorage.ReadOnly := False;
RemoteProgramVersionHistory.StoreProperties;
FRemoteAppStorage.Flush;
FRemoteAppStorage.ReadOnly := True;
end;
procedure TJvProgramVersionCheck.VersionInfoButtonClick(const ParameterList: TJvParameterList;
const Parameter: TJvBaseParameter);
var
I: TJvProgramReleaseType;
begin
I := Low(I);
Inc(I, Parameter.Tag);
with RemoteProgramVersionHistory do
if Assigned(CurrentProgramVersion[I]) then
ShowProgramVersionsDescription(CurrentFileVersion, CurrentProgramVersion[I].ProgramVersion);
end;
{$IFDEF USE_3RDPARTY_INDY}
//=== { TJvProgramVersionHTTPLocationIndy } ==================================
constructor TJvProgramVersionHTTPLocationIndy.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FIdHTTP := TIdHTTP.Create(Self);
end;
destructor TJvProgramVersionHTTPLocationIndy.Destroy;
begin
FIdHttp.Free;
inherited Destroy;
end;
function TJvProgramVersionHTTPLocationIndy.LoadFileFromRemoteInt(
const ARemotePath, ARemoteFileName, ALocalPath, ALocalFileName: string;
ABaseThread: TJvBaseThread): string;
begin
Result := '';
if Assigned(FOnLoadFileFromRemote) then
Result := FOnLoadFileFromRemote(Self, ARemotePath, ARemoteFileName,
ALocalPath, ALocalFileName)
else
Result := LoadFileFromRemoteIndy(ARemotePath, ARemoteFileName, ALocalPath,
ALocalFileName, ABaseThread);
end;
function TJvProgramVersionHTTPLocationIndy.LoadFileFromRemoteIndy(
const ARemotePath, ARemoteFileName, ALocalPath, ALocalFileName: string;
ABaseThread: TJvBaseThread): string;
var
ResultStream: TFileStream;
ResultName: string;
begin
Result := '';
if (DirectoryExists(ALocalPath) or (ALocalPath = '')) then
if ALocalFileName = '' then
ResultName := PathAppend(ALocalPath, ARemoteFileName)
else
ResultName := PathAppend(ALocalPath, ALocalFileName)
else
Exit;
ResultStream := TFileStream.Create(ResultName, fmCreate);
try
FIdHTTP.Port := Port;
with FIdHTTP do
begin
ProxyParams.ProxyPort := ProxySettings.Port;
ProxyParams.ProxyServer := ProxySettings.Server;
ProxyParams.ProxyUsername := ProxySettings.UserName;
ProxyParams.ProxyPassword := ProxySettings.Password;
if UserName <> '' then
Request.UserName := UserName;
if Password <> '' then
Request.Password := Password;
try
if Copy(ARemotePath, Length(ARemotePath), 1) <> '/' then
Get(ARemotePath + '/' + ARemoteFileName, ResultStream)
else
Get(ARemotePath + ARemoteFileName, ResultStream);
except
on E: Exception do
DownloadError := E.Message;
end;
end;
finally
ResultStream.Free;
end;
if FileExists(ResultName) and (DownloadError = '') then
Result := ResultName;
end;
//=== { TJvProgramVersionFTPLocationIndy } ===================================
constructor TJvProgramVersionFTPLocationIndy.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FIdFTP := TIdFTP.Create(Self);
end;
destructor TJvProgramVersionFTPLocationIndy.Destroy;
begin
FIdFtp.Free;
inherited Destroy;
end;
function TJvProgramVersionFTPLocationIndy.LoadFileFromRemoteInt(
const ARemotePath, ARemoteFileName, ALocalPath, ALocalFileName: string;
ABaseThread: TJvBaseThread): string;
begin
Result := '';
if Assigned(FOnLoadFileFromRemote) then
Result := FOnLoadFileFromRemote(Self, ARemotePath, ARemoteFileName,
ALocalPath, ALocalFileName)
else
Result := LoadFileFromRemoteIndy(ARemotePath, ARemoteFileName, ALocalPath,
ALocalFileName, ABaseThread);
end;
function TJvProgramVersionFTPLocationIndy.LoadFileFromRemoteIndy(
const ARemotePath, ARemoteFileName, ALocalPath, ALocalFileName: string;
ABaseThread: TJvBaseThread): string;
var
ResultStream: TFileStream;
ResultName: string;
begin
Result := '';
if (DirectoryExists(ALocalPath) or (ALocalPath = '')) then
if ALocalFileName = '' then
ResultName := PathAppend(ALocalPath, ARemoteFileName)
else
ResultName := PathAppend(ALocalPath, ALocalFileName)
else
Exit;
ResultStream := TFileStream.Create(ResultName, fmCreate);
try
FIdFTP.Port := Port;
FIdFTP.ProxySettings.Port := ProxySettings.Port;
FIdFTP.ProxySettings.Host := ProxySettings.Server;
FIdFTP.ProxySettings.UserName := ProxySettings.UserName;
FIdFTP.ProxySettings.Password := ProxySettings.Password;
with FIdFTP do
begin
try
if Copy(ARemotePath, Length(ARemotePath), 1) <> '/' then
Get(ARemotePath + '/' + ARemoteFileName, ResultStream)
else
Get(ARemotePath + ARemoteFileName, ResultStream);
except
on E: Exception do
DownloadError := E.Message;
end;
end;
finally
ResultStream.Free;
end;
if FileExists(ResultName) and (DownloadError = '') then
Result := ResultName;
end;
{$ENDIF USE_3RDPARTY_INDY}
{$IFDEF USE_3RDPARTY_ICS}
//=== { TJvProgramVersionHTTPLocationIcs } ===================================
constructor TJvProgramVersionHTTPLocationIcs.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FHttpCli := THttpCli.Create(Self);
end;
destructor TJvProgramVersionHTTPLocationIcs.Destroy;
begin
FHttpCli.Free;
inherited Destroy;
end;
function TJvProgramVersionHTTPLocationIcs.LoadFileFromRemoteInt(
const ARemotePath, ARemoteFileName, ALocalPath, ALocalFileName: string;
ABaseThread: TJvBaseThread): string;
begin
Result := '';
if Assigned(FOnLoadFileFromRemote) then
Result := FOnLoadFileFromRemote(Self, ARemotePath, ARemoteFileName,
ALocalPath, ALocalFileName)
else
Result := LoadFileFromRemoteIcs(ARemotePath, ARemoteFileName, ALocalPath,
ALocalFileName, ABaseThread);
end;
function TJvProgramVersionHTTPLocationIcs.LoadFileFromRemoteIcs(
const ARemotePath, ARemoteFileName, ALocalPath, ALocalFileName: string;
ABaseThread: TJvBaseThread): string;
var
ResultStream: TFileStream;
ResultName: string;
begin
Result := '';
if (DirectoryExists(ALocalPath) or (ALocalPath = '')) then
if ALocalFileName = '' then
ResultName := PathAppend(ALocalPath, ARemoteFileName)
else
ResultName := PathAppend(ALocalPath, ALocalFileName)
else
Exit;
ResultStream := TFileStream.Create(ResultName, fmCreate);
try
//FHttpCli.Port := Port;
with FHttpCli do
begin
MultiThreaded := False;
ProxyPort := inttostr(ProxySettings.Port);
Proxy := ProxySettings.Server;
ProxyUsername := ProxySettings.UserName;
ProxyPassword := ProxySettings.Password;
RcvdStream := ResultStream;
if Copy(ARemotePath, Length(ARemotePath), 1) <> '/' then
Url := ARemotePath + '/' + ARemoteFileName
else
Url := ARemotePath + ARemoteFileName;
try
Get
except
on E: EHttpException do
DownloadError := Format(RsPVDownloadFailed, [IntToStr(StatusCode) + ' ' + ReasonPhrase]);
else
raise;
end;
end;
finally
ResultStream.Free;
end;
if FileExists(ResultName) and (DownloadError = '') then
Result := ResultName;
end;
//=== { TJvProgramVersionFTPLocationIcs } ====================================
constructor TJvProgramVersionFTPLocationIcs.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FFtpClient := TFtpClient.Create(Self);
end;
destructor TJvProgramVersionFTPLocationIcs.Destroy;
begin
FFtpClient.Free;
inherited Destroy;
end;
function TJvProgramVersionFTPLocationIcs.LoadFileFromRemoteInt(
const ARemotePath, ARemoteFileName, ALocalPath, ALocalFileName: string;
ABaseThread: TJvBaseThread): string;
begin
Result := '';
if Assigned(FOnLoadFileFromRemote) then
Result := FOnLoadFileFromRemote(Self, ARemotePath, ARemoteFileName,
ALocalPath, ALocalFileName)
else
Result := LoadFileFromRemoteIcs(ARemotePath, ARemoteFileName, ALocalPath,
ALocalFileName, ABaseThread);
end;
function TJvProgramVersionFTPLocationIcs.LoadFileFromRemoteIcs(
const ARemotePath, ARemoteFileName, ALocalPath, ALocalFileName: string;
ABaseThread: TJvBaseThread): string;
var
ResultStream: TFileStream;
ResultName: string;
P: Integer;
begin
Result := '';
if (DirectoryExists(ALocalPath) or (ALocalPath = '')) then
if ALocalFileName = '' then
ResultName := PathAppend(ALocalPath, ARemoteFileName)
else
ResultName := PathAppend(ALocalPath, ALocalFileName)
else
Exit;
ResultStream := TFileStream.Create(ResultName, fmCreate);
try
// FFtpClient.Port := inttostr(Port);
FFtpClient.DataPortRangeStart := Port;
FFtpClient.DataPortRangeEnd := Port;
FFtpClient.UserName := UserName;
FFtpClient.Password := Password;
with FFtpClient do
begin
// FtpClient1.HostName := HostNameEdit.Text;
// FtpClient1.Port := PortEdit.Text;
// FtpClient1.DataPortRangeStart := StrToInt(Trim(DataPortRangeStartEdit.Text));
// FtpClient1.DataPortRangeEnd := Port;
// FtpClient1.UserName := UserNameEdit.Text;
// FtpClient1.Password := PasswordEdit.Text;
// FtpClient1.Account := AccountEdit.Text;
// FtpClient1.HostDirName := HostDirEdit.Text;
// FtpClient1.HostFileName := HostFileEdit.Text;
// FtpClient1.LocalFileName := LocalFileEdit.Text;
// FtpClient1.Passive := PassiveCheckBox.Checked;
// FtpClient1.Binary := BinaryCheckBox.Checked;
MultiThreaded := False;
Binary := True;
ProxyPort := IntToStr(ProxySettings.Port);
ProxyServer := ProxySettings.Server;
// ProxyUsername := ProxySettings.UserName;
// ProxyPassword := ProxySettings.Password;
// Port := 'ftp';
// RcvdStream := ResultStream;
LocalFileName := ResultName;
P := Pos('://', ARemotePath);
if P > 0 then
begin
HostName := Copy(ARemotePath, P + 3, Length(ARemotePath)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -