using Common.system;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XHZB.Model;
namespace XHZB.Desktop.Utils
{
//接口调用
public class RegisterController
{
///
/// 登陆
///
///
///
public int Login(string loginname, string loginpwd)
{
string url = APP.apiUrl + "/user/login";//地址
Dictionary dic = new Dictionary
{
{ "loginname", loginname},
{ "loginpwd", loginpwd}
};
string body = JsonHelper.ToJson(dic);
ResultVo result = HttpHelper.PostAndRespSignle>(url, postData: body);
if (result != null)
{
APP.ErrorMessage = result.msg;
APP.LoginUser = result.obj;
return result.code;
}
else
{
APP.ErrorMessage = "网络异常!";
APP.LoginUser = new LoginModel();
return 1;
}
}
///
/// 开始直播
///
///
///
public int UpdateState()
{
string url = APP.apiUrl + "/course/update_state";//地址
Dictionary dic = new Dictionary
{
{ "courseid", 1},
{ "loginpwd", 2}
};
string body = JsonHelper.ToJson(dic);
ResultVo result = HttpHelper.PostAndRespSignle>(url, postData: body);
if (result != null)
{
APP.ErrorMessage = result.msg;
return result.code;
}
else
{
APP.ErrorMessage = "网络异常!";
return 1;
}
}
///
/// 教师任教班级
///
///
///
public int ClassList()
{
try
{
string url = APP.apiUrl + "/class_teacher/tclist";//地址
Dictionary dic = new Dictionary
{
{ "createid", APP.LoginUser.userid},
{ "year", APP.LoginUser.year}
};
string body = JsonHelper.ToJson(dic);
ResultVo> result = HttpHelper.PostAndRespSignle>>(url, postData: body);
if (result != null)
{
APP.ErrorMessage = result.msg;
APP.ClassList = result.obj;
return result.code;
}
else
{
APP.ErrorMessage = "网络异常!";
return 1;
}
}
catch (Exception ex)
{
LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
return 1;
}
}
///
/// 教师教材列表
///
///
///
public int TsubjectbookList()
{
try
{
string url = APP.apiUrl + "/tsubjectbook/list";//地址
Dictionary dic = new Dictionary
{
{ "teacherid",APP.LoginUser.userid}
};
string body = JsonHelper.ToJson(dic);
ResultVo> result = HttpHelper.PostAndRespSignle>>(url, postData: body);
if (result != null)
{
APP.ErrorMessage = result.msg;
APP.TsubjectbookList = result.obj;
return result.code;
}
else
{
APP.ErrorMessage = "网络异常!";
return 1;
}
}
catch (Exception ex)
{
LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
return 1;
}
}
///
/// 章节--列表
///
///
///
public int DirectorList(int lsbid,int directortype,int createid)
{
try
{
string url = APP.apiUrl + "/director/list";//地址
Dictionary dic = new Dictionary
{
{ "lsbid", lsbid },
{ "directortype", directortype },
{ "createid", createid }
};
string body = JsonHelper.ToJson(dic);
ResultVo> result = HttpHelper.PostAndRespSignle>>(url, postData: body);
if (result != null)
{
APP.ErrorMessage = result.msg;
APP.DirectorList = result.obj;
return result.code;
}
else
{
APP.ErrorMessage = "网络异常!";
return 1;
}
}
catch (Exception ex)
{
LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
return 1;
}
}
///
/// 我的备课--列表
///
///
///
public int ResourceMyList(int _lsbid, int _directorid, int _resourceclass)
{
try
{
string url = APP.apiUrl + "/resource/my_list2";//地址
Dictionary dic = new Dictionary
{
{ "lsbid", _lsbid},
{ "directorid", _directorid},
{ "resourceclass", _resourceclass},
{ "resourcetype", 0},
{ "readcount", 0},
{ "createid", APP.LoginUser.userid},
{ "schoolid", APP.LoginUser.schoolid}
};
string body = DataProvider.SerializeDictionaryToJsonString(dic);
string xmlDoc = DataProvider.HttpPost(body, url);
if (string.IsNullOrEmpty(xmlDoc))
{
APP.ErrorMessage = "网络异常!";
return 1;
}
else
{
ResultListVo obj = JsonHelper.JsonToObj>(xmlDoc);
if (obj != null)
{
APP.ResourceMyList.obj = new List();
APP.ResourceMyList.obj = obj.obj;
return 0;
}
else
{
APP.ErrorMessage = "网络异常!";
return 1;
}
}
}
catch (Exception ex)
{
LogHelper.WriteErrLog("我的备课接口" + ex.Message, ex);
}
return 0;
}
/////
///// 班级学生--列表
/////
/////
/////
//public int ClassStudentList(ref TeachingData teachingData)
//{
// try
// {
// string url = ZConfig.apiUrl + "/room/list_student";//地址
// Dictionary dic = new Dictionary
// {
// { "classid", ZCommonData.classid },
// {"lsbid",ZCommonData.lsbid }
// };
// string body = ZJsonHelper.ToJson(dic);
// ResultVo> result = ZHttpUtil.PostAndRespSignle>>(url, postData: body);
// Shared.ServerMsg = result?.msg;
// int code = 0;
// if (result != null)
// {
// Shared.TeachingData.RESP_ClassStudentList = result?.obj;
// }
// else
// {
// code = 1;
// Shared.ServerMsg = "网络异常";
// }
// return code;
// }
// catch (Exception ex)
// {
// LogHelper.WriteErrLog("【调用接口(RegisterController)】错误日志:" + ex.Message, ex);
// }
// return 0;
//}
}
}