public VPNItem GetVpnParams() { #region VPN VPNItem vpnItem = new VPNItem(); StringBuilder sb = new StringBuilder(); int i = 1; string vpnName = this.txtVpnName.Text.Trim(); if (!string.IsNullOrEmpty(vpnName)) { vpnItem.EntryName = vpnName; } else { sb.AppendLine(string.Format("{0}、请录入正确的VPN连接名称!", i++)); } string vpnIP = this.txtVpnIP.Text.Trim(); if (!string.IsNullOrEmpty(vpnIP) && TextHelper.IsIP(vpnIP)) { vpnItem.IP = vpnIP; } else { sb.AppendLine(string.Format("{0}、您录入的不是有效的VPN IP地址!", i++)); } string vpnUser = this.txtVpnUser.Text.Trim(); if (!string.IsNullOrEmpty(vpnUser)) { vpnItem.User = vpnUser; } else { sb.AppendLine(string.Format("{0}、请录入正确的VPN登录用户名!", i++)); } string vpnPwd = this.txtVpnPwd.Text.Trim(); if (!string.IsNullOrEmpty(vpnPwd)) { vpnItem.Password = vpnPwd; } else { sb.AppendLine(string.Format("{0}、请录入正确的VPN登录密码!", i++)); } if (sb.Length > 0) { MessageBox.Show(sb.ToString()); return(null); } return(vpnItem); #endregion }
public RouterItem GetRouterItem() { #region Router RouterItem routerItem = new RouterItem(); StringBuilder sb = new StringBuilder(); int i = 1; RouterType routerType = (RouterType)this.comboRouter.SelectedValue; routerItem.RouterType = routerType; string routerIp = this.txtRounterIp.Text.Trim(); if (!string.IsNullOrEmpty(routerIp) && TextHelper.IsIP(routerIp)) { routerItem.IP = routerIp; } else { sb.AppendLine(string.Format("{0}、您录入的不是有效的路由器IP地址!", i++)); } string routerUser = this.txtRouterUser.Text.Trim(); if (!string.IsNullOrEmpty(routerUser)) { routerItem.User = routerUser; } else { sb.AppendLine(string.Format("{0}、请录入正确的路由器登录用户名!", i++)); } string routerPwd = this.txtRouterPwd.Text.Trim(); if (!string.IsNullOrEmpty(routerPwd)) { routerItem.Password = routerPwd; } else { sb.AppendLine(string.Format("{0}、请录入正确的路由器登录密码!", i++)); } if (sb.Length > 0) { MessageBox.Show(sb.ToString()); return(null); } return(routerItem); #endregion }