星火微课系统客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. if (result.obj != null)
  134. {
  135. APP.UserInfo = result.obj;
  136. }
  137. return result.code;
  138. }
  139. else
  140. {
  141. APP.ServerMsg = "网络异常!";
  142. APP.UserInfo = new Model_UserInfo();
  143. return 1;
  144. }
  145. }
  146. /// <summary>
  147. /// 教师教材列表
  148. /// </summary>
  149. /// <param name="request"></param>
  150. /// <returns></returns>
  151. public int TsubjectbookList()
  152. {
  153. APP.TsubjectbookList = new List<Model_TsubjectbookList>();
  154. try
  155. {
  156. string url = APP.apiUrl + "/tsubjectbook/list";//地址
  157. Dictionary<string, int> dic = new Dictionary<string, int>
  158. {
  159. { "teacherid",APP.UserInfo.Userid}
  160. };
  161. string body = JsonHelper.ToJson(dic);
  162. ResultVo<List<Model_TsubjectbookList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_TsubjectbookList>>>(url, postData: body);
  163. if (result != null)
  164. {
  165. APP.ServerMsg = result.msg;
  166. APP.TsubjectbookList = result.obj;
  167. return result.code;
  168. }
  169. else
  170. {
  171. APP.ServerMsg = "网络异常!";
  172. return 1;
  173. }
  174. }
  175. catch (Exception ex)
  176. {
  177. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  178. return 1;
  179. }
  180. }
  181. /// <summary>
  182. /// 章节--列表
  183. /// </summary>
  184. /// <param name="request"></param>
  185. /// <returns></returns>
  186. public int DirectorList(int lsbid, int directortype, int createid)
  187. {
  188. APP.DirectorList = new List<Model_DirectorList>();
  189. try
  190. {
  191. string url = APP.apiUrl + "/director/list";//地址
  192. Dictionary<string, int> dic = new Dictionary<string, int>
  193. {
  194. { "lsbid", lsbid },
  195. { "directortype", directortype },
  196. { "createid", createid }
  197. };
  198. string body = JsonHelper.ToJson(dic);
  199. ResultVo<List<Model_DirectorList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_DirectorList>>>(url, postData: body);
  200. if (result != null)
  201. {
  202. APP.ServerMsg = result.msg;
  203. APP.DirectorList = result.obj;
  204. return result.code;
  205. }
  206. else
  207. {
  208. APP.ServerMsg = "网络异常!";
  209. return 1;
  210. }
  211. }
  212. catch (Exception ex)
  213. {
  214. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  215. return 1;
  216. }
  217. }
  218. /// <summary>
  219. /// 资源--添加
  220. /// </summary>
  221. /// <param name="request"></param>
  222. /// <returns></returns>
  223. public int ResourceAdd(Model_ResourceAdd model)
  224. {
  225. APP.DirectorList = new List<Model_DirectorList>();
  226. try
  227. {
  228. string url = APP.apiUrl + "/resource/add";//地址
  229. Dictionary<string, object> dic = new Dictionary<string, object>
  230. {
  231. // converted: 0
  232. //createid: 80
  233. //directorid: 1009
  234. //duration: 39
  235. //imgUrl: ""
  236. //level: 2
  237. //lsbid: 40
  238. //mp4code: "h264"
  239. //resourcebelong: 3
  240. //resourceclass: 2
  241. //resourcecover: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.jpg"
  242. //resourcename: "weather_pic"
  243. //resourcesize: 6105268
  244. //resourcetype: 0
  245. //resourceurl: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.mp4"
  246. //schoolid: 12
  247. //suffix: "mp4"
  248. //uid: 80
  249. { "converted", model.converted },
  250. { "createid", model.createid }
  251. };
  252. if (model.directorid != 999999)//章节上传可以不选
  253. {
  254. dic.Add("directorid", model.directorid);
  255. }
  256. dic.Add("duration", model.duration);
  257. dic.Add("imgUrl", model.imgUrl);
  258. dic.Add("level", model.level);
  259. dic.Add("lsbid", model.lsbid);
  260. dic.Add("mp4code", model.mp4code);
  261. dic.Add("resourcebelong", model.resourcebelong);
  262. dic.Add("resourceclass", model.resourceclass);
  263. dic.Add("resourcecover", model.resourcecover);
  264. dic.Add("resourcename", model.resourcename);
  265. dic.Add("resourcesize", model.resourcesize);
  266. dic.Add("resourcetype", model.resourcetype);
  267. dic.Add("resourceurl", model.resourceurl);
  268. dic.Add("schoolid", model.schoolid);
  269. dic.Add("suffix", model.suffix);
  270. //dic.Add("uid", model.uid);
  271. string body = JsonHelper.ToJson(dic);
  272. string xmlDoc = HttpHelper.HttpPost(body, url);
  273. JObject obj = JObject.Parse(xmlDoc);
  274. if (obj != null)
  275. {
  276. APP.ServerMsg = obj["msg"].ToString();
  277. return Convert.ToInt32(obj["code"].ToString());
  278. }
  279. else
  280. {
  281. APP.ServerMsg = "网络异常!";
  282. return 1;
  283. }
  284. }
  285. catch (Exception ex)
  286. {
  287. APP.ServerMsg = "网络异常!";
  288. LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
  289. return 1;
  290. }
  291. }
  292. }
  293. }