ComplianceServer/oldcode/ZXDService/ExamService.svc.cs

171 lines
6.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using CRM.Core.Common.Layui;
using System;
using System.Collections.Generic;
using WX.CRM.Common;
namespace ZXDService
{
// 注意: 使用“重构”菜单上的“重命名”命令可以同时更改代码、svc 和配置文件中的类名“ExamService”。
// 注意: 为了启动 WCF 测试客户端以测试此服务,请在解决方案资源管理器中选择 ExamService.svc 或 ExamService.svc.cs然后开始调试。
public class ExamService : IExamService
{
private readonly CRM.Core.BLL.Application.Exam.ExamService examService = new CRM.Core.BLL.Application.Exam.ExamService();
public ExamService()
{
//if (WebOperationContext.Current != null)
//{
// WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin", "*");
// WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
//}
}
public ExamResult Gen(int type, string appid, string appuserid)
{
try
{
if (string.IsNullOrEmpty(appid) || string.IsNullOrEmpty(appuserid))
{
return null;
}
var data = examService.GenerateExam(type, appid, appuserid);
var result = new ExamResult
{
isNew = data.isNew,
paper = data.paper,
singleSubject = data.singleSubject,
composeSubject = data.composeSubject
};
return result;
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return null;
}
}
public JsonResult<string> Save(CRM.Core.BLL.Application.Exam.AnswerDto dto)
{
try
{
//LogHelper.Info(dto.ToJson());
var result = examService.Save(dto);
//var result = true;
return new JsonResult<string>() { result = result, retcode = 200, retmsg = result.ToString() };
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return new JsonResult<string>() { result = false, retcode = 500, retmsg = "保存失败!" };
}
}
public PageResult<List<ExamPaperView>> List(string appid, string appuserid, int type, DateTime sTime, DateTime eTime, int page, int limit)
{
try
{
var pager = new Laypage() { page = page > 0 ? page : 1, limit = limit > 0 ? limit : 10 };
var data = examService.List(ref pager, appid, appuserid, type > 0 ? type : (int?)null, sTime == DateTime.MinValue ? (DateTime?)null : sTime, eTime == DateTime.MinValue ? (DateTime?)null : eTime);
var list = new List<ExamPaperView>();
foreach (var item in data)
{
var info = new ExamPaperView()
{
ID = item.ID,
TITLE = item.TITLE,
TYPE = item.TYPE,
TYPENAME = item.TYPENAME,
TOTALSCORE = item.TOTALSCORE,
SCORE = item.SCORE,
STARTTIME = item.STARTTIME.ToString(),
ENDTIME = item.ENDTIME.ToString(),
TIMELENGTH = item.TIMELENGTH,
HANDTIME = item.HANDTIME.ToString(),
USETIME = item.USETIME,
APPID = item.APPID,
APPUSERID = item.APPUSERID
};
list.Add(info);
}
return new PageResult<List<ExamPaperView>>() { pageindex = pager.page, pagecount = pager.count, data = list };
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return new PageResult<List<ExamPaperView>>() { pageindex = 1, pagecount = 0, data = null };
}
}
public ExamResult Show(int paperId)
{
try
{
var data = examService.Show(paperId);
var result = new ExamResult
{
isNew = data.isNew,
paper = data.paper,
singleSubject = data.singleSubject,
composeSubject = data.composeSubject
};
return result;
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
return null;
}
}
}
public class ExamPaperView
{
public int ID { get; set; }
/// <summary>
/// 试卷名
/// </summary>
public string TITLE { get; set; }
/// <summary>
/// 试卷类型
/// </summary>
public int TYPE { get; set; }
/// <summary>
/// 试卷类型名称
/// </summary>
public string TYPENAME { get; set; }
/// <summary>
/// 试卷总分
/// </summary>
public decimal TOTALSCORE { get; set; }
/// <summary>
/// 得分
/// </summary>
public decimal? SCORE { get; set; }
/// <summary>
/// 考试开始时间
/// </summary>
public string STARTTIME { get; set; }
/// <summary>
/// 考试结束时间
/// </summary>
public string ENDTIME { get; set; }
/// <summary>
/// 考试时长
/// </summary>
public int TIMELENGTH { get; set; }
/// <summary>
/// 交卷时间
/// </summary>
public string HANDTIME { get; set; }
/// <summary>
/// 用时
/// </summary>
public int? USETIME { get; set; }
public string APPID { get; set; }
public string APPUSERID { get; set; }
}
}