public UdtServiceInfo JsonParser(string sJson) { UdtServiceInfo udtServiceInfo = new UdtServiceInfo(); JObject jObject = JObject.Parse(sJson); udtServiceInfo.ServiceName = jObject["ServiceName"].ToString(); udtServiceInfo.InputType = jObject["InputType"].ToString(); udtServiceInfo.ReturnType = jObject["ReturnType"].ToString(); udtServiceInfo.ConnectName = jObject["ConnectName"].ToString(); udtServiceInfo.IpAddress = jObject["IpAddress"].ToString(); JObject paramObject = (JObject)jObject["DicParams"]; Dictionary <string, string> dicParmas = new Dictionary <string, string>(); foreach (var item in paramObject) { dicParmas.Add(item.Key, item.Value.ToString()); } udtServiceInfo.DicParams = dicParmas; return(udtServiceInfo); }
/// <summary> /// xml을 분석하여 데이터 정리 후 리턴 /// </summary> /// <param name="sXml"></param> /// <returns>기본 속성을 포함 한 형태의 클래스 지정 후 반환 /// 기본 형태는 추후 작성</returns> public UdtServiceInfo XmlParser(string sXml) { UdtServiceInfo udtServiceInfo = new UdtServiceInfo(); //0.xml에서 데이터 추출 //0.udtServiceInfo에 데이터 넣기 XElement xElement = XElement.Parse(sXml); udtServiceInfo.ServiceName = xElement.Element("ServiceName").Value; udtServiceInfo.InputType = xElement.Element("InputType").Value; udtServiceInfo.ReturnType = xElement.Element("ReturnType").Value; udtServiceInfo.ConnectName = xElement.Element("ConnectName").Value; udtServiceInfo.IpAddress = xElement.Element("IpAddress").Value; XElement paramElement = xElement.Element("DicParams"); Dictionary <string, string> dicParmas = new Dictionary <string, string>(); foreach (var item in paramElement.Elements()) { dicParmas.Add(item.Name.ToString(), item.Value); } udtServiceInfo.DicParams = dicParmas; return(udtServiceInfo); }
private string JsonComm(string sInputJson) { string sResult = string.Empty; // 0. sInputJson 분석 후 데이터 정리(서비스 명, 파라미터 등) UdtServiceInfo udtServiceInfo = typeParser.JsonParser(sInputJson); // return type 정리 // 1. DB or Service 통신 후 데이터 획득 하여 arrData에 저장 // DB 통신 테스트 EntityConnecter.DbService dbService = new EntityConnecter.DbService(); List <Dictionary <string, string> > dicResult = new List <Dictionary <string, string> >(); List <string> arrTempResult = TypeParser.XmlToList(ConnectDll(udtServiceInfo)); for (int i = 0; i < arrTempResult.Count; i++) { dicResult.Add(TypeParser.XmlToDictionary(arrTempResult[i])); } // 2. 데이터 활용 해서 ConvertMessageType 함수로 메세지 타입에(XML or Json) 맞춰 조립 // 0 : XML, 1: JSON, 2 : String sResult = ConvertMessageType(udtServiceInfo, dicResult); return(sResult); }
/// <summary> /// Return Type, Paramater 받아서 Xml, Json, String으로 결과값 반환 /// </summary> /// <param name="serviceInfo"></param> /// <returns>결과값</returns> private string ConvertMessageType(UdtServiceInfo serviceInfo, List <Dictionary <string, string> > arrDicResult) { string sResult = "지원하지 않는 반환 형식입니다."; List <string> arrResult = new List <string>(); if (serviceInfo.ReturnType.Equals("JSON")) { for (int i = 0; i < arrDicResult.Count; i++) { arrResult.Add(TypeParser.DictionaryToJson(arrDicResult[i])); } sResult = TypeParser.ListToJson(arrResult); } else if (serviceInfo.ReturnType.Equals("XML")) { for (int i = 0; i < arrDicResult.Count; i++) { arrResult.Add(TypeParser.DictionaryToXml(arrDicResult[i])); } sResult = TypeParser.ListToXml(arrResult); } else { sResult = "지원하지 않는 반환 형식입니다."; } return(sResult); }
/// <summary> /// 클론 생성 함수 /// </summary> /// <returns></returns> public UdtServiceInfo Clone() { UdtServiceInfo cloneUdtServiceInfo = new UdtServiceInfo(); cloneUdtServiceInfo.ServiceName = this.ServiceName; cloneUdtServiceInfo.InputType = this.InputType; cloneUdtServiceInfo.ReturnType = this.ReturnType; cloneUdtServiceInfo.DicParams = this.DicParams; cloneUdtServiceInfo.ConnectName = this.ConnectName; cloneUdtServiceInfo.IpAddress = this.IpAddress; return(cloneUdtServiceInfo); }
private string ConnectDll(UdtServiceInfo serviceInfo) { // dll 에서 호출 필요한 데이터들 줌 // 함수명은 뭔지 모름 return(dbService.CallQuery(serviceInfo.ServiceName, serviceInfo.IpAddress, serviceInfo.DicParams)); }