/// <summary> /// 通过BPSV类型对象获取代理类型对象 /// </summary> /// <param name="bpsvType"></param> /// <returns></returns> public ReturnMessage <ProxyType> GetProxyType(BPSVType bpsvType) { if (bpsvType == null) { throw new ProxyServiceException("bpsvType is null"); } if (string.IsNullOrEmpty(bpsvType.AssemblyName)) { throw new ProxyServiceException("bpsvType.AssemblyName is empty"); } if (string.IsNullOrEmpty(bpsvType.FullName)) { throw new ProxyServiceException("bpsvType.FullName is empty"); } //代理类dll string proxyAssemblyName = (bpsvType.AssemblyName.ToLower().EndsWith(".dll") ? bpsvType.AssemblyName.Substring(0, bpsvType.AssemblyName.Length - 4) : bpsvType.AssemblyName) + ".Agent.dll"; Assembly assembly = TypeManager.TypeLoader.ProbeAssembly(proxyAssemblyName); if (assembly == null) { throw new ProxyServiceException(string.Format("Assembly {0} is not exist", proxyAssemblyName)); } string[] arrFullName = bpsvType.FullName.Split('.'); string proxyClassName = arrFullName[arrFullName.Length - 1] + "Proxy"; string agentTypeFullName = string.Join(".", arrFullName.Take(arrFullName.Length - 1)) + ".Proxy." + proxyClassName; Type agentType = null; List <Type> types = new List <Type>(); foreach (Type searchType in assembly.GetTypes()) { if (searchType.FullName == agentTypeFullName) { agentType = searchType; break; } if (searchType.Name == proxyClassName && searchType.IsSubclassOf(typeof(ProxyBase))) { types.Add(searchType); } } if (agentType == null) { if (types.Count == 0) { throw new ProxyServiceException(string.Format("className: {0} in {1} no exist", proxyClassName, proxyAssemblyName)); } if (types.Count > 1) { throw new ProxyServiceException(string.Format("className: {0} in {1} no only one", proxyClassName, proxyAssemblyName)); } agentType = types[0]; } ProxyType proxyType = new ProxyType(); proxyType.AssemblyName = proxyAssemblyName; proxyType.FullName = agentType.FullName; proxyType.InMaxExpandDepth = ProxyJsonHelper.DefaultInMaxWritingDepth; proxyType.OutMaxExpandDepth = ProxyJsonHelper.DefaultOutMaxWritingDepth; ReturnMessage <ProxyType> ret = new ReturnMessage <ProxyType>(); ret.Result = proxyType; ret.IsSuccess = true; return(ret); }
/// <summary> /// 查询服务信息 /// </summary> /// <param name="bpsvTypeQuery"></param> /// <returns></returns> public ReturnMessage <List <BPSVType> > QueryBPSVType(BPSVTypeQuery bpsvTypeQuery) { if (bpsvTypeQuery == null) { throw new ArgumentException("bpsvTypeQuery is null"); } if (string.IsNullOrWhiteSpace(bpsvTypeQuery.QueryStr)) { throw new ArgumentException("bpsvTypeQuery.QueryStr is empty"); } string[] arrQueryStr = bpsvTypeQuery.QueryStr.Split(' '); StringBuilder sb = new StringBuilder(); sb.Append(@"SELECT B.DisplayName, A.FullName, C.AssemblyName, C.Kind FROM UBF_MD_Class AS A LEFT JOIN UBF_MD_Class_Trl AS B ON A.Local_ID = B.Local_ID LEFT JOIN UBF_MD_Component AS C ON A.MD_Component_ID = C.ID LEFT JOIN UBF_MD_Component_Trl AS D ON C.Local_ID = D.Local_ID WHERE ( C.Kind = 'SV' OR C.Kind = 'BP' ) AND ("); StringBuilder fullNameSb = new StringBuilder(); StringBuilder displayNameSb = new StringBuilder(); fullNameSb.Append("("); displayNameSb.Append("("); bool isFirst = true; DataParamList dataParams = new DataParamList(); for (int i = 0; i < arrQueryStr.Length; i++) { string str = arrQueryStr[i]; string paramName = "param" + i; if (string.IsNullOrWhiteSpace(str)) { continue; } if (!isFirst) { fullNameSb.Append(" AND "); displayNameSb.Append(" AND "); } fullNameSb.AppendFormat("A.FullName LIKE @{0}", paramName); displayNameSb.AppendFormat("B.DisplayName LIKE @{0}", paramName); dataParams.Add(DataParamFactory.CreateInput(paramName, string.Format("%{0}%", str), DbType.String)); isFirst = false; } fullNameSb.Append(")"); displayNameSb.Append(")"); sb.Append(fullNameSb + " OR " + displayNameSb); sb.Append(")"); DataSet dataSet; DataAccessor.RunSQL(DatabaseManager.GetCurrentConnection(), sb.ToString(), dataParams, out dataSet); List <BPSVType> list = new List <BPSVType>(); if (dataSet != null && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0) { foreach (DataRow row in dataSet.Tables[0].Rows) { BPSVType bpsv = new BPSVType(); bpsv.DisplayName = AsString(row, "DisplayName"); bpsv.FullName = AsString(row, "FullName"); bpsv.AssemblyName = AsString(row, "AssemblyName"); bpsv.Kind = AsString(row, "Kind"); list.Add(bpsv); } } ReturnMessage <List <BPSVType> > ret = new ReturnMessage <List <BPSVType> >(); ret.Result = list; ret.IsSuccess = true; return(ret); }