浏览代码

操作日志

1550076451 3 年之前
父节点
当前提交
cb8588a44b
共有 2 个文件被更改,包括 76 次插入14 次删除
  1. 25 0
      RMYY_CallCenter_Api/Common/Common.cs
  2. 51 14
      RMYY_CallCenter_Api/Controllers/HomeController.cs

+ 25 - 0
RMYY_CallCenter_Api/Common/Common.cs

@@ -6,6 +6,7 @@ using System.ComponentModel;
6 6
 using System.Data;
7 7
 using System.Linq;
8 8
 using System.Reflection;
9
+using System.Text.RegularExpressions;
9 10
 using System.Web;
10 11
 
11 12
 namespace RMYY_CallCenter_Api
@@ -95,5 +96,29 @@ namespace RMYY_CallCenter_Api
95 96
             }
96 97
             return slist;
97 98
         }
99
+        /// <summary>
100
+        /// 是否为ip
101
+        /// </summary>
102
+        /// <param name="ip"></param>
103
+        /// <returns></returns>
104
+        public static bool IsIP(string ip)
105
+        {
106
+            return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
107
+        }
108
+        /// <summary>
109
+        /// 获得当前页面客户端的IP
110
+        /// </summary>
111
+        /// <returns>当前页面客户端的IP</returns>
112
+        public static string GetIP()
113
+        {
114
+            string result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
115
+            if (string.IsNullOrEmpty(result))
116
+                result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
117
+            if (string.IsNullOrEmpty(result))
118
+                result = HttpContext.Current.Request.UserHostAddress;
119
+            if (string.IsNullOrEmpty(result) || !IsIP(result))
120
+                return "127.0.0.1";
121
+            return result;
122
+        }
98 123
     }
99 124
 }

+ 51 - 14
RMYY_CallCenter_Api/Controllers/HomeController.cs

@@ -63,7 +63,7 @@ namespace RMYY_CallCenter_Api.Controllers
63 63
                 Dic.Add("F_DeptId", dr["F_DeptId"].ToString());
64 64
 
65 65
                 var token = FormsPrincipal<Dictionary<string, string>>.GetCookieValue(Dic["F_UserCode"], Dic);
66
-                AddLogAsync(dr["F_UserName"].ToString(), dr["F_UserCode"].ToString(), "登录成功", "", 1);
66
+                AddLogAsync(dr["F_UserName"].ToString(), dr["F_UserCode"].ToString(), "登录成功", Common.GetIP(), 1);
67 67
                 return Success("登录成功", token);
68 68
             }
69 69
             else
@@ -137,16 +137,53 @@ namespace RMYY_CallCenter_Api.Controllers
137 137
                 Dictionary<string, string> userData = ticket.UserData.ToObject<Dictionary<string, string>>();
138 138
                 if (userData != null)
139 139
                 {
140
-                    var LoginLogs = new Bll.T_Sys_Login_Logs().GetModel(userData["F_UserCode"]);
141
-                    if (LoginLogs != null)
140
+                    AddLogAsync(userData["F_UserName"].ToString(), userData["F_UserCode"].ToString(), "登出成功", Common.GetIP(), 1);
141
+                    //var LoginLogs = new Bll.T_Sys_Login_Logs().GetModel(userData["F_UserCode"]);
142
+                    //if (LoginLogs != null)
143
+                    //{
144
+                    //    LoginLogs.T_result = "登出成功";
145
+                    //    LoginLogs.T_LoginOutDate = DateTime.Now;
146
+                    //    new Bll.T_Sys_Login_Logs().Update(LoginLogs);
147
+                    //}
148
+                }
149
+            }
150
+            return Success("退出成功");
151
+        }
152
+
153
+        public ActionResult Teljournal(string token = "",int state=0)
154
+        {
155
+            if (string.IsNullOrEmpty(token))
156
+                return Error("身份验证失败");
157
+            if (state<=0)
158
+                return Error("请选择话务状态");
159
+            FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(token);
160
+            if (ticket != null && !ticket.Expired && !string.IsNullOrEmpty(ticket.UserData))
161
+            {
162
+                Dictionary<string, string> userData = ticket.UserData.ToObject<Dictionary<string, string>>();
163
+                if (userData != null)
164
+                {
165
+                    string message = "";
166
+                    switch (state )
142 167
                     {
143
-                        LoginLogs.T_LoginOutDate = DateTime.Now;
144
-                        new Bll.T_Sys_Login_Logs().Update(LoginLogs);
168
+                        case 1 :
169
+                            message = "签入成功";
170
+                            break;
171
+                        case 2:
172
+                            message = "签出成功";
173
+                            break;
174
+                        case 3:
175
+                            message = "置忙成功";
176
+                            break;
177
+                        case 4:
178
+                            message = "置闲成功";
179
+                            break;
145 180
                     }
181
+                    AddLogAsync(userData["F_UserName"].ToString(), userData["F_UserCode"].ToString(), message, Common.GetIP(), 1);
146 182
                 }
147 183
             }
148
-            return Success("退出成功");
184
+            return Success("成功");
149 185
         }
186
+
150 187
         public ActionResult GetLoginLogList(string username, string starttime = "", string endtime = "",  int pageindex = 1, int pagesize = 10)
151 188
         {
152 189
             DataTable datatable= new DataTable();
@@ -162,17 +199,17 @@ namespace RMYY_CallCenter_Api.Controllers
162 199
                 sql += " and datediff(day,T_time,'" + starttime + "')<=0";
163 200
             if (endtime.Trim() != "" && endtime != "undefined")
164 201
                 sql += " and datediff(day,T_time,'" + endtime + "')>=0";
165
-            string cols = "(select top 1  LoginTime from  rep_agentState_Duration  where LoginTime>=a.T_time  and LoginTime<=  " +
166
-                "[dbo].[GetLoginTime](a.T_id)) as LoginTime, " +
167
-                "(select top 1  T_time from  rep_agentState_Duration where LoginTime >= a.T_time  and LoginTime<= " +
168
-                " [dbo].[GetLoginTime](a.T_id))as LogoutTime," +
169
-                "(select top 1  OccurTime from  rep_agent_state where OccurTime >= a.T_time and State = 2  and OccurTime<= " +
170
-                "[dbo].[GetLoginTime](a.T_id))as IdleTime,(select top 1  OccurTime from  rep_agent_state " +
171
-                "where OccurTime >= a.T_time and State = 5  and OccurTime<=   [dbo].[GetLoginTime](a.T_id))as BusyTime, *";
202
+            //string cols = "(select top 1  LoginTime from  rep_agentState_Duration  where LoginTime>=a.T_time  and LoginTime<=  " +
203
+            //    "[dbo].[GetLoginTime](a.T_id)) as LoginTime, " +
204
+            //    "(select top 1  T_time from  rep_agentState_Duration where LoginTime >= a.T_time  and LoginTime<= " +
205
+            //    " [dbo].[GetLoginTime](a.T_id))as LogoutTime," +
206
+            //    "(select top 1  OccurTime from  rep_agent_state where OccurTime >= a.T_time and State = 2  and OccurTime<= " +
207
+            //    "[dbo].[GetLoginTime](a.T_id))as IdleTime,(select top 1  OccurTime from  rep_agent_state " +
208
+            //    "where OccurTime >= a.T_time and State = 5  and OccurTime<=   [dbo].[GetLoginTime](a.T_id))as BusyTime, *";
172 209
             datatable = Bll.PagerBll.GetListPager
173 210
                                 ("T_Sys_Login_Logs a",
174 211
                                   "T_id",
175
-                                  cols,
212
+                                  "*",
176 213
                                   sql,
177 214
                                   "order by T_id desc",
178 215
                                   pagesize,