MES登录接口设置
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
using System;
|
using JY.Inspection.Enums;
|
||||||
|
using JY.Inspection.Mes;
|
||||||
|
using JY.MES.Entity;
|
||||||
|
using JY.MES.MES;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -36,14 +41,11 @@ namespace JY.Inspection.Common
|
|||||||
///
|
///
|
||||||
[Display(Name = "密码")]
|
[Display(Name = "密码")]
|
||||||
public string PassWord { get; set; }
|
public string PassWord { get; set; }
|
||||||
/// <summary>
|
|
||||||
/// 权限
|
|
||||||
/// </summary>
|
|
||||||
///
|
|
||||||
[Display(Name = "权限")]
|
[Display(Name = "权限")]
|
||||||
public Autuority Level { get; set; }
|
public Autuority Level { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 权限枚举
|
/// 权限枚举
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -54,7 +56,6 @@ namespace JY.Inspection.Common
|
|||||||
操作员,//操作员
|
操作员,//操作员
|
||||||
Empty,
|
Empty,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserHelper
|
public class UserHelper
|
||||||
{
|
{
|
||||||
private string filePath = string.Empty;
|
private string filePath = string.Empty;
|
||||||
@@ -292,5 +293,52 @@ namespace JY.Inspection.Common
|
|||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用MES员工信息接口校验登录信息
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public User CheckMesUserLogin(string userName, string passWord, ref string strErr)
|
||||||
|
{
|
||||||
|
User user = null;
|
||||||
|
|
||||||
|
ReqLoginMes req = new ReqLoginMes()
|
||||||
|
{
|
||||||
|
SiteCode = Global.systemConfig.siteCode,
|
||||||
|
LineCode = Global.systemConfig.lineCode,
|
||||||
|
EquipNum = Global.systemConfig.equipCode,
|
||||||
|
UserName = userName,
|
||||||
|
PassWord = passWord,
|
||||||
|
UserCardID = string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
string strJson = JsonConvert.SerializeObject(req);
|
||||||
|
|
||||||
|
MesCallResult<RespLoginMes> result = new MESDataCombin().LoginMes(req);
|
||||||
|
|
||||||
|
if (result.IsSuccess && result.OriResponse?.Rows.Length == 1)
|
||||||
|
{
|
||||||
|
// TODO 权限转化
|
||||||
|
string levelStr = result.OriResponse.Rows[0].PermissionLevel;
|
||||||
|
|
||||||
|
bool resultLevel = Int32.TryParse(levelStr, out int level);
|
||||||
|
if (!resultLevel)
|
||||||
|
{
|
||||||
|
strErr = $"权限转化失败,权限值为:{levelStr}";
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
user = new User() {
|
||||||
|
UserName = result.OriResponse.Rows[0].Username,
|
||||||
|
Level = level.ToEnum<EnumAutority>().MapperEnum()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strErr = string.IsNullOrEmpty(result.OriResponse?.Message) ? result.ErrorMessage : result.OriResponse?.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户权限
|
||||||
|
/// </summary>
|
||||||
|
public enum EnumAutority
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 管理员
|
||||||
|
/// </summary>
|
||||||
|
[Description("管理员")]
|
||||||
|
Administrator = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 工程师
|
||||||
|
/// </summary>
|
||||||
|
[Description("工程师")]
|
||||||
|
Engineer = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 操作员
|
||||||
|
/// </summary>
|
||||||
|
[Description("操作员")]
|
||||||
|
Operator = 3,
|
||||||
|
|
||||||
|
None = 4
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
using JY.Inspection.Common;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Enums
|
||||||
|
{
|
||||||
|
public static class EnumExtension
|
||||||
|
{
|
||||||
|
// 输入枚举,获取其Description属性对应的名称
|
||||||
|
public static string GetDescription(this Enum value)
|
||||||
|
{
|
||||||
|
FieldInfo field = value.GetType().GetField(value.ToString());
|
||||||
|
if (field != null)
|
||||||
|
{
|
||||||
|
DescriptionAttribute attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
|
||||||
|
if (attribute != null)
|
||||||
|
{
|
||||||
|
return attribute.Description;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 输入数字,转化成对应的枚举
|
||||||
|
public static T ToEnum<T>(this int value)
|
||||||
|
{
|
||||||
|
return (T)Enum.ToObject(typeof(T), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Autuority MapperEnum(this EnumAutority srcEnum)
|
||||||
|
{
|
||||||
|
switch (srcEnum)
|
||||||
|
{
|
||||||
|
case EnumAutority.Administrator:
|
||||||
|
return Autuority.管理员;
|
||||||
|
|
||||||
|
case EnumAutority.Engineer:
|
||||||
|
return Autuority.工程师;
|
||||||
|
|
||||||
|
case EnumAutority.Operator:
|
||||||
|
return Autuority.操作员;
|
||||||
|
|
||||||
|
case EnumAutority.None:
|
||||||
|
return Autuority.Empty;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return Autuority.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -43,7 +43,6 @@ namespace JY.Inspection.Frm
|
|||||||
TimeSpan ts = _tempDt.Subtract(_dt);
|
TimeSpan ts = _tempDt.Subtract(_dt);
|
||||||
if (ts.Milliseconds > 100)
|
if (ts.Milliseconds > 100)
|
||||||
{
|
{
|
||||||
|
|
||||||
txtPassword2.Text = "";//清空
|
txtPassword2.Text = "";//清空
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -75,7 +74,6 @@ namespace JY.Inspection.Frm
|
|||||||
}
|
}
|
||||||
private void btLogin_Click(object sender, EventArgs e)
|
private void btLogin_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(txtUserID.Text) | string.IsNullOrEmpty(txtPassWord.Text))
|
if (string.IsNullOrEmpty(txtUserID.Text) | string.IsNullOrEmpty(txtPassWord.Text))
|
||||||
{
|
{
|
||||||
txtUserID.Focus();
|
txtUserID.Focus();
|
||||||
@@ -84,12 +82,31 @@ namespace JY.Inspection.Frm
|
|||||||
}
|
}
|
||||||
UserHelper helper = new UserHelper("");
|
UserHelper helper = new UserHelper("");
|
||||||
string strErr = "";
|
string strErr = "";
|
||||||
var res = helper.CheckUserLogin("user.pt", txtUserID.Text.Trim(), txtPassWord.Text.Trim(), ref strErr);
|
|
||||||
|
User res = null;
|
||||||
|
|
||||||
|
if (check_isMesLogin.Checked)
|
||||||
|
{
|
||||||
|
res = helper.CheckMesUserLogin(txtUserID.Text.Trim(), txtPassWord.Text.Trim(), ref strErr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = helper.CheckUserLogin("user.pt", txtUserID.Text.Trim(), txtPassWord.Text.Trim(), ref strErr);
|
||||||
|
}
|
||||||
|
|
||||||
if (res == null)
|
if (res == null)
|
||||||
{
|
{
|
||||||
txtPassWord.Focus();
|
txtPassWord.Focus();
|
||||||
loginFailedCount++;
|
loginFailedCount++;
|
||||||
MessageBox.Show($"用户名或密码不正确,登录失败({loginFailedCount})次!", "系统提示");
|
if (check_isMesLogin.Checked)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"使用MES账户登录失败,错误信息: {strErr}!", "系统提示");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show($"用户名或密码不正确,登录失败({loginFailedCount})次!", "系统提示");
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Generated
+29
-13
@@ -42,6 +42,7 @@ namespace JY.Inspection.Frm
|
|||||||
this.pLogin_card = new System.Windows.Forms.Panel();
|
this.pLogin_card = new System.Windows.Forms.Panel();
|
||||||
this.lblICCard = new MetroFramework.Controls.MetroLabel();
|
this.lblICCard = new MetroFramework.Controls.MetroLabel();
|
||||||
this.txtPassword2 = new MetroFramework.Controls.MetroTextBox();
|
this.txtPassword2 = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.check_isMesLogin = new MetroFramework.Controls.MetroCheckBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
this.pLogin_pwd.SuspendLayout();
|
this.pLogin_pwd.SuspendLayout();
|
||||||
this.pLogin_card.SuspendLayout();
|
this.pLogin_card.SuspendLayout();
|
||||||
@@ -51,7 +52,7 @@ namespace JY.Inspection.Frm
|
|||||||
//
|
//
|
||||||
this.chkIsSK.AutoSize = true;
|
this.chkIsSK.AutoSize = true;
|
||||||
this.chkIsSK.Location = new System.Drawing.Point(237, 390);
|
this.chkIsSK.Location = new System.Drawing.Point(237, 390);
|
||||||
this.chkIsSK.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.chkIsSK.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.chkIsSK.Name = "chkIsSK";
|
this.chkIsSK.Name = "chkIsSK";
|
||||||
this.chkIsSK.Size = new System.Drawing.Size(168, 17);
|
this.chkIsSK.Size = new System.Drawing.Size(168, 17);
|
||||||
this.chkIsSK.TabIndex = 20;
|
this.chkIsSK.TabIndex = 20;
|
||||||
@@ -61,7 +62,7 @@ namespace JY.Inspection.Frm
|
|||||||
// btExit
|
// btExit
|
||||||
//
|
//
|
||||||
this.btExit.Location = new System.Drawing.Point(279, 428);
|
this.btExit.Location = new System.Drawing.Point(279, 428);
|
||||||
this.btExit.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.btExit.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.btExit.Name = "btExit";
|
this.btExit.Name = "btExit";
|
||||||
this.btExit.Size = new System.Drawing.Size(127, 46);
|
this.btExit.Size = new System.Drawing.Size(127, 46);
|
||||||
this.btExit.TabIndex = 22;
|
this.btExit.TabIndex = 22;
|
||||||
@@ -72,7 +73,7 @@ namespace JY.Inspection.Frm
|
|||||||
// btLogin
|
// btLogin
|
||||||
//
|
//
|
||||||
this.btLogin.Location = new System.Drawing.Point(81, 428);
|
this.btLogin.Location = new System.Drawing.Point(81, 428);
|
||||||
this.btLogin.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.btLogin.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.btLogin.Name = "btLogin";
|
this.btLogin.Name = "btLogin";
|
||||||
this.btLogin.Size = new System.Drawing.Size(127, 46);
|
this.btLogin.Size = new System.Drawing.Size(127, 46);
|
||||||
this.btLogin.TabIndex = 21;
|
this.btLogin.TabIndex = 21;
|
||||||
@@ -83,7 +84,7 @@ namespace JY.Inspection.Frm
|
|||||||
//
|
//
|
||||||
this.pictureBox1.Image = global::JY.Inspection.Properties.Resources.登录;
|
this.pictureBox1.Image = global::JY.Inspection.Properties.Resources.登录;
|
||||||
this.pictureBox1.Location = new System.Drawing.Point(153, 55);
|
this.pictureBox1.Location = new System.Drawing.Point(153, 55);
|
||||||
this.pictureBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.pictureBox1.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.pictureBox1.Name = "pictureBox1";
|
this.pictureBox1.Name = "pictureBox1";
|
||||||
this.pictureBox1.Size = new System.Drawing.Size(168, 165);
|
this.pictureBox1.Size = new System.Drawing.Size(168, 165);
|
||||||
this.pictureBox1.TabIndex = 18;
|
this.pictureBox1.TabIndex = 18;
|
||||||
@@ -95,10 +96,10 @@ namespace JY.Inspection.Frm
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
this.txtUserID.CustomButton.Image = null;
|
this.txtUserID.CustomButton.Image = null;
|
||||||
this.txtUserID.CustomButton.Location = new System.Drawing.Point(236, 1);
|
this.txtUserID.CustomButton.Location = new System.Drawing.Point(177, 1);
|
||||||
this.txtUserID.CustomButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.txtUserID.CustomButton.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.txtUserID.CustomButton.Name = "";
|
this.txtUserID.CustomButton.Name = "";
|
||||||
this.txtUserID.CustomButton.Size = new System.Drawing.Size(36, 34);
|
this.txtUserID.CustomButton.Size = new System.Drawing.Size(27, 27);
|
||||||
this.txtUserID.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
this.txtUserID.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
this.txtUserID.CustomButton.TabIndex = 1;
|
this.txtUserID.CustomButton.TabIndex = 1;
|
||||||
this.txtUserID.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
this.txtUserID.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
@@ -107,7 +108,7 @@ namespace JY.Inspection.Frm
|
|||||||
this.txtUserID.Lines = new string[] {
|
this.txtUserID.Lines = new string[] {
|
||||||
"Admin"};
|
"Admin"};
|
||||||
this.txtUserID.Location = new System.Drawing.Point(108, 16);
|
this.txtUserID.Location = new System.Drawing.Point(108, 16);
|
||||||
this.txtUserID.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.txtUserID.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.txtUserID.MaxLength = 32767;
|
this.txtUserID.MaxLength = 32767;
|
||||||
this.txtUserID.Name = "txtUserID";
|
this.txtUserID.Name = "txtUserID";
|
||||||
this.txtUserID.PasswordChar = '\0';
|
this.txtUserID.PasswordChar = '\0';
|
||||||
@@ -131,10 +132,10 @@ namespace JY.Inspection.Frm
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
this.txtPassWord.CustomButton.Image = null;
|
this.txtPassWord.CustomButton.Image = null;
|
||||||
this.txtPassWord.CustomButton.Location = new System.Drawing.Point(236, 1);
|
this.txtPassWord.CustomButton.Location = new System.Drawing.Point(177, 1);
|
||||||
this.txtPassWord.CustomButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.txtPassWord.CustomButton.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.txtPassWord.CustomButton.Name = "";
|
this.txtPassWord.CustomButton.Name = "";
|
||||||
this.txtPassWord.CustomButton.Size = new System.Drawing.Size(36, 34);
|
this.txtPassWord.CustomButton.Size = new System.Drawing.Size(27, 27);
|
||||||
this.txtPassWord.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
this.txtPassWord.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
this.txtPassWord.CustomButton.TabIndex = 1;
|
this.txtPassWord.CustomButton.TabIndex = 1;
|
||||||
this.txtPassWord.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
this.txtPassWord.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
@@ -143,7 +144,7 @@ namespace JY.Inspection.Frm
|
|||||||
this.txtPassWord.Lines = new string[] {
|
this.txtPassWord.Lines = new string[] {
|
||||||
"Admin"};
|
"Admin"};
|
||||||
this.txtPassWord.Location = new System.Drawing.Point(108, 60);
|
this.txtPassWord.Location = new System.Drawing.Point(108, 60);
|
||||||
this.txtPassWord.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.txtPassWord.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.txtPassWord.MaxLength = 32767;
|
this.txtPassWord.MaxLength = 32767;
|
||||||
this.txtPassWord.Name = "txtPassWord";
|
this.txtPassWord.Name = "txtPassWord";
|
||||||
this.txtPassWord.PasswordChar = '*';
|
this.txtPassWord.PasswordChar = '*';
|
||||||
@@ -246,11 +247,25 @@ namespace JY.Inspection.Frm
|
|||||||
this.txtPassword2.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
this.txtPassword2.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
this.txtPassword2.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
this.txtPassword2.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
//
|
//
|
||||||
|
// check_isMesLogin
|
||||||
|
//
|
||||||
|
this.check_isMesLogin.AutoSize = true;
|
||||||
|
this.check_isMesLogin.Checked = true;
|
||||||
|
this.check_isMesLogin.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
|
this.check_isMesLogin.Location = new System.Drawing.Point(81, 390);
|
||||||
|
this.check_isMesLogin.Margin = new System.Windows.Forms.Padding(4);
|
||||||
|
this.check_isMesLogin.Name = "check_isMesLogin";
|
||||||
|
this.check_isMesLogin.Size = new System.Drawing.Size(114, 17);
|
||||||
|
this.check_isMesLogin.TabIndex = 28;
|
||||||
|
this.check_isMesLogin.Text = "MES员工登录";
|
||||||
|
this.check_isMesLogin.UseSelectable = true;
|
||||||
|
//
|
||||||
// LoginForm
|
// LoginForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(472, 529);
|
this.ClientSize = new System.Drawing.Size(472, 529);
|
||||||
|
this.Controls.Add(this.check_isMesLogin);
|
||||||
this.Controls.Add(this.pLogin_pwd);
|
this.Controls.Add(this.pLogin_pwd);
|
||||||
this.Controls.Add(this.pLogin_card);
|
this.Controls.Add(this.pLogin_card);
|
||||||
this.Controls.Add(this.chkIsSK);
|
this.Controls.Add(this.chkIsSK);
|
||||||
@@ -258,7 +273,7 @@ namespace JY.Inspection.Frm
|
|||||||
this.Controls.Add(this.btLogin);
|
this.Controls.Add(this.btLogin);
|
||||||
this.Controls.Add(this.pictureBox1);
|
this.Controls.Add(this.pictureBox1);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
|
this.Margin = new System.Windows.Forms.Padding(4);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "LoginForm";
|
this.Name = "LoginForm";
|
||||||
@@ -290,5 +305,6 @@ namespace JY.Inspection.Frm
|
|||||||
private System.Windows.Forms.Panel pLogin_card;
|
private System.Windows.Forms.Panel pLogin_card;
|
||||||
private MetroFramework.Controls.MetroLabel lblICCard;
|
private MetroFramework.Controls.MetroLabel lblICCard;
|
||||||
private MetroFramework.Controls.MetroTextBox txtPassword2;
|
private MetroFramework.Controls.MetroTextBox txtPassword2;
|
||||||
|
private MetroFramework.Controls.MetroCheckBox check_isMesLogin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,8 +137,6 @@ namespace JY.Inspection.Frm
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void btAdd_Click(object sender, EventArgs e)
|
private void btAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
User user = GetUser(ListUser);
|
User user = GetUser(ListUser);
|
||||||
var res = helper.AddUser("user.pt", ListUser, user);
|
var res = helper.AddUser("user.pt", ListUser, user);
|
||||||
if (res)
|
if (res)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using JY.DAL.Repository;
|
|||||||
using JY.DAL.Service;
|
using JY.DAL.Service;
|
||||||
using JY.Inspection.Common;
|
using JY.Inspection.Common;
|
||||||
using JY.Inspection.Entity;
|
using JY.Inspection.Entity;
|
||||||
|
using JY.Inspection.Enums;
|
||||||
using JY.Inspection.Frm;
|
using JY.Inspection.Frm;
|
||||||
using JY.Inspection.Mes;
|
using JY.Inspection.Mes;
|
||||||
using JY.MES;
|
using JY.MES;
|
||||||
@@ -1235,11 +1236,11 @@ namespace JY.Inspection
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void tsmiUserConfig_Click(object sender, EventArgs e)
|
private void tsmiUserConfig_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (!CheckAdmin())
|
//if (!CheckAdmin())
|
||||||
{
|
//{
|
||||||
MessageBox.Show("权限不足", "系统提示");
|
// MessageBox.Show("权限不足", "系统提示");
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
SetForm setForm = new SetForm();
|
SetForm setForm = new SetForm();
|
||||||
setForm.ShowDialog();
|
setForm.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,6 +190,8 @@
|
|||||||
<Compile Include="Common\DGShowMsg.cs" />
|
<Compile Include="Common\DGShowMsg.cs" />
|
||||||
<Compile Include="Common\DateTimeSynchronization.cs" />
|
<Compile Include="Common\DateTimeSynchronization.cs" />
|
||||||
<Compile Include="Entity\AlarmStatus.cs" />
|
<Compile Include="Entity\AlarmStatus.cs" />
|
||||||
|
<Compile Include="Enums\EnumAutority.cs" />
|
||||||
|
<Compile Include="Enums\EnumExtension.cs" />
|
||||||
<Compile Include="Frm\FormMesGradingSet.cs">
|
<Compile Include="Frm\FormMesGradingSet.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ namespace JY.Inspection.Mes
|
|||||||
/// <param name="req"></param>
|
/// <param name="req"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
RespExitStation PostProductExitStationData(ReqExitStation req);
|
RespExitStation PostProductExitStationData(ReqExitStation req);
|
||||||
|
|
||||||
|
MesCallResult<RespLoginMes> LoginMes(ReqLoginMes req);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MESDataCombin : IMes
|
public class MESDataCombin : IMes
|
||||||
@@ -310,5 +312,49 @@ namespace JY.Inspection.Mes
|
|||||||
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MesCallResult<RespLoginMes> LoginMes(ReqLoginMes req)
|
||||||
|
{
|
||||||
|
if (req == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("MES员工登录请求信息为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO MES登录请求地址
|
||||||
|
DateTime currentTime = DateTime.Now;
|
||||||
|
string reqUrl = string.Empty;
|
||||||
|
MesCallResult<RespLoginMes> resp = new MesCallResult<RespLoginMes>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string reqJsonStr = JsonConvert.SerializeObject(req);
|
||||||
|
var sw = new Stopwatch();
|
||||||
|
sw.Start();
|
||||||
|
string mesRes = MESApiHelper.HttpPostJsonAPI(
|
||||||
|
reqUrl,
|
||||||
|
reqJsonStr,
|
||||||
|
Global.systemConfig.MesRequestTime
|
||||||
|
);
|
||||||
|
resp = MESApiHelper.HttpPostJsonAPI<RespLoginMes>(reqUrl, reqJsonStr, Global.systemConfig.MesRequestTime);
|
||||||
|
sw.Stop();
|
||||||
|
|
||||||
|
if (resp?.OriResponse != null && resp?.OriResponse.Success != true)
|
||||||
|
{
|
||||||
|
resp.IsSuccess = false;
|
||||||
|
resp.ErrorType = MesErrorType.BusinessError;
|
||||||
|
resp.ErrorMessage = resp?.OriResponse?.Message ?? "MES业务处理失败, 错误消息为空";
|
||||||
|
}
|
||||||
|
|
||||||
|
new MesLog().LogLoginMes(currentTime, reqJsonStr, resp.OriRespJsonStr, sw.ElapsedMilliseconds);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
resp.IsSuccess = false;
|
||||||
|
resp.ErrorType = MesErrorType.ClientError;
|
||||||
|
resp.ErrorMessage = "获取MES员工登录信息异常:" + ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ namespace JY.Inspection.Mes
|
|||||||
void LogArrivalStation(DateTime curTime, string reqJsonStr, string respMes, long costTime);
|
void LogArrivalStation(DateTime curTime, string reqJsonStr, string respMes, long costTime);
|
||||||
|
|
||||||
void LogExitStation(DateTime curTime, string reqJsonStr, string respMes, long costTime);
|
void LogExitStation(DateTime curTime, string reqJsonStr, string respMes, long costTime);
|
||||||
|
|
||||||
|
void LogLoginMes(DateTime curTime, string reqJsonStr, string respMes, long costTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MesLog : IMesLog
|
public class MesLog : IMesLog
|
||||||
@@ -62,5 +64,12 @@ namespace JY.Inspection.Mes
|
|||||||
|
|
||||||
LogoutAction(actionName, curTime, reqJsonStr, respMes, costTime);
|
LogoutAction(actionName, curTime, reqJsonStr, respMes, costTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LogLoginMes(DateTime curTime, string reqJsonStr, string respMes, long costTime)
|
||||||
|
{
|
||||||
|
string actionName = "Mes员工登录";
|
||||||
|
|
||||||
|
LogoutAction(actionName, curTime, reqJsonStr, respMes, costTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,9 +73,11 @@
|
|||||||
<Compile Include="MES\ProductResultParameters.cs" />
|
<Compile Include="MES\ProductResultParameters.cs" />
|
||||||
<Compile Include="MES\ReqArrivalStation.cs" />
|
<Compile Include="MES\ReqArrivalStation.cs" />
|
||||||
<Compile Include="MES\ReqExitStation.cs" />
|
<Compile Include="MES\ReqExitStation.cs" />
|
||||||
|
<Compile Include="MES\ReqLoginMes.cs" />
|
||||||
<Compile Include="MES\RespArrivalStation.cs" />
|
<Compile Include="MES\RespArrivalStation.cs" />
|
||||||
<Compile Include="MES\RespBase.cs" />
|
<Compile Include="MES\RespBase.cs" />
|
||||||
<Compile Include="MES\RespExitStation.cs" />
|
<Compile Include="MES\RespExitStation.cs" />
|
||||||
|
<Compile Include="MES\RespLoginMes.cs" />
|
||||||
<Compile Include="MES\RespProductResult.cs" />
|
<Compile Include="MES\RespProductResult.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.MES.MES
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 登录MES
|
||||||
|
/// </summary>
|
||||||
|
public class ReqLoginMes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 工厂代码
|
||||||
|
/// </summary>
|
||||||
|
public string SiteCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 产线编号
|
||||||
|
/// </summary>
|
||||||
|
public string LineCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备编号
|
||||||
|
/// </summary>
|
||||||
|
public string EquipNum { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 员工账号 账号登录时,账号,密码必填
|
||||||
|
/// </summary>
|
||||||
|
public string UserName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 员工密码
|
||||||
|
/// </summary>
|
||||||
|
public string PassWord { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 员工卡号 刷卡时,卡号必填
|
||||||
|
/// </summary>
|
||||||
|
public string UserCardID { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.MES.MES
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// MES登录响应
|
||||||
|
/// </summary>
|
||||||
|
public class RespLoginMes
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 错误代码,成功不返回
|
||||||
|
/// </summary>
|
||||||
|
public string ErrorCode { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 成功标识 (false失败 true 成功)
|
||||||
|
/// </summary>
|
||||||
|
public bool Success { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据处理消息,成功不返回
|
||||||
|
/// </summary>
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报错消息类型
|
||||||
|
/// </summary>
|
||||||
|
public string Category { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 员工账号&权限等级
|
||||||
|
/// </summary>
|
||||||
|
public MesUserInfo[] Rows { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 条数,统一返回1
|
||||||
|
/// </summary>
|
||||||
|
public int Total { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MesUserInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 员工账号
|
||||||
|
/// </summary>
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 权限等级
|
||||||
|
/// </summary>
|
||||||
|
public string PermissionLevel { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user