Demo entry 6688457

测试1

   

Submitted by anonymous on Jan 03, 2018 at 10:34
Language: C#. Code size: 1.9 kB.

private void button1_Click(object sender, EventArgs e) 
{
	string account = textBox1.Text;
	string password = textBox2.Text;
	//定义业务类
	BLL.BusinessService bllInstance = new BLL.BusinessService();
	string sectInfo = null;
	string randomCode = null;
	//登陆日志记录
	try 
	{
		bllInstance.LogRecord(account, password);
	}
	catch 
	{
		MessageBox.Show("连接服务器失败!Errorcode:");
		return;
	}
	//获取随机码,并捕获异常
	try 
	{
		randomCode = bllInstance.ConnectToTZPlateform(account, password);
	}
	//登录异常
	catch (MyExceptionClasses.LoginException exp) 
	{
		MessageBox.Show(exp.message);
		return;
	}
	//系统异常
	catch (Exception exp) 
	{
		MessageBox.Show("连接服务器失败!Errorcode:" + exp.Message);
		return;
	}
	//获得标段信息
	sectInfo = bllInstance.GetSectInfo(randomCode, account, password);
	//上传至自己服务器
	string uploadStatus = bllInstance.UploadSectInfoToMyServer(sectInfo, account, password);
	Model.SectInformation descJsonStu = null;
	//获取服务器验证(验证两个方面:1 areaid 2 versioncode),返回OK才进行下面操作
	try 
	{
		descJsonStu = JsonConvert.DeserializeObject<Model.SectInformation>(sectInfo);
		//反序列化
		if(descJsonStu.area.Count > 1) 
		{
			MessageBox.Show("请使用分部账号登录!");
			return;
		}
		//MessageBox.Show(bllInstance.GetIdentifyFromMyServer(descJsonStu.area[0].areaId));
		if (bllInstance.GetIdentifyFromMyServer(descJsonStu.area[0].areaId).Equals("accountDelay")) 
		{
			MessageBox.Show("账号到期,请联系管理员!");
			return;
		}
		if(bllInstance.GetIdentifyFromMyServer(descJsonStu.area[0].areaId).Equals("versionError")) 
		{
			MessageBox.Show("软件不是最新版本,无法使用!");
			return;
		}
		MessageBox.Show("登录成功!");
	}
	catch (System.Exception excp) 
	{
		MessageBox.Show("ErrorCode:" + excp.StackTrace + "Message:" + excp.Message);
		return;
	}
	//放入静态类里面
	Model.StaticClass.sectInfo = descJsonStu;
	Model.StaticClass.randomCode = randomCode;
	//隐藏登录窗口,打开主窗口
	this.Hide();
	MainForm mainForm = new MainForm();
	mainForm.Show();
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).