using HH.WMS.Entitys.Func;
|
using HH.WMS.Entitys.Sys;
|
using HH.WMS.Client.Common;
|
using Newtonsoft.Json;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Management;
|
using System.Net;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
using HH.WMS.Common;
|
|
namespace HH.WMS.Client.frm
|
{
|
public partial class frmLogin : DevComponents.DotNetBar.Metro.MetroForm
|
{
|
public frmLogin()
|
{
|
//Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.NonClientAreaEnabled;
|
EnableGlass = false;
|
InitializeComponent();
|
this.EnableGlass = false;//关键,
|
}
|
|
private void btnLogin_Click(object sender, EventArgs e)
|
{
|
if (string.IsNullOrEmpty(txtUser.Text))
|
{
|
MessageBox.Show("请输入用户名");
|
return;
|
}
|
if (string.IsNullOrEmpty(txtPassword.Text))
|
{
|
MessageBox.Show("请输入密码");
|
return;
|
}
|
var entity = new
|
{
|
userName = txtUser.Text,
|
userPwd = txtPassword.Text,
|
appCode = StaticUtil.AppCode,
|
showType = 2,
|
ip = ""
|
};
|
|
string str = WebApiManager.HttpWMS_Post("/api/Login/Login", JsonConvert.SerializeObject(entity));
|
if (str.Length > 0)
|
{
|
AccountEntity results = JsonConvert.DeserializeObject<AccountEntity>(str);
|
if (results.Code == "0")
|
{
|
StaticUtil.TokenId = results.Token;
|
StaticUtil.User = results.userExt;
|
StaticUtil.User.userCode = txtUser.Text.Trim();
|
StaticUtil.User.userName = results.UserName;
|
GetHostInfo();
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
}
|
else
|
{
|
MessageBox.Show(results.Data);
|
}
|
}
|
else
|
{
|
MessageBox.Show("登录接口不通!");
|
}
|
}
|
|
private void GetHostInfo()
|
{
|
string hostName = Dns.GetHostName(); //获取本机名
|
IPHostEntry localhost = Dns.GetHostByName(hostName); //方法已过期,可以获取IPv4的地址
|
StaticUtil.Ip = localhost.AddressList[0].ToString();
|
|
string strMac = string.Empty;
|
ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
|
ManagementObjectCollection moc = mc.GetInstances();
|
|
foreach (ManagementObject mo in moc)
|
{
|
if ((bool)mo["IPEnabled"] == true)
|
{
|
strMac = mo["MacAddress"].ToString();
|
StaticUtil.Mac = strMac;
|
}
|
}
|
|
StaticUtil.StockCode = InIHelper.ReadConfig<string>("SYS", "仓库");
|
if (!string.IsNullOrEmpty(StaticUtil.StockCode))
|
{
|
string str = WebApiManager.HttpWMS_Get("/api/Strategy/GetOptionValue?stockCode=" + StaticUtil.StockCode);
|
|
OperateResult or = JsonConvert.DeserializeObject<OperateResult>(str);
|
if (or.Status == ResultStatus.Success)
|
{
|
StaticUtil.StrategyList = JsonConvert.DeserializeObject<List<TN_WM_B_STRATEGY_VALUEEntity>>(or.Data.ToString());
|
}
|
else
|
{
|
MessageBox.Show("获取策略值失败!" + or.Msg);
|
}
|
}
|
}
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void llblSet_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
{
|
frmSetServer frm = new frmSetServer();
|
frm.ShowDialog();
|
}
|
|
private void frmLogin_Load(object sender, EventArgs e)
|
{
|
try
|
{
|
Application.VisualStyleState = System.Windows.Forms.VisualStyles.VisualStyleState.NoneEnabled;
|
StaticUtil.ServiceUrl = InIHelper.ReadConfig<string>("SYS", "服务器IP");
|
StaticUtil.AppCode = InIHelper.ReadConfig<string>("SYS", "应用编号");
|
StaticUtil.WorkBench = InIHelper.ReadConfig<string>("SYS", "工作台");
|
StaticUtil.WorkArea = InIHelper.ReadConfig<string>("SYS", "工作库区");
|
StaticUtil.WorkBenchTrayBit = InIHelper.ReadConfig<string>("SYS", "容器站点");
|
if (!string.IsNullOrEmpty(InIHelper.ReadConfig<string>("SYS", "周转台")))
|
{
|
StaticUtil.UniPakBits = InIHelper.ReadConfig<string>("SYS", "周转台").Split(',').ToList<string>();
|
}
|
else
|
{
|
StaticUtil.UniPakBits = null;
|
}
|
if (!string.IsNullOrEmpty(InIHelper.ReadConfig<string>("SYS", "复验台")))
|
{
|
StaticUtil.RecheckBits = InIHelper.ReadConfig<string>("SYS", "复验台").Split(',').ToList<string>();
|
}
|
System.Diagnostics.FileVersionInfo fv = System.Diagnostics.FileVersionInfo.GetVersionInfo("HH.WMS.Client.exe");
|
lblVersion.Text = "Ver:" + fv.ProductVersion;// fv.FileVersion;
|
//lblVersion.Text="Ver:"+System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
|
}
|
catch (Exception)
|
{
|
|
|
}
|
}
|
}
|
}
|