예제 #1
0
        public string[,] getPopularKwdAndTag(int doaminNo, int count)
        {
            int i           = 0;
            int rc          = 0;
            int MaxOutCount = 10;       // 인기검색어 리턴 개수(max)

            if (count > 0)
            {
                MaxOutCount = count;
            }

            object out_str   = null;    // 인기검색어 배열
            object out_tag   = null;    // 인기검색어의 태그값 배열
            object out_count = null;    // 리턴 인기검색어 수

            string[,] arr_ppk = null;   // 리턴 이차원배열(인기검색어, 태그)

            // DOCRUZER 객체 생성
            ClientClass crz = new ClientClass();

            try
            {
                // 핸들 생성
                if (crz.BeginSession() < 0)
                {
                    throw (new KonanException("BeginSession : " + crz.GetErrorMessage()));
                }

                //if ("utf8".Equals(INDEX_CHARSET, StringComparison.OrdinalIgnoreCase))
                //{

                //    rc = crz.SetOption(crz.OPTION_REQUEST_CHARSET_UTF8, 1);

                //    if (rc < 0)
                //    {
                //        throw (new KonanException("SetOption : " + crz.GetErrorMessage()));
                //    }
                //}

                //인기 검색어를 추출함. (태그 정보 포함)
                rc = crz.GetPopularKeyword2(DAEMON_SERVICE_ADDRESS, out out_count, out out_str, out out_tag, MaxOutCount, doaminNo);

                if (rc != 0)
                {
                    throw (new KonanException("rc : " + rc + " doaminNo : " + doaminNo + "\n count : " + count));
                }

                if ((int)out_count > 0)
                {
                    arr_ppk = new string[(int)out_count, 2];

                    for (i = 0; i < (int)out_count; i++)
                    {
                        arr_ppk[i, 0] = ((object[])out_str)[i].ToString();
                        if (((object[])out_tag)[i].ToString().Length == 0)
                        {
                            arr_ppk[i, 1] = "&nbsp;";
                        }
                        else
                        {
                            arr_ppk[i, 1] = ((object[])out_tag)[i].ToString();
                        }
                    }
                }
            }
            catch (KonanException e)
            {
                throw (new KonanException("Unexpected Error : " + e.Message));
            }
            catch (Exception e)
            {
                throw (new Exception("Unexpected Error : " + e.Message));
            }
            finally
            {
                // 핸들 삭제
                crz.EndSession();
            }


            return(arr_ppk);
        }