Mustafa Bozkurt

api/v2/Print/ItemSlipsPrinting Netopenx Rest Fatura Basım

  Netsis/REST
Netopenx REst Test Apps ile POST işlemi yapıyorum.

api/v2/Print/ItemSlipsPrinting


{
 "DesignNumber": 6,
 "StreamSupport": false,
 "DocumentType": 0,
 "DocumentNumber": "A00000000010220",
 "CustomerCode": "1"
}


Bütün Basım çeşitlerini denedim PRN,Windows,Windows Grafik ve Görsel Basım Hepsinde değişik hatalar verdi.


PRN
{
 "IsSuccessful": false,
 "ErrorCode": "101",
 "ErrorDesc": "PRN\r\nThe specified file was not found\r\nDLLName=D:\\Netsis\\STANDARD9\\TemelSet\\DIZAYN.DLLNetOpenX50.Basim"
}

WINDOWS

{
 "IsSuccessful": false,
 "ErrorDesc": "Print-Base64 conversion failed."
}


GÖRSEL BASIM

{
 "IsSuccessful": false,
 "ErrorCode": "101",
 "ErrorDesc": "Gosterilmek istenen form nesnesi aktif ortam için uygun değil. (ShowNetMesaj-Unclosed quotation mark after the character string '00000010220\r\n')\r\nDLLName=D:\\Netsis\\STANDARD9\\Ortak\\EphesDLL.DLL\r\nDLLName=D:\\Netsis\\STANDARD9\\TemelSet\\DIZAYN.DLLNetOpenX50.Basim"
}


WINDOWS GRAFIK

{
 "IsSuccessful": false,
 "ErrorCode": "101",
 "ErrorDesc": "Gosterilmek istenen form nesnesi aktif ortam için uygun değil. (TNetBasimForm Dizayn Açıklama Bilgileri)\r\nDLLName=D:\\Netsis\\STANDARD9\\TemelSet\\DIZAYN.DLLNetOpenX50.Basim"
}


Basım yapamıyorum. Bununla ilgili örnekte yok. Pdf yapma şansım varsa daha iyi olur.



Netopenx Rest Basım


Mustafa Bozkurt

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;








06/06/18 10:37

Cevap vermek için giriş yapmanız gerekmektedir.