jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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)
            {
 
 
            }
        }
    }
}