public IPGWMsg(bool s, String t, String c, IPGW_type a) { Success = s; Title = t; Content = c; Type = a; }
private void BDred_PointerExited(object sender, PointerRoutedEventArgs e) { if (!(PageStatus == IPGWstatus.Choosing)) { return; } PageStatus = IPGWstatus.Multing; ConnectType = IPGW_type.None; TXTBLKred.Text = ""; STRBDredDec.Begin(); }
private void BDyellow_PointerEntered(object sender, PointerRoutedEventArgs e) { if (!(PageStatus == IPGWstatus.Multing)) { return; } PageStatus = IPGWstatus.Choosing; ConnectType = IPGW_type.DisconnectAll; TXTBLKyellow.Text = "断开所有连接"; STRBDyellowInc.Begin(); }
private void BDblue_PointerEntered(object sender, PointerRoutedEventArgs e) { if (!(PageStatus == IPGWstatus.Multing)) { return; } PageStatus = IPGWstatus.Choosing; ConnectType = IPGW_type.ConnectFree; TXTBLKblue.Text = "连接免费"; STRBDblueInc.Begin(); }
private void PATHyellow_PointerEntered(object sender, PointerRoutedEventArgs e) { if (PageStatus != IPGWstatus.Multing) { return; } PageStatus = IPGWstatus.Choosing; ConnectType = IPGW_type.ConnectNofree; SetTitle("连接收费地址"); STRBDyellowRoll.Begin(); }
private void PATHgreen_PointerEntered(object sender, PointerRoutedEventArgs e) { if (PageStatus != IPGWstatus.Multing) { return; } PageStatus = IPGWstatus.Choosing; ConnectType = IPGW_type.Disconnect; SetTitle("断开连接"); STRBDgreenRoll.Begin(); }
private void PATHyellow_PointerExited(object sender, PointerRoutedEventArgs e) { if (PageStatus != IPGWstatus.Choosing) { return; } PageStatus = IPGWstatus.Multing; SetTitle("北大网关"); ConnectType = IPGW_type.None; STRBDyellowRoll.Stop(); PROJyellow.RotationY = 0; }
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(); }
public static async Task <IPGWMsg> DoConnection(IPGW_type connectType, String hintString = "") { if (connectType == IPGW_type.None) { return(null); } 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"; } List <Parameters> paramList = new List <Parameters>(); 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")); Parameters result = await WebConnection.Connect("https://its.pku.edu.cn:5428/ipgatewayofpku", paramList); if (!"200".Equals(result.name)) { Util.DealWithDisconnect(result); return(null); } Dictionary <String, String> map = GetReturnMsg(result.value); if (!map.ContainsKey("SUCCESS")) { return(null); } String successMsg = map["SUCCESS"]; bool success = "YES".Equals(successMsg); String title = "", content = ""; switch (connectType) { case IPGW_type.ConnectFree: { if (success) { title = "连接免费地址成功"; } else { title = map["REASON"]; } String scope = ""; if ("f".Equals(map["SCOPE"].Trim())) { scope = "免费地址"; } else if ("international".Equals(map["SCOPE"].Trim())) { scope = "收费地址"; } content = scope + "\n" + "IP: " + map["IP"] + "\n当前连接数:" + map["CONNECTIONS"] + "\n" + "已用时长: " + map["FR_TIME"] + "\n" + "账户余额:" + map["BALANCE"]; } break; case IPGW_type.ConnectNofree: { if (success) { title = "连接收费地址成功"; } else { title = map["REASON"]; } String scope = ""; if ("f".Equals(map["SCOPE"].Trim())) { scope = "免费地址"; } else if ("international".Equals(map["SCOPE"].Trim())) { scope = "收费地址"; } content = scope + "\n" + "IP: " + map["IP"] + "\n当前连接数:" + map["CONNECTIONS"] + "\n" + "已用时长: " + map["FR_TIME"] + "\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(); * } * }*/ } break; case IPGW_type.Disconnect: { if (success) { title = "断开连接成功"; } else { title = "断开连接失败"; content = map["REASON"]; } } break; case IPGW_type.DisconnectAll: { if (success) { title = "断开全部连接成功"; } else { title = "断开全部连接失败"; content = map["REASON"]; } } break; } return(new IPGWMsg(success, title, content, connectType)); }
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; } } } }