private async void GRIDipgwMain_ManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e) { if (!((PageStatus == IPGWstatus.Choosing) || (PageStatus == IPGWstatus.Multing))) { return; } IPGWmain.Opacity = 0.5; if (!(PageStatus == IPGWstatus.Choosing)) { PageStatus = IPGWstatus.Nothing; STRBDconnectEnd.Begin(); return; } PageStatus = IPGWstatus.Connecting; STRBDconnecting.Begin(); TXTBLKblue.Text = ""; TXTBLKgreen.Text = ""; TXTBLKred.Text = ""; TXTBLKyellow.Text = ""; IPGWMsg msg = await IPGWUtil.DoConnection(ConnectType); try { Constants.BoxPage.ShowMessage(msg.Content, msg.Title); } catch { Constants.BoxPage.ShowMessage("连接网关失败!"); } PageStatus = IPGWstatus.Nothing; STRBDconnecting.Stop(); STRBDconnectEnd.Begin(); }
private void IPGWmain_PointerReleased(object sender, PointerRoutedEventArgs e) { if (!(PageStatus == IPGWstatus.Beginning)) { return; } PageStatus = IPGWstatus.Nothing; IPGWmain.Opacity = 0.5; STRBDconnectEnd.Begin(); }
private void Reset() { SetTitle("北大网关"); RectangleGeometry tempRec = PATHslid.Data as RectangleGeometry; Rect re = tempRec.Rect; re.X = HistoryX; re.Y = HistoryY; tempRec.Rect = re; PATHslid.Data = tempRec; PageStatus = IPGWstatus.Nothing; ConnectType = IPGW_type.None; STRBDconnectEnd.Begin(); }
private void ELPSin_PointerReleased(object sender, PointerRoutedEventArgs e) { PageStatus = IPGWstatus.Nothing; STRBDconnectEnd.Begin(); }
private async void DoConnection(IPGW_type connectType, String hintString) { String type = "connect"; String free = "2"; if (connectType == IPGW_type.ConnectNofree) { free = "1"; } else if (connectType == IPGW_type.Disconnect) { type = "disconnect"; } else if (connectType == IPGW_type.DisconnectAll) { type = "disconnectall"; } //if (!Constants.isLogin()) ;//日后加入登录内容 List <Parameters> paramList = new List <Parameters>(); /** * 这两句仅用于测试!!! * 必须改掉! */ //Constants.username = "******"; //Constants.password = "******"; paramList.Add(new Parameters("uid", Constants.username)); paramList.Add(new Parameters("password", Constants.password)); paramList.Add(new Parameters("operation", type)); paramList.Add(new Parameters("range", free)); paramList.Add(new Parameters("timeout", "-1")); Reset(); PageStatus = IPGWstatus.Connecting; STRBDconnectEnd.Begin(); Parameters parameter = await WebConnection.Connect("https://its.pku.edu.cn:5428/ipgatewayofpku", paramList); if (!"200".Equals(parameter.name)) { if ("-1".Equals(parameter.name)) { Constants.BoxPage.ShowMessage("无法连接网络"); } else { Constants.BoxPage.ShowMessage("无法连接到服务器 (HTTP " + parameter.name + ")"); } } else { Dictionary <String, String> map = GetReturnMsg(parameter.value); if (!map.ContainsKey("SUCCESS")) { Constants.BoxPage.ShowMessage("网关连接失败,请重试"); STRBDconnecting.Stop(); return; } String successMsg = map["SUCCESS"]; Boolean success = "YES".Equals(successMsg); if (connectType == IPGW_type.ConnectFree || connectType == IPGW_type.ConnectNofree) { if (success) { String scope = ""; if ("f".Equals(map["SCOPE"].Trim())) { scope = "免费地址"; } else if ("international".Equals(map["SCOPE"].Trim())) { scope = "收费地址"; } hintString = scope + "\r\n" + "IP: " + map["IP"] + "\r\n当前连接数:" + map["CONNECTIONS"] + "\r\n" + "已用时长: " + map["FR_TIME"] + "\r\n" + "账户余额:" + map["BALANCE"]; if (free.Equals("1")) { Boolean whether_get_bing = false; String his_str = Editor.getString("bing_history", ""); try { if (!his_str.Equals("")) { DateTime history = DateTime.Parse(his_str); int span = DateTime.Now.Day - history.Day; if (span >= 1 || span < 0) { whether_get_bing = true; } } else { whether_get_bing = true; } } catch { } if (whether_get_bing) { await GetBingToday(); } } // 显示对话框 //两个Lib的函数?仍然没看懂 Constants.BoxPage.ShowMessage(hintString, "连接状态:已连接"); } else { Constants.BoxPage.ShowMessage(map["REASON"], "连接失败"); //一个Lib的函数,未实现 } STRBDconnecting.Stop(); return; } if (connectType == IPGW_type.Disconnect) { if (success) { Constants.BoxPage.ShowMessage("", "断开连接成功"); } else { Constants.BoxPage.ShowMessage(map["REASON"], "断开连接失败"); STRBDconnecting.Stop(); return; } } if (connectType == IPGW_type.DisconnectAll) { if (success) { Constants.BoxPage.ShowMessage("", "断开全部连接成功"); } else { Constants.BoxPage.ShowMessage(map["REASON"], "断开全部连接失败"); STRBDconnecting.Stop(); return; } } } }