mengjie 7 anni fa
parent
commit
78ea189988

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

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

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

1
 using CallCenter.Utility;
1
 using CallCenter.Utility;
2
+using CallCenter.Utility.Common;
2
 using CallCenterApi.Common;
3
 using CallCenterApi.Common;
3
 using CallCenterApi.DB;
4
 using CallCenterApi.DB;
4
 using CallCenterApi.Interface.Controllers.Base;
5
 using CallCenterApi.Interface.Controllers.Base;
465
                 var obj = new
466
                 var obj = new
466
                 {
467
                 {
467
                     user = userModel,
468
                     user = userModel,
468
-                    role = roleModel
469
+                    role = roleModel,
470
+                    date = Configs.GetValue("AuthDate"),
471
+                    days = CommonHelper.GetRemainingDay()
469
                 };
472
                 };
470
                 res = Success("获取成功", obj);
473
                 res = Success("获取成功", obj);
471
             }
474
             }

+ 17 - 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.Write(new AjaxResult { state = ResultTypes.error.ToString(), message = "授权过期,请联系系统厂家。" }.ToJson());
37
+                    context.Response.End();
38
+                }
39
+            }
40
+            catch (Exception ex)
41
+            {
42
+                var log = LogFactory.GetLogger(this.GetType().ToString());
43
+                log.Error(Configs.GetValue("AuthDate"));
44
+                log.Error(ex.ToString());
45
+            }
30
             var token = context.Request["token"];
46
             var token = context.Request["token"];
31
             if (string.IsNullOrWhiteSpace(token)) return;
47
             if (string.IsNullOrWhiteSpace(token)) return;
32
             try
48
             try

+ 7 - 2
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/obj/Release/Package/PackageTmp/Configs/system.config

22
   <!-- 设置微信需要的问卷id -->
22
   <!-- 设置微信需要的问卷id -->
23
   <add key="WXPagerID" value="8" />
23
   <add key="WXPagerID" value="8" />
24
   <!-- 设置微信appid -->
24
   <!-- 设置微信appid -->
25
-  <add key="WechatAppid" value="wxe03366d8c63d9b09" />
25
+  <add key="WechatAppid" value="wx44a8844db00267b3" />
26
   <!-- 设置微信appsecret -->
26
   <!-- 设置微信appsecret -->
27
-  <add key="WechatAppsecret" value="3e42313935a4d6dc8b450172b8be2765" />
27
+  <add key="WechatAppsecret" value="70da5c4bd7fbbc11496d849183e8b29f" />
28
   <!-- 微信支付分配的商户号 --><!--
28
   <!-- 微信支付分配的商户号 --><!--
29
   <add key="WechatMchid" value="1493808312"/>
29
   <add key="WechatMchid" value="1493808312"/>
30
   --><!-- 商户的API密钥 --><!--
30
   --><!-- 商户的API密钥 --><!--
43
   <add key="WechatRemark" value="为回报广大群众提供的信息,特此发放红包以兹鼓励"/>-->
43
   <add key="WechatRemark" value="为回报广大群众提供的信息,特此发放红包以兹鼓励"/>-->
44
   <!-- ================== 4:性能监控 - 配置语音文件盘符 ================== -->
44
   <!-- ================== 4:性能监控 - 配置语音文件盘符 ================== -->
45
   <add key="VideoHardDisc" value="D" />
45
   <add key="VideoHardDisc" value="D" />
46
+  <!-- ================== 5:系统授权 ================== -->
47
+  <!--到期提醒天数-->
48
+  <add key="AuthRemindDay" value="30" />
49
+  <!--到期日期-->
50
+  <add key="AuthDate" value="2018-10-20 23:59:59" />
46
 </appSettings>
51
 </appSettings>

+ 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
 }