149 lines
4.9 KiB
ObjectPascal
149 lines
4.9 KiB
ObjectPascal
|
|
||
|
|
||
|
{%RunFlags MESSAGES+}
|
||
|
{$mode ObjFPC}{$H+}
|
||
|
program helloworld(output);
|
||
|
|
||
|
|
||
|
uses
|
||
|
TariffCalculator, CTypes, LazUtils, LazFileUtils, LazUtf8, SysUtils,
|
||
|
fpjson, jsonparser;
|
||
|
|
||
|
type
|
||
|
PTJSONObject = ^TJSONObject;
|
||
|
|
||
|
var
|
||
|
jData: TJSONData;
|
||
|
jObject, jObjTemp: TJSONObject;
|
||
|
|
||
|
jEnum: TJSONEnum;
|
||
|
jArray: TJSONArray;
|
||
|
s: Utf8String;
|
||
|
fileId: String;
|
||
|
localRepository: String;
|
||
|
|
||
|
//TariffCalc: TariffCalculatorHandle;
|
||
|
CustomerRepo: array[0..100] of char;
|
||
|
LocalRepo: array[0..100] of char;
|
||
|
LocalCustomerRepo: array[0..100] of char;
|
||
|
LocalBranchName: array[0..32] of char;
|
||
|
FileToCommit: array[0..128] of char;
|
||
|
CommitMessage: array[0..256] of char;
|
||
|
UserName: array[0..64] of char;
|
||
|
PassWord: array[0..64] of char;
|
||
|
P, R: PChar;
|
||
|
Q: String;
|
||
|
I: Integer;
|
||
|
|
||
|
begin
|
||
|
// TariffCalc := NewTariffCalculator;
|
||
|
// DeleteTariffCalculator(TariffCalc);
|
||
|
try
|
||
|
jArray := TJSONArray.Create;
|
||
|
jObject := TJSONObject.Create;
|
||
|
|
||
|
CustomerRepo := 'https://git.mimbach49.de/GerhardHoffmann/customer_999.git';
|
||
|
LocalCustomerRepo := 'H:\\customer_999';
|
||
|
LocalBranchName := 'zg1/zone1';
|
||
|
FileToCommit := 'etc/psa_tariff/tariff01.json';
|
||
|
CommitMessage := 'TEST TEST';
|
||
|
UserName := 'GerhardHoffmann';
|
||
|
PassWord := 'ghlinux12345';
|
||
|
LocalRepo := 'customer_999';
|
||
|
localRepository := 'customer_999';
|
||
|
|
||
|
|
||
|
if GetFileMenuAsJson(localRepository, @jObject) then begin
|
||
|
jArray := jObject['File-Menue'] as TJSONArray;
|
||
|
for jEnum in jArray do begin
|
||
|
jObjTemp := jEnum.Value as TJSONObject;
|
||
|
fileId := jObjTemp.Strings['File-ID'];
|
||
|
writeln();
|
||
|
writeLn(fileId);
|
||
|
s := GetFileNameStr(localRepository, fileId);
|
||
|
writeln();
|
||
|
writeLn(s);
|
||
|
end;
|
||
|
end;
|
||
|
|
||
|
halt;
|
||
|
|
||
|
P := GetFileMenu(LocalRepo);
|
||
|
if P <> nil then
|
||
|
begin
|
||
|
jData := GetJSON(P);
|
||
|
s := jData.FormatJSON;
|
||
|
writeLn(s);
|
||
|
jObject := jData as TJSONObject;
|
||
|
writeLn(jObject['File-Menue'].Count);
|
||
|
|
||
|
jArray := jObject['File-Menue'] as TJSONArray;
|
||
|
for jEnum in jArray do begin
|
||
|
jObjTemp := jEnum.Value as TJSONObject;
|
||
|
s := jObjTemp.Strings['File-ID'];
|
||
|
writeln();
|
||
|
writeLn(s);
|
||
|
|
||
|
end;
|
||
|
|
||
|
for i := 0 to jObject['File-Menue'].Count-1 do
|
||
|
begin
|
||
|
jObjTemp := jObject['File-Menue'].Items[i] as TJSONObject;
|
||
|
s := jObjTemp.Find('File-ID').AsString;
|
||
|
writeLn(s);
|
||
|
R := GetFileName(LocalRepo, PChar(s));
|
||
|
if R <> nil then
|
||
|
begin
|
||
|
writeLn(R);
|
||
|
writeLn(GetFileSize(LocalRepo, PChar(s)));
|
||
|
writeLn(GetFile(LocalRepo, PChar(s)));
|
||
|
DeleteMem(R);
|
||
|
end;
|
||
|
end;
|
||
|
//writeLn(jObject['File-Menue'].Items[0].ToString());
|
||
|
//jObject := jObject['File-Menue'].Items[0] as TJSONObject;
|
||
|
//s := jObject.FormatJSON;
|
||
|
//writeLn(s);
|
||
|
//s := jObject.Find('File-ID').AsString;
|
||
|
//writeLn(s);
|
||
|
//Q := ':';
|
||
|
//writeLn(UTF8Pos(Q, s));
|
||
|
//jArray := jObject.FindPath('File-Menue') as TJSONArray;
|
||
|
//s := jArray[0].AsString;
|
||
|
//writeLn(s);
|
||
|
//jArray := jObject.Get('File-Menue', TJSONArray.Create);
|
||
|
//writeLn(jArray.Extract(0).AsString);
|
||
|
DeleteMem(P)
|
||
|
end;
|
||
|
//:w
|
||
|
//StrDispose(PChar(P));
|
||
|
|
||
|
//if not DirectoryExistsUTF8(ExpandFilenameUtf8(LocalCustomerRepo)) then
|
||
|
// CreateDirUTF8(ExpandFilenameUtf8(LocalCustomerRepo));
|
||
|
|
||
|
//if InitGitLibrary() > 0 then
|
||
|
// Try
|
||
|
// writeLn('initialized git library') ;
|
||
|
// if not DirectoryExistsUTF8(ExpandFilenameUtf8(LocalCustomerRepo+'\\.git')) then
|
||
|
// CloneRepository(CustomerRepo, LocalCustomerRepo);
|
||
|
// if not CheckoutLocalBranch(LocalCustomerRepo, LocalBranchName) = 0 then
|
||
|
// writeLn('cannot check out') ;
|
||
|
// if not CommitFile(LocalCustomerRepo, LocalBranchName, FileToCommit, CommitMessage) = 0 then
|
||
|
// writeLn('cannot commit') ;
|
||
|
// if not PushLocalRepository(LocalCustomerRepo, LocalBranchName, UserName, PassWord) = 0 then
|
||
|
// writeLn('cannot push') ;
|
||
|
// Finally
|
||
|
// if ShutdownGitLibrary() >= 0 then
|
||
|
// writeLn('shutdown git library') ;
|
||
|
// end
|
||
|
//else
|
||
|
// begin
|
||
|
// writeLn('initializing git library FAILED') ;
|
||
|
// Readln;
|
||
|
// end;
|
||
|
finally
|
||
|
jArray.Free;
|
||
|
end;
|
||
|
end.
|
||
|
|