You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
4.4 KiB
Plaintext

unit U_MSG;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,u_op_seae_DsWebService,SoapHTTPClient,InvokeRegistry;
type
Tfrm_MSG = class(TForm)
mmo1: TMemo;
mmo2: TMemo;
btn1: TButton;
procedure FormShow(Sender: TObject);
procedure btn1Click(Sender: TObject);
private
Letter_flag:Integer;
mServiceSoap_Ds:DsWebServiceSoap;
mHttpRIO_ds:THTTPRIO;
XML :String;
public
function GetXML:integer;
end;
var
frm_MSG: Tfrm_MSG;
implementation
uses U_op_seae, u_data_share, u_sys_progress;
procedure Tfrm_MSG.FormShow(Sender: TObject);
var _i,MSGCount,p1,p2:integer;
block:string;
begin
//刷新
MSGCount:= GetXML;
if (MSGCount>0) then begin
mmo1.Clear;
for _i:=1 to MSGCount do begin
p1:=frm_data_share.GettimePotion(_i,'<MSGInfo>',xml);
p2:=frm_data_share.GettimePotion(_i,'</MSGInfo>',xml);
block:=Copy(xml,p1,p2-p1);
mmo1.Lines.Add(frm_data_share.GetXMLValue('SENDERNAME',block)+' '+frm_data_share.GetXMLValue('MSGDate',block));
mmo1.Lines.Add(frm_data_share.GetXMLValue('FieldValue',block));
end;
mmo1.SelStart := Length(mmo1.Text);
mmo1.SelLength:= Length(mmo1.Text);//0;
end;
end;
function Tfrm_MSG.GetXML:integer;
var _s,url,block:string;
p1,p2,MSGCount:integer;
begin
if not ASSIGNED(frm_sys_progress) then
frm_sys_progress:=tfrm_sys_progress.Create(application);
frm_sys_progress.bsSkinGauge1.ProgressText:='正在获取数据请等候。。。';
frm_sys_progress.bsSkinGauge1.MaxValue:=100;
frm_sys_progress.bsSkinGauge1.MinValue:=0;
frm_sys_progress.Show;
frm_sys_progress.bsSkinGauge1.Value:=0;
try
frm_op_seae.getwebservice_ds;
//获取该业务的沟通信息
_s:='<?xml version="1.0" encoding="UTF-8" standalone="no"?> ';
_s:=_s+' <UserInfo xmlns="urn:Declaration:datamodel:standard:CN:MT2101:1"> ';
_s:=_s+' <UserList> ';
_s:=_s+' <User> ';
_s:=_s+' <UserID>'+frm_data_share.t_load_employee.fieldbyname('订舱系统序列号').asstring+'</UserID> ';
// _s:=_s+' <USERNAME>SENDERCOMPANYID</USERNAME> ';
_s:=_s+' <BSNO>'+frm_op_seae.t_op_seae.fieldbyname('订舱序列号').asstring+'</BSNO> ';
_s:=_s+' </User> ';
_s:=_s+' </UserList> ';
_s:=_s+' </UserInfo> ';
//ShowMessage(_s);
XML:=mServiceSoap_Ds.ReceiveMSG(_s);
XML:=StringReplace(XML,'#$A','',[rfReplaceAll]);
p1:=frm_data_share.GettimePotion(1,'<MSGList>',XML);
p2:=frm_data_share.GettimePotion(1,'</MSGList>',xml);
XML:=copy(XML,p1,p2-p1);
//ShowMessage(XML);
MSGcount:= frm_data_share.countString('MSGInfo',xml);
result:= MSGcount;
finally
frm_sys_progress.Close;
frm_sys_progress.Free;
frm_sys_progress:=nil;
if (XML='') then begin
result:=0;
//showmessage('没有连接到服务器');
end;
end;
//if assigned(MT1) then MT1.first;
end;
procedure Tfrm_MSG.btn1Click(Sender: TObject);
var _s,XML :string;
begin
//发出
frm_op_seae.getwebservice_ds;
_s:='<?xml version="1.0" encoding="UTF-8" standalone="no"?>';
_s:=_s+'<BookingMSG xmlns="urn:Declaration:datamodel:standard:CN:MT2101:1">';
_s:=_s+'<MSGList> ';
_s:=_s+' <MSGInfo> ';
_s:=_s+' <SENDERID>'+frm_data_share.t_load_employee.fieldbyname('订舱系统序列号').asstring+'</SENDERID> ';
//_s:=_s+' <SENDERCOMPANYID>SENDERCOMPANYID</SENDERCOMPANYID> ';
//_s:=_s+' <SENDERNAME>SENDERNAME</SENDERNAME> ';
//_s:=_s+' <SENDERCOMPANYNAME>SENDERCOMPANYNAME</SENDERCOMPANYNAME> ';
//_s:=_s+' <RECEIVERID>RECEIVERID</RECEIVERID> ';
//_s:=_s+' <RECEIVERCOMPANYID>RECEIVERCOMPANYID</RECEIVERCOMPANYID> ';
//_s:=_s+' <RECEIVERNAME>RECEIVERNAME</RECEIVERNAME> ';
//_s:=_s+' <RECEIVERCOMPANYNAME>RECEIVERCOMPANYNAME</RECEIVERCOMPANYNAME> ';
_s:=_s+' <BSTYPE>沟通消息</BSTYPE> ';
_s:=_s+' <BSNO>'+frm_op_seae.t_op_seae.fieldbyname('订舱序列号').asstring+'</BSNO> ';
_s:=_s+' <FieldName>信息内容</FieldName> ';
_s:=_s+' <FieldValue>'+mmo2.Lines.Text+'</FieldValue> ';
//_s:=_s+' <MSGDate></MSGDate> ';
//_s:=_s+' <RECDate></RECDate> ';
_s:=_s+' </MSGInfo> ';
_s:=_s+'</MSGList> ';
_s:=_s+'</BookingMSG> ';
XML:=mServiceSoap_Ds.SendMSG(_s);
if (pos('成功',XML)>0) then begin
mmo2.Clear;
frm_MSG.FormShow(Self);
end else begin
showmessage('发送失败');
end;
end;
end.