Sorun Çözüldü. Windows Grafik yapılı başka bir dizaynda çalıştır.
Delphi Code :
function TNetRestFatura.tokenal(url,dbname,dbuser,dbpassword,username,password:string;var tokenhata:string):string;
var
PostData: TStringList;
rta: string;
X: ISuperObject;
FHTTPRequest : TNetHTTPRequest;
FHTTPClient : TNetHTTPClient;
LResponse: IHTTPResponse;
hata,hatadetay:string;
begin
Result:='';
PostData := TStringList.Create;
Try
try
PostData.Add('grant_type=password');
PostData.Add('branchcode=0');
PostData.Add('password='+password);
PostData.Add('username='+username);
PostData.Add('dbname='+dbname);
PostData.Add('dbuser='+dbuser);
PostData.Add('dbpassword='+dbpassword);
PostData.Add('dbtype=0');
FHTTPClient := TNetHTTPClient.Create(nil);
FHTTPRequest :=TNetHTTPRequest.Create(nil);
FHTTPClient.ContentType := 'application/json';
FHTTPRequest.Client := FHTTPClient;
LResponse:=FHTTPRequest .Post(url+'/api/v2/token',PostData);
rta:=LResponse.ContentAsString();
finally
PostData.Free;
FreeAndNil(FHTTPRequest);
FreeAndNil(FHTTPClient);
end;
X := SO(rta);
hata:=X['"error"'].AsString;
hatadetay:=X['"error_description"'].AsString;
if hata<>'' then
begin
tokenhata:=hatadetay;
Result:='';
end else
begin
Result:= 'Authorization=Bearer ' + X['"access_token"'].AsString;
end;
except
result:='';
End;;
end;
function TNetRestFatura.FaturaBasim(Token: String;Tip:Integer;Fatirs_No,Cari_Kodu,dizayno:string; var faturahata: string): string;
var
i:integer;
data:string;
DataToSend:tstringstream;
LURL,LName: string;
LHeader: TNetHeader;
LHeaders: TNetHeaders;
LResponse: IHTTPResponse;
LIndex: Integer;
FHTTPRequest : TNetHTTPRequest;
FHTTPClient : TNetHTTPClient;
ftstringlist : TStringList;
sonucstringlist : TStringList;
LJSON: TJSONValue;
X: ISuperObject;
donus:string;
faturahataic,faturahatadetayic:string;
begin
ftstringlist := TStringList.Create;
ftstringlist.Add('{');
ftstringlist.Add('"DesignNumber": '+dizayno+',');
ftstringlist.Add('"StreamSupport": true,');
ftstringlist.Add('"DocumentType": '+inttostr(Tip)+',');
ftstringlist.Add('"DocumentNumber": "'+Fatirs_No+'",');
ftstringlist.Add('"CustomerCode": "'+Cari_Kodu+'",');
ftstringlist.Add('}');
FHTTPClient := TNetHTTPClient.Create(nil);
FHTTPRequest :=TNetHTTPRequest.Create(nil);
FHTTPClient.ContentType := 'application/json';
for LIndex := 0 to StringToStringList(token).Count - 1 do
begin
LName := StringToStringList(token).Names[LIndex];
LHeader := TNetHeader.Create(LName, StringToStringList(token).Values[LName]);
LHeaders := LHeaders + [LHeader];
end;
for i := 0 to ftstringlist.count-1 do data:=data+ftstringlist[i];
DataToSend := TStringStream.Create(data, TEncoding.UTF8);
LURL := nurl +'/api/v2/Print/ItemSlipsPrinting';
FHTTPRequest.Client := FHTTPClient;
LResponse := FHTTPRequest.Post(LURL, DataToSend, nil, LHeaders);
LJSON := TJSONObject.ParseJSONValue(LResponse.ContentAsString(tencoding.UTF8));
try
try
donus:= TJson.Format(LJSON);
faturahata:='';
faturahataic:=jsonoku(donus,'','','ErrorCode');
faturahatadetayic:=jsonoku(donus,'','','ErrorDesc');
if faturahataic<>'' then
faturahata:=faturahataic+#13#10+faturahatadetayic else
result:=jsonoku(donus,'','','Data');;
finally
freeandnil(LJSON);
end;
except
end;
end;
function TNetRestFatura.jsonoku(deger,alan1,alan2,alan3:string):string;
var
js,xs:TlkJSONobject;
ws: TlkJSONstring;
begin
try
try
js := TlkJSON.ParseText(deger) as TlkJSONobject;
if (alan1='') and (alan2='') and (alan3<>'') then result:=js.getString(alan3);
if (alan1='') and (alan2<>'') and (alan3<>'') then result:=vartostr(js.Field[alan2].Field[alan3].Value);
if (alan1<>'') and (alan2<>'') and (alan3<>'') then result:=vartostr(js.Field[alan1].Field[alan2].Field[alan3].Value);
finally
js.free
end;
except
end;
end;
Basım Butonu
Uses XSuperJSON,XSuperObject, REST.Json, System.JSON,System.JSON.Readers, System.JSON.Types, System.Net.URLClient, System.Net.HttpClient, System.Net.HttpClientComponent,uLkJSON,IdCoderMIME
procedure TForm1.Button16Click(Sender: TObject);
var
i:integer;
a:TStringList;
fatura:TNetRestFatura;
kalemstok_kodu:TStringList;
token1:string;
tokenhata,faturahata,faturahatadetay,faturadonus:string;
X:ISuperObject;
FS: TFormatSettings;
begin
fatura:=TNetRestFatura.Create;
token1:=fatura.Tokenal(edit1.Text,edit2.Text,edit3.Text,edit4.Text,edit6.Text,edit7.Text,tokenhata);
fatura.url:=edit1.text;
faturadonus:=fatura.Faturabasim(token1,strtoint(edit11.text),edit12.text,edit13.text,edit14.text,faturahatadetay);
if faturahatadetay<>'' then
begin
showmessage(faturahatadetay);
end
else
begin
memo9.lines.clear;
memo9.Lines.Add(faturadonus); //hata
saveFileToBase64(faturadonus,'C:\deneme.pdf');
end;
end;
function TForm1.saveFileToBase64(const Data,AFileName: string): String;
var
MStream:TMemoryStream;
Decoder:TIdDecoderMIME;
Base64: string;
begin
Decoder := TIdDecoderMIME.Create(nil);
MStream := TMemoryStream.Create;
Base64 := Data;
Decoder.DecodeStream(Base64,MStream);
MStream.SaveToFile(AFileName);
FreeAndNil(Decoder);
FreeAndNil(MStream);
end;
Cevap vermek için giriş yapmanız gerekmektedir.
Soru sormak için lütfen oturum açınız.
api/v2/Print/ItemSlipsPrinting Netopenx Rest Fatura Basım
04/06/18 19:10   Netsis/RESTBütün Basım çeşitlerini denedim PRN,Windows,Windows Grafik ve Görsel Basım Hepsinde değişik hatalar verdi.
Basım yapamıyorum. Bununla ilgili örnekte yok. Pdf yapma şansım varsa daha iyi olur.
Netopenx Rest Basım