123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- using Common.system;
-
- using Newtonsoft.Json.Linq;
-
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
-
- using XHWK.Model;
-
- namespace XHWK.WKTool.DAL
- {
- public class Interface
- {
-
-
-
-
-
-
-
-
- public int ActivationAdd(string mac, string device, string projectcode)
- {
- try
- {
- string url = APP.certapiUrl + "/activation/add";
- Dictionary<string, object> dic = new Dictionary<string, object>
- {
- { "mac", mac },
- { "device", device },
- { "projectcode", projectcode }
- };
- string body = JsonHelper.ToJson(dic);
-
- string xmlDoc = HttpHelper.HttpPost(body, url);
-
- if (string.IsNullOrEmpty(xmlDoc))
- {
- APP.ServerMsg = "网络异常!";
- return 1;
- }
- else
- {
- JObject obj = JObject.Parse(xmlDoc);
- if (obj != null)
- {
- if (obj["code"].ToString().Equals("0"))
- {
- APP.Signature = obj["obj"].ToString();
- if (!Directory.Exists(APP.dataPath))
- {
- Directory.CreateDirectory(APP.dataPath);
- }
- string ApplicationData = APP.dataPath + "signature.txt";
-
- System.IO.File.WriteAllText(ApplicationData, APP.Signature, Encoding.Default);
- return 0;
- }
- else
- {
- APP.ServerMsg = obj["msg"].ToString();
- return Convert.ToInt32(obj["code"].ToString());
- }
- }
- else
- {
- return 1;
- }
- }
- }
- catch (Exception ex)
- {
- APP.ServerMsg = "网络异常!";
- LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
- return 1;
- }
- }
-
-
-
-
-
- public int ActivationAddHistory()
- {
- try
- {
- string url = APP.certapiUrl + "/activation/add_history";
- Dictionary<string, object> dic = new Dictionary<string, object>
- {
- { "sign", APP.Signature }
- };
- string body = JsonHelper.ToJson(dic);
- string xmlDoc = HttpHelper.HttpPost(body, url);
-
- if (string.IsNullOrEmpty(xmlDoc))
- {
- return 1;
-
- }
- else
- {
- JObject obj = JObject.Parse(xmlDoc);
- if (obj != null)
- {
- APP.ServerMsg = obj["msg"].ToString();
- return Convert.ToInt32(obj["code"].ToString());
- }
- else
- {
- return 1;
- }
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
- return 1;
- }
- }
-
-
-
-
-
- public int Login(string loginname, string loginpwd)
- {
- string url = APP.apiUrl + "/user/login";
- Dictionary<string, object> dic = new Dictionary<string, object>
- {
- { "loginname", loginname},
- { "loginpwd", loginpwd}
- };
- string body = JsonHelper.ToJson(dic);
- ResultVo<Model_UserInfo> result = HttpHelper.PostAndRespSignle<ResultVo<Model_UserInfo>>(url, postData: body);
- if (result != null)
- {
- APP.UserInfo = new Model_UserInfo();
- APP.ServerMsg = result.msg;
- if (result.obj != null)
- {
- APP.UserInfo = result.obj;
- }
- return result.code;
- }
- else
- {
- APP.ServerMsg = "网络异常!";
- APP.UserInfo = new Model_UserInfo();
- return 1;
- }
- }
-
-
-
-
-
- public int TsubjectbookList()
- {
- APP.TsubjectbookList = new List<Model_TsubjectbookList>();
- try
- {
- string url = APP.apiUrl + "/tsubjectbook/list";
- Dictionary<string, int> dic = new Dictionary<string, int>
- {
- { "teacherid",APP.UserInfo.Userid}
- };
- string body = JsonHelper.ToJson(dic);
- ResultVo<List<Model_TsubjectbookList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_TsubjectbookList>>>(url, postData: body);
- if (result != null)
- {
- APP.ServerMsg = result.msg;
- APP.TsubjectbookList = result.obj;
- return result.code;
- }
- else
- {
- APP.ServerMsg = "网络异常!";
- return 1;
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
- return 1;
- }
- }
-
-
-
-
-
- public int DirectorList(int lsbid, int directortype, int createid)
- {
- APP.DirectorList = new List<Model_DirectorList>();
- try
- {
- string url = APP.apiUrl + "/director/list";
- Dictionary<string, int> dic = new Dictionary<string, int>
- {
- { "lsbid", lsbid },
- { "directortype", directortype },
- { "createid", createid }
- };
- string body = JsonHelper.ToJson(dic);
- ResultVo<List<Model_DirectorList>> result = HttpHelper.PostAndRespSignle<ResultVo<List<Model_DirectorList>>>(url, postData: body);
- if (result != null)
- {
- APP.ServerMsg = result.msg;
- APP.DirectorList = result.obj;
- return result.code;
- }
- else
- {
- APP.ServerMsg = "网络异常!";
- return 1;
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
- return 1;
- }
- }
-
-
-
-
-
- public int ResourceAdd(Model_ResourceAdd model)
- {
- APP.DirectorList = new List<Model_DirectorList>();
- try
- {
- string url = APP.apiUrl + "/resource/add";
- Dictionary<string, object> dic = new Dictionary<string, object>
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- { "converted", model.converted },
- { "createid", model.createid }
- };
- if (model.directorid != 999999)
- {
- dic.Add("directorid", model.directorid);
- }
- dic.Add("duration", model.duration);
- dic.Add("imgUrl", model.imgUrl);
- dic.Add("level", model.level);
- dic.Add("lsbid", model.lsbid);
- dic.Add("mp4code", model.mp4code);
- dic.Add("resourcebelong", model.resourcebelong);
- dic.Add("resourceclass", model.resourceclass);
- dic.Add("resourcecover", model.resourcecover);
- dic.Add("resourcename", model.resourcename);
- dic.Add("resourcesize", model.resourcesize);
- dic.Add("resourcetype", model.resourcetype);
- dic.Add("resourceurl", model.resourceurl);
- dic.Add("schoolid", model.schoolid);
- dic.Add("suffix", model.suffix);
-
-
-
- string body = JsonHelper.ToJson(dic);
- string xmlDoc = HttpHelper.HttpPost(body, url);
- JObject obj = JObject.Parse(xmlDoc);
- if (obj != null)
- {
- APP.ServerMsg = obj["msg"].ToString();
- return Convert.ToInt32(obj["code"].ToString());
- }
- else
- {
- APP.ServerMsg = "网络异常!";
- return 1;
- }
- }
- catch (Exception ex)
- {
- APP.ServerMsg = "网络异常!";
- LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
- return 1;
- }
- }
- }
- }
|