public static List <DBInfo> GetAllDBs(string strHost, string strPort) { List <DBInfo> lstResult = new List <DBInfo>(); BasicHttpBinding binding = Common.CreateBasicHttpBinding(60); EndpointAddress adress = Common.CreateEndPoint("HTTP", strHost, strPort, "WcfServices", "Service00000"); Service00000Client client = new Service00000Client(binding, adress); try { OperationDataArgs resultArgs = client.OperationMethodA(5, null); if (resultArgs.BoolReturn) { DBInfo dbInfo; DataRow row; int iDBtype = 0; string LStrVerificationCode = Common.CreateVerificationCode(EncryptionAndDecryption.UMPKeyAndIVType.M104); for (int i = 0; i < resultArgs.DataSetReturn.Tables[0].Rows.Count; i++) { row = resultArgs.DataSetReturn.Tables[0].Rows[i]; dbInfo = new DBInfo(); int.TryParse(row["DBType"].ToString(), out iDBtype); dbInfo.DbType = iDBtype; dbInfo.Host = EncryptionAndDecryption.EncryptDecryptString(row["ServerHost"].ToString(), LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M104); dbInfo.Port = EncryptionAndDecryption.EncryptDecryptString(row["ServerPort"].ToString(), LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M104); dbInfo.ServiceName = EncryptionAndDecryption.EncryptDecryptString(row["NameService"].ToString(), LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M104); dbInfo.LoginName = EncryptionAndDecryption.EncryptDecryptString(row["LoginID"].ToString(), LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M104); dbInfo.Password = EncryptionAndDecryption.EncryptDecryptString(row["LoginPwd"].ToString(), LStrVerificationCode, EncryptionAndDecryption.UMPKeyAndIVType.M104); lstResult.Add(dbInfo); } } } catch { } finally { if (client.State == CommunicationState.Opened) { client.Close(); } } return(lstResult); }
/// <summary> /// 根据ObjectID和Page获得对应的语言 /// </summary> /// <param name="strUmpServerPort"></param> /// <param name="strUmpServerHost"></param> /// <param name="strDBHost"></param> /// <param name="strDBPort"></param> /// <param name="strMessageID"></param> /// <returns></returns> public static string GetLanguageItemInDBByObjectIDAndPage(ServerInfomation UmpServer, DBInfo dbInfo, string strObjectID, string strLanCode, string strPage) { string strConnString = string.Empty; switch (dbInfo.DbType) { case (int)Enums.DBType.MSSQL: strConnString = App.CreateMSSqlConnString(dbInfo); break; case (int)Enums.DBType.Oracle: strConnString = App.CreateOracleConnString(dbInfo); break; } string strMessageContent = string.Empty; OperationDataArgs result = new OperationDataArgs(); BasicHttpBinding binding = Common.CreateBasicHttpBinding(60); EndpointAddress adress = Common.CreateEndPoint("HTTP", UmpServer.Host, UmpServer.Port, "WcfServices", "Service00000"); Service00000Client client = new Service00000Client(binding, adress); try { List <string> lstParams = new List <string>(); lstParams.Add(dbInfo.DbType.ToString()); lstParams.Add(strConnString); lstParams.Add(strLanCode); lstParams.Add("M21"); lstParams.Add("0"); lstParams.Add(strPage); result = client.OperationMethodA(8, lstParams); } catch (Exception ex) { result.BoolReturn = false; result.StringReturn = ex.Message; } finally { if (client.State == CommunicationState.Opened) { client.Close(); } } if (result.BoolReturn) { if (result.DataSetReturn.Tables.Count > 0) { List <DataRow> lstRows = result.DataSetReturn.Tables[0].Select("C012 = '" + strObjectID + "'").ToList(); if (lstRows.Count > 0) { strMessageContent = lstRows[0]["C005"].ToString(); } } } return(strMessageContent); }
/// <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); }