Browse Source

记录登陆信息

章政 8 years ago
parent
commit
3a77661fa8
2 changed files with 22 additions and 8 deletions
  1. 12 7
      UAS-MES/Login.cs
  2. 10 1
      UAS-MES/PublicMethod/LogicHandler.cs

+ 12 - 7
UAS-MES/Login.cs

@@ -5,6 +5,8 @@ using UAS_MES.DataOperate;
 using UAS_MES.Entity;
 using UAS_MES.PublicMethod;
 using System.Security.Cryptography.X509Certificates;
+using System.Net;
+using System.Net.Sockets;
 
 namespace UAS_MES
 {
@@ -60,12 +62,7 @@ namespace UAS_MES
                 PassWord.Select();
             else
                 UserName.Select();
-            //本来static是不要实例化的,但是需要调用触发添加键值对的构造函数
-            if (lgc == null)
-                lgc = new LogicHandler();
             BaseUtil.SetFormCenter(this);
-            //try { CertImport(); }
-            //catch (Exception) { }
         }
 
         //点击登陆按钮的时候
@@ -82,7 +79,6 @@ namespace UAS_MES
                     SystemInf.ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width;
                     SystemInf.ScreenHeight = Screen.PrimaryScreen.WorkingArea.Height;
                     SystemInf.ConnectionString = "Data Source=" + DbComboxData.Rows[i]["ma_address"] + ";User ID=" + DbComboxData.Rows[i]["ma_user"] + ";PassWord=" + DbComboxData.Rows[i]["ms_pwd"];
-                    Console.WriteLine(SystemInf.ConnectionString);
                     DataHelper.DBConnectionString = SystemInf.ConnectionString;
                     //重新执行一遍构造函数使得重置之后的链接字符串生效
                     dh = new DataHelper();
@@ -98,7 +94,16 @@ namespace UAS_MES
                 {
                     this.Hide();
                     SetInf();//设置User的全局变量
-                    LogManager.DoLog("登陆成功" + User.UserName +"  "+User.UserAccountType);
+                    IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
+                    string IPAddress = "";
+                    for (int i = 0; i < IpEntry.AddressList.Length; i++)
+                    {
+                        if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
+                            IPAddress = IpEntry.AddressList[i].ToString();
+                    }
+                    string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
+                    LogicHandler.RecordLogInfo(User.UserCode, User.UserName, version, "CS", IPAddress);
+                    LogManager.DoLog("登陆成功" + User.UserName + "  " + User.UserAccountType);
                     Main dialog = new Main();
                     dialog.ShowDialog();
                     this.Close();

+ 10 - 1
UAS-MES/PublicMethod/LogicHandler.cs

@@ -367,6 +367,14 @@ namespace UAS_MES.PublicMethod
             }
         }
 
+        /// <summary>
+        /// 记录登陆信息
+        /// </summary>
+        public static void RecordLogInfo(string iUserCode,string iUserName,string iVersion,string iType,string iIP)
+        {
+            dh.ExecuteSql("insert into LogInfo(id,sip,usname,indate,uscode,versioncode,terminaltype) values (LogInfo_seq.nextval,'"+iIP+"','"+iUserName+"',sysdate,'"+iUserCode+"','"+ iVersion + "','"+iType+"')", "insert");
+        }
+
         /// <summary>
         /// 验证用户身份信息和岗位资源
         /// </summary>
@@ -996,7 +1004,8 @@ namespace UAS_MES.PublicMethod
                 InsertMakeProcess(iSN, iMakeCode, iSourceCode, iMPKind, iResult, iUserCode);
                 return true;
             }
-            else {
+            else
+            {
                 return CS_SetFinish(iMakeCode, iSourceCode, iSN, iUserCode, out oErrorMessage);
             }
         }