ScController.cs 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. using Microsoft.AspNetCore.Mvc;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using TEAMModelOS.Models;
  7. using TEAMModelOS.SDK.DI;
  8. using System.Text.Json;
  9. using TEAMModelOS.SDK.Models;
  10. using Microsoft.AspNetCore.Http;
  11. using TEAMModelOS.SDK.Extension;
  12. using Azure.Cosmos;
  13. using System.Text;
  14. using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
  15. using Microsoft.Extensions.Options;
  16. using Azure.Messaging.ServiceBus;
  17. using Microsoft.Extensions.Configuration;
  18. using TEAMModelOS.Services.Common;
  19. using HTEXLib.COMM.Helpers;
  20. using TEAMModelOS.SDK;
  21. using System.IdentityModel.Tokens.Jwt;
  22. using TEAMModelOS.Services;
  23. using TEAMModelOS.SDK.Models.Service;
  24. using System.IO;
  25. using System.Dynamic;
  26. using Microsoft.AspNetCore.Authorization;
  27. using Azure.Storage.Blobs.Models;
  28. using static TEAMModelOS.SDK.Models.Teacher;
  29. using System.Web;
  30. namespace TEAMModelOS.Controllers.Third
  31. {
  32. /// <summary>
  33. ///
  34. /// </summary>
  35. ///
  36. [ProducesResponseType(StatusCodes.Status200OK)]
  37. [ProducesResponseType(StatusCodes.Status400BadRequest)]
  38. //[Authorize(Roles = "IES5")]
  39. //[Route("")]
  40. //[Route("api/[controller]")]
  41. [ApiController]
  42. public class ScController : ControllerBase
  43. {
  44. private readonly SnowflakeId _snowflakeId;
  45. private readonly AzureCosmosFactory _azureCosmos;
  46. private readonly DingDing _dingDing;
  47. private readonly Option _option;
  48. private readonly AzureStorageFactory _azureStorage;
  49. private readonly AzureServiceBusFactory _serviceBus;
  50. private readonly AzureRedisFactory _azureRedis;
  51. private readonly CoreAPIHttpService _accountHttpService;
  52. private readonly ThirdApisService _scsApisService;
  53. public readonly string type = "scsyxpt";
  54. private readonly HttpTrigger _httpTrigger;
  55. /// <summary>
  56. /// 机构安全码
  57. /// </summary>
  58. public string _sc_passKey;
  59. /// <summary>
  60. /// 机构ID
  61. /// </summary>
  62. public string _sc_trainComID;
  63. /// <summary>
  64. /// 机构 AES 密钥
  65. /// </summary>
  66. public string _sc_privateKey;
  67. /// <summary>
  68. /// 访问地址
  69. /// </summary>
  70. public string _sc_url;
  71. public IConfiguration _configuration { get; set; }
  72. public ScController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
  73. AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService accountHttpService, ThirdApisService scsApisService, HttpTrigger httpTrigger)
  74. {
  75. _azureCosmos = azureCosmos;
  76. _snowflakeId = snowflakeId;
  77. _dingDing = dingDing;
  78. _option = option?.Value;
  79. _azureStorage = azureStorage;
  80. _serviceBus = serviceBus;
  81. _configuration = configuration;
  82. _azureRedis = azureRedis;
  83. _accountHttpService = accountHttpService;
  84. _scsApisService = scsApisService;
  85. _sc_passKey = _configuration.GetValue<string>("Third:scsyxpt:passKey");
  86. _sc_trainComID = _configuration.GetValue<string>("Third:scsyxpt:trainComID");
  87. _sc_privateKey = _configuration.GetValue<string>("Third:scsyxpt:privateKey");
  88. _sc_url = _configuration.GetValue<string>("Third:scsyxpt:url");
  89. _httpTrigger = httpTrigger;
  90. }
  91. /// <summary>
  92. ///
  93. /// </summary>
  94. /// <param name="request"></param>
  95. /// <returns></returns>
  96. [ProducesDefaultResponseType]
  97. [HttpPost("sc/binda")]
  98. [AllowAnonymous]
  99. public async Task<IActionResult> FixBlobBinds(JsonElement json)
  100. {
  101. List<Teacher> teachers = new List<Teacher>();
  102. string sql = $" SELECT value(c) FROM c where ARRAY_LENGTH(c.binds)>0 ";
  103. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sql,
  104. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  105. {
  106. teachers.Add(item);
  107. }
  108. var url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
  109. var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
  110. var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
  111. var location = _option.Location;
  112. List<string> unbind = new List<string>();
  113. List<string> list = new List<string>();
  114. (int code, string content) = await _accountHttpService.Implicit(clientID, clientSecret, location, $"{url}/oauth2/implicit",
  115. new Dictionary<string, string>()
  116. {
  117. { "grant_type", "implicit" },
  118. { "client_id",clientID },
  119. { "account","1639025968" },
  120. { "nonce",Guid.NewGuid().ToString()}
  121. });
  122. foreach (var teacher in teachers)
  123. {
  124. var a = teacher.binds.SelectMany(y => y.data).ToList().Find(x => !string.IsNullOrEmpty(x));
  125. if (a != null)
  126. {
  127. // await _azureStorage.UploadFileByContainer("teammodelos", a, $"yxpt/scpjx/scbind", $"{teacher.id}.json");
  128. }
  129. else
  130. {
  131. unbind.Add(teacher.id);
  132. }
  133. //(int code, string content) = await _accountHttpService.Implicit(clientID, clientSecret, location, $"{url}/oauth2/implicit",
  134. // new Dictionary<string, string>()
  135. // {
  136. // { "grant_type", "implicit" },
  137. // { "client_id",clientID },
  138. // { "account",teacher.id },
  139. // { "nonce",Guid.NewGuid().ToString()}
  140. // });
  141. //if (content.Contains("error")) {
  142. // unbind.Add(teacher.id);
  143. //}
  144. //list.Add(content);
  145. }
  146. await _dingDing.SendBotMsg($"OS,{_option.Location}\n绑定失败,出现的原因可能是 参数异常:\n{unbind.ToJsonString()}", GroupNames.成都开发測試群組);
  147. return Ok(new { unbind ,list});
  148. }
  149. /// <summary>
  150. ///
  151. /// </summary>
  152. /// <param name="request"></param>
  153. /// <returns></returns>
  154. [ProducesDefaultResponseType]
  155. [HttpPost("sc/bind")]
  156. [AllowAnonymous]
  157. public async Task<IActionResult> Bind(SSO sso) {
  158. try
  159. {
  160. Teacher teacher = null;
  161. if (string.IsNullOrEmpty(sso.id_token)) {
  162. return Ok(new
  163. {
  164. location = _option.Location,
  165. status = 2,
  166. });
  167. }
  168. JwtSecurityToken jwt = null;
  169. try {
  170. jwt = new JwtSecurityToken(sso.id_token);
  171. } catch (Exception ex) {
  172. await _dingDing.SendBotMsg($"OS,{_option.Location}\n绑定失败,出现的原因可能是 参数异常:\n{sso.ToJsonString()},{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  173. return BadRequest();
  174. }
  175. if (!jwt.Payload.Iss.Equals("account.teammodel", StringComparison.OrdinalIgnoreCase)) return BadRequest();
  176. var id = jwt.Payload.Sub;
  177. jwt.Payload.TryGetValue("name", out object name);
  178. jwt.Payload.TryGetValue("picture", out object picture);
  179. ScSSOData scsso = HttpUtility.UrlDecode(sso.param, Encoding.UTF8).ToObject<ScSSOData>();
  180. var client = _azureCosmos.GetCosmosClient();
  181. try
  182. {
  183. teacher = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>(id, new PartitionKey("Base"));
  184. //先检查绑定的平台是否已经被绑定
  185. //四川研训平台跳转隐式登录/或者绑定IES平台接入规范
  186. string sql = $"SELECT distinct value(c) FROM c join A1 in c.binds where A1.tid='{scsso.tid}'";
  187. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sql,
  188. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  189. {
  190. teacher = item;
  191. break;
  192. }
  193. if (teacher != null)
  194. {
  195. if (teacher.id.Equals(id))
  196. {
  197. //var bind = teacher.binds.Find(x => x.source.Equals($"{scsso.Webid}") && x.userid.Equals($"{scsso.tid}"));
  198. var bind = teacher.binds.Find(x => x.userid.Equals($"{scsso.tid}"));
  199. if (bind == null)
  200. {
  201. teacher.binds = new List<Teacher.ThirdBind> { new Teacher.ThirdBind { data = new List<string> { scsso.data }, userid = $"{scsso.tid}", /*source = $"{scsso.Webid}",*/ type = type } };
  202. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  203. }
  204. else
  205. {
  206. var bindData = scsso.data.ToObject<ScBindData>();
  207. bool isnew = true;
  208. for (int index = 0; index < bind.data.Count; index++)
  209. {
  210. ScBindData scBind = bind.data[index].ToObject<ScBindData>();
  211. if (scBind.pxid.Equals(bindData.pxid))
  212. {
  213. bind.data[index] = bindData.ToJsonString();
  214. isnew = false;
  215. }
  216. }
  217. if (isnew)
  218. {
  219. bind.data.Add(bindData.ToJsonString());
  220. }
  221. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  222. await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
  223. }
  224. }
  225. else
  226. {
  227. return Ok(new
  228. {
  229. location = _option.Location,
  230. //账号已被别的醍摩豆id绑定
  231. status = 3,
  232. tmdid = teacher.id,
  233. name = teacher.name,
  234. tid = scsso.tid
  235. });
  236. }
  237. }
  238. }
  239. catch (CosmosException ex)
  240. {
  241. teacher = new Teacher
  242. {
  243. id = id,
  244. pk = "Base",
  245. code = "Base",
  246. name = name?.ToString(),
  247. picture = picture?.ToString(),
  248. //创建账号并第一次登录IES5则默认赠送1G
  249. size = 1,
  250. defaultSchool = null,
  251. schools = new List<Teacher.TeacherSchool>(),
  252. binds = new List<Teacher.ThirdBind> { new Teacher.ThirdBind { data = new List<string> { scsso.data }, userid = $"{scsso.tid}", /*source = $"{scsso.Webid}",*/ type = type } }
  253. };
  254. var container = _azureStorage.GetBlobContainerClient(id);
  255. await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
  256. teacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<Teacher>(teacher, new PartitionKey("Base"));
  257. await _azureStorage.UploadFileByContainer("teammodelos", scsso.data.ToJsonString(), $"yxpt/{scsso.path}/scbind", $"{teacher.id}.json");
  258. }
  259. catch (Exception ex) {
  260. await _dingDing.SendBotMsg($"OS,{_option.Location}\n绑定失败:\n{sso.ToJsonString()},{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  261. return Ok(new
  262. {
  263. location = _option.Location,
  264. status = 2,
  265. });
  266. }
  267. return Ok(new
  268. {
  269. location = _option.Location,
  270. status = 200,
  271. });
  272. } catch (Exception ex ) {
  273. await _dingDing.SendBotMsg($"OS,{_option.Location}\n绑定失败:\n{sso.ToJsonString()},{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
  274. return Ok(new
  275. {
  276. location = _option.Location,
  277. status = 2,
  278. });
  279. }
  280. }
  281. /// <summary>
  282. /// 动态地址路由。"config":"scsyxpt","path":"sc{pjx/jinniu}"
  283. /// </summary>
  284. /// <param name="request"></param>
  285. /// <returns></returns>
  286. [HttpGet("{path}/sso")]
  287. [AllowAnonymous]
  288. public async Task<IActionResult> Sso([FromQuery] ScSSO scsso,string path)
  289. {
  290. var HostName = HttpContext.GetHostName();
  291. if (path.Equals("sc"))
  292. {
  293. path = $"scpjx";
  294. }
  295. else
  296. {
  297. path = $"sc{path}";
  298. }
  299. //var rurl = new StringBuilder($"https://{_option.HostName}/sso");
  300. var rurl = new StringBuilder($"https://{HostName}/sso");
  301. try {
  302. string parmas = $"Pxid={scsso.Pxid}&Webid={scsso.Webid}&tid={scsso.tid}&time={scsso.time}";
  303. if (Md5Hash.GetMd5String(parmas).Equals($"{scsso.Encrypt}"))
  304. {
  305. //四川研训平台跳转隐式登录/或者绑定IES平台接入规范
  306. long ssotime = long.Parse($"{scsso.time}");
  307. long nowtime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
  308. if (nowtime - ssotime > 60 * 10)//10分钟有效期
  309. {
  310. // return Ok(new { status = 2, msg = "登录超时!" });
  311. }
  312. }
  313. else
  314. {
  315. return Redirect(rurl.Append($"?status=1").ToString());
  316. }
  317. string setsql = $"select value(c) from c where contains(c.accessConfig,'{path}') and contains(c.accessConfig,'scsyxpt') ";
  318. AreaSetting setting = null;
  319. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<AreaSetting>(queryText: setsql,
  320. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AreaSetting") }))
  321. {
  322. setting = item;
  323. break;
  324. }
  325. if (setting==null ||(setting != null && string.IsNullOrEmpty(setting.accessConfig)))
  326. {
  327. return Redirect(rurl.Append($"?status=1").ToString());
  328. }
  329. string accessConfig = setting.accessConfig;
  330. Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", accessConfig }, { "pxid", scsso.Pxid }, { "tid", scsso.tid } };
  331. string SchoolName="",SchoolID = "", ProjectID = "", ProjectItemID ="" ;
  332. (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSingleTeacherByProject");
  333. if (status == 200)
  334. {
  335. ScTeacher scTeacher = json.ToObject<ScTeacher>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
  336. await _dingDing.SendBotMsg($"OS,{_option.Location}\n省平台教师信息:\n{scTeacher.ToJsonString()}",GroupNames.成都开发測試群組);
  337. if (scTeacher != null && $"{scTeacher.PXID}".Equals(scsso.Pxid) && $"{scTeacher.TID}".Equals(scsso.tid))
  338. {
  339. SchoolName = scTeacher.SchoolName;
  340. SchoolID = $"{scTeacher.SchoolID}";
  341. ProjectID =$"{ scTeacher.ProjectID}";
  342. ProjectItemID =$"{ scTeacher.ProjectItemID}";
  343. }
  344. }
  345. ScBindData bindData = new ScBindData
  346. {
  347. sn = SchoolName,
  348. sid = SchoolID,
  349. pd = ProjectID,
  350. pid = ProjectItemID,
  351. pxid = scsso.Pxid
  352. };
  353. var data = bindData.ToJsonString();
  354. ScSSOData sso = new ScSSOData {
  355. path = path,
  356. Pxid = scsso.Pxid,
  357. Encrypt = scsso.Encrypt,
  358. tid = scsso.tid,
  359. time = scsso.time,
  360. data= data
  361. };
  362. Teacher teacher = null;
  363. //四川研训平台跳转隐式登录/或者绑定IES平台接入规范
  364. //string sql = $"SELECT distinct value(c) FROM c join A1 in c.binds where A1.pxid='{sso.Pxid}' and A1.webid='{sso.Webid}' and A1.tid='{sso.tid}'";
  365. string sql = $"SELECT distinct value(c) FROM c join A1 in c.binds where A1.userid='{sso.tid}'";
  366. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sql,
  367. requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  368. {
  369. teacher = item;
  370. break;
  371. }
  372. if (teacher == null)
  373. {
  374. //string enurl = HttpUtility.UrlEncode(rurl.Append($"?status=4&param={sso.ToJsonString()}&type={type}&bindurl=sc/bind").ToString());
  375. string enurl = $"status=4&param={HttpUtility.UrlEncode(sso.ToJsonString(), Encoding.UTF8)}&type={type}&bindurl=sc/bind";
  376. return Redirect(rurl.Append($"?{enurl}").ToString());
  377. }
  378. else
  379. {
  380. var url = _configuration.GetValue<string>("HaBookAuth:CoreAPI");
  381. var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
  382. var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
  383. var location = _option.Location;
  384. (int code, string content) = await _accountHttpService.Implicit(clientID, clientSecret, location, $"{url}/oauth2/implicit",
  385. new Dictionary<string, string>()
  386. {
  387. { "grant_type", "implicit" },
  388. { "client_id",clientID },
  389. { "account",teacher.id },
  390. { "nonce",Guid.NewGuid().ToString()}
  391. });
  392. TmdidImplicit implicit_token = new TmdidImplicit();
  393. if (!string.IsNullOrEmpty(content) && code == 200)
  394. {
  395. implicit_token = content.ToObject<TmdidImplicit>();
  396. if (string.IsNullOrEmpty(implicit_token.id_token)) {
  397. await _dingDing.SendBotMsg($"OS,隐式登录获得信息位空:{_option.Location}-\n{scsso.ToJsonString()} \npath:{path}\n{content}", GroupNames.成都开发測試群組);
  398. return Redirect(rurl.Append($"?status=1").ToString());
  399. }
  400. var bind = teacher.binds.Find(x => x.userid.Equals(sso.tid));
  401. //var bind = teacher.binds.Find(x => x.userid.Equals(sso.tid) && x.source.Equals(sso.Webid));
  402. if (bind != null)
  403. {
  404. bool isnew = true;
  405. for (int index = 0;index< bind.data.Count; index++) {
  406. ScBindData scBind = bind.data[index].ToObject<ScBindData>();
  407. if (scBind.pxid.Equals(bindData.pxid))
  408. {
  409. bind.data[index]= bindData.ToJsonString();
  410. isnew = false;
  411. }
  412. }
  413. if (isnew)
  414. {
  415. bind.data.Add(bindData.ToJsonString());
  416. }
  417. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  418. //var scbind= bind.data.FindAll(x=>x.Contains("scsyxpt"));
  419. //if (scbind != null) {
  420. // foreach (var bd in scbind) {
  421. // }
  422. //}
  423. //if (bind.pxid != null)
  424. //{
  425. // if (bind.pxid.Add(sso.Pxid))
  426. // {
  427. // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  428. // }
  429. //}
  430. //else
  431. //{
  432. // bind.pxid = new HashSet<string> { sso.Pxid };
  433. // await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  434. //}
  435. }
  436. await _azureStorage.UploadFileByContainer("teammodelos", bindData.ToJsonString(), $"yxpt/{sso.path}/scbind", $"{teacher.id}.json");
  437. rurl.Append($"?status=200&id_token={implicit_token.id_token}&access_token={implicit_token.access_token}&expires_in={HttpUtility.UrlEncode(implicit_token.expires_in)}&token_type={HttpUtility.UrlEncode(implicit_token.token_type)}").ToString();
  438. string uri = rurl.ToString();
  439. return Redirect(uri);
  440. }
  441. else
  442. {
  443. //绑定失效
  444. if (teacher.binds.IsNotEmpty())
  445. {
  446. // teacher.binds.RemoveAll(x => x.userid.Equals(sso.tid) && x.source.Equals(sso.Webid));
  447. teacher.binds.RemoveAll(x => x.userid.Equals(sso.tid) );
  448. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(teacher, teacher.id, new PartitionKey(teacher.code));
  449. }
  450. // string enurl = HttpUtility.UrlEncode(rurl.Append($"status=4&param={sso.ToJsonString()}&type={type}&bindurl=sc/bind").ToString());
  451. string enurl = $"status=4&param={HttpUtility.UrlEncode(sso.ToJsonString(),Encoding.UTF8)}&type={type}&bindurl=sc/bind";
  452. return Redirect(rurl.Append($"?{enurl}").ToString());
  453. }
  454. }
  455. } catch (Exception ex) {
  456. await _dingDing.SendBotMsg($"OS,{_option.Location}-\n{scsso.ToJsonString()} \npath:{path}\n{ex.StackTrace}\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
  457. return Redirect(rurl.Append($"?status=1").ToString());
  458. }
  459. }
  460. /// <summary>
  461. ///
  462. /// </summary>
  463. /// <param name="json"></param>
  464. /// <returns></returns>
  465. [ProducesDefaultResponseType]
  466. [HttpPost("sc/get-list")]
  467. [AllowAnonymous]
  468. public async Task<IActionResult> GetProjectList(JsonElement json)
  469. {
  470. // 5.3.1.1获取项目列表
  471. string trainComID = _sc_trainComID;
  472. string Code = "GetProjectInfoByTrainComID";
  473. Dictionary<string, object> parameterMap = new Dictionary<string, object>();
  474. parameterMap.Add("TrainComID", _sc_trainComID);
  475. ScsResult GetProjectInfoByTrainComID = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  476. GetProjectInfoByTrainComID.code = Code;
  477. GetProjectInfoByTrainComID.title = "5.3.1.1获取项目列表";
  478. // 5.3.1.2获取学员名单,暂不对接 V1。
  479. Code = "GetTeachersListByProject";
  480. parameterMap = new Dictionary<string, object>();
  481. parameterMap.Add("TrainComID", trainComID);
  482. parameterMap.Add("ProjectID", "22");
  483. parameterMap.Add("ProjectItemID", "24");
  484. ScsResult GetTeachersListByProject = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  485. GetTeachersListByProject.code = Code;
  486. GetTeachersListByProject.title = "5.3.1.2获取学员名单";
  487. // 5.3.1.3通过项目编号获取学员测评能力项,需要确认每个教师是是否一样。
  488. Code = "GetDiagnosisListByProject";
  489. parameterMap = new Dictionary<string, object>();
  490. parameterMap.Add("TrainComID", trainComID);
  491. parameterMap.Add("ProjectID", "22");
  492. parameterMap.Add("ProjectItemID", "24");
  493. parameterMap.Add("PXID", "65321");
  494. ScsResult GetDiagnosisListByProject = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  495. GetDiagnosisListByProject.code = Code;
  496. GetDiagnosisListByProject.title = "5.3.1.3通过项目编号获取学员测评能力项";
  497. // 补充
  498. // 5.3.1.3通过项目编号获取学员测评能力项,需要确认每个教师是是否一样。
  499. Code = "GetDiagnosisListByProject_V2";
  500. parameterMap = new Dictionary<string, object>();
  501. parameterMap.Add("TrainComID", trainComID);
  502. //parameterMap.Add("ProjectID", "22");
  503. //parameterMap.Add("ProjectItemID", "22");
  504. parameterMap.Add("PXID", "65321");
  505. ScsResult GetDiagnosisListByProject_V2 = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  506. GetDiagnosisListByProject_V2.code = Code;
  507. GetDiagnosisListByProject_V2.title = "5.3.1.3通过项目编号获取学员测评能力项V2";
  508. ScsResult UpdateTeacherSituation = null;
  509. // 5.3.1.4学员培训基本情况回写
  510. try
  511. {
  512. Code = "UpdateTeacherSituation";
  513. parameterMap = new Dictionary<string, object>();
  514. parameterMap.Add("TrainComID", trainComID);
  515. parameterMap.Add("PXID", "65324");
  516. parameterMap.Add("TID", "253940");
  517. parameterMap.Add("TeacherName", "宋鸿");
  518. parameterMap.Add("CourseHour", "50");
  519. parameterMap.Add("ResearchText", "");//学习成果描述,字符长度<=300
  520. parameterMap.Add("ComPassed", "1");//0、未认定 1、合格 2、优秀 3、不合格 4、其他
  521. UpdateTeacherSituation = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  522. UpdateTeacherSituation.code = Code;
  523. UpdateTeacherSituation.title = "5.3.1.4学员培训基本情况回写";
  524. }
  525. catch (Exception ex) { }
  526. ScsResult UpdateTeacherDiagnosis = null;
  527. try
  528. {
  529. // 5.3.1.5学员能力点测评结果回写
  530. Code = "UpdateTeacherDiagnosis";
  531. parameterMap = new Dictionary<string, object>();
  532. parameterMap.Add("TrainComID", trainComID);
  533. parameterMap.Add("PXID", "65321");
  534. parameterMap.Add("TID", "32393");
  535. parameterMap.Add("DiagnosisNum", "A1");
  536. //0"未认定", 1"合格", 2"优秀", 3"不合格"
  537. parameterMap.Add("zpresult", "1");
  538. parameterMap.Add("hpresult", "1");
  539. parameterMap.Add("xzpresult", "1");
  540. List<Dictionary<string, string>> pfilesA = new List<Dictionary<string, string>>();
  541. parameterMap.Add("pfiles", pfilesA);
  542. Dictionary<string, string> pfileMapA = new Dictionary<string, string>();
  543. pfileMapA.Add("url", "https://scnltsfiles.scedu.com.cn/upload/infofj/202104011628463774.pdf");
  544. pfileMapA.Add("fileName", "XXX.pdf");
  545. pfileMapA.Add("fileSize", "247767");
  546. pfileMapA.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  547. pfileMapA.Add("fileType", "pdf");
  548. pfilesA.Add(pfileMapA);
  549. UpdateTeacherDiagnosis = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  550. UpdateTeacherDiagnosis.code = Code;
  551. UpdateTeacherDiagnosis.title = "5.3.1.5学员能力点测评结果回写";
  552. }
  553. catch (Exception ex)
  554. {
  555. }
  556. // 5.3.1.6获取能力测评体系字典值数据
  557. Code = "GetDiagnosisDic";
  558. parameterMap = new Dictionary<string, object>();
  559. parameterMap.Add("TrainComID", trainComID);
  560. ScsResult GetDiagnosisDic = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  561. GetDiagnosisDic.code = Code;
  562. GetDiagnosisDic.title = "5.3.1.6获取能力测评体系字典值数据";
  563. // 5.3.1.7获取能力测评评价类型字典值数据 ,不用对接
  564. Code = "GetDiagnosisItemDic";
  565. parameterMap = new Dictionary<string, object>();
  566. parameterMap.Add("TrainComID", trainComID);
  567. parameterMap.Add("DiagnosisDicID", "3");
  568. ScsResult GetDiagnosisItemDic = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  569. GetDiagnosisItemDic.code = Code;
  570. GetDiagnosisItemDic.title = "5.3.1.7获取能力测评评价类型字典值数据";
  571. // 5.3.1.8获取能力测评评价类型细则字典值数据,不用对接。
  572. Code = "GetchoiceDic";
  573. parameterMap = new Dictionary<string, object>();
  574. parameterMap.Add("TrainComID", trainComID);
  575. parameterMap.Add("DiagnosisItemID", "4");
  576. ScsResult GetchoiceDic = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  577. GetchoiceDic.code = Code;
  578. GetchoiceDic.title = "5.3.1.8获取能力测评评价类型细则字典值数据";
  579. // 5.3.1.9根据培训ID与机构ID获取老师信息
  580. Code = "GetTeacherInfoByPXID";
  581. parameterMap = new Dictionary<string, object>();
  582. parameterMap.Add("TrainComID", trainComID);
  583. parameterMap.Add("PXID", "65321");
  584. ScsResult GetTeacherInfoByPXID = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  585. GetTeacherInfoByPXID.code = Code;
  586. GetTeacherInfoByPXID.title = "5.3.1.9根据培训ID与机构ID获取老师信息";
  587. // 5.3.1.10根据培训项目ID与学校ID获取学校方案,用于展示学校的id方案。顺便确认学校的名单。
  588. Code = "GetSchoolPlanBySchoolID";
  589. parameterMap = new Dictionary<string, object>();
  590. parameterMap.Add("TrainComID", trainComID);
  591. parameterMap.Add("ProjectItemID", "3");
  592. parameterMap.Add("SchoolID", "220913");
  593. parameterMap.Add("Type", "0");
  594. ScsResult GetSchoolPlanBySchoolID = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  595. GetSchoolPlanBySchoolID.code = Code;
  596. GetSchoolPlanBySchoolID.title = "5.3.1.10根据培训项目ID与学校ID获取学校方案";
  597. // 5.3.1.11获取跳转学员信息。用于sso单点,后端验证
  598. Code = "GetSingleTeacherByProject";
  599. parameterMap = new Dictionary<string, object>();
  600. parameterMap.Add("TrainComID", trainComID);
  601. parameterMap.Add("Pxid", "65321");
  602. parameterMap.Add("Tid", "32393");
  603. ScsResult GetSingleTeacherByProject = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  604. GetSingleTeacherByProject.code = Code;
  605. GetSingleTeacherByProject.title = "5.3.1.11获取跳转学员信息";
  606. ScsResult UpdateTeacherListSituation = null;
  607. Dictionary<string, object> parameterContent = new Dictionary<string, object>();
  608. List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
  609. try
  610. { // 5.3.1.12学员培训基本情况批量回写
  611. Code = "UpdateTeacherListSituation";
  612. parameterContent.Add("TrainComID", trainComID);
  613. parameterContent.Add("List", list);
  614. // {"TrainComID":"39","List":[{"ResearchText":"","ComPassed":1,"PXID":"35455","CourseHour":"50.0","TID":"411105","TeacherName":"付绍令"}]}
  615. {
  616. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  617. parameterMapData.Add("PXID", "65324");
  618. parameterMapData.Add("TID", "253940");
  619. parameterMapData.Add("TeacherName", "柏成伟");
  620. parameterMapData.Add("CourseHour", "50");
  621. parameterMapData.Add("ResearchText", "学习成果描述,字符长度<=300");
  622. parameterMapData.Add("ComPassed", "2");//0、未认定 1、合格 2、优秀 3、不合格 4、其他
  623. list.Add(parameterMapData);
  624. parameterMapData = new Dictionary<string, object>();
  625. parameterMapData.Add("PXID", "65324");
  626. parameterMapData.Add("TID", "253940");
  627. parameterMapData.Add("TeacherName", "柏成伟");
  628. parameterMapData.Add("CourseHour", "50");
  629. parameterMapData.Add("ResearchText", "学习成果描述,字符长度<=300");
  630. parameterMapData.Add("ComPassed", "2");//0、未认定 1、合格 2、优秀 3、不合格 4、其他
  631. list.Add(parameterMapData);
  632. parameterMapData = new Dictionary<string, object>();
  633. //parameterMapData.Add("PXID", "22");
  634. //parameterMapData.Add("TID", "21348");
  635. //parameterMapData.Add("TeacherName", "邓泽燕");
  636. //parameterMapData.Add("CourseHour", "50");
  637. //parameterMapData.Add("ResearchText", "学习成果描述,字符长度<=300");
  638. //parameterMapData.Add("ComPassed", "2");//0、未认定 1、合格 2、优秀 3、不合格 4、其他
  639. //list.Add(parameterMapData);
  640. //parameterMapData = new Dictionary<string, object>();
  641. //parameterMapData.Add("PXID", "35546");
  642. //parameterMapData.Add("TID", "411182");
  643. //parameterMapData.Add("TeacherName", "刘晓莉");
  644. //parameterMapData.Add("CourseHour", "50");
  645. //parameterMapData.Add("ResearchText", "");
  646. //parameterMapData.Add("ComPassed", "1");//0、未认定 1、合格 2、优秀 3、不合格 4、其他
  647. //list.Add(parameterMapData);
  648. }
  649. UpdateTeacherListSituation = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterContent);
  650. UpdateTeacherListSituation.code = Code;
  651. UpdateTeacherListSituation.title = "5.3.1.12学员培训基本情况批量回写";
  652. }
  653. catch (Exception ex) { }
  654. ScsResult UpdateTeacherListDiagnosis = null;
  655. try
  656. { // 5.3.1.13学员能力点测评结果批量回写
  657. Code = "UpdateTeacherListDiagnosis";
  658. parameterContent = new Dictionary<string, object>();
  659. list = new List<Dictionary<string, object>>();
  660. parameterContent.Add("TrainComID", trainComID);
  661. parameterContent.Add("List", list);
  662. {
  663. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  664. parameterMapData.Add("PXID", "65321");
  665. parameterMapData.Add("TID", "32393");
  666. parameterMapData.Add("DiagnosisNum", "A1");
  667. //0"未认定", 1"合格", 2"优秀", 3"不合格"
  668. parameterMapData.Add("zpresult", "1");
  669. parameterMapData.Add("hpresult", "2");
  670. parameterMapData.Add("xzpresult", "2");
  671. List<Dictionary<string, object>> pfiles = new List<Dictionary<string, object>>();
  672. parameterMapData.Add("pfiles", pfiles);
  673. Dictionary<string, object> pfileMap = new Dictionary<string, object>();
  674. pfileMap.Add("url", "https://srt-read-online.3ren.cn/basebusiness/material/20210422/1619055398463iE97VWe36i001.mp4");
  675. pfileMap.Add("fileName", "697a58c2375f7a031456c893e1e1860c.mp4");
  676. pfileMap.Add("fileSize", "17036168");
  677. pfileMap.Add("md5", "");
  678. pfileMap.Add("fileType", "video");
  679. pfiles.Add(pfileMap);
  680. list.Add(parameterMapData);
  681. pfileMap = new Dictionary<string, object>();
  682. pfileMap.Add("url", "https://srt-read-online.3ren.cn/basebusiness/material/20210422/1619055446704gbKuNF8eas001.pdf");
  683. pfileMap.Add("fileName", "A6技术支持的课堂反思.pdf");
  684. pfileMap.Add("fileSize", "32192");
  685. pfileMap.Add("md5", "");
  686. pfileMap.Add("fileType", "pdf");
  687. pfiles.Add(pfileMap);
  688. list.Add(parameterMapData);
  689. }
  690. //{
  691. // Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  692. // parameterMapData.Add("PXID", "3062");
  693. // parameterMapData.Add("TID", "401268");
  694. // parameterMapData.Add("DiagnosisNum", "A1");
  695. // //0"未认定", 1"合格", 2"优秀", 3"不合格"
  696. // parameterMapData.Add("zpresult", "1");
  697. // parameterMapData.Add("hpresult", "2");
  698. // parameterMapData.Add("xzpresult", "2");
  699. // List<Dictionary<string, object>> pfiles = new List<Dictionary<string, object>>();
  700. // parameterMapData.Add("pfiles", pfiles);
  701. // Dictionary<string, object> pfileMap = new Dictionary<string, object>();
  702. // pfileMap.Add("url", "https://srt-read-online.3ren.cn/basebusiness/material/20210422/1619058650000bphKFbDVSa001.pdf");
  703. // pfileMap.Add("fileName", "学情分析.pdf");
  704. // pfileMap.Add("fileSize", "94926");
  705. // pfileMap.Add("md5", "");
  706. // pfileMap.Add("fileType", "pdf");
  707. // pfiles.Add(pfileMap);
  708. // list.Add(parameterMapData);
  709. // pfileMap = new Dictionary<string, object>();
  710. // pfileMap.Add("url", "https://srt-read-online.3ren.cn/basebusiness/material/20210422/1619058698452gF19jmiuML001.mp4");
  711. // pfileMap.Add("fileName", "种子萌发学情分析.mp4");
  712. // pfileMap.Add("fileSize", "12692368");
  713. // pfileMap.Add("md5", "");
  714. // pfileMap.Add("fileType", "video");
  715. // pfiles.Add(pfileMap);
  716. // list.Add(parameterMapData);
  717. //}
  718. UpdateTeacherListDiagnosis = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterContent);
  719. UpdateTeacherListDiagnosis.code = Code;
  720. UpdateTeacherListDiagnosis.title = "5.3.1.13学员能力点测评结果批量回写";
  721. }
  722. catch (Exception ex)
  723. {
  724. }
  725. ScsResult UploadSBTARPDF = null;
  726. try
  727. { // 5.3.1.14学员校本研修PDF回写
  728. Code = "UploadSBTARPDF";
  729. parameterMap = new Dictionary<string, object>();
  730. parameterMap.Add("TrainComID", trainComID);
  731. parameterMap.Add("PXID", "16");
  732. parameterMap.Add("TID", "16");
  733. parameterMap.Add("url", "http://image1.cersp.com.cn/scpx/images/article/file/20190318/upload__51f98fc8_1697695ae73__7ffe_00001297.pdf");
  734. parameterMap.Add("fileName", "XXX.pdf");
  735. parameterMap.Add("fileSize", "247767");
  736. parameterMap.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  737. parameterMap.Add("fileType", "pdf");
  738. UploadSBTARPDF = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  739. UploadSBTARPDF.code = Code;
  740. UploadSBTARPDF.title = "5.3.1.14学员校本研修PDF回写";
  741. }
  742. catch (Exception ex)
  743. {
  744. }
  745. ScsResult UploadSBTARPDFList = null;
  746. try
  747. { // 5.3.1.15学员校本教研PDF批量回写
  748. Code = "UploadSBTARPDFList";
  749. parameterContent = new Dictionary<string, object>();
  750. list = new List<Dictionary<string, object>>();
  751. parameterContent.Add("TrainComID", trainComID);
  752. parameterContent.Add("List", list);
  753. {
  754. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  755. parameterMapData.Add("PXID", "65309");
  756. parameterMapData.Add("TID", "253940");
  757. parameterMapData.Add("url", "https://scnltsfiles.scedu.com.cn/upload/infofj/202104011628463774.pdf");
  758. parameterMapData.Add("fileName", "XXX.pdf");
  759. parameterMapData.Add("fileSize", "247767");
  760. parameterMapData.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  761. parameterMapData.Add("fileType", "pdf");
  762. list.Add(parameterMapData);
  763. }
  764. {
  765. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  766. parameterMapData.Add("PXID", "65306");
  767. parameterMapData.Add("TID", "32393");
  768. parameterMapData.Add("url", "https://scnltsfiles.scedu.com.cn/upload/infofj/202104011628463774.pdf");
  769. parameterMapData.Add("fileName", "XXX.pdf");
  770. parameterMapData.Add("fileSize", "247767");
  771. parameterMapData.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  772. parameterMapData.Add("fileType", "pdf");
  773. list.Add(parameterMapData);
  774. }
  775. UploadSBTARPDFList = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterContent);
  776. UploadSBTARPDFList.code = Code;
  777. UploadSBTARPDFList.title = "5.3.1.15学员校本教研PDF批量回写";
  778. }
  779. catch (Exception ex) { }
  780. ScsResult UploadKTSL = null;
  781. try
  782. {
  783. // 5.3.1.16学员课堂实录回写
  784. Code = "UploadKTSL";
  785. parameterMap = new Dictionary<string, object>();
  786. parameterMap.Add("TrainComID", trainComID);
  787. parameterMap.Add("PXID", "16");
  788. parameterMap.Add("TID", "16");
  789. parameterMap.Add("url", "https://xxx.mp4");
  790. parameterMap.Add("url2", "https://xxx.mp4");
  791. parameterMap.Add("fileName", "XXX.mp4");
  792. parameterMap.Add("fileSize", "247767");
  793. parameterMap.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  794. parameterMap.Add("fileType", "mp4");
  795. UploadKTSL = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  796. UploadKTSL.code = Code;
  797. UploadKTSL.title = "5.3.1.16学员课堂实录回写";
  798. }
  799. catch (Exception ex) { }
  800. ScsResult UploadKTSLList = null;
  801. try
  802. {
  803. // 5.3.1.17学员课堂实录批量回写
  804. Code = "UploadKTSLList";
  805. parameterContent = new Dictionary<string, object>();
  806. list = new List<Dictionary<string, object>>();
  807. parameterContent.Add("TrainComID", trainComID);
  808. parameterContent.Add("List", list);
  809. {
  810. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  811. parameterMapData.Add("PXID", "16");
  812. parameterMapData.Add("TID", "16");
  813. parameterMapData.Add("url", "https://xxx.mp4");
  814. parameterMapData.Add("url2", "https://xxx.mp4");
  815. parameterMapData.Add("fileName", "XXX.mp4");
  816. parameterMapData.Add("fileSize", "247767");
  817. parameterMapData.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  818. parameterMapData.Add("fileType", "mp4");
  819. list.Add(parameterMapData);
  820. }
  821. {
  822. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  823. parameterMapData.Add("PXID", "16");
  824. parameterMapData.Add("TID", "16");
  825. parameterMapData.Add("url", "https://xxx.mp4");
  826. parameterMapData.Add("url2", "https://xxx.mp4");
  827. parameterMapData.Add("fileName", "XXX.mp4");
  828. parameterMapData.Add("fileSize", "247767");
  829. parameterMapData.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  830. parameterMapData.Add("fileType", "mp4");
  831. list.Add(parameterMapData);
  832. }
  833. UploadKTSLList = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterContent);
  834. UploadKTSLList.code = Code;
  835. UploadKTSLList.title = "5.3.1.17学员课堂实录批量回写";
  836. }
  837. catch (Exception ex) { }
  838. // 5.3.1.18根据机构ID、项目ID、子项目ID返回学校列表
  839. Code = "GetSchoolList";
  840. parameterMap = new Dictionary<string, object>();
  841. parameterMap.Add("TrainComID", trainComID);
  842. parameterMap.Add("ProjectID", "22");
  843. parameterMap.Add("ProjectItemID", "24");
  844. ScsResult GetSchoolList = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  845. GetSchoolList.code = Code;
  846. GetSchoolList.title = "5.3.1.18根据机构ID、项目ID、子项目ID返回学校列表";
  847. // 5.3.1.19获取项目设置的可选能力点,
  848. Code = "GetProjectDiagnosis";
  849. parameterMap = new Dictionary<string, object>();
  850. parameterMap.Add("TrainComID", trainComID);
  851. parameterMap.Add("ProjectID", "22");
  852. parameterMap.Add("ProjectItemID", "21");
  853. ScsResult GetProjectDiagnosis = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  854. GetProjectDiagnosis.code = Code;
  855. GetProjectDiagnosis.title = "5.3.1.19获取项目设置的可选能力点";
  856. // 5.3.1.20获取学校设置的可选能力点,
  857. Code = "GetSchoolDiagnosis";
  858. parameterMap = new Dictionary<string, object>();
  859. parameterMap.Add("TrainComID", trainComID);
  860. parameterMap.Add("ProjectID", "22");
  861. parameterMap.Add("ProjectItemID", "21");
  862. parameterMap.Add("SchoolID", "200001");
  863. ScsResult GetSchoolDiagnosis = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  864. GetSchoolDiagnosis.code = Code;
  865. GetSchoolDiagnosis.title = "5.3.1.20获取学校设置的可选能力点";
  866. // 5.3.1.21分页获取学员名单
  867. Code = "GetTeachersPageListByProject";
  868. parameterMap = new Dictionary<string, object>();
  869. parameterMap.Add("TrainComID", trainComID);
  870. parameterMap.Add("ProjectID", "22");
  871. parameterMap.Add("ProjectItemID", "24");
  872. parameterMap.Add("curPage", "1");
  873. parameterMap.Add("pageSize", "10");
  874. ScsResult GetTeachersPageListByProject = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterMap);
  875. GetTeachersPageListByProject.code = Code;
  876. GetTeachersPageListByProject.title = "5.3.1.21分页获取学员名单";
  877. // 5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写
  878. Code = "UploadSBTARPDFListV2";
  879. parameterContent = new Dictionary<string, object>();
  880. parameterContent.Add("TrainComID", trainComID);
  881. list = new List<Dictionary<string, object>>();
  882. parameterContent.Add("List", list);
  883. {
  884. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  885. parameterMapData.Add("PXID", "65309");
  886. parameterMapData.Add("TID", "253940");
  887. List<Dictionary<string, object>> pfiles = new List<Dictionary<string, object>>();
  888. parameterMapData.Add("pfiles", pfiles);
  889. Dictionary<string, object> pfileMap = new Dictionary<string, object>();
  890. pfileMap.Add("url", "https://scnltsfiles.scedu.com.cn/upload/infofj/202104011628463774.pdf");
  891. pfileMap.Add("fileName", "XXX.pdf");
  892. pfileMap.Add("fileSize", "247767");
  893. pfileMap.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  894. pfileMap.Add("fileType", "pdf");
  895. pfiles.Add(pfileMap);
  896. pfileMap = new Dictionary<string, object>(); //添加第二个校本研修方案
  897. pfileMap.Add("url", "https://scnltsfiles.scedu.com.cn/upload/infofj/202104011628463774.pdf");
  898. pfileMap.Add("fileName", "XXX.pdf");
  899. pfileMap.Add("fileSize", "247767");
  900. pfileMap.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  901. pfileMap.Add("fileType", "pdf");
  902. pfiles.Add(pfileMap);
  903. parameterMapData.Add("files", pfiles);
  904. list.Add(parameterMapData);
  905. }
  906. {
  907. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  908. parameterMapData.Add("PXID", "65306");
  909. parameterMapData.Add("TID", "32393");
  910. List<Dictionary<string, object>> pfiles = new List<Dictionary<string, object>>();
  911. parameterMapData.Add("pfiles", pfiles);
  912. Dictionary<string, object> pfileMap = new Dictionary<string, object>();
  913. pfileMap.Add("url", "https://scnltsfiles.scedu.com.cn/upload/infofj/202104011628463774.pdf");
  914. pfileMap.Add("fileName", "XXX.pdf");
  915. pfileMap.Add("fileSize", "247767");
  916. pfileMap.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  917. pfileMap.Add("fileType", "pdf");
  918. pfiles.Add(pfileMap);
  919. pfileMap = new Dictionary<string, object>(); //添加第二个校本研修方案
  920. pfileMap.Add("url", "https://scnltsfiles.scedu.com.cn/upload/infofj/202104011628463774.pdf");
  921. pfileMap.Add("fileName", "XXX.pdf");
  922. pfileMap.Add("fileSize", "247767");
  923. pfileMap.Add("md5", "9c3da8c5c07c2c660cd73c01f56d7fca");
  924. pfileMap.Add("fileType", "pdf");
  925. pfiles.Add(pfileMap);
  926. parameterMapData.Add("files", pfiles);
  927. list.Add(parameterMapData);
  928. }
  929. ScsResult UploadSBTARPDFListV2 = await _scsApisService.Post(_sc_url, Code, _sc_passKey, _sc_privateKey, parameterContent);
  930. UploadSBTARPDFListV2.code = Code;
  931. UploadSBTARPDFListV2.title = "5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写";
  932. return Ok(new
  933. {
  934. GetProjectInfoByTrainComID,
  935. GetTeachersListByProject,
  936. GetDiagnosisListByProject,
  937. GetDiagnosisListByProject_V2,
  938. UpdateTeacherSituation,
  939. UpdateTeacherDiagnosis,
  940. GetDiagnosisDic,
  941. GetDiagnosisItemDic,
  942. GetchoiceDic,
  943. GetTeacherInfoByPXID,
  944. GetSchoolPlanBySchoolID,
  945. GetSingleTeacherByProject,
  946. UpdateTeacherListSituation,
  947. UpdateTeacherListDiagnosis,
  948. UploadSBTARPDF,
  949. UploadSBTARPDFList,
  950. UploadKTSL,
  951. UploadKTSLList,
  952. GetSchoolList,
  953. GetProjectDiagnosis,
  954. GetSchoolDiagnosis,
  955. GetTeachersPageListByProject,
  956. UploadSBTARPDFListV2
  957. });
  958. //return Ok(GetProjectInfoByTrainComID);
  959. }
  960. public record ScSSO{
  961. public string Webid { get; set; }
  962. public string Pxid { get; set; }
  963. public string tid { get; set; }
  964. public string time { get; set; }
  965. public string Encrypt { get; set; }
  966. // public string data { get; set; }
  967. }
  968. public record ScSSOData
  969. {
  970. public string path { get; set; }
  971. public string Pxid { get; set; }
  972. public string tid { get; set; }
  973. public string time { get; set; }
  974. public string Encrypt { get; set; }
  975. public string data { get; set; }
  976. }
  977. public record SSO
  978. {
  979. public string type { get; set; }
  980. public string param { get; set; }
  981. public string id_token { get; set; }
  982. }
  983. public record TmdidImplicit {
  984. public string id_token { get; set; }
  985. public string access_token { get; set; }
  986. public string expires_in { get; set; }
  987. public string token_type { get; set; }
  988. }
  989. }
  990. }