Example #1
0
        private async void loadBoardList(myParam myparam)
        {

            secName.Text = myparam.boardname;
            string response;
            httputils myhttputils = new httputils();
            response = await myhttputils.GetAsync("http://bbs.jiangnan.edu.cn/rainstyle/boards_json.php?sec=" + myparam.boardid);
            System.Diagnostics.Debug.WriteLine(response);
            if (response.Contains("Error:"))
            {
                MessageDialog md = new MessageDialog("连接错误");
                await md.ShowAsync();
            }
            else
            {
                JsonObject boardlistJson = JsonObject.Parse(response);
                JsonArray boardlistArray = boardlistJson["boards"].GetArray();
                foreach (var singleboard in boardlistArray)
                {
                    string boardname = singleboard.GetObject()["name"].GetString();
                    string boardid = singleboard.GetObject()["id"].GetString();
                    ListViewItem single = new ListViewItem();
                    TextBlock singleText = new TextBlock();
                    singleText.Text = boardname;
                    singleText.Tag = boardid;
                    singleText.FontSize = 32;
                    single.Content = singleText;
                    ListView1.Items.Add(single);
                }
            }
        }
Example #2
0
        private async void loadThread()
        {
            string response;
            httputils myhttputils = new httputils();
            response = await myhttputils.GetAsync("http://bbs.jiangnan.edu.cn/rainstyle/thread_json.php?boardName=" + myparam.threadboard + "&ID=" + myparam.threadid +"&page="+pageNum);

            //string filename = myparam.threadboard + "-" + myparam.threadid + "-page1" + ".html";
            System.Diagnostics.Debug.WriteLine(response);
            //System.Diagnostics.Debug.WriteLine(filename);

            if (response.Contains("Error:"))
            {
                MessageDialog md = new MessageDialog("连接错误");
                await md.ShowAsync();
            }
            else if (response.Contains("{\"status\":0") == false)
            {
                MessageDialog md = new MessageDialog("网站数据错误");
                await md.ShowAsync();
            }
            else
            {

                JsonObject contentJson = JsonObject.Parse(response);

                JsonArray contentArray = contentJson["posts"].GetArray();
                var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

                string myHtml;
                myHtml = "<!DOCTYPE html>\n";
                myHtml = myHtml + "<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\n";
                myHtml = myHtml + "<head>\n";
                myHtml = myHtml + "<meta charset=\"utf-8\" />\n";
                myHtml = myHtml + "<title>" + myparam.threadname + "</title>\n";
                myHtml = myHtml + "<link rel=\"stylesheet\" type=\"text/css\" href=\"ms-appx-web:///Assets/mystyle.css\" />";
                if (localSettings.Values.ContainsKey("IfOverrideLink") == true)
                {
                    Object value = localSettings.Values["IfOverrideLink"];
                    if (value.ToString() == "true")
                    {
                        myHtml = myHtml + "<script src=\"ms-appx-web:///Assets/jquery-1.11.3.min.js\" type=\"text/javascript\" language=\"javascript\"></script>";
                        myHtml = myHtml + "<script src=\"ms-appx-web:///Assets/myjs.js\" type=\"text/javascript\" language=\"javascript\"></script>";
                    }
                }

                myHtml = myHtml + "</head>\n";
                myHtml = myHtml + "<body>\n";
                myHtml = myHtml + "<h1>" + myparam.threadname + "</h1>";
                foreach (var single in contentArray)
                {
                    myHtml = myHtml + "<div>\n";
                    string singleThreadHtml = single.GetObject()["content"].GetString();
                    myHtml = myHtml + singleThreadHtml;
                    myHtml = myHtml + "</div>\n";
                    myHtml = myHtml + "<hr />\n";

                }
                myHtml = myHtml + "</body>\n";
                myHtml = myHtml + "</html>\n";
                myHtml = myHtml.Replace("js/xheditor-1.1.9/xheditor_emot/default/", "ms-appx-web:///Assets/em/");
                myHtml = myHtml.Replace("emot/jn/", "ms-appx-web:///Assets/em/");
                myHtml = myHtml.Replace("downip.php", "http://bbs.jiangnan.edu.cn/rainstyle/bbscon.php");


                if (localSettings.Values.ContainsKey("IfLoadImg") == true)
                {
                    Object value2 = localSettings.Values["IfLoadImg"];
                    if (value2.ToString() == "true")
                    {
                        if (localSettings.Values.ContainsKey("imgQuality") == true)
                        {
                            Object value3 = localSettings.Values["imgQuality"];
                            if (value3.ToString() == "origin")
                            {
                                myHtml = myHtml.Replace("/attachments/", "http://bbs.jiangnan.edu.cn/attachments/");
                            }
                            else if (value3.ToString() == "mid")
                            {
                                myHtml = myHtml.Replace("/attachments/", "https://jnrainbbs-bookjnrain.rhcloud.com/attachments-mid/");
                            }
                            else
                            {
                                myHtml = myHtml.Replace("/attachments/", "https://jnrainbbs-bookjnrain.rhcloud.com/attachments-small/");
                            }
                        }
                        else
                        {
                            myHtml = myHtml.Replace("/attachments/", "http://bbs.jiangnan.edu.cn/attachments/");
                        }                        
                    }
                }
                System.Diagnostics.Debug.WriteLine(myHtml);

                /*StorageFolder d = await ApplicationData.Current.LocalFolder.CreateFolderAsync("folder", CreationCollisionOption.OpenIfExists);
                StorageFile htmlFile = await d.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
                await FileIO.WriteTextAsync(htmlFile, myHtml);
                System.Diagnostics.Debug.WriteLine(ApplicationData.Current.LocalFolder.Path);
                Uri filepath = new Uri("ms-appdata:///local/folder/"+filename);
                //WebView1.Navigate(filepath);*/
                WebView1.NavigateToString(myHtml);


            }
        }
Example #3
0
        private async void clearButton_Click(object sender, RoutedEventArgs e)
        {
            loadStarted();
            httputils myhttputils = new httputils();
            string message = await myhttputils.GetAsync("http://bbs.jiangnan.edu.cn/rainstyle/apilogout.php");
            string message2= await myhttputils.GetAsync("https://jnrainbbs-bookjnrain.rhcloud.com/clear/" + accountTextBox.Text + "/" + passwdTextBox.Password);
            loadCompleted();
            if (message == "{\"status\":0}")
            {
                var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

                localSettings.Values["logined"] = "false";
                System.Diagnostics.Debug.WriteLine("注销成功");
            }
            if (message2 == "清除成功")
            {
                MessageDialog md = new MessageDialog("可以了");
                await md.ShowAsync();
            }
            else
            {
                MessageDialog md = new MessageDialog("连接错误或密码不正确");
                await md.ShowAsync();
            }
        }
Example #4
0
        private async void logoutButton_Click(object sender, RoutedEventArgs e)
        {
            loadStarted();
            httputils myhttputils = new httputils();
            string message = await myhttputils.GetAsync("http://bbs.jiangnan.edu.cn/rainstyle/apilogout.php");
            loadCompleted();
            if (message == "{\"status\":0}")
            {
                var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

                localSettings.Values["logined"] = "false";
                MessageDialog md = new MessageDialog("注销成功");
                await md.ShowAsync();
            }
            else
            {
                MessageDialog md = new MessageDialog("连接错误");
                await md.ShowAsync();
            }
        }
        private async void loadThreadList()
        {
            ListView1.Items.Clear();
            boardName.Text = myparam.boardname;
            httputils myhttputils = new httputils();
            string response = await myhttputils.GetAsync("http://bbs.jiangnan.edu.cn/rainstyle/board_json.php?name=" + myparam.boardid + "&page="+pageNum);
            System.Diagnostics.Debug.WriteLine(response);
            if (response.Contains("Error:"))
            {
                MessageDialog md = new MessageDialog("连接错误");
                await md.ShowAsync();
            }
            else if (response.Contains("{\"status\":0") == false)
            {
                MessageDialog md = new MessageDialog("网站数据错误");
                await md.ShowAsync();
            }
            else
            {
                JsonObject contentJson = JsonObject.Parse(response);
                JsonArray contentArray = contentJson["posts"].GetArray();
                foreach (var single in contentArray)
                {
                    myParam2 myparam2 = new myParam2();
                    JsonObject myjson = single.GetObject();

                    try
                    {
                        string threadTitle = myjson["title"].GetString();
                        string threadBoard = myjson["board"].GetString();
                        string threadId=String.Empty;
                        if (myjson["id"].ValueType.ToString() == "Number")
                        {
                            threadId = myjson["id"].GetNumber().ToString();
                        }
                        else if (myjson["id"].ValueType.ToString() == "String")
                        {
                            threadId = myjson["id"].GetString();
                        }
                        myparam2.threadboard = threadBoard;
                        myparam2.threadid = threadId;
                        myparam2.threadname = threadTitle;
                        ListViewItem singleItem = new ListViewItem();
                        TextBlock singleText = new TextBlock();
                        singleText.TextWrapping = TextWrapping.Wrap;
                        singleText.Text = threadTitle;
                        singleText.Tag = myparam2;
                        singleText.FontSize = 24;
                        singleItem.Content = singleText;
                        ListView1.Items.Add(singleItem);
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                    }

                }

            }
        }