|
|
@@ -1,7 +1,9 @@
|
|
1
|
|
-using Newtonsoft.Json.Linq;
|
|
|
1
|
+using Newtonsoft.Json;
|
|
|
2
|
+using Newtonsoft.Json.Linq;
|
|
2
|
3
|
using System;
|
|
3
|
4
|
using System.Collections.Generic;
|
|
4
|
5
|
using System.Linq;
|
|
|
6
|
+using System.Net;
|
|
5
|
7
|
using System.Text;
|
|
6
|
8
|
using System.Threading.Tasks;
|
|
7
|
9
|
|
|
|
@@ -170,5 +172,63 @@ namespace RMYY_CallCenter_Api.Utility
|
|
170
|
172
|
string result = SendMessage(userids, deptids, msg.ToJson());
|
|
171
|
173
|
return result;
|
|
172
|
174
|
}
|
|
|
175
|
+
|
|
|
176
|
+ /// <summary>
|
|
|
177
|
+ ///
|
|
|
178
|
+ /// </summary>
|
|
|
179
|
+ /// <param name="userid"></param>
|
|
|
180
|
+ /// <returns></returns>
|
|
|
181
|
+ public static string GetUserInfoByUserId(string userid)
|
|
|
182
|
+ {
|
|
|
183
|
+ WebClient web = new WebClient();
|
|
|
184
|
+ web.Encoding = Encoding.UTF8;
|
|
|
185
|
+ string strresult = web.DownloadString(string.Format("https://oapi.dingtalk.com/user/get?access_token={0}&userid={1}", GetAccessToken(), userid));
|
|
|
186
|
+
|
|
|
187
|
+ JObject jo = (JObject)JsonConvert.DeserializeObject(strresult);
|
|
|
188
|
+
|
|
|
189
|
+
|
|
|
190
|
+ return jo.ToJson();
|
|
|
191
|
+
|
|
|
192
|
+ }
|
|
|
193
|
+
|
|
|
194
|
+ //给某个部门的所有的人发消息
|
|
|
195
|
+ //获取部门列表
|
|
|
196
|
+ //https://open.dingtalk.com/document/orgapp-server/obtain-the-department-list-v2
|
|
|
197
|
+ public static string GetDeptlist()
|
|
|
198
|
+ {
|
|
|
199
|
+ WebClient web = new WebClient();
|
|
|
200
|
+ web.Encoding = Encoding.UTF8;
|
|
|
201
|
+ string strresult = web.DownloadString(string.Format("https://oapi.dingtalk.com/topapi/v2/department/listsub?access_token={0}&dept_id={1}", GetAccessToken(), 1));
|
|
|
202
|
+
|
|
|
203
|
+ JObject jo = (JObject)JsonConvert.DeserializeObject(strresult);
|
|
|
204
|
+
|
|
|
205
|
+
|
|
|
206
|
+ return jo.ToJson();
|
|
|
207
|
+
|
|
|
208
|
+ }
|
|
|
209
|
+
|
|
|
210
|
+ /// <summary>
|
|
|
211
|
+ /// 获取部门所有的userid
|
|
|
212
|
+ /// </summary>
|
|
|
213
|
+ /// <param name="deptid">get https://oapi.dingtalk.com/user/getDeptMember</param>
|
|
|
214
|
+ /// <returns></returns>
|
|
|
215
|
+
|
|
|
216
|
+
|
|
|
217
|
+
|
|
|
218
|
+ public static string GetUserIdsByDeptId(double deptid)
|
|
|
219
|
+ {
|
|
|
220
|
+ WebClient web = new WebClient();
|
|
|
221
|
+ web.Encoding = Encoding.UTF8;
|
|
|
222
|
+ string strresult = web.DownloadString(string.Format("https://oapi.dingtalk.com/user/getDeptMember?access_token={0}&deptId={1}", GetAccessToken(), deptid));
|
|
|
223
|
+
|
|
|
224
|
+ JObject jo = (JObject)JsonConvert.DeserializeObject(strresult);
|
|
|
225
|
+ if (jo != null && jo["userIds"] != null)
|
|
|
226
|
+ {
|
|
|
227
|
+ return jo["userIds"].ToString();
|
|
|
228
|
+ }
|
|
|
229
|
+
|
|
|
230
|
+ return "";
|
|
|
231
|
+
|
|
|
232
|
+ }
|
|
173
|
233
|
}
|
|
174
|
234
|
}
|