Example #1
0
        private async void Post()
        {
            try
            {
                HttpClient httpClient = new HttpClient();
                var headers = httpClient.DefaultRequestHeaders;
                headers.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 6.2; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
                // 对要post的数据进行编码
                //string zhanpucontent = this.my_zb.Text;
                var content = new FormUrlEncodedContent(new[] {
                    new KeyValuePair<string, string>( "type","1" ),
                    new KeyValuePair<string, string>("id", "1")
                });

                // post请求
                HttpResponseMessage response = await httpClient.PostAsync(postUrl, content);
                // 得到返回信息
                response.EnsureSuccessStatusCode();
                string responseText = await response.Content.ReadAsStringAsync();
                JsonArray allResponse = JsonArray.Parse(responseText);
                int sizeOfJson = allResponse.Count();
                for (int i = 0; i < sizeOfJson; i++)
                {
                    JsonObject jsontemp = allResponse[i].GetObject();
                    Information tem = new Information(jsontemp.GetNamedString("type"));
                    tem.zhanpucontent = jsontemp.GetNamedString("zhanpucontent");
                    tem.paicontent = jsontemp.GetNamedString("paicontent");
                    tem.time = jsontemp.GetNamedString("time");
                    tem.tagid = i.ToString();
                    tem.resultid = jsontemp.GetNamedString("resultid");
                    tem.isshared = "已分享";
                    allinformation.Add(tem);
                }
                this.intro.ItemsSource = allinformation;
            }
            catch (HttpRequestException hre)
            {
                //zhishi.Text = hre.ToString();
            }
            catch (Exception ex)
            {
                // zhishi.Text = ex.ToString();
            }
        }
Example #2
0
        private async void Post()
        {
            try
            {
                HttpClient httpClient = new HttpClient();
                var headers = httpClient.DefaultRequestHeaders;
                headers.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 6.2; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");
                // 对要post的数据进行编码
                Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                Object value = localSettings.Values["userid"];
                string username = value.ToString();
                var content = new FormUrlEncodedContent(new[] {
                    new KeyValuePair<string, string>( "type","0" ),
                    new KeyValuePair<string, string>("id", username)
                });

                // post请求
                HttpResponseMessage response = await httpClient.PostAsync(postUrl, content);
                // 得到返回信
                response.EnsureSuccessStatusCode();
                string responseText = await response.Content.ReadAsStringAsync();
                JsonArray allResponse = JsonArray.Parse(responseText);
                int sizeOfJson = allResponse.Count();
                for (int i = 0; i < sizeOfJson; i++)
                {
                    JsonObject jsontemp  = allResponse[i].GetObject();
                    Information tem = new Information(jsontemp.GetNamedString("type"));
                    tem.zhanpucontent = jsontemp.GetNamedString("zhanpucontent");
                    tem.paicontent = jsontemp.GetNamedString("paicontent");
                    tem.time = jsontemp.GetNamedString("time");
                    tem.tagid = i.ToString();
                    tem.resultid = jsontemp.GetNamedString("resultid");
                    tem.isshared = "已分享";
                    allinformation.Add(tem);
                }

                Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
                StorageFile sampleFile = await localFolder.GetFileAsync("dataFile.txt");
                List<string> example = new List<string>();
                IList<string> tempoflist = await FileIO.ReadLinesAsync(sampleFile);
                for (int i = 0; i < tempoflist.Count(); i++)
                {
                    string first = tempoflist[i];
                    string[] arryofstring = new string[4];
                    int j = 0;
                    for (int k = 0; k < first.Count(); k++)
                    {
                        if (first[k] == '|')
                        {
                            k++;
                            j++;
                        }
                        arryofstring[j] += first[k];
                    }
                    Information tem = new Information(arryofstring[0]);
                    tem.paicontent = arryofstring[1];
                    if (arryofstring[0] == "0")
                    {
                        tem.zhanpucontent = "能测任何事的万用一张占卜牌阵" + "占卜";
                    }
                    else if (arryofstring[0] == "1")
                    {
                        tem.zhanpucontent = "过去现在未来都知道的三角塔罗牌阵" + "占卜";
                    }
                    else
                    {
                        tem.zhanpucontent = "帮助做出选择的必中二选一牌阵" + "占卜";
                    }
                    tem.time = arryofstring[2];
                    tem.tagid = i.ToString();
                    allinformation.Add(tem);
                } 



                    this.intro.ItemsSource = allinformation;
            }
            catch (HttpRequestException hre)
            {
               zhishi.Text = hre.ToString();
            }
            catch (Exception ex)
            {
                zhishi.Text = ex.ToString();
            }
        }
Example #3
0
        //当到达这个页面时,所进行的一些初始化操作
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {

            cl = (Information)e.Parameter;
            this.sq.Text = cl.zhanpucontent;
            this.pz = Convert.ToInt32(cl.paixing);


            //初始化牌的内容
            if (pz == 0)
            {
                b[0] = Convert.ToInt32(cl.paicontent);
            }
            else if (pz == 1)
            {
                int j = 0;
                string temp1 = "", paiconetent1 = cl.paicontent;
                for (int i = 0; i < paiconetent1.Length; i++)
                {
                    if (paiconetent1[i] == ';')
                    {
                        b[j + 1] = Convert.ToInt32(temp1);
                        temp1 = "";
                        i++;
                        j++;
                    }
                    temp1 += paiconetent1[i];
                }
                b[j + 1] = Convert.ToInt32(temp1);
            }
            else
            {
                int j = 0;
                string temp1 = "", paiconetent1 = cl.paicontent;
                for (int i = 0; i < paiconetent1.Length; i++)
                {
                    if (paiconetent1[i] == ';')
                    {
                        b[j + 4] = Convert.ToInt32(temp1);
                        temp1 = "";
                        i++;
                        j++;
                    }
                    temp1 += paiconetent1[i];
                }
                b[j + 1] = Convert.ToInt32(temp1);
            }


            //显示牌
            if (pz == 0)
            {
                //button显示部分
                b1_0.Visibility = Visibility.Visible;
                //解释部分
                js.Text = "我的占卜解释:\n" + JS[b[0]];
            }
            else if (pz == 1)
            {
                //button显示部分
                b3_0.Visibility = Visibility.Visible;
                b3_1.Visibility = Visibility.Visible;
                b3_2.Visibility = Visibility.Visible;
                //解释部分
                js.Text = "我的占卜解释:\n" + "过去的经验:\n" + JS[b[2]] + "现在的状况:\n" + JS[b[3]] + "未来的发展:\n" + JS[b[1]];
            }
            else
            {
                //button显示部分
                b5_0.Visibility = Visibility.Visible;
                b5_1.Visibility = Visibility.Visible;
                b5_2.Visibility = Visibility.Visible;
                b5_3.Visibility = Visibility.Visible;
                b5_4.Visibility = Visibility.Visible;
                //解释部分
                js.Text = "占卜解释:\n" + "自身的状况:\n" + JS[b[8]] + "与A的状况:\n" + JS[b[6]] + "与A的发展:\n" + JS[b[4]] + "与B的状况:\n" + JS[b[7]] + "与B的发展:\n" + JS[b[5]];
            }
            sort0();
            sort1();
            sort2();
            sort3();
            sort4();
            sort5();
            sort6();
            sort7();
            sort8();


            //获取评论
            Post(CommentUrl);
        }
Example #4
0
     int tp;//传给TEXT用来判断放哪个的牌的解释;
        protected override void OnNavigatedTo(NavigationEventArgs e)
         {

             Information cl = (Information)e.Parameter;
             tempForthePage2 = cl;
              pz_3 = cl.paixing[0];
              pz_1 = pz_3 - '0';
         }
Example #5
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     tempFortheBlank6 = (Information)e.Parameter;
 }
Example #6
0
 private void next(object sender, RoutedEventArgs e)
 {
     
     var information = new Information(pz.ToString());
     Frame.Navigate(typeof(BlankPage6), information);
 }