duhongyu 3 anni fa
parent
commit
9209245cb8

+ 15 - 0
RMYY_CallCenter_Api.Bll/T_Sys_Login_Logs.cs

@@ -16,8 +16,23 @@ namespace RMYY_CallCenter_Api.Bll
16 16
         {
17 17
             return dal.Add(model);
18 18
         }
19
+        /// <summary>
20
+		/// 更新一条数据
21
+		/// </summary>
22
+		public bool Update(RMYY_CallCenter_Api.Model.T_Sys_Login_Logs model)
23
+        {
24
+            return dal.Update(model);
25
+        }
26
+
19 27
 
28
+        /// <summary>
29
+        /// 得到一个对象实体
30
+        /// </summary>
31
+        public RMYY_CallCenter_Api.Model.T_Sys_Login_Logs GetModel(string   T_usercode)
32
+        {
20 33
 
34
+            return dal.GetModel(T_usercode);
35
+        }
21 36
 
22 37
     }
23 38
 }

+ 112 - 0
RMYY_CallCenter_Api.Dal/T_Sys_Login_Logs.cs

@@ -48,5 +48,117 @@ namespace RMYY_CallCenter_Api.Dal
48 48
                 return Convert.ToInt32(obj);
49 49
             }
50 50
         }
51
+        /// <summary>
52
+        /// 更新一条数据
53
+        /// </summary>
54
+        public bool Update(RMYY_CallCenter_Api.Model.T_Sys_Login_Logs model)
55
+        {
56
+            StringBuilder strSql = new StringBuilder();
57
+            strSql.Append("update T_Sys_Login_Logs set ");
58
+            strSql.Append("T_username=@T_username,");
59
+            strSql.Append("T_usercode=@T_usercode,");
60
+            strSql.Append("T_result=@T_result,");
61
+            strSql.Append("T_login_ip=@T_login_ip,");
62
+            strSql.Append("T_channel=@T_channel,");
63
+            strSql.Append("T_time=@T_time,");
64
+            strSql.Append("T_LoginOutDate=@T_LoginOutDate");
65
+            strSql.Append(" where T_id=@T_id");
66
+            SqlParameter[] parameters = {
67
+                    new SqlParameter("@T_username", SqlDbType.NVarChar,100),
68
+                    new SqlParameter("@T_usercode", SqlDbType.NVarChar,100),
69
+                    new SqlParameter("@T_result", SqlDbType.NVarChar,100),
70
+                    new SqlParameter("@T_login_ip", SqlDbType.NVarChar,100),
71
+                    new SqlParameter("@T_channel", SqlDbType.Int,4),
72
+                    new SqlParameter("@T_time", SqlDbType.DateTime),
73
+                    new SqlParameter("@T_LoginOutDate", SqlDbType.DateTime),
74
+                    new SqlParameter("@T_id", SqlDbType.Int,4)};
75
+            parameters[0].Value = model.T_username;
76
+            parameters[1].Value = model.T_usercode;
77
+            parameters[2].Value = model.T_result;
78
+            parameters[3].Value = model.T_login_ip;
79
+            parameters[4].Value = model.T_channel;
80
+            parameters[5].Value = model.T_time;
81
+            parameters[6].Value = model.T_LoginOutDate;
82
+            parameters[7].Value = model.T_id;
83
+
84
+            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
85
+            if (rows > 0)
86
+            {
87
+                return true;
88
+            }
89
+            else
90
+            {
91
+                return false;
92
+            }
93
+        }
94
+        /// <summary>
95
+        /// 根据工单编号得到一个最新对象实体
96
+        /// </summary>
97
+        public RMYY_CallCenter_Api.Model.T_Sys_Login_Logs GetModel(string T_usercode)
98
+        {
99
+
100
+            StringBuilder strSql = new StringBuilder();
101
+            strSql.Append("select  top 1 * from T_Sys_Login_Logs WITH(NOLOCK) ");
102
+            strSql.Append(" where T_usercode=@T_usercode and F_IsDelete=0 ");
103
+            strSql.Append(" order by T_time desc");
104
+            SqlParameter[] parameters = {
105
+                    new SqlParameter("@T_usercode", SqlDbType.NVarChar,50)
106
+            };
107
+            parameters[0].Value = T_usercode;
108
+
109
+            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
110
+            if (ds.Tables[0].Rows.Count > 0)
111
+            {
112
+                return DataRowToModel(ds.Tables[0].Rows[0]); ;
113
+            }
114
+            else
115
+            {
116
+                return null;
117
+            }
118
+        }
119
+        /// <summary>
120
+        /// 得到一个对象实体
121
+        /// </summary>
122
+        public RMYY_CallCenter_Api.Model.T_Sys_Login_Logs DataRowToModel(DataRow row)
123
+        {
124
+            RMYY_CallCenter_Api.Model.T_Sys_Login_Logs model = new RMYY_CallCenter_Api.Model.T_Sys_Login_Logs();
125
+            if (row != null)
126
+            {
127
+                if (row["T_id"] != null && row["T_id"].ToString() != "")
128
+                {
129
+                    model.T_id = row["T_id"].ToString();
130
+                }
131
+                if (row["T_username"] != null)
132
+                {
133
+                    model.T_username = row["T_username"].ToString();
134
+                }
135
+                if (row["T_usercode"] != null)
136
+                {
137
+                    model.T_usercode = row["T_usercode"].ToString();
138
+                }
139
+                if (row["T_result"] != null)
140
+                {
141
+                    model.T_result = row["T_result"].ToString();
142
+                }
143
+                if (row["T_login_ip"] != null)
144
+                {
145
+                    model.T_login_ip = row["T_login_ip"].ToString();
146
+                }
147
+                if (row["T_channel"] != null && row["T_channel"].ToString() != "")
148
+                {
149
+                    model.T_channel = int.Parse(row["T_channel"].ToString());
150
+                }
151
+                if (row["T_time"] != null && row["T_time"].ToString() != "")
152
+                {
153
+                    model.T_time = DateTime.Parse(row["T_time"].ToString());
154
+                }
155
+                if (row["T_LoginOutDate"] != null && row["T_LoginOutDate"].ToString() != "")
156
+                {
157
+                    model.T_LoginOutDate = DateTime.Parse(row["T_LoginOutDate"].ToString());
158
+                }
159
+            }
160
+            return model;
161
+        }
162
+
51 163
     }
52 164
 }

+ 8 - 3
RMYY_CallCenter_Api.Model/T_Sys_Login_Logs.cs

@@ -35,10 +35,15 @@ namespace RMYY_CallCenter_Api.Model
35 35
         public int T_channel { get; set; } = 1;
36 36
         
37 37
         /// <summary>
38
-        /// 登录登出时间
38
+        /// 登录时间
39 39
         /// </summary>
40 40
         public DateTime T_time { get; set; }
41
-        
42
-        
41
+
42
+        /// <summary>
43
+        /// 登出时间
44
+        /// </summary>
45
+        public DateTime T_LoginOutDate { get; set; }
46
+
47
+
43 48
     }
44 49
 }

+ 24 - 3
RMYY_CallCenter_Api/Controllers/HomeController.cs

@@ -126,7 +126,17 @@ namespace RMYY_CallCenter_Api.Controllers
126 126
             };
127 127
             return bll.Add(login_log);
128 128
         }
129
-
129
+        public ActionResult Logout(string token = "")
130
+        {
131
+            var LoginLogs = new Bll.T_Sys_Login_Logs().GetModel(User.F_UserCode);
132
+            if (LoginLogs!=null )
133
+            {
134
+                LoginLogs.T_LoginOutDate = DateTime.Now;
135
+                new Bll.T_Sys_Login_Logs().Update(LoginLogs);
136
+            }
137
+            
138
+            return Success("退出成功");
139
+        }
130 140
         public ActionResult GetLoginLogList(string username, string starttime = "", string endtime = "",  int pageindex = 1, int pagesize = 10)
131 141
         {
132 142
             DataTable datatable= new DataTable();
@@ -142,10 +152,21 @@ namespace RMYY_CallCenter_Api.Controllers
142 152
                 sql += " and datediff(day,T_time,'" + starttime + "')<=0";
143 153
             if (endtime.Trim() != "" && endtime != "undefined")
144 154
                 sql += " and datediff(day,T_time,'" + endtime + "')>=0";
155
+            string cols = "(select top 1  LoginTime from  rep_agentState_Duration  where LoginTime>=a.T_time  and LoginTime<= " +
156
+                "isnull((select top 1T_time from  T_Sys_Login_Logs where  " +
157
+                "T_usercode=a.T_usercode and T_time >a .T_time order by T_time  ),GETDATE())   and AgentID=a.T_usercode)as LoginTime," +
158
+                "(select top 1  T_time  from  rep_agentState_Duration where LoginTime>=a.T_time  and LoginTime<= " +
159
+                "isnull((select top 1T_time from  T_Sys_Login_Logs where " +
160
+                "T_usercode=a.T_usercode and T_time >a .T_time order by T_time  ),GETDATE()) and AgentID=a.T_usercode   )as LogoutTime," +
161
+                "(select top 1  OccurTime   from  rep_agent_state where OccurTime>=a.T_time and State =2  and OccurTime<=" +
162
+                " isnull((select top 1 T_time from  T_Sys_Login_Logs where  T_usercode=a.T_usercode and T_time >a .T_time  " +
163
+                " order by T_time ),GETDATE())  and AgentID=a.T_usercode  )as IdleTime,(select top 1  OccurTime  from  rep_agent_state " +
164
+                "where OccurTime>=a.T_time and State =5  and OccurTime<= isnull((select top 1 T_time from  T_Sys_Login_Logs where " +
165
+                "T_usercode=a.T_usercode and T_time >a .T_time   order by T_time ),GETDATE())  and AgentID=a.T_usercode )as BusyTime, *";
145 166
             datatable = Bll.PagerBll.GetListPager
146
-                                ("T_Sys_Login_Logs ",
167
+                                ("T_Sys_Login_Logs a",
147 168
                                   "T_id",
148
-                                  "*",
169
+                                  cols,
149 170
                                   sql,
150 171
                                   "order by T_id desc",
151 172
                                   pagesize,