Exemple #1
0
        private void LoginAction()
        {
            //网络登录
            object obj = LoginHelper.Login(tbUsername.Text.Trim(), tbPassword.Text.Trim(), cbNetType.Text);

            if (obj == null)
            {
                logoutPanel(false);
                setLoginResult(false, "连接失败!请检查网络类型后重新尝试!");
                btnLogin.Enabled = true;
                return;
            }

            if (cbNetType.Text == "实验室网络")
            {
                LoginHelper.labNetResponse netResponse = (LoginHelper.labNetResponse)obj;
                labAnalysis(netResponse);
            }
            else if (cbNetType.Text == "联通服务" || cbNetType.Text == "校园网服务" || cbNetType.Text == "电信服务")
            {
                LoginHelper.dormNetResponse netResponse = (LoginHelper.dormNetResponse)obj;
                dormAnalysis(netResponse);
            }
            if (ckbReConnect.Checked && !beenLogin)
            {
                tSecond.Enabled = true;
            }
            else
            {
                tSecond.Enabled    = false;
                seconds            = userconfig.reconnectTime;
                times              = userconfig.recoonceMaxNum;
                lblReconnMess.Text = "";
            }
        }
Exemple #2
0
        //解析实验室网络登录结果
        private void labAnalysis(LoginHelper.labNetResponse netResponse)
        {
            string message = "";

            if (netResponse.reply_code == 1 || netResponse.reply_code == 6)
            {
                logoutPanel(beenLogin = true);
                long     unixTimeStamp = long.Parse(netResponse.userinfo.acctstarttime);
                DateTime startTime     = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
                DateTime dt            = startTime.AddSeconds(unixTimeStamp);
                message = "您好!欢迎进入南京师范大学校园网\r\n" +
                          "登录时间:" + dt.ToString("yyyy/MM/dd HH:mm") +
                          "\r\n当前IP:" + IntToIp(long.Parse(netResponse.userinfo.useripv4));
            }
            else
            {
                logoutPanel(beenLogin = false);
                message = "code " + netResponse.reply_code + ":" + netResponse.reply_msg;
            }
            setLoginResult(beenLogin, message);
        }