|
@@ -194,6 +194,7 @@ type
|
|
|
procedure DoGETRequest(const AMethodType: TMethodType);
|
|
|
procedure DoPOSTRequest(const AMethodType: TMethodType);
|
|
|
procedure UpdateEditor(const AText: string);
|
|
|
+ procedure CheckForUpdate;
|
|
|
public
|
|
|
MainConfig: TJSONConfig;
|
|
|
ActiveEditor: TSynEdit;
|
|
@@ -222,7 +223,7 @@ implementation
|
|
|
{$R *.dfm}
|
|
|
|
|
|
uses System.NetEncoding, System.UITypes, _EncryptStr, JsonDataObjects, IdGlobal, System.IOUtils, uRwXmlDOM,
|
|
|
- _frmBiggerEditor, IdUri, _frmSearch;
|
|
|
+ _frmBiggerEditor, IdUri, _frmSearch, ShellApi;
|
|
|
|
|
|
procedure TfrmMain.tbbtnRunClick(Sender: TObject);
|
|
|
begin
|
|
@@ -394,6 +395,92 @@ begin
|
|
|
SaveProject;
|
|
|
end;
|
|
|
|
|
|
+procedure TfrmMain.CheckForUpdate;
|
|
|
+begin
|
|
|
+ TThread.CreateAnonymousThread(
|
|
|
+ procedure
|
|
|
+ var
|
|
|
+ HTTP: TIdHTTP;
|
|
|
+ bNewVersion: Boolean;
|
|
|
+ strlist: TStringList;
|
|
|
+ fs: TFileStream;
|
|
|
+ UpdateFile: TStringList;
|
|
|
+ begin
|
|
|
+ bNewVersion := False;
|
|
|
+ HTTP := TIdHTTP.Create(nil);
|
|
|
+ strlist := TStringList.Create;
|
|
|
+ try
|
|
|
+ try
|
|
|
+ strlist.Text := HTTP.Get('https://www.simnet.cx/WebUpdate/RESTDebugger/Update.txt');
|
|
|
+ except
|
|
|
+ bNewVersion := False;
|
|
|
+ raise;
|
|
|
+ end;
|
|
|
+
|
|
|
+ if strlist.Count = 2 then
|
|
|
+ begin
|
|
|
+ if strlist[0] = GetAppVersion then
|
|
|
+ begin
|
|
|
+ bNewVersion := False;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ DeleteFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.exe');
|
|
|
+ fs := TFileStream.Create(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.exe', fmCreate);
|
|
|
+ try
|
|
|
+ try
|
|
|
+ HTTP.Get(strlist[1], fs);
|
|
|
+ except
|
|
|
+ bNewVersion := False;
|
|
|
+ raise;
|
|
|
+ end;
|
|
|
+ finally
|
|
|
+ fs.Free;
|
|
|
+ end;
|
|
|
+
|
|
|
+ bNewVersion := True;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ finally
|
|
|
+ strlist.Free;
|
|
|
+ HTTP.Free;
|
|
|
+
|
|
|
+ TThread.Synchronize(TThread.CurrentThread,
|
|
|
+ procedure
|
|
|
+ begin
|
|
|
+ if bNewVersion then
|
|
|
+ begin
|
|
|
+ //Create Update file and start it
|
|
|
+ UpdateFile := TStringList.Create;
|
|
|
+ try
|
|
|
+ UpdateFile.Add('timeout 1');
|
|
|
+ UpdateFile.Add('taskkill /F /IM RESTDebugger.exe');
|
|
|
+ UpdateFile.Add('"%~dp0Update.exe" -o"' + ExtractFilePath(ParamStr(0)) + '" -y');
|
|
|
+ UpdateFile.Add('start "" "' + ParamStr(0) + '" "/updated"');
|
|
|
+ UpdateFile.Add('del "%~dp0Update.exe"');
|
|
|
+ UpdateFile.Add('del "%~dp0Update.cmd"');
|
|
|
+ UpdateFile.SaveToFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.cmd');
|
|
|
+ finally
|
|
|
+ UpdateFile.Free;
|
|
|
+ end;
|
|
|
+
|
|
|
+ if MessageDlg('Es ist eine neue Software Version verfügbar. Möchten Sie diese nun installieren?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
|
|
|
+ begin
|
|
|
+ ShellExecute(handle, 'open', PChar(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.cmd'), nil, nil, SW_HIDE);
|
|
|
+ Close;
|
|
|
+ end
|
|
|
+ else
|
|
|
+ begin
|
|
|
+ //CleanUp temp files
|
|
|
+ DeleteFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.cmd');
|
|
|
+ DeleteFile(IncludeTrailingPathDelimiter(TPath.GetTempPath) + 'Update.exe');
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end);
|
|
|
+ end;
|
|
|
+ end).Start;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TfrmMain.comboMethodPropertiesChange(Sender: TObject);
|
|
|
begin
|
|
|
tabPostData.TabVisible := (comboMethod.ItemIndex = 1) or (comboMethod.ItemIndex = 2) or (comboMethod.ItemIndex = 3);
|
|
@@ -865,7 +952,7 @@ begin
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
- if ParamStr(1) <> '' then
|
|
|
+ if (ParamStr(1) <> '') and not (LowerCase(ParamStr(1)) = '/updated') then
|
|
|
begin
|
|
|
FActiveProject := ParamStr(1);
|
|
|
FIsTempProjectLoaded := False;
|
|
@@ -959,6 +1046,14 @@ begin
|
|
|
gsSearchTextHistory := MainConfig.ReadString('Search', 'gsSearchTextHistory', gsSearchTextHistory);
|
|
|
gsReplaceText := MainConfig.ReadString('Search', 'gsReplaceText', gsReplaceText);
|
|
|
gsReplaceTextHistory := MainConfig.ReadString('Search', 'gsReplaceTextHistory', gsReplaceTextHistory);
|
|
|
+
|
|
|
+
|
|
|
+ CheckForUpdate;
|
|
|
+
|
|
|
+ if LowerCase(ParamStr(1)) = '/updated' then
|
|
|
+ begin
|
|
|
+ //ShowMessage('updated');
|
|
|
+ end;
|
|
|
end;
|
|
|
|
|
|
function TfrmMain.GetAppVersion: string;
|