Beispiel #1
0
        //取得歷史開獎
        private void useHttpWebRequest_GetHistory()
        {
            //a.hywin888.net hyqa.azurewebsites.net/
            DateTime       dt      = DateTime.Now.AddDays(-2); //最早取前2天
            string         dt1     = dt.Year + dt.Month.ToString("00") + dt.Day.ToString("00");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://hyqa.azurewebsites.net/DrawHistory/GetBySerialNumber?name=" + Game_Function.GameNameToCode(HD_GameSelect.Text) + "&startSerialNumber=" + dt1 + "&endSerialNumber=" + dt1 + "120");

            request.Method      = WebRequestMethods.Http.Get;
            request.ContentType = "application/json";
            #region test in DL
            using (var response = (HttpWebResponse)request.GetResponse())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    using (var stream = response.GetResponseStream())
                        using (var reader = new StreamReader(stream))
                        {
                            var    temp = reader.ReadToEnd();
                            JArray ja   = (JArray)JsonConvert.DeserializeObject(temp);
                            jArr = ja;
                            //處理最近開獎號碼
                            string lastWinPeriod = ja[0]["Issue"].ToString(); //最近開獎的期數

                            if ((lastWinPeriod.Substring(8, 3) == "120" && lblNextPeriod.Text.Substring(8, 3) == "002") ||
                                (lastWinPeriod.Substring(8, 3) == "119" && lblNextPeriod.Text.Substring(8, 3) == "001")) //倒數結束後到完成開獎的空檔 針對跨日( 0404120期>0405002期 或 0404119期>0405001期 )
                            {
                                if (lastWinPeriod.Substring(8, 3) == "120")
                                {
                                    lblCurrentPeriod.Text = lblNextPeriod.Text.Substring(0, 8) + "" + "001"; //當期
                                }
                                else
                                {
                                    lblCurrentPeriod.Text = lastWinPeriod.Substring(0, 8) + "" + "120"; //當期
                                }
                                lblNumber1.Text      = lblNumber2.Text = lblNumber3.Text = lblNumber4.Text = lblNumber5.Text = "?";
                                strHistoryNumberOpen = "?";
                            }
                            else if (Int16.Parse(lblNextPeriod.Text.Substring(8, 3)) - Int16.Parse(lastWinPeriod.Substring(8, 3)) == 2) //倒數結束後到完成開獎的空檔 針對同一日( 0404100期>0404098期 )
                            {
                                lblCurrentPeriod.Text = (Convert.ToInt64(lastWinPeriod) + 1).ToString();                                //當期
                                lblNumber1.Text       = lblNumber2.Text = lblNumber3.Text = lblNumber4.Text = lblNumber5.Text = "?";
                                strHistoryNumberOpen  = "?";
                            }
                            else
                            {
                                lblCurrentPeriod.Text = lastWinPeriod; //當期
                                lblNumber1.Text       = ja[0]["Number"].ToString().Substring(0, 1);
                                lblNumber2.Text       = ja[0]["Number"].ToString().Substring(2, 1);
                                lblNumber3.Text       = ja[0]["Number"].ToString().Substring(4, 1);
                                lblNumber4.Text       = ja[0]["Number"].ToString().Substring(6, 1);
                                lblNumber5.Text       = ja[0]["Number"].ToString().Substring(8, 1);
                                strHistoryNumberOpen  = ja[0]["Number"].ToString().Substring(0, 1);
                            }
                            //處理歷史開獎
                            //strHistory = "";
                            //strHistoryCount = ja.Count.ToString();
                            //for (int i = 0; i < ja.Count; i++)
                            //{
                            //    if (i == 120) break; //寫120筆就好
                            //    strHistory += ja[i]["Issue"].ToString() + "  " + ja[i]["Number"].ToString().Replace(",", " ") + "\r\n";
                            //}
                        }
                }
                else
                {
                }
            }
            #endregion
        }
Beispiel #2
0
        //取得下一期時間
        private void useHttpWebRequest_GetNextPeriod()
        {
            //a.hywin888.net  hyqa.azurewebsites.net
            //HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://a.hywin888.net/Bet/GetCurrentIssueByGameName?name=" + Game_Function.GameNameToCode(HD_GameSelect.Text) + "");
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://hyqa.azurewebsites.net/Bet/GetCurrentIssueByGameName?name=" + Game_Function.GameNameToCode(HD_GameSelect.Text) + "");

            request.Method      = WebRequestMethods.Http.Get;
            request.ContentType = "application/json";

            using (var response = (HttpWebResponse)request.GetResponse())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    using (var stream = response.GetResponseStream())
                        using (var reader = new StreamReader(stream))
                        {
                            var        temp       = reader.ReadToEnd();
                            string     json       = JsonConvert.SerializeObject(temp);
                            NextPeriod NextPeriod = JsonConvert.DeserializeObject <NextPeriod>(temp);

                            if (NextPeriod.SerialNumber == null)
                            {
                                lblNextPeriod.Text = "00000000000";
                                frmGameMain.globalGetCurrentPeriod = "00000000000";
                                lblNextPeriodTime.Text             = "-- : -- : --";
                            }
                            else
                            {
                                lblNextPeriod.Text = NextPeriod.SerialNumber;
                                frmGameMain.globalGetCurrentPeriod = NextPeriod.SerialNumber;
                                DateTime dt1 = Convert.ToDateTime(NextPeriod.CloseTime);
                                DateTime dt2 = DateTime.Now;
                                TimeSpan ts  = new TimeSpan(dt1.Ticks - dt2.Ticks);
                                string   hh  = ts.Hours.ToString("00");
                                string   mm  = ts.Minutes.ToString("00");
                                string   ss  = ts.Seconds.ToString("00");
                                if (ss.IndexOf("-") > -1)
                                {
                                    ss = "00";
                                }
                                lblNextPeriodTime.Text = hh + " : " + mm + " : " + ss;
                            }
                        }
                }
                else
                {
                }
            }
        }