duhongyu %!s(int64=6) %!d(string=před) roky
rodič
revize
6a9d92a2b3

+ 1 - 0
codegit/CallCenterApi/CallCenterApi.DB/DbHelperSQL.cs

@@ -14,6 +14,7 @@ namespace CallCenterApi.DB
14 14
     {
15 15
         //数据库连接字符串(web.config来配置),可以动态更改connectionString支持多数据库.		
16 16
         public static string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
17
+      
17 18
         public DbHelperSQL() { }
18 19
 
19 20
         #region 公用方法

+ 6 - 4
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/report/BusinessController.cs

@@ -28,6 +28,7 @@ namespace CallCenterApi.Interface.Controllers.report
28 28
         public class Conversation
29 29
         {
30 30
             public int Incomingcall;//来电量
31
+            public int time;
31 32
             public int Connect;//接通量
32 33
         }
33 34
         public class Proportion
@@ -44,24 +45,24 @@ namespace CallCenterApi.Interface.Controllers.report
44 45
             if (stime == "")
45 46
             {
46 47
                 sql += " and datediff(day,F_CreateTime,'" + DateTime.Now.ToString("yyyy-MM-dd") + "')<=0 ";
47
-                where += " and datediff(day,BeginTime,'" + DateTime.Now.ToString("yyyy-MM-dd") + "')<=0 ";
48
+                where += "  datediff(day,BeginTime,'" + DateTime.Now.ToString("yyyy-MM-dd") + "')<=0 ";
48 49
             }
49 50
                
50 51
             else
51 52
             {
52 53
                 sql += " and datediff(day,F_CreateTime,'" + stime + "')<=0 ";
53
-                where += " and datediff(day,BeginTime,'" + stime + "')<=0 ";
54
+                where += "  datediff(day,BeginTime,'" + stime + "')<=0 ";
54 55
             }
55 56
               
56 57
             if (endtime == "")
57 58
             {
58 59
                 sql += " and datediff(day,F_CreateTime,'" + DateTime.Now.ToString("yyyy-MM-dd") + "')>=0   ";
59
-                sql += " and datediff(day,BeginTime,'" + DateTime.Now.ToString("yyyy-MM-dd") + "')>=0 ";
60
+                where += " and datediff(day,BeginTime,'" + DateTime.Now.ToString("yyyy-MM-dd") + "')>=0 ";
60 61
             }
61 62
             else
62 63
             {
63 64
                 sql += " and datediff(day,F_CreateTime,'" + endtime + "')>=0   ";
64
-                sql += " and datediff(day,BeginTime,'" + endtime + "')>=0 ";
65
+                where += " and datediff(day,BeginTime,'" + endtime + "')>=0 ";
65 66
             }
66 67
                
67 68
             var workorder = new BLL.T_Bus_WorkOrder().GetModelList(sql);
@@ -93,6 +94,7 @@ namespace CallCenterApi.Interface.Controllers.report
93 94
                 Conversation conversation = new Conversation();
94 95
                 conversation.Connect = 0;
95 96
                 conversation.Incomingcall = 0;
97
+                conversation. time = i;
96 98
                 foreach (var it in CallRecords)
97 99
                 {
98 100
                     var time = DateTime.Parse(it.BeginTime.ToString()).Hour;

+ 1 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkOrderController.cs

@@ -1321,6 +1321,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1321 1321
             itemModel.F_OptContent = content;
1322 1322
             itemModel.F_NextUser = nextuser;
1323 1323
             itemModel.F_NextDept = nextdept;
1324
+            itemModel.F_IsSMS = 0;
1324 1325
             itemModel.F_IsUsed = F_IsUsed;
1325 1326
             itemModel.F_CreateTime = DateTime.Now;
1326 1327
             itemModel.F_CreateUser = nowUser.F_UserCode;

+ 1 - 0
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/workorder/WorkorderAppController.cs

@@ -1398,6 +1398,7 @@ namespace CallCenterApi.Interface.Controllers.workorder
1398 1398
             itemModel.F_OptType = opttype;
1399 1399
             itemModel.F_OptContent = content;
1400 1400
             itemModel.F_NextUser = nextuser;
1401
+            itemModel.F_IsSMS = 0;
1401 1402
             itemModel.F_NextDept = nextdept;
1402 1403
             itemModel.F_IsUsed = F_IsUsed;
1403 1404
             itemModel.F_CreateTime = DateTime.Now;

+ 113 - 15
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Global.asax.cs

@@ -3,6 +3,9 @@ using CallCenterApi.Common;
3 3
 using CallCenterApi.Interface.Models.Common;
4 4
 using System;
5 5
 using System.Collections.Generic;
6
+using System.Configuration;
7
+using System.Data;
8
+using System.Data.SqlClient;
6 9
 using System.IO;
7 10
 using System.Linq;
8 11
 using System.Runtime.CompilerServices;
@@ -24,28 +27,123 @@ namespace CallCenterApi.Interface
24 27
             RouteConfig.RegisterRoutes(RouteTable.Routes);
25 28
             //clq 增加异常日志记录 自定义 HandleErrorAttribute
26 29
             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
27
-       //   timer = new System.Threading.Timer(SetCensusURL, null, 0, 1000 * 60);
30
+          timer = new System.Threading.Timer(SetCensusURL, null, 0, 1000 * 60);
28 31
 
29 32
         }
30
-
31
-        string filePath = "D:" + "\\CallCenter_log\\";
32
-        [MethodImpl(MethodImplOptions.Synchronized)]
33
+      
33 34
         public void SetCensusURL(object obj)
34 35
         {
35
-            if (!Directory.Exists(filePath))
36
+            var modellist = new BLL.T_Bus_WorkOrder().GetModelList("F_IsDelete=0 and F_State in(1,3,5)");
37
+            if (modellist!=null )
38
+            {
39
+                foreach (var it in modellist)
40
+                {
41
+                    var modellast = new BLL.T_Wo_WorkOrderItem_New().GetModelList("F_WoID = " + it.F_Id + "and F_IsUsed =0 order by F_ID desc").FirstOrDefault ();
42
+                  System.TimeSpan id = DateTime.Now - DateTime.Parse(modellast.F_CreateTime.ToString () );
43
+                    if (id.TotalMinutes  <120)
44
+                    {
45
+                        continue;
46
+                    }
47
+                    else
48
+                    {
49
+                        try
50
+                        {
51
+                            int a = (int)modellast.F_IsSMS ;
52
+                            if (id.TotalMinutes >= 120 + a*10 && id.TotalMinutes < 130 +a * 10)
53
+                            {
54
+                                SendSMS(modellast);
55
+                                AddLog(modellast, a + 1);
56
+                            }
57
+                            else
58
+                                continue;
59
+                        }
60
+                        catch
61
+                        {
62
+                            SendSMS(modellast);
63
+                            AddLog(modellast, 1);
64
+                        }
65
+                    }
66
+                }
67
+            }
68
+        }
69
+        private void SendSMS(Model .T_Wo_WorkOrderItem_New modellast)
70
+        {
71
+            if (!string.IsNullOrEmpty(modellast.F_NextUser))
72
+            {
73
+                var usercount = new BLL.T_Sys_UserAccount().GetModel(modellast.F_NextUser);
74
+                if (usercount != null)
75
+                {
76
+                    if (!string.IsNullOrEmpty(usercount.F_Mobile))
77
+                    {
78
+                        string msg = "你有新的工单,请及时处理";
79
+                        Dictionary<string, string> paras = new Dictionary<string, string>();
80
+                        paras.Add("@tel", usercount.F_Mobile);
81
+                        paras.Add("@content", msg);
82
+                        paras.Add("@sort", "0");
83
+                        var par = RunProcedure("sp_SmsSend", paras, "sp_SmsSend");
84
+                    }
85
+                }
86
+            }
87
+        }
88
+        public static string connectionString = ConfigurationManager.ConnectionStrings["connectionSMS"].ConnectionString;
89
+        /// <summary>
90
+        /// 执行存储过程,返回SqlDataReader ( 注意:调用该方法后,一定要对SqlDataReader进行Close )
91
+        /// </summary>
92
+        /// <param name="storedProcName">存储过程名</param>
93
+        /// <param name="parameters">存储过程参数</param>
94
+        /// <returns>SqlDataReader</returns>
95
+        public static DataSet RunProcedure(string storedProcName, Dictionary<String, String> paras, string tableName)
96
+        {
97
+            List<SqlParameter> ps = new List<SqlParameter>();
98
+            foreach (KeyValuePair<string, string> kvp in paras)
99
+            {
100
+                ps.Add(new SqlParameter(kvp.Key, kvp.Value));
101
+            }
102
+            try
103
+            {
104
+                using (SqlConnection connection = new SqlConnection(connectionString))
105
+                {
106
+                    DataSet dataSet = new DataSet();
107
+                    connection.Open();
108
+                    SqlDataAdapter sqlDA = new SqlDataAdapter();
109
+                    sqlDA.SelectCommand = BuildQueryCommand(connection, storedProcName, ps.ToArray());
110
+                    sqlDA.Fill(dataSet, tableName);
111
+                    connection.Close();
112
+                    return dataSet;
113
+                }
114
+            }
115
+            catch (Exception e)
116
+            {
117
+                return null  ;
118
+            }
119
+           
120
+        }
121
+        private static SqlCommand BuildQueryCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
122
+        {
123
+            SqlCommand command = new SqlCommand(storedProcName, connection);
124
+            command.CommandType = CommandType.StoredProcedure;
125
+            foreach (SqlParameter parameter in parameters)
36 126
             {
37
-                Directory.CreateDirectory(filePath);
127
+                if (parameter != null)
128
+                {
129
+                    // 检查未分配值的输出参数,将其分配以DBNull.Value.
130
+                    if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) &&
131
+                        (parameter.Value == null))
132
+                    {
133
+                        parameter.Value = DBNull.Value;
134
+                    }
135
+                    command.Parameters.Add(parameter);
136
+                }
38 137
             }
39
-          
40
-            FileStream fs = new FileStream(filePath + "Debug.txt", FileMode.Append, FileAccess.Write);
41
-            //获得字节数组
42
-            byte[] data = System.Text.Encoding.Default.GetBytes("执行写入!" + DateTime.Now+"\n");
43
-            //开始写入
44
-            fs.Write(data, 0, data.Length);
45
-            //清空缓冲区、关闭流
46
-            fs.Flush();
47
-            fs.Close();
48 138
 
139
+            return command;
140
+        }
141
+        BLL.T_Wo_WorkOrderItem_New itembll = new BLL.T_Wo_WorkOrderItem_New();
142
+        public bool  AddLog(Model.T_Wo_WorkOrderItem_New  itemlist, int F_IsSMS )
143
+        {
144
+            itemlist.F_IsSMS = F_IsSMS;
145
+                var res = itembll.Update (itemlist);
146
+            return res;
49 147
         }
50 148
         protected void Application_AuthenticateRequest(object sender, EventArgs e)
51 149
         {

+ 2 - 2
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Web.config

@@ -14,11 +14,11 @@
14 14
     <add key="smsurl" value="http://api.1086sms.com/api/"/>
15 15
     <add key="smsusername" value="zxzb"/>
16 16
     <add key="smspassword" value="zxzb123"/>
17
-    <add key="smssign" value="中鑫之宝"/>
17
+    <add key="smssign" value=""/>
18 18
   </appSettings>
19 19
   <connectionStrings>
20 20
     <add name="ConnectionString" connectionString="Data Source=192.168.4.18;User ID=sa;pwd=800100;Initial Catalog=CallCenter_ShuangHui;"/>
21
-    <!--<add name="ConnectionString" connectionString="Data Source=192.168.5.8;User ID=sa;pwd=hykj800100;Initial Catalog=CallCenter_Anto_20180725;"/>-->
21
+   <add name="connectionSMS" connectionString="Data Source=192.168.1.4;User ID=sh_gggxzx;pwd=ShGggxzx@2019;Initial Catalog=sms_sh;"/>
22 22
   </connectionStrings>
23 23
   <system.web>
24 24
     <compilation debug="true" targetFramework="4.5"/>