unit U_SelectLinkMan; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, ADODB, Grids, DBGrids,u_op_seae_DsWebService,my_sys_function, kbmMemTable, dxExEdtr, dxTL, dxDBCtrl, dxDBGrid, dxCntner, StdCtrls, bsSkinCtrls,SoapHTTPClient,InvokeRegistry; type Tfrm_SelectLinkMan = class(TForm) ds1: TDataSource; MT1: TkbmMemTable; MT1UserID: TStringField; MT1USERNAME: TStringField; MT1Mobile: TStringField; MT1Companyid: TStringField; dxDBGrid1: TdxDBGrid; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridColumn; bsSkinPanel3: TbsSkinPanel; edt1: TEdit; Label1: TLabel; dxDBGrid1Column3: TdxDBGridColumn; MT1Email: TStringField; SaveQry: TADOQuery; edt2: TEdit; Label2: TLabel; bsSkinButton8: TbsSkinButton; Label3: TLabel; GetQry: TADOQuery; SaveQry2: TADOQuery; procedure FormShow(Sender: TObject); procedure dxDBGrid1DblClick(Sender: TObject); procedure edt1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure bsSkinButton8Click(Sender: TObject); private XML:String; mServiceSoap_Ds:DsWebServiceSoap; mHttpRIO_ds:THTTPRIO; procedure SaveUserInfo; public procedure GetUserInfo; procedure GetCurrUserInfo; procedure getwebservice_ds; end; var frm_SelectLinkMan: Tfrm_SelectLinkMan; implementation uses crm_spxcompany, u_data_share,u_main; {$R *.dfm} procedure Tfrm_SelectLinkMan.FormShow(Sender: TObject); var str:widestring; begin GetCurrUserInfo; end; procedure Tfrm_SelectLinkMan.GetUserInfo; var _s,url,block,XML,str,PWD:string; UserCount,_i,_j,p1,p2:integer; begin getwebservice_ds; str:=edt1.Text; PWD:=edt2.text; XML:=mServiceSoap_Ds.SearchUser(frm_data_share.AnsiStringToWideString(str,936),frm_data_share.AnsiStringToWideString(PWD,936)); UserCount:= frm_data_share.countString('User',xml); if (UserCount>0) then begin MT1.Close; //写入MT1 for _i:=1 to UserCount do begin p1:=frm_data_share.GettimePotion(_i,'',xml); p2:=frm_data_share.GettimePotion(_i,'',xml); block:=Copy(XML,p1,p2-p1); MT1.Open; MT1.Edit; MT1.Insert; MT1['UserID']:=frm_data_share.GetXMLValue('UserID',block); MT1['USERNAME']:=frm_data_share.GetXMLValue('USERNAME',block); MT1['Mobile']:=frm_data_share.GetXMLValue('Mobile',block); MT1['Companyid']:=frm_data_share.GetXMLValue('Companyid',block); MT1['Email']:=frm_data_share.GetXMLValue('Email',block); MT1.Post; end; end; end; procedure Tfrm_SelectLinkMan.dxDBGrid1DblClick(Sender: TObject); var _t_employee:string; begin end; procedure Tfrm_SelectLinkMan.edt1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (Key=13) then begin bsSkinButton8Click(self); end; end; procedure Tfrm_SelectLinkMan.bsSkinButton8Click(Sender: TObject); var _s,url,block,XML,str,PWD:string; UserCount,_i,_j,p1,p2:integer; begin if (edt1.text='') and (edt2.text='') then begin if MessageDlg('不填写shippingbox登录信息进行同步,即会取消当前用户的同步信息,确定吗',mtWarning,[mbyes,mbno],0)=mryes then begin //用空值同步当前信息 MT1.Delete; MT1.Open; MT1.Edit; MT1.Insert; MT1['UserID']:=''; MT1['USERNAME']:=''; MT1['Mobile']:=''; MT1['Companyid']:=''; MT1['Email']:=''; MT1.Post; SaveQry2.Close; SaveQry2.Parameters.ParamByName('UserID').Value:=MT1.fieldbyname('UserID').asstring; SaveQry2.Parameters.ParamByName('姓名').Value:=employee; SaveQry2.ExecSQL; showmessage('取消成功'); frm_data_share.t_load_employee.close; frm_data_share.t_load_employee.Parameters.ParamByName('姓名').Value:=employee; frm_data_share.t_load_employee.open; end; end else if (length(trim(edt1.text))<8) or (pos('@',edt1.text)=-1) then begin showmessage('请正确填写shippingbox的登陆用户名'); end else begin GetUserInfo; SaveUserInfo; end; end; procedure Tfrm_SelectLinkMan.getwebservice_ds; var URL:String; begin try URL:=get_WebseviceURL; mHttpRIO_ds:=THTTPRIO.Create(nil); mHttpRIO_ds.WSDLLocation:=URL+'?WSDL'; mHttpRIO_ds.URL:=URL; // mHttpRIO_ds.WSDLLocation:='http://192.168.1.5:8086/webservice/DsWebService.asmx?WSDL'; // mHttpRIO_ds.URL:='http://192.168.1.5:8086/webservice/DsWebService.asmx'; mHttpRIO_ds.Port:='DsWebServiceSoap'; mHttpRIO_ds.Service:='DsWebService'; mHttpRIO_ds.HTTPWebNode.UseUTF8InHeader:=true; InvRegistry.RegisterInvokeOptions(TypeInfo(DsWebServiceSoap),ioDocument );//就是这一行 mServiceSoap_Ds:=mHttpRIO_ds as DsWebServiceSoap; except on E:Exception do begin ShowMessage(e.Message); exit; end; end; end; procedure Tfrm_SelectLinkMan.SaveUserInfo; var _t_employee:string; begin //employee if (MT1.RecordCount>0) then begin SaveQry.Close; SaveQry.Parameters.ParamByName('UserID').Value:=MT1.fieldbyname('UserID').asstring; SaveQry.Parameters.ParamByName('Mobile').Value:=MT1.fieldbyname('Mobile').asstring; SaveQry.Parameters.ParamByName('姓名').Value:=employee; SaveQry.ExecSQL; showmessage('同步成功'); _t_employee:=employee; frm_data_share.t_load_employee.close; frm_data_share.t_load_employee.Parameters.ParamByName('姓名').Value:=_t_employee; frm_data_share.t_load_employee.open; end; end; procedure Tfrm_SelectLinkMan.GetCurrUserInfo; var _s,url,block,XML,str,PWD,SPXNO:string; UserCount,_i,_j,p1,p2:integer; begin getwebservice_ds; str:=edt1.Text; PWD:=edt2.text; getqry.close; getqry.Parameters.ParamByName('姓名').Value:=employee; getqry.open; SPXNO:=getqry.fieldbyname('订舱系统序列号').asstring; XML:=mServiceSoap_Ds.GetCurrUserInfo(frm_data_share.AnsiStringToWideString(SPXNO,936)); UserCount:= frm_data_share.countString('User',xml); MT1.Close; //写入MT1 for _i:=1 to UserCount do begin p1:=frm_data_share.GettimePotion(_i,'',xml); p2:=frm_data_share.GettimePotion(_i,'',xml); block:=Copy(XML,p1,p2-p1); MT1.Open; MT1.Edit; MT1.Insert; MT1['UserID']:=frm_data_share.GetXMLValue('UserID',block); MT1['USERNAME']:=frm_data_share.GetXMLValue('USERNAME',block); MT1['Mobile']:=frm_data_share.GetXMLValue('Mobile',block); MT1['Companyid']:=frm_data_share.GetXMLValue('Companyid',block); MT1['Email']:=frm_data_share.GetXMLValue('Email',block); MT1.Post; end; MT1.first; end; end.