From 4ced58ce6d3cfd703de419a0a30945acd01295c8 Mon Sep 17 00:00:00 2001
From: yzh <snbbt@21cn.com>
Date: 星期五, 13 五月 2022 18:32:09 +0800
Subject: [PATCH] 优化密码框

---
 web/web/GwClient.ashx |   78 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/web/web/GwClient.ashx b/web/web/GwClient.ashx
index ccf09d3..ba332cc 100644
--- a/web/web/GwClient.ashx
+++ b/web/web/GwClient.ashx
@@ -15,6 +15,10 @@
 
 public class GwClientHandler : PageHandler<Model.SysUser>
 {
+
+    private UserDao _SysUserDao = new UserDao();
+    private List<SysUser> _SysUserList;
+
     public override JsonPageResult ProcessRequestInternal(PageContext<Model.SysUser> context)
     {
         string action = context.GetString("action");
@@ -89,7 +93,11 @@
                     {
                         Certification_StatusResult = "宸茶璇�";
                     }
-                    str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Top_up_Amount_Total + "鍏�</td><td>" + item.Agent + "</td><td>" + Certification_StatusResult + "</td>";
+                    //edit:yangzh by 20220511
+                    //str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Top_up_Amount_Total + "鍏�</td><td>" + item.Agent + "</td><td>" + Certification_StatusResult + "</td>";
+                    //str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "鍏�</td><td>" + item.Top_up_Amount_Total/1000 + "鍏�</td><td>" + item.Agent + "</td><td>" + Certification_StatusResult + "</td>";
+                    str += @"<tr ><td>" + item.ClientID + "</td><td>" + item.Company + "</td><td>" + item.ClientName + "</td><td>" + item.Telephone + "</td><td>" + item.Balance/1000 + "鍏�</td><td>" + item.Top_up_Amount_Total/1000 + "鍏�</td><td>" + SysUserName(string.IsNullOrEmpty(item.Agent)? 0: int.Parse(item.Agent) ) + "</td><td>" + Certification_StatusResult + "</td>";
+
 
                     str += @"<td>";
                     string loginStr = "http://" + serverIp + ":" + clientPort + "/Attachedlogin.aspx?action=Attachedlogin&account=" + item.Account + "&password=" + item.Password;
@@ -229,6 +237,7 @@
     {
         int id = Int32.Parse(context.GetString("id"));
         string clientID = context.GetString("clientID");
+        string company = context.GetString("company");
         string password = context.GetString("password");
         string clientName = context.GetString("clientName");
         string address = context.GetString("address");
@@ -261,12 +270,26 @@
             throw new ArgumentException("鑱旂郴浜�/鑱旂郴鐢佃瘽锛屼笉鑳戒负绌猴紒");
         }
 
+        string savePassword = "";
+        if (!string.IsNullOrEmpty(clientID))
+        {
+            GwClient gwClient = this._Dao.Get(clientID);
+            savePassword = (gwClient.Password == password ? gwClient.Password : DataHelper.MD5Hex(password) );
+        }
+        else
+        {
+            savePassword = DataHelper.MD5Hex(password);
+        }
+
 
         var client = new Model.GwClient();
 
         client.Id = id;
         client.ClientID = clientID;
-        client.Password = password;
+        client.Company = company;
+        //client.Password = password;
+        client.Password = savePassword;
+            
         client.ClientName = clientName;
         client.Address = address;
         client.Remark = remark;
@@ -284,7 +307,7 @@
     {
         string clientID = context.GetString("clientID");
         string password = context.GetString("password");
-        //string clientName = context.GetString("clientName");
+        string clientName = context.GetString("clientName");
         string address = context.GetString("address");
         string telephone = context.GetString("telephone");
         string remark = context.GetString("remark");
@@ -309,6 +332,11 @@
         if (string.IsNullOrEmpty(password) || !System.Text.RegularExpressions.Regex.IsMatch(password, @"[a-zA-Z0-9]{4,10}"))
         {
             throw new ArgumentException("瀹㈡埛瀵嗙爜涓嶈兘涓虹┖锛屼笖蹇呴』涓�4-10浣嶈嫳鏂囨垨鏁板瓧瀛楃缁勫悎锛�");
+        }
+
+        if (string.IsNullOrEmpty(clientName) || string.IsNullOrEmpty(telephone))
+        {
+            throw new ArgumentException("鑱旂郴浜�/鑱旂郴鐢佃瘽锛屼笉鑳戒负绌猴紒");
         }
 
         //if (string.IsNullOrEmpty(clientName))
@@ -358,14 +386,20 @@
                     return new JsonPageResult(false, "涓婁紶鍥剧墖澶勭悊寮傚父锛�" + ex.Message);
                 }
             }
+            else
+            {
+                throw new ArgumentException("鏂囦欢鏍煎紡閿欒锛岃纭鏄惁涓簀pg|jpeg|gif|png銆�");
+            }
         }
 
+        //瀵嗙爜鍔犲瘑
+        password = DataHelper.MD5Hex(password);
 
         var client = new Model.GwClient();
         client.ClientID = clientID;
         client.Password = password;
 
-        //client.ClientName = clientName;
+        client.ClientName = clientName;
         client.Address = address;
         client.Remark = remark;
         client.Telephone = telephone;
@@ -378,6 +412,8 @@
 
         //淇濆瓨浜у搧璁板綍
         //鑾峰彇鍚敤鐨勯粯璁ょ殑浜у搧
+        /**
+        //edit:鍦ㄥ鎴锋縺娲绘椂娣诲姞璁板綍
         List<string> defaultProductList = GwProductDao.Instance.GetDefaultProduct();
         if (defaultProductList.Count > 0)
         {
@@ -390,9 +426,43 @@
                 GwClientProductDao.Instance.Add(gcp);
             }
         }
+        **/
 
         return new JsonPageResult(true, "鍒涘缓璐︽埛鎴愬姛锛�");
     }
+
+
+
+    //鑾峰彇绠$悊绔处鎴峰垪琛�
+    private List<SysUser> SysUserList
+    {
+        get
+        {
+            if (this._SysUserList == null)
+            {
+
+                using (UserDao sysUserDao = new UserDao())
+                {
+                    int recordCount = 0;
+                    int int1 = 999999999;
+                    int int2 = 1;
+                    this._SysUserList = sysUserDao.LoadInfoList(out recordCount, int1, int2);
+                }
+            }
+            return this._SysUserList;
+        }
+    }
+
+    //绠$悊绔处鎴峰悕绉�
+    private string SysUserName(int userId)
+    {
+        if (this.SysUserList == null)
+            return string.Empty;
+        SysUser sysUser = this._SysUserList.Find((Predicate<SysUser>)(bean => bean.UserID == userId));
+        if (sysUser != null)
+            return string.Format("{0}-{1}", (object)sysUser.UserID, (object)sysUser.UserName);
+        return string.Empty;
+    }
 }
 
 

--
Gitblit v1.9.1