|
|
@@ -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
|
{
|