|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+using Newtonsoft.Json;
|
|
|
2
|
+using Newtonsoft.Json.Linq;
|
|
|
3
|
+using RMYY_CallCenter_Api.Utility;
|
|
|
4
|
+using System;
|
|
|
5
|
+using System.Collections.Generic;
|
|
|
6
|
+using System.Linq;
|
|
|
7
|
+using System.Net.Http;
|
|
|
8
|
+using System.Text;
|
|
|
9
|
+using System.Web;
|
|
|
10
|
+
|
|
|
11
|
+namespace RMYY_CallCenter_Api
|
|
|
12
|
+{
|
|
|
13
|
+ public class InvokeZD
|
|
|
14
|
+ {
|
|
|
15
|
+ private static string domainUrl = "";
|
|
|
16
|
+
|
|
|
17
|
+ public static string ZDSubmitWorkOrder(Dictionary<string, object> dic ,string usercode)
|
|
|
18
|
+ {
|
|
|
19
|
+ HttpClient client = new HttpClient();
|
|
|
20
|
+ var requestHeaders = new Dictionary<string, string>();
|
|
|
21
|
+
|
|
|
22
|
+ string token = GetToken(usercode);
|
|
|
23
|
+ string url = ConfigHelper.GetValue("zdaddurl");
|
|
|
24
|
+
|
|
|
25
|
+ requestHeaders.Add("userCode", $"{usercode }");
|
|
|
26
|
+ requestHeaders.Add("authorization", $"{token }");
|
|
|
27
|
+ requestHeaders.Add("domainUrl", $"{domainUrl }");
|
|
|
28
|
+
|
|
|
29
|
+ foreach (var item in requestHeaders)
|
|
|
30
|
+ {
|
|
|
31
|
+ client.DefaultRequestHeaders.Add(item.Key, item.Value);
|
|
|
32
|
+ }
|
|
|
33
|
+ var d = JsonConvert.SerializeObject(dic);
|
|
|
34
|
+ StringContent content = new StringContent(d, Encoding.UTF8, "application/json");
|
|
|
35
|
+
|
|
|
36
|
+ var result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
|
|
|
37
|
+ JObject jo = (JObject)JsonConvert.DeserializeObject(result);
|
|
|
38
|
+ string code = jo["success"].ToString();
|
|
|
39
|
+ if (code == "true")
|
|
|
40
|
+ return jo["result"].ToString();
|
|
|
41
|
+ else
|
|
|
42
|
+ return "";
|
|
|
43
|
+
|
|
|
44
|
+
|
|
|
45
|
+ }
|
|
|
46
|
+
|
|
|
47
|
+ public static string ZDUrgeWorkOrder(Dictionary<string, object> dic, string usercode)
|
|
|
48
|
+ {
|
|
|
49
|
+ HttpClient client = new HttpClient();
|
|
|
50
|
+ var requestHeaders = new Dictionary<string, string>();
|
|
|
51
|
+
|
|
|
52
|
+ string token = GetToken(usercode);
|
|
|
53
|
+ string url = ConfigHelper.GetValue("zdurgeurl");
|
|
|
54
|
+
|
|
|
55
|
+ requestHeaders.Add("userCode", $"{usercode }");
|
|
|
56
|
+ requestHeaders.Add("authorization", $"{token }");
|
|
|
57
|
+ requestHeaders.Add("domainUrl", $"{domainUrl }");
|
|
|
58
|
+
|
|
|
59
|
+ foreach (var item in requestHeaders)
|
|
|
60
|
+ {
|
|
|
61
|
+ client.DefaultRequestHeaders.Add(item.Key, item.Value);
|
|
|
62
|
+ }
|
|
|
63
|
+ var d = JsonConvert.SerializeObject(dic);
|
|
|
64
|
+ StringContent content = new StringContent(d, Encoding.UTF8, "application/json");
|
|
|
65
|
+
|
|
|
66
|
+ var result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
|
|
|
67
|
+ JObject jo = (JObject)JsonConvert.DeserializeObject(result);
|
|
|
68
|
+ string code = jo["success"].ToString();
|
|
|
69
|
+ return code;
|
|
|
70
|
+
|
|
|
71
|
+ }
|
|
|
72
|
+
|
|
|
73
|
+ public static string ZDRevokeWorkOrder(Dictionary<string, object> dic, string usercode)
|
|
|
74
|
+ {
|
|
|
75
|
+ HttpClient client = new HttpClient();
|
|
|
76
|
+ var requestHeaders = new Dictionary<string, string>();
|
|
|
77
|
+
|
|
|
78
|
+ string token = GetToken(usercode);
|
|
|
79
|
+ string url = ConfigHelper.GetValue("zdrevokeurl");
|
|
|
80
|
+
|
|
|
81
|
+ requestHeaders.Add("userCode", $"{usercode }");
|
|
|
82
|
+ requestHeaders.Add("authorization", $"{token }");
|
|
|
83
|
+ requestHeaders.Add("domainUrl", $"{domainUrl }");
|
|
|
84
|
+
|
|
|
85
|
+ foreach (var item in requestHeaders)
|
|
|
86
|
+ {
|
|
|
87
|
+ client.DefaultRequestHeaders.Add(item.Key, item.Value);
|
|
|
88
|
+ }
|
|
|
89
|
+ var d = JsonConvert.SerializeObject(dic);
|
|
|
90
|
+ StringContent content = new StringContent(d, Encoding.UTF8, "application/json");
|
|
|
91
|
+
|
|
|
92
|
+ var result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
|
|
|
93
|
+ JObject jo = (JObject)JsonConvert.DeserializeObject(result);
|
|
|
94
|
+ string code = jo["success"].ToString();
|
|
|
95
|
+ return code;
|
|
|
96
|
+
|
|
|
97
|
+ }
|
|
|
98
|
+
|
|
|
99
|
+ public static string ZDEvaluate(Dictionary<string, object> dic, string usercode)
|
|
|
100
|
+ {
|
|
|
101
|
+ HttpClient client = new HttpClient();
|
|
|
102
|
+ var requestHeaders = new Dictionary<string, string>();
|
|
|
103
|
+
|
|
|
104
|
+ string token = GetToken(usercode);
|
|
|
105
|
+ string url = ConfigHelper.GetValue("zdevaurl");
|
|
|
106
|
+
|
|
|
107
|
+ requestHeaders.Add("userCode", $"{usercode }");
|
|
|
108
|
+ requestHeaders.Add("authorization", $"{token }");
|
|
|
109
|
+ requestHeaders.Add("domainUrl", $"{domainUrl }");
|
|
|
110
|
+
|
|
|
111
|
+ foreach (var item in requestHeaders)
|
|
|
112
|
+ {
|
|
|
113
|
+ client.DefaultRequestHeaders.Add(item.Key, item.Value);
|
|
|
114
|
+ }
|
|
|
115
|
+ var d = JsonConvert.SerializeObject(dic);
|
|
|
116
|
+ StringContent content = new StringContent(d, Encoding.UTF8, "application/json");
|
|
|
117
|
+
|
|
|
118
|
+ var result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
|
|
|
119
|
+ JObject jo = (JObject)JsonConvert.DeserializeObject(result);
|
|
|
120
|
+ string code = jo["success"].ToString();
|
|
|
121
|
+ return code;
|
|
|
122
|
+
|
|
|
123
|
+ }
|
|
|
124
|
+
|
|
|
125
|
+
|
|
|
126
|
+
|
|
|
127
|
+ public static string GetToken(string userCode)
|
|
|
128
|
+ {
|
|
|
129
|
+ string appKey = ConfigHelper.GetValue("zhidianappKey");
|
|
|
130
|
+ string appSecret = ConfigHelper.GetValue("zhidianappSecret");
|
|
|
131
|
+
|
|
|
132
|
+ string url = ConfigHelper.GetValue("zhidiantokenurl");
|
|
|
133
|
+
|
|
|
134
|
+ HttpClient client = new HttpClient();
|
|
|
135
|
+ var requestHeaders = new Dictionary<string, string>();
|
|
|
136
|
+ //签名算法。支持HmacSHA256、HmacMD5、HmacSHA224、HmacSHA384、HmacSHA512
|
|
|
137
|
+ requestHeaders.Add("appKey", $"{appKey }");
|
|
|
138
|
+ requestHeaders.Add("appSecret", $"{appSecret }");
|
|
|
139
|
+ requestHeaders.Add("userCode", $"{userCode }");
|
|
|
140
|
+ foreach (var item in requestHeaders)
|
|
|
141
|
+ {
|
|
|
142
|
+ client.DefaultRequestHeaders.Add(item.Key, item.Value);
|
|
|
143
|
+ }
|
|
|
144
|
+
|
|
|
145
|
+ HttpResponseMessage response = client.PostAsync(url, null).Result;
|
|
|
146
|
+
|
|
|
147
|
+ string result = response.Content.ReadAsStringAsync().Result;
|
|
|
148
|
+ try
|
|
|
149
|
+ {
|
|
|
150
|
+ Token jo = JsonConvert.DeserializeObject<Token>(result);
|
|
|
151
|
+ if (jo.success == "true")
|
|
|
152
|
+ {
|
|
|
153
|
+ return jo.result;
|
|
|
154
|
+ }
|
|
|
155
|
+
|
|
|
156
|
+ }
|
|
|
157
|
+ catch (Exception e)
|
|
|
158
|
+ {
|
|
|
159
|
+
|
|
|
160
|
+ return "";
|
|
|
161
|
+ }
|
|
|
162
|
+ return "";
|
|
|
163
|
+ }
|
|
|
164
|
+ }
|
|
|
165
|
+ public class Token
|
|
|
166
|
+ {
|
|
|
167
|
+ public string success { set; get; }
|
|
|
168
|
+ public string msg { set; get; }
|
|
|
169
|
+ public string result { get; set; }
|
|
|
170
|
+ }
|
|
|
171
|
+}
|