/// <summary> /// 검색엔진의 스칼라 값을 가져온다. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="aColName"></param> /// <param name="aScenario"></param> /// <param name="aQuery"></param> /// <param name="aGroupBy"></param> /// <returns></returns> public IDictionary <string, object> GetScalar <T>(Expression <Func <T, object> > aColName, string aScenario, string aQuery) { IDictionary <string, object> lResult = new Dictionary <string, object>(); int lReturnCode = 0; string lReturnMessage = string.Empty; object lGroupCount; object lOutGroupKeyCount; object lGroupKeyVal; object lGroupSize; int lPageNumber = 1; int lPageSize = 1000; int lStartNum = (lPageNumber - 1) * lPageSize; string lGroupBy = "group by " + ReflectionUtil.GetMemberName(aColName); string lOrderBy = "order by " + ReflectionUtil.GetMemberName(aColName); string lLogInfo = ""; try { if (mClient.BeginSession() < 0) { throw (new KonanException("BeginSession : " + mClient.GetErrorMessage())); } lReturnCode = mClient.SetOption(mClient.OPTION_SOCKET_TIMEOUT_REQUEST, 3 * 60); if (lReturnCode < 0) { throw (new KonanException("SetOption : " + mClient.GetErrorMessage())); } lReturnCode = mClient.Search(DAEMON_SERVICE_ADDRESS, aScenario, string.Format("{0} {1}", aQuery, lGroupBy), lOrderBy, "", lLogInfo, lStartNum, lPageSize, mClient.LC_KOREAN, mClient.CS_EUCKR); if (lReturnCode != 0) { throw (new KonanException("ReturnCode : " + lReturnCode + " Scenario : " + aScenario + "\n Query : " + aQuery)); } if (mClient.GetResult_GroupBy(out lGroupCount, out lOutGroupKeyCount, out lGroupKeyVal, out lGroupSize, 10) < 0) { throw (new KonanException("GetResult_GroupBy:" + mClient.GetErrorMessage())); } for (int i = 0; i < (int)lGroupCount; i++) { var key = (string)((object[, ])lGroupKeyVal)[i, 0]; var val = ((object[])lGroupSize)[i]; lResult.Add(key.ToUpper(), val); } //mTotal = (int)lTotal; } catch (KonanException e) { throw (new KonanException("Unexpected Error : " + e.Message)); } catch (Exception e) { throw (new Exception("Unexpected Error : " + e.Message)); } finally { mClient.EndSession(); } return(lResult); }