Parcourir la Source

Merge branch 'master' of http://192.168.1.222:3000/zhengbingbing/PDSXHQ_API

zhengbingbing il y a 6 ans
Parent
commit
6b623bc3ae

+ 5 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Configs/system.config

41
   <add key="WechatRemark" value="为回报广大群众提供的信息,特此发放红包以兹鼓励"/>-->
41
   <add key="WechatRemark" value="为回报广大群众提供的信息,特此发放红包以兹鼓励"/>-->
42
   <!-- ================== 4:性能监控 - 配置语音文件盘符 ================== -->
42
   <!-- ================== 4:性能监控 - 配置语音文件盘符 ================== -->
43
   <add key="VideoHardDisc" value="D" />
43
   <add key="VideoHardDisc" value="D" />
44
+  <!-- ================== 5:系统授权 ================== -->
45
+  <!--到期提醒天数-->
46
+  <add key="AuthRemindDay" value="30" />
47
+  <!--到期日期-->
48
+  <add key="AuthDate" value="2018-10-31 23:59:59" />
44
 </appSettings>
49
 </appSettings>

+ 3 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/Login/LoginController.cs

70
                     CacheHelper.Insert(token, currentUserInfo, 10080, System.Web.Caching.CacheItemPriority.NotRemovable);
70
                     CacheHelper.Insert(token, currentUserInfo, 10080, System.Web.Caching.CacheItemPriority.NotRemovable);
71
                     return Success("登录成功", new
71
                     return Success("登录成功", new
72
                     {
72
                     {
73
-                        token = token
73
+                        token,
74
+                        date = Configs.GetValue("AuthDate"),
75
+                        days = CallCenter.Utility.Common.CommonHelper.GetRemainingDay()
74
                     });
76
                     });
75
 
77
 
76
 
78
 

+ 3 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/UserAccountController.cs

465
                 var obj = new
465
                 var obj = new
466
                 {
466
                 {
467
                     user = userModel,
467
                     user = userModel,
468
-                    role = roleModel
468
+                    role = roleModel,
469
+                    date = Configs.GetValue("AuthDate"),
470
+                    days = CommonHelper.GetRemainingDay()
469
                 };
471
                 };
470
                 res = Success("获取成功", obj);
472
                 res = Success("获取成功", obj);
471
             }
473
             }

+ 18 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Global.asax.cs

1
-using CallCenterApi.Common;
1
+using CallCenter.Utility;
2
+using CallCenterApi.Common;
2
 using CallCenterApi.Interface.Models.Common;
3
 using CallCenterApi.Interface.Models.Common;
3
 using System;
4
 using System;
4
 using System.Collections.Generic;
5
 using System.Collections.Generic;
27
             HttpApplication app = (HttpApplication)sender;
28
             HttpApplication app = (HttpApplication)sender;
28
             var context = app.Context;
29
             var context = app.Context;
29
             if (context == null) throw new ArgumentNullException("context");
30
             if (context == null) throw new ArgumentNullException("context");
31
+            try
32
+            {
33
+                var date = DateTime.Parse(Configs.GetValue("AuthDate"));
34
+                if (date < DateTime.Now)
35
+                {
36
+					context.Response.ContentType = "text/plain; charset=utf-8";
37
+                    context.Response.Write(new AjaxResult { state = ResultTypes.error.ToString(), message = "授权过期,请联系系统厂家。" }.ToJson());
38
+                    context.Response.End();
39
+                }
40
+            }
41
+            catch (Exception ex)
42
+            {
43
+                var log = LogFactory.GetLogger(this.GetType().ToString());
44
+                log.Error(Configs.GetValue("AuthDate"));
45
+                log.Error(ex.ToString());
46
+            }
30
             var token = context.Request["token"];
47
             var token = context.Request["token"];
31
             if (string.IsNullOrWhiteSpace(token)) return;
48
             if (string.IsNullOrWhiteSpace(token)) return;
32
             try
49
             try

+ 21 - 0
codegit/CallCenterCommon/CallCenter.Utility/Common/CommonHelper.cs

245
             //return gb2312.GetString(bs);
245
             //return gb2312.GetString(bs);
246
             return bs;
246
             return bs;
247
         }
247
         }
248
+
249
+        public static string GetRemainingDay()
250
+        {
251
+            try
252
+            {
253
+                string days = "0";
254
+                var date = DateTime.Parse(Configs.GetValue("AuthDate"));
255
+                int remindday = Int32.Parse(Configs.GetValue("AuthRemindDay"));
256
+                var subtime = date.Subtract(DateTime.Now);
257
+                if (subtime.TotalDays <= remindday)
258
+                {
259
+                    days = Math.Floor(subtime.TotalDays).ToString();
260
+                }
261
+
262
+                return days;
263
+            }
264
+            catch (Exception ex)
265
+            {
266
+                return "0";
267
+            }
268
+        }
248
     }
269
     }
249
 }
270
 }

+ 39 - 20
codegit/CallCenterCommon/CallCenter.Utility/Configs/Configs.cs

4
 {
4
 {
5
     public static class Configs
5
     public static class Configs
6
     {
6
     {
7
-        public static System.Xml.XmlDocument xDoc;
8
-        public static System.Xml.XmlNode xNode;
7
+        //public static System.Xml.XmlDocument xDoc;
8
+        //public static System.Xml.XmlNode xNode;
9
 
9
 
10
-        static Configs()
11
-        {
12
-            xDoc = new System.Xml.XmlDocument();
13
-            xDoc.Load(HttpContext.Current.Server.MapPath("~/Configs/system.config"));
14
-            xNode = xDoc.SelectSingleNode("//appSettings");
15
-        }
10
+        //static Configs()
11
+        //{
12
+        //    xDoc = new System.Xml.XmlDocument();
13
+        //    xDoc.Load(HttpContext.Current.Server.MapPath("~/Configs/system.config"));
14
+        //    xNode = xDoc.SelectSingleNode("//appSettings");
15
+        //}
16
 
16
 
17
 
17
 
18
 
18
 
22
         /// <param name="key"></param>
22
         /// <param name="key"></param>
23
         public static string GetValue(string key)
23
         public static string GetValue(string key)
24
         {
24
         {
25
-            var xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
26
-            return xElem1?.GetAttribute("value") ?? "";
25
+            try
26
+            {
27
+                System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
28
+                xDoc.Load(HttpContext.Current.Server.MapPath("~/Configs/system.config"));
29
+                System.Xml.XmlNode xNode = xDoc.SelectSingleNode("//appSettings");
30
+                var xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
31
+                return xElem1?.GetAttribute("value") ?? "";
32
+            }
33
+            catch
34
+            {
35
+                return "";
36
+            }
27
         }
37
         }
28
         /// <summary>
38
         /// <summary>
29
         /// 根据Key修改Value
39
         /// 根据Key修改Value
33
         public static void SetValue(string key, string value)
43
         public static void SetValue(string key, string value)
34
         {
44
         {
35
 
45
 
36
-            System.Xml.XmlElement xElem1;
37
-            System.Xml.XmlElement xElem2;
38
-            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
39
-            if (xElem1 != null) xElem1.SetAttribute("value", value);
40
-            else
46
+            try
41
             {
47
             {
42
-                xElem2 = xDoc.CreateElement("add");
43
-                xElem2.SetAttribute("key", key);
44
-                xElem2.SetAttribute("value", value);
45
-                xNode.AppendChild(xElem2);
48
+                System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
49
+                xDoc.Load(HttpContext.Current.Server.MapPath("~/Configs/system.config"));
50
+                System.Xml.XmlNode xNode = xDoc.SelectSingleNode("//appSettings");
51
+                //System.Xml.XmlNode xNode;
52
+                System.Xml.XmlElement xElem1;
53
+                System.Xml.XmlElement xElem2;
54
+                xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
55
+                if (xElem1 != null) xElem1.SetAttribute("value", value);
56
+                else
57
+                {
58
+                    xElem2 = xDoc.CreateElement("add");
59
+                    xElem2.SetAttribute("key", key);
60
+                    xElem2.SetAttribute("value", value);
61
+                    xNode.AppendChild(xElem2);
62
+                }
63
+                xDoc.Save(HttpContext.Current.Server.MapPath("~/Configs/system.config"));
46
             }
64
             }
47
-            xDoc.Save(HttpContext.Current.Server.MapPath("~/Configs/system.config"));
65
+            catch
66
+            { }
48
         }
67
         }
49
     }
68
     }
50
 }
69
 }