Esempio n. 1
0
        private async void LoadCommentData()
        {
            LoadProgress.IsActive = true;
            if (HttpPostUntil.isInternetAvailable)
            {
                var postdata = HttpPostUntil.GetBasicPostData();
                postdata.Add(new KeyValuePair <string, string>("plateId", "0"));
                postdata.Add(new KeyValuePair <string, string>("messageId", obsdata.messageId));
                var json = await HttpPostUntil.HttpPost(Data.Urls.Playground.getMessageDetail, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata));

                try
                {
                    json = Windows.Data.Json.JsonObject.Parse(json)["data"].GetObject()["commentListBO"].GetObject()["commentBOs"].GetArray().ToString();
                    var comments = Data.Json.DataContractJsonDeSerialize <List <Model.Playground.OBComment> >(json);
                    CommentNum.Text = comments.Count.ToString();
                    if (CommentNum.Text == "0")
                    {
                        NoCommentGrid.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        CommentList.ItemsSource = comments;
                    }
                }
                catch (Exception)
                {
                    NoCommentGrid.Visibility = Visibility.Visible;
                }
            }
            else
            {
                Tools.ShowMsgAtFrame("网络出现异常");
            }
            LoadProgress.IsActive = false;
        }
Esempio n. 2
0
        private async void LoadObsData()
        {
            if (HttpPostUntil.isInternetAvailable)
            {
                var postdata = HttpPostUntil.GetBasicPostData();
                postdata.Add(new KeyValuePair <string, string>("timestamp", timestamp.ToString()));
                postdata.Add(new KeyValuePair <string, string>("studentId", studentId));
                var json = await HttpPostUntil.HttpPost(Data.Urls.user.showMovement, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata));

                try
                {
                    json = JsonObject.Parse(json).GetNamedObject("data").GetNamedArray("messageBOs").ToString();
                    var obs = Data.Json.DataContractJsonDeSerialize <List <Model.Playground.Topic.BOs> >(json);
                    foreach (var item in obs)
                    {
                        myobs.Add(item);
                    }
                    timestamp = obs[obs.Count - 1].issueTime;
                }
                catch (Exception)
                {
                    Tools.ShowMsgAtFrame("没有主题");
                }
            }
            else
            {
                Tools.ShowMsgAtFrame("网络异常");
            }
        }
Esempio n. 3
0
        private async void LikeBtnClicked(object sender, RoutedEventArgs e)
        {
            if (HttpPostUntil.isInternetAvailable)
            {
                var postdata = HttpPostUntil.GetBasicPostData();
                postdata.Add(new KeyValuePair <string, string>("plateId", "0"));
                postdata.Add(new KeyValuePair <string, string>("num", "1"));
                postdata.Add(new KeyValuePair <string, string>("messageId", obsdata.messageId));
                var json = await HttpPostUntil.HttpPost(Data.Urls.Playground.sendlike, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata));

                if (json.Contains("true"))
                {
                    obsdata.likeCount = obsdata.likeCount + 1;
                    obsdata.RaisePropertyChanged("likeCount");
                }
                else
                {
                    Tools.ShowMsgAtFrame("点赞失败");
                }
            }
            else
            {
                Tools.ShowMsgAtFrame("网络出现异常");
            }
        }
        private async void GetAllXueYuan()
        {
            progressBar.Visibility = Visibility.Visible;
            if (HttpPostUntil.isInternetAvailable)
            {
                try
                {
                    var postdata = HttpPostUntil.GetBasicPostData();
                    postdata.Add(new KeyValuePair <string, string>("schoolId", schoolId));
                    var json = await HttpPostUntil.HttpPost(Data.Urls.user.Register.findAcademysBySchoolId, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata), false);

                    json = JsonObject.Parse(json).GetNamedObject("data").GetNamedArray("academyList").ToString();
                    var xueyuan = Data.Json.DataContractJsonDeSerialize <List <XueYuan> >(json);
                    foreach (var item in xueyuan)
                    {
                        allxueyuan.Add(item);
                    }
                    searchBox.IsEnabled = true;
                }
                catch (Exception)
                {
                    Tools.ShowMsgAtFrame("网络异常");
                }
            }
            else
            {
                Tools.ShowMsgAtFrame("网络异常");
            }
            progressBar.Visibility = Visibility.Collapsed;
        }
Esempio n. 5
0
        private async void LoadCommentData(string[] data)
        {
            LoadProgress.IsActive = true;
            if (HttpPostUntil.isInternetAvailable)
            {
                var postdata = HttpPostUntil.GetBasicPostData();
                postdata.Add(new KeyValuePair <string, string>("timestamp", "0"));
                postdata.Add(new KeyValuePair <string, string>("plateId", data[0]));
                postdata.Add(new KeyValuePair <string, string>("commentId", data[1]));
                var json = await HttpPostUntil.HttpPost(Data.Urls.Playground.getmorecomment, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata));

                try
                {
                    json = Windows.Data.Json.JsonObject.Parse(json)["data"].GetObject()["commentBOs"].GetArray().ToString();
                    var comments = Data.Json.DataContractJsonDeSerialize <List <commentData> >(json);
                    for (int i = 0; i < comments.Count; i++)
                    {
                        if (i % 2 == 0)
                        {
                            comments[i].isleft = false;
                        }
                        else
                        {
                            comments[i].isleft = true;
                        }
                    }
                    CommentList.ItemsSource = comments;
                }
                catch (Exception)
                {
                }
            }
            else
            {
                Tools.ShowMsgAtFrame("网络出现异常");
            }
            LoadProgress.IsActive = false;
        }
Esempio n. 6
0
        private async void SendCommentBtnClicked(object sender, RoutedEventArgs e)
        {
            if (SendCommentTextBox.Text != "")
            {
                LoadProgress.IsActive = true;
                if (HttpPostUntil.isInternetAvailable)
                {
                    var postdata = HttpPostUntil.GetBasicPostData();
                    postdata.Add(new KeyValuePair <string, string>("anonymous", isanonymous.IsChecked.ToString()));
                    postdata.Add(new KeyValuePair <string, string>("plateId", "0"));
                    postdata.Add(new KeyValuePair <string, string>("source", "Friday_android"));
                    postdata.Add(new KeyValuePair <string, string>("messageId", obsdata.messageId));
                    postdata.Add(new KeyValuePair <string, string>("content", SendCommentTextBox.Text));
                    var json = await HttpPostUntil.HttpPost(Data.Urls.Playground.sendcomment, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata));

                    if (json.Contains("commentId"))
                    {
                        Tools.ShowMsgAtFrame("评论成功");
                        SendCommentTextBox.Text = "";
                        LoadCommentData();
                    }
                    else
                    {
                        Tools.ShowMsgAtFrame("评论失败");
                    }
                }
                else
                {
                    Tools.ShowMsgAtFrame("网络出现异常");
                }
                LoadProgress.IsActive = false;
            }
            else
            {
                Tools.ShowMsgAtFrame("请输入评论内容");
            }
        }
Esempio n. 7
0
        private async void LoadUserData()
        {
            if (HttpPostUntil.isInternetAvailable)
            {
                var postdata = HttpPostUntil.GetBasicPostData();
                postdata.Add(new KeyValuePair <string, string>("studentId", studentId));
                var json = await HttpPostUntil.HttpPost(Data.Urls.user.getTopInfoById, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata));

                try
                {
                    json = JsonObject.Parse(json).GetNamedObject("data").ToString();
                    var stu = Data.Json.DataContractJsonDeSerialize <Student>(json);
                    topGrid2.DataContext = stu;
                }
                catch (Exception)
                {
                    Tools.ShowMsgAtFrame("没有主题");
                }
            }
            else
            {
                Tools.ShowMsgAtFrame("网络异常");
            }
        }
        private async void GetAllSchools()
        {
            if (HttpPostUntil.isInternetAvailable)
            {
                try
                {
                    var postdata = HttpPostUntil.GetBasicPostData();
                    postdata.Add(new KeyValuePair <string, string>("addTime", "0"));
                    var json = await HttpPostUntil.HttpPost(Data.Urls.user.Register.getUpdateSchoolList, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata), false);

                    json                = JsonObject.Parse(json).GetNamedObject("data").GetNamedArray("schoolBOs").ToString();
                    allschools          = Data.Json.DataContractJsonDeSerialize <List <School> >(json);
                    searchBox.IsEnabled = true;
                }
                catch (Exception)
                {
                    Tools.ShowMsgAtFrame("网络异常");
                }
            }
            else
            {
                Tools.ShowMsgAtFrame("网络异常");
            }
        }
        private async void GetNearSchools()
        {
            progressBar.Visibility = Visibility.Visible;
            if (HttpPostUntil.isInternetAvailable)
            {
                try
                {
label1:
                    Windows.Devices.Geolocation.Geolocator location = new Windows.Devices.Geolocation.Geolocator();
                    try
                    {
                        var position = await location.GetGeopositionAsync();

                        if (position != null)
                        {
                            var postdata = HttpPostUntil.GetBasicPostData();
                            postdata.Add(new KeyValuePair <string, string>("lng", position.Coordinate.Point.Position.Longitude.ToString()));
                            postdata.Add(new KeyValuePair <string, string>("lat", position.Coordinate.Point.Position.Latitude.ToString()));
                            var json = await HttpPostUntil.HttpPost(Data.Urls.user.Register.getRecommendSchoolList, new Windows.Web.Http.HttpFormUrlEncodedContent(postdata), false);

                            json = JsonObject.Parse(json).GetNamedObject("data").GetNamedArray("schoolBOs").ToString();
                            var schools = Data.Json.DataContractJsonDeSerialize <List <School> >(json);
                            if (schools != null)
                            {
                                foreach (var item in schools)
                                {
                                    nearschools.Add(item);
                                }
                            }
                            else
                            {
                                Tools.ShowMsgAtFrame("附近没有学校");
                            }
                        }
                    }
                    catch (Exception)
                    {
                        var dialog = new Windows.UI.Popups.MessageDialog("无法定位,请打开定位开关")
                        {
                            Title = "提示"
                        };
                        dialog.Commands.Add(new Windows.UI.Popups.UICommand("转到设置")
                        {
                            Id = 0
                        });
                        dialog.Commands.Add(new Windows.UI.Popups.UICommand("重试")
                        {
                            Id = 1
                        });
                        dialog.DefaultCommandIndex = 0;
                        var res = await dialog.ShowAsync();

                        if ((int)res.Id == 1)
                        {
                            goto label1;
                        }
                        if ((int)res.Id == 0)
                        {
                            await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-location"));
                        }
                    }
                }
                catch (Exception)
                {
                    Tools.ShowMsgAtFrame("网络异常");
                }
            }
            else
            {
                Tools.ShowMsgAtFrame("网络异常");
            }
            progressBar.Visibility = Visibility.Collapsed;
        }