Beispiel #1
0
 private void SetPageing(ShopSearchRslt aSsr)
 {
     if (aSsr.total < 1)
     {
         this.ucPaging.Visible = false;
     }
     else
     {
         this.ucPaging.Visible = true;
         this.ucPaging.Setting(aSsr.total);
     }
 }
Beispiel #2
0
        private void CreateSearchRsltCtrl(ShopSearchRslt aSsr)
        {
            if (aSsr != null)
            {
                this.SetSearchRsltInfo(aSsr.start, aSsr.display, aSsr.total);

                foreach (ShopItem itm in aSsr.items)
                {
                    ShopControl sc = new ShopControl();

                    sc.Width = this.flpSearchRslt.Width - 25;
                    sc.SetValue(itm);

                    this.flpSearchRslt.Controls.Add(sc);
                }
            }
        }
Beispiel #3
0
        public void Search(bool aNewSearchState)
        {
            if (!this.CheckBeforeSearch())
            {
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                this.ClearSearchBefore(aNewSearchState);

                string subUrl = string.Format("query={0}&display=10&start={1}", this.tbxShopTitle.Text, (this.ucPaging.CurPage.Equals(1) ? 1 : ((this.ucPaging.CurPage - 1) * 10) + 1));
                string url    = "https://openapi.naver.com/v1/search/shop.json?" + subUrl;
                string text   = string.Empty;

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Headers.Add("X-Naver-Client-Id", Definition.ConstValue.ConstValue.NaverClintInfo.ID);
                request.Headers.Add("X-Naver-Client-Secret", Definition.ConstValue.ConstValue.NaverClintInfo.PASS);

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    string status = response.StatusCode.ToString();

                    if (status == "OK")
                    {
                        using (Stream stream = response.GetResponseStream())
                        {
                            using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                            {
                                text = reader.ReadToEnd();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(string.Format("에러 발생! {0}", status), "알림", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                ShopSearchRslt ssr = Newtonsoft.Json.JsonConvert.DeserializeObject <ShopSearchRslt>(text);

                if (ssr.total < 1)
                {
                    MessageBox.Show("검색결과가 존재하지 않습니다.", "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                this.CreateSearchRsltCtrl(ssr);
                this.SetPageing(ssr);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "알림", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }