private void IBackgroundWorkerObtainInitTableData_DoWork(object sender, DoWorkEventArgs e) { BasicHttpBinding LBasicHttpBinding = null; EndpointAddress LEndpointAddress = null; Service00001Client LService00001Client = null; string LStrDatabaseVersion = e.Argument as string; List <string> LListStrWcfArguments = new List <string>(); LListStrWcfArguments.Add(LStrDatabaseVersion); LBasicHttpBinding = WebHelper.CreateBasicHttpBinding(); LEndpointAddress = WebHelper.CreateEndpointAddress(App.GClassSessionInfo.AppServerInfo, "Service00001"); OperationDataArgs LWCFOperationReturn = new OperationDataArgs(); LService00001Client = new Service00001Client(LBasicHttpBinding, LEndpointAddress); LWCFOperationReturn = LService00001Client.OperationMethodA(13, LListStrWcfArguments); if (LWCFOperationReturn.BoolReturn) { IDataTableInitTablesData = LWCFOperationReturn.DataSetReturn.Tables[0]; } else { IDataTableInitTablesData = null; } LService00001Client.Close(); LService00001Client = null; }
/// <summary> /// 调用WCF的OperationMthodA(传入的参数多 需整理好再传入时调用) /// </summary> /// <param name="strProtocol"></param> /// <param name="strHost"></param> /// <param name="strPort"></param> /// <param name="strDirName"></param> /// <param name="wcfName"></param> /// <param name="iSeconds"></param> /// <param name="OperationID"></param> /// <param name="lstArgs"></param> /// <returns></returns> public static ReturnResult WCFOperationMthodA(string strProtocol, string strHost, string strPort, int OperationID, List <string> lstArgs) { ReturnResult result = new ReturnResult(); BasicHttpBinding binding = Common.CreateBasicHttpBinding(60); EndpointAddress adress = Common.CreateEndPoint(strProtocol, strHost, strPort, "WcfServices", "Service00001"); Service00001Client client = new Service00001Client(binding, adress); try { result = client.OperationMethodA(OperationID, lstArgs); } catch (Exception ex) { result.BoolReturn = false; result.StringReturn = ex.Message; } finally { if (client.State == CommunicationState.Opened) { client.Close(); } } return(result); }
private void IBackgroundWorkerObtainDatabasesLogins_DoWork(object sender, DoWorkEventArgs e) { BasicHttpBinding LBasicHttpBinding = null; EndpointAddress LEndpointAddress = null; IWCFOperationDataArgs = new OperationDataArgs(); Service00001Client LService00001Client = null; List <string> LListStrDatabaseServerProfile = e.Argument as List <string>; LBasicHttpBinding = WebHelper.CreateBasicHttpBinding(); LEndpointAddress = WebHelper.CreateEndpointAddress(App.GClassSessionInfo.AppServerInfo, "Service00001"); LService00001Client = new Service00001Client(LBasicHttpBinding, LEndpointAddress); IWCFOperationDataArgs = LService00001Client.OperationMethodA(204, LListStrDatabaseServerProfile); LService00001Client.Close(); LService00001Client = null; }
/// <summary> /// 调用WCF的OperationMthodA(传入的参数少 只传数据库连接信息时调用) /// </summary> /// <param name="strProtocol"></param> /// <param name="strHost"></param> /// <param name="strPort"></param> /// <param name="strDirName"></param> /// <param name="wcfName"></param> /// <param name="iSeconds"></param> /// <param name="dbInfo"></param> /// <returns></returns> public static ReturnResult WCFOperationMthodA(string strProtocol, string strHost, string strPort, int OperationID, DBInfo dbInfo) { List <string> lstArgs = new List <string>(); lstArgs.Add(dbInfo.DbType.ToString()); lstArgs.Add(dbInfo.Host); lstArgs.Add(dbInfo.Port); lstArgs.Add(dbInfo.ServiceName); lstArgs.Add(dbInfo.LoginName); lstArgs.Add(dbInfo.Password); BasicHttpBinding binding = Common.CreateBasicHttpBinding(60); //EndpointAddress adress = Common.CreateEndPoint("Http", serverInfo.Host, serverInfo.Port, "WcfServices/WCF_LanguagePackOperation", "LanPackOperation"); EndpointAddress adress = Common.CreateEndPoint(strProtocol, strHost, strPort, "WcfServices", "Service00001"); Service00001Client client = new Service00001Client(binding, adress); ReturnResult result = new ReturnResult(); try { result = client.OperationMethodA(OperationID, lstArgs); } catch (Exception ex) { result.BoolReturn = false; result.StringReturn = ex.Message; } finally { if (client.State == CommunicationState.Opened) { client.Close(); } } client.Close(); return(result); }