-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnaForm.pas
207 lines (181 loc) · 6.23 KB
/
AnaForm.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
unit AnaForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils,
System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
System.Actions, Vcl.ActnList,
Vcl.StdCtrls, Soap.InvokeRegistry,
Soap.Rio, Soap.SOAPHTTPClient, Soap.SOAPHTTPTrans, QueryDocumentWS1,
Xml.xmldom, Xml.XMLIntf, Xml.XMLDoc;
type
TForm1 = class(TForm)
Button1: TButton;
HTTPRIO1: THTTPRIO;
MemoLog: TMemo;
Button2: TButton;
Button3: TButton;
ActionList1: TActionList;
ActionGetCreditCout: TAction;
ActionSendInvoice: TAction;
Action1: TAction;
XMLDocument1: TXMLDocument;
procedure ActionGetCreditCoutExecute(Sender: TObject);
procedure HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp;
Data: Pointer);
procedure HTTPRIO1BeforeExecute(const MethodName: string;
SOAPRequest: TStream);
procedure HTTPRIO1AfterExecute(const MethodName: string;
SOAPResponse: TStream);
procedure ActionSendInvoiceExecute(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
procedure LogEkle(Str1: String);
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses InvoiceWS1, WinInet;
const
//
PR_cbc = 'cbc';
NS_cbc = 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2';
PR_cac = 'cac';
NS_cac = 'urn:oasis:names:specification:ubl:schema:xsd:UBL-CommonAggregateComponents-2.1';
//
HizliUserName = '111111190';
HizliPassword = '1';
// HizliServiceUrl = 'http://94.103.42.45:8080/InvoiceService/InvoiceWS';
HizliServiceUrl = 'https://servis.hizlibilisimteknolojileri.net/InvoiceService/InvoiceWS';
hizliservis2 ='https://servis.hizlibilisimteknolojileri.net/QueryInvoiceService/QueryDocumentWS' ;
sourceUrn = '';
procedure TForm1.ActionGetCreditCoutExecute(Sender: TObject);
var
Servis: InvoiceWS;
servis2: QueryDocumentWS;
Cevap: CreditInfo;
cevap2:DocumentQueryResponse;
begin
inherited;
Screen.Cursor := crSQLWait;
try
Servis := GetInvoiceWS(False, HizliServiceUrl, HTTPRIO1);
// servis2:= GetQueryDocumentWS(False,hizliservis2,HTTPRIO1);
// Cevap2:= servis2.QueryOutboxDocumentsWithDocumentDate('01.01.2017','23.11.2018','1','ALL','YES','1');
//MemoLog.Lines.Add( IntToStr(Cevap2.documentsCount) );
Cevap := Servis.getCustomerCreditCount('4620553774');
if Cevap.code = '000' then
begin
ShowMessage('Toplam Krediniz: ' + cevap.totalCredit.DecimalString);
end else
begin
ShowMessage('HATA: ' + Cevap.explanation);
end;
finally
if Cevap <> nil then Cevap.Free;
Screen.Cursor := crDefault;
end;
end;
procedure TForm1.ActionSendInvoiceExecute(Sender: TObject);
var
Servis: InvoiceWS;
Sorgu: updateInvoice;
Cevap: updateInvoiceResponse;
Sayac: Integer;
const
FaturaSayisi = 5;
begin
inherited;
Screen.Cursor := crSQLWait;
try
Servis := GetInvoiceWS(False, HizliServiceUrl, HTTPRIO1);
SetLength(Sorgu, FaturaSayisi); //amacı anlayamadım(enes)
for Sayac := 0 to FaturaSayisi - 1 do
begin
Sorgu[Sayac] := InputDocument.Create;
Sorgu[Sayac].documentUUID := '16a3fbc4-3539-4384-b4a3-16268b4912fc'; // GUID Kendimiz üretmeliyiz
Sorgu[Sayac].xmlContent := ''; // Faturamızın UBL formatındaki hali
Sorgu[Sayac].sourceUrn := 'urn:mail:[email protected]'; // Bizim urn (GB) kodumuz (Faturayı gönderenin)
Sorgu[Sayac].destinationUrn := 'urn:mail:[email protected]'; // Alıcının urn (PK) kodu. (Faturayı alacak olanın)
Sorgu[Sayac].documentNoPrefix := ''; // Fatura no üretilirken kullanılan ön ek (Zorunlu değil)
Sorgu[Sayac].localId := '66'; // Yerel DB Referans ID
Sorgu[Sayac].documentId := 'GIB20180000056891'; // Fatura GİB numarası (Örn: GIB2018000000001)
end;
Cevap := Servis.sendInvoice(Sorgu);
for Sayac := 0 to Length(Cevap) - 1 do
begin
if Cevap[Sayac].code = '000' then
begin
ShowMessage('Gönderme Başarılı: ' + cevap[Sayac].documentID);
end else
begin
ShowMessage('HATA: ' + Cevap[Sayac].explanation);
end;
end;
finally
for Sayac := 0 to Length(Cevap) - 1 do
begin
if Cevap[Sayac] <> nil then Cevap[Sayac].Free;
end;
Screen.Cursor := crDefault;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
servis1:QueryDocumentWS;
cevap: DocumentQueryResponse;
cevapdty:ResponseDocument;
begin
servis1:=GetQueryDocumentWS(False,hizliservis2,HTTPRIO1);
cevap:=DocumentQueryResponse.Create;
MemoLog.Lines.Add(servis1.QueryOutboxDocument('Envelope_UUID','f661c25c-61ac-4a16-aa8e-5366b8117288','NO').stateExplanation);
ShowMessage(cevap.stateExplanation);
end;
procedure TForm1.HTTPRIO1AfterExecute(const MethodName: string;
SOAPResponse: TStream);
var // bu procedure xml okuyor
StrList1 : TStringList; //işlem tamamlandıktan sonra yani response dolunca
begin
StrList1 := TStringList.Create;
try
SOAPResponse.Seek(0, soFromBeginning);
StrList1.LoadFromStream(SOAPResponse);
LogEkle('CEVAP OLARAK GELEN XML KODLARI' + #13#10#13#10 + StringReplace(StrList1.Text, '><', '>' + #13#10 + '<', [rfReplaceAll]) + #13#10);
finally
FreeAndNil(StrList1);
end;
end;
procedure TForm1.HTTPRIO1BeforeExecute(const MethodName: string;
SOAPRequest: TStream);
var
StrList1: TStringList;
begin
inherited;
StrList1 := TStringList.Create;
try
SOAPRequest.Position := 0;
StrList1.LoadFromStream(SOAPRequest);
LogEkle('GÖNDERİLEN XML KODLARI' + #13#10#13#10 + StringReplace(StrList1.Text, '><', '>' + #13#10 + '<', [rfReplaceAll]) + #13#10);
finally
StrList1.Free;
end;
end;
procedure TForm1.HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp;
Data: Pointer);
var
HeaderStr: string;
begin
HeaderStr := 'Username: ' + HizliUserName;
HttpAddRequestHeaders(Data, PChar(HeaderStr), Length(HeaderStr), HTTP_ADDREQ_FLAG_ADD);
HeaderStr := 'Password: ' + HizliPassword;
HttpAddRequestHeaders(Data, PChar(HeaderStr), Length(HeaderStr), HTTP_ADDREQ_FLAG_ADD);
end;
procedure TForm1.LogEkle(Str1: String);
begin
MemoLog.Lines.Add(FormatDateTime('hh:nn:ss', Now) + ' ' + Str1);
end;
end.