星火微课系统客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Interface.cs 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. using Common.system;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Text;
  7. using XHWK.Model;
  8. namespace XHWK.WKTool.DAL
  9. {
  10. public class Interface
  11. {
  12. //private string APIRequestAddress = FileToolsCommon.GetConfigValue("APIRequestAddress");
  13. //private string FileRequestAddress = FileToolsCommon.GetConfigValue("FileRequestAddress");
  14. //private string schoolfileRequestAddress = FileToolsCommon.GetConfigValue("schoolfileRequestAddress");
  15. /// <summary>
  16. /// 激活信息--添加
  17. /// </summary>
  18. /// <param name="request"></param>
  19. /// <returns></returns>
  20. public int ActivationAdd(string mac, string device, string projectcode)
  21. {
  22. try
  23. {
  24. string url = APP.certapiUrl + "/activation/add";//地址
  25. Dictionary<string, object> dic = new Dictionary<string, object>
  26. {
  27. { "mac", mac },
  28. { "device", device },
  29. { "projectcode", projectcode }
  30. };
  31. string body = JsonHelper.ToJson(dic);
  32. string xmlDoc = HttpHelper.HttpPost(body, url);
  33. if (string.IsNullOrEmpty(xmlDoc))
  34. {
  35. APP.ServerMsg = "网络异常!";
  36. return 1;
  37. }
  38. else
  39. {
  40. JObject obj = JObject.Parse(xmlDoc);
  41. if (obj != null)
  42. {
  43. if (obj["code"].ToString().Equals("0"))
  44. {
  45. APP.Signature = obj["obj"].ToString();
  46. if (!Directory.Exists(APP.dataPath))
  47. {
  48. Directory.CreateDirectory(APP.dataPath);
  49. }
  50. string ApplicationData = APP.dataPath + "signature.txt";
  51. System.IO.File.WriteAllText(ApplicationData, APP.Signature, Encoding.Default);//存放签名
  52. return 0;
  53. }
  54. else
  55. {
  56. APP.ServerMsg = obj["msg"].ToString();
  57. return Convert.ToInt32(obj["code"].ToString());
  58. }
  59. }
  60. else
  61. {
  62. return 1;
  63. }
  64. }
  65. }
  66. catch (Exception ex)
  67. {
  68. APP.ServerMsg = "网络异常!";
  69. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  70. return 1;
  71. }
  72. }
  73. /// <summary>
  74. /// 激活信息--添加激活历史
  75. /// </summary>
  76. /// <param name="request"></param>
  77. /// <returns></returns>
  78. public int ActivationAddHistory()
  79. {
  80. try
  81. {
  82. string url = APP.certapiUrl + "/activation/add_history";
  83. Dictionary<string, object> dic = new Dictionary<string, object>
  84. {
  85. { "sign", APP.Signature }
  86. };
  87. string body = JsonHelper.ToJson(dic);
  88. string xmlDoc = HttpHelper.HttpPost(body, url);
  89. if (string.IsNullOrEmpty(xmlDoc))
  90. {
  91. return 1;
  92. //returnObj.message = "账号密码不正确";
  93. }
  94. else
  95. {
  96. JObject obj = JObject.Parse(xmlDoc);
  97. if (obj != null)
  98. {
  99. APP.ServerMsg = obj["msg"].ToString();
  100. return Convert.ToInt32(obj["code"].ToString());
  101. }
  102. else
  103. {
  104. return 1;
  105. }
  106. }
  107. }
  108. catch (Exception ex)
  109. {
  110. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  111. return 1;
  112. }
  113. }
  114. /// <summary>
  115. /// 登陆
  116. /// </summary>
  117. /// <param name="request"></param>
  118. /// <returns></returns>
  119. public int Login(string loginname, string loginpwd)
  120. {
  121. string url = APP.apiUrl + "/user/login";//地址
  122. Dictionary<string, object> dic = new Dictionary<string, object>
  123. {
  124. { "loginname", loginname},
  125. { "loginpwd", loginpwd}
  126. };
  127. string body = JsonHelper.ToJson(dic);
  128. ResultVo<Model_UserInfo> result = HttpHelper.PostAndRespSignle<ResultVo<Model_UserInfo>>(url, postData: body);
  129. if (result != null)
  130. {
  131. APP.UserInfo = new Model_UserInfo();
  132. APP.ServerMsg = result.msg;
  133. APP.UserInfo = result.obj;
  134. return result.code;
  135. }
  136. else
  137. {
  138. APP.ServerMsg = "网络异常!";
  139. APP.UserInfo = new Model_UserInfo();
  140. return 1;
  141. }
  142. }
  143. /// <summary>
  144. /// 教师教材列表
  145. /// </summary>
  146. /// <param name="request"></param>
  147. /// <returns></returns>
  148. public int TsubjectbookList()
  149. {
  150. APP.TsubjectbookList = new List<Model_TsubjectbookList>();
  151. try
  152. {
  153. string url = APP.apiUrl + "/tsubjectbook/list";//地址
  154. Dictionary<string, int> dic = new Dictionary<string, int>
  155. {
  156. { "teacherid",APP.UserInfo.Userid}
  157. };
  158. string body = JsonHelper.ToJson(dic);
  159. ResultVo<List<Model_TsubjectbookList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_TsubjectbookList>>>(url, postData: body);
  160. if (result != null)
  161. {
  162. APP.ServerMsg = result.msg;
  163. APP.TsubjectbookList = result.obj;
  164. return result.code;
  165. }
  166. else
  167. {
  168. APP.ServerMsg = "网络异常!";
  169. return 1;
  170. }
  171. }
  172. catch (Exception ex)
  173. {
  174. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  175. return 1;
  176. }
  177. }
  178. /// <summary>
  179. /// 章节--列表
  180. /// </summary>
  181. /// <param name="request"></param>
  182. /// <returns></returns>
  183. public int DirectorList(int lsbid, int directortype, int createid)
  184. {
  185. APP.DirectorList = new List<Model_DirectorList>();
  186. try
  187. {
  188. string url = APP.apiUrl + "/director/list";//地址
  189. Dictionary<string, int> dic = new Dictionary<string, int>
  190. {
  191. { "lsbid", lsbid },
  192. { "directortype", directortype },
  193. { "createid", createid }
  194. };
  195. string body = JsonHelper.ToJson(dic);
  196. ResultVo<List<Model_DirectorList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_DirectorList>>>(url, postData: body);
  197. if (result != null)
  198. {
  199. APP.ServerMsg = result.msg;
  200. APP.DirectorList = result.obj;
  201. return result.code;
  202. }
  203. else
  204. {
  205. APP.ServerMsg = "网络异常!";
  206. return 1;
  207. }
  208. }
  209. catch (Exception ex)
  210. {
  211. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  212. return 1;
  213. }
  214. }
  215. /// <summary>
  216. /// 资源--添加
  217. /// </summary>
  218. /// <param name="request"></param>
  219. /// <returns></returns>
  220. public int ResourceAdd(Model_ResourceAdd model)
  221. {
  222. APP.DirectorList = new List<Model_DirectorList>();
  223. try
  224. {
  225. string url = APP.apiUrl + "/resource/add";//地址
  226. Dictionary<string, object> dic = new Dictionary<string, object>
  227. {
  228. // converted: 0
  229. //createid: 80
  230. //directorid: 1009
  231. //duration: 39
  232. //imgUrl: ""
  233. //level: 2
  234. //lsbid: 40
  235. //mp4code: "h264"
  236. //resourcebelong: 3
  237. //resourceclass: 2
  238. //resourcecover: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.jpg"
  239. //resourcename: "weather_pic"
  240. //resourcesize: 6105268
  241. //resourcetype: 0
  242. //resourceurl: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.mp4"
  243. //schoolid: 12
  244. //suffix: "mp4"
  245. //uid: 80
  246. { "converted", model.converted },
  247. { "createid", model.createid }
  248. };
  249. if (model.directorid != 999999)//章节上传可以不选
  250. {
  251. dic.Add("directorid", model.directorid);
  252. }
  253. dic.Add("duration", model.duration);
  254. dic.Add("imgUrl", model.imgUrl);
  255. dic.Add("level", model.level);
  256. dic.Add("lsbid", model.lsbid);
  257. dic.Add("mp4code", model.mp4code);
  258. dic.Add("resourcebelong", model.resourcebelong);
  259. dic.Add("resourceclass", model.resourceclass);
  260. dic.Add("resourcecover", model.resourcecover);
  261. dic.Add("resourcename", model.resourcename);
  262. dic.Add("resourcesize", model.resourcesize);
  263. dic.Add("resourcetype", model.resourcetype);
  264. dic.Add("resourceurl", model.resourceurl);
  265. dic.Add("schoolid", model.schoolid);
  266. dic.Add("suffix", model.suffix);
  267. //dic.Add("uid", model.uid);
  268. string body = JsonHelper.ToJson(dic);
  269. string xmlDoc = HttpHelper.HttpPost(body, url);
  270. JObject obj = JObject.Parse(xmlDoc);
  271. if (obj != null)
  272. {
  273. APP.ServerMsg = obj["msg"].ToString();
  274. return Convert.ToInt32(obj["code"].ToString());
  275. }
  276. else
  277. {
  278. APP.ServerMsg = "网络异常!";
  279. return 1;
  280. }
  281. }
  282. catch (Exception ex)
  283. {
  284. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  285. return 1;
  286. }
  287. }
  288. }
  289. }