using DevExpress.XtraEditors.TextEditController.Win32;
|
using HStation.RevitDev.RevitDataExport.Common;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.IO;
|
using System.Linq;
|
using System.Net.Http;
|
using System.Security.Cryptography;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace HStation.RevitDev.RevitDataExport.Forms
|
{
|
public partial class Form_Login : Form
|
{
|
public Form_Login()
|
{
|
InitializeComponent();
|
}
|
private void simpleButton1_Click(object sender, EventArgs e)
|
{
|
if (textEdit1.Text == "")
|
{
|
MessageBox.Show("请输入用户名");
|
return;
|
}
|
if (textEdit2.Text == "")
|
{
|
MessageBox.Show("请输入密码");
|
return;
|
}
|
else
|
{
|
|
var loginModel = new
|
{
|
LoginName = textEdit1.Text,
|
LoginPwd = textEdit2.Text,
|
Software = GlobalResource.ConfigSettingModel.Software,
|
};
|
|
try
|
{
|
using (var client = new HttpClient())
|
{
|
var content = new StringContent(JsonHelper.ToJson(loginModel), Encoding.UTF8, "application/json");
|
|
var res = client.PostAsync(GlobalResource.ConfigSettingModel.ApiUrl + "/Auth/User/Login/LoginSoftwareStandardBySystemAccount@V1.0", content)
|
.Result.Content.ReadAsStringAsync().Result;
|
var result = JsonHelper.ToObject<HttpResultModel>(res);
|
if (result.Code == 0 && result.Data.Status == 0)
|
{
|
var rst = JsonHelper.ToObject<JObject>(res);
|
var rsv = rst["Data"];
|
var rv = JsonHelper.ToJson(rsv);
|
if (!File.Exists(GlobalResource.LoginUserFilePath))
|
File.Create(GlobalResource.LoginUserFilePath).Dispose();
|
File.WriteAllText(GlobalResource.LoginUserFilePath, rv);
|
DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
else
|
{
|
MessageBox.Show("登录失败,请重试!");
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
MessageBox.Show("登录失败,请检查网络设置!");
|
}
|
}
|
}
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
}
|
}
|