|
|
@ -1,339 +1,246 @@ |
|
|
|
|
|
|
|
|
|
|
|
using Tiobon.Core.IServices; |
|
|
|
|
|
|
|
using Tiobon.Core.Model.Models; |
|
|
|
|
|
|
|
using Tiobon.Core.Services.BASE; |
|
|
|
|
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
|
|
|
|
using Tiobon.Core.Model; |
|
|
|
|
|
|
|
using System.Dynamic; |
|
|
|
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
|
|
|
|
using Mysqlx.Crud; |
|
|
|
|
|
|
|
using AgileObjects.AgileMapper.Extensions; |
|
|
|
|
|
|
|
using System.Data; |
|
|
|
using System.Data; |
|
|
|
|
|
|
|
using AgileObjects.AgileMapper; |
|
|
|
using Tiobon.Core.Common; |
|
|
|
using Tiobon.Core.Common; |
|
|
|
using Tiobon.Core.Common.DB.Dapper; |
|
|
|
using Tiobon.Core.Common.DB.Dapper; |
|
|
|
using MySqlX.XDevAPI.Common; |
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Tiobon.Core.IServices; |
|
|
|
|
|
|
|
using Tiobon.Core.Model; |
|
|
|
|
|
|
|
using Tiobon.Core.Model.Models; |
|
|
|
|
|
|
|
using Tiobon.Core.Services.BASE; |
|
|
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services |
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// 题目 (服务) |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDto, InsertGhre_QuestionInput, EditGhre_QuestionInput>, IGhre_QuestionServices |
|
|
|
{ |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
|
private readonly IBaseRepository<Ghre_Question> _dal; |
|
|
|
/// 题目 (服务) |
|
|
|
private IGhre_QuestionAnswerServices _ghre_QuestionAnswerServices; |
|
|
|
/// </summary> |
|
|
|
private IGhre_CourseServices _ghre_CourseServices; |
|
|
|
public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDto, InsertGhre_QuestionInput, EditGhre_QuestionInput>, IGhre_QuestionServices |
|
|
|
private IGhre_CourseClassServices _ghre_CourseClassServices; |
|
|
|
|
|
|
|
public Ghre_QuestionServices(IBaseRepository<Ghre_Question> dal, |
|
|
|
|
|
|
|
IGhre_QuestionAnswerServices ghre_QuestionAnswerServices, |
|
|
|
|
|
|
|
IGhre_CourseServices ghre_CourseServices, |
|
|
|
|
|
|
|
IGhre_CourseClassServices ghre_CourseClassServices) |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly IBaseRepository<Ghre_Question> _dal; |
|
|
|
this._dal = dal; |
|
|
|
private IGhre_QuestionAnswerServices _ghre_QuestionAnswerServices; |
|
|
|
base.BaseDal = dal; |
|
|
|
private IGhre_CourseServices _ghre_CourseServices; |
|
|
|
_ghre_QuestionAnswerServices = ghre_QuestionAnswerServices; |
|
|
|
private IGhre_CourseClassServices _ghre_CourseClassServices; |
|
|
|
_ghre_CourseServices = ghre_CourseServices; |
|
|
|
public Ghre_QuestionServices(IBaseRepository<Ghre_Question> dal, |
|
|
|
_ghre_CourseClassServices = ghre_CourseClassServices; |
|
|
|
IGhre_QuestionAnswerServices ghre_QuestionAnswerServices, |
|
|
|
} |
|
|
|
IGhre_CourseServices ghre_CourseServices, |
|
|
|
|
|
|
|
IGhre_CourseClassServices ghre_CourseClassServices) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
this._dal = dal; |
|
|
|
|
|
|
|
base.BaseDal = dal; |
|
|
|
|
|
|
|
_ghre_QuestionAnswerServices = ghre_QuestionAnswerServices; |
|
|
|
|
|
|
|
_ghre_CourseServices = ghre_CourseServices; |
|
|
|
|
|
|
|
_ghre_CourseClassServices = ghre_CourseClassServices; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<ServicePageResult<Ghre_QuestionDto>> QueryFilterPage(QueryBody body) |
|
|
|
public override async Task<ServicePageResult<Ghre_QuestionDto>> QueryFilterPage(QueryBody body) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var data1 = await BaseDal.QueryFilterPage(body); |
|
|
|
var data1 = await BaseDal.QueryFilterPage(body); |
|
|
|
var data = Mapper.Map(data1.result.DT_TableDataT1).ToANew<List<Ghre_QuestionDto>>(); |
|
|
|
var data = Mapper.Map(data1.result.DT_TableDataT1).ToANew<List<Ghre_QuestionDto>>(); |
|
|
|
var courseIds = data.Where(x => x.CourseId != null).Select(x => x.CourseId).ToList(); |
|
|
|
var courseIds = data.Where(x => x.CourseId != null).Select(x => x.CourseId).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var courses = await _ghre_CourseServices.Query(x => courseIds.Contains(x.Id)); |
|
|
|
var courses = await _ghre_CourseServices.Query(x => courseIds.Contains(x.Id)); |
|
|
|
var classs = await _ghre_CourseClassServices.Query(); |
|
|
|
var classs = await _ghre_CourseClassServices.Query(); |
|
|
|
data.ForEach(x => |
|
|
|
data.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (x.DifficultyLevel == "Easy") |
|
|
|
|
|
|
|
x.DifficultyLevel = "简单"; |
|
|
|
|
|
|
|
else if (x.DifficultyLevel == "Normal") |
|
|
|
|
|
|
|
x.DifficultyLevel = "普通"; |
|
|
|
|
|
|
|
else if (x.DifficultyLevel == "Hard") |
|
|
|
|
|
|
|
x.DifficultyLevel = "困难"; |
|
|
|
|
|
|
|
x.QuestionType = ConvertQuestionType(x.QuestionType); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (x.CourseId != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (x.DifficultyLevel == "Easy") |
|
|
|
var course = courses.Where(a => a.Id == x.CourseId).FirstOrDefault(); |
|
|
|
x.DifficultyLevel = "简单"; |
|
|
|
x.CourseName = course?.CourseName; |
|
|
|
else if (x.DifficultyLevel == "Normal") |
|
|
|
var courseClass = classs.Where(a => a.Id == course.CourseClassId).FirstOrDefault(); |
|
|
|
x.DifficultyLevel = "普通"; |
|
|
|
x.CourseType = courseClass.ClassName; |
|
|
|
else if (x.DifficultyLevel == "Hard") |
|
|
|
} |
|
|
|
x.DifficultyLevel = "困难"; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (x.QuestionType == "Single") |
|
|
|
|
|
|
|
x.QuestionType = "单选题"; |
|
|
|
|
|
|
|
else if (x.QuestionType == "Multiple") |
|
|
|
|
|
|
|
x.QuestionType = "多选题"; |
|
|
|
|
|
|
|
else if (x.QuestionType == "TrueOrFalse") |
|
|
|
|
|
|
|
x.QuestionType = "判断题"; |
|
|
|
|
|
|
|
else if (x.QuestionType == "Completion") |
|
|
|
|
|
|
|
x.QuestionType = "填空题"; |
|
|
|
|
|
|
|
else if (x.QuestionType == "ShortAnswer") |
|
|
|
|
|
|
|
x.QuestionType = "简答题"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (x.CourseId != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var course = courses.Where(a => a.Id == x.CourseId).FirstOrDefault(); |
|
|
|
|
|
|
|
x.CourseName = course?.CourseName; |
|
|
|
|
|
|
|
var courseClass = classs.Where(a => a.Id == course.CourseClassId).FirstOrDefault(); |
|
|
|
|
|
|
|
x.CourseType = courseClass.ClassName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ServicePageResult<Ghre_QuestionDto>(body.pageNum, data1.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new ServicePageResult<Ghre_QuestionDto>(body.pageNum, data1.result.DT_TablePageInfoT1.TotalCount, body.pageSize, data); |
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="Id"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
public async Task<ServiceResult<FromGhre_QuestionInput>> QueryFrom(long Id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var data = new FromGhre_QuestionInput(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Column |
|
|
|
|
|
|
|
data.Column.Add(new FromGhre_QuestionColumn() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "课程名称", |
|
|
|
|
|
|
|
field = "courseID", |
|
|
|
|
|
|
|
elementType = "ApiSelect", |
|
|
|
|
|
|
|
required = true, |
|
|
|
|
|
|
|
multipleSelect = true, |
|
|
|
|
|
|
|
editable = true, |
|
|
|
|
|
|
|
dataSource = "api/Common/GetSelect?type=Ghre_Course" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
data.Column.Add(new FromGhre_QuestionColumn() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "题目编号", |
|
|
|
|
|
|
|
field = "questionNo", |
|
|
|
|
|
|
|
elementType = "Input", |
|
|
|
|
|
|
|
required = false, |
|
|
|
|
|
|
|
multipleSelect = false, |
|
|
|
|
|
|
|
editable = false, |
|
|
|
|
|
|
|
dataSource = "", |
|
|
|
|
|
|
|
placeholder = "保存后自动生成" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
#region PageData |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
var answerList = new List<FromGhre_QuestionQuestionAnswerList> |
|
|
|
/// |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="Id"></param> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
public async Task<ServiceResult<FromGhre_QuestionInput>> QueryFrom(long Id) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
var data = new FromGhre_QuestionInput(); |
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
|
|
|
|
|
|
|
#region Column |
|
|
|
|
|
|
|
data.Column.Add(new FromGhre_QuestionColumn() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
label = "课程名称", |
|
|
|
No = "A", |
|
|
|
field = "courseID", |
|
|
|
}, |
|
|
|
elementType = "ApiSelect", |
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
required = true, |
|
|
|
|
|
|
|
multipleSelect = true, |
|
|
|
|
|
|
|
editable = true, |
|
|
|
|
|
|
|
dataSource = "api/Common/GetSelect?type=Ghre_Course" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
data.Column.Add(new FromGhre_QuestionColumn() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
label = "题目编号", |
|
|
|
No = "B", |
|
|
|
field = "questionNo", |
|
|
|
}, |
|
|
|
elementType = "Input", |
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
required = false, |
|
|
|
|
|
|
|
multipleSelect = false, |
|
|
|
|
|
|
|
editable = false, |
|
|
|
|
|
|
|
dataSource = "", |
|
|
|
|
|
|
|
placeholder = "保存后自动生成" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region PageData |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var answerList = new List<FromGhre_QuestionQuestionAnswerList> |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
No = "C", |
|
|
|
{ |
|
|
|
}, |
|
|
|
No = "A", |
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
No = "B", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
No = "C", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
No = "D", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var answerList1 = new List<FromGhre_QuestionQuestionAnswerList> |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
No = "D", |
|
|
|
{ |
|
|
|
} |
|
|
|
No = "A", |
|
|
|
}; |
|
|
|
}, |
|
|
|
var answerList1 = new List<FromGhre_QuestionQuestionAnswerList> |
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
{ |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
No = "A", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
No = "B", |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
data.PageData.questionType = new List<FromGhre_QuestionQuestionType> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "单选题", |
|
|
|
|
|
|
|
type = "Single", |
|
|
|
|
|
|
|
isActive = 1, |
|
|
|
|
|
|
|
detail= new FromGhre_QuestionQuestionTypeDetail() |
|
|
|
{ |
|
|
|
{ |
|
|
|
No = "B", |
|
|
|
answerList=answerList |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}, |
|
|
|
data.PageData.questionType = new List<FromGhre_QuestionQuestionType> |
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
{ |
|
|
|
{ |
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
label = "多选题", |
|
|
|
|
|
|
|
type = "Multiple", |
|
|
|
|
|
|
|
isActive = 0, |
|
|
|
|
|
|
|
detail= new FromGhre_QuestionQuestionTypeDetail() |
|
|
|
{ |
|
|
|
{ |
|
|
|
label = "单选题", |
|
|
|
answerList=answerList |
|
|
|
type = "Single", |
|
|
|
|
|
|
|
isActive = 1, |
|
|
|
|
|
|
|
detail= new FromGhre_QuestionQuestionTypeDetail() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
answerList=answerList |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "多选题", |
|
|
|
|
|
|
|
type = "Multiple", |
|
|
|
|
|
|
|
isActive = 0, |
|
|
|
|
|
|
|
detail= new FromGhre_QuestionQuestionTypeDetail() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
answerList=answerList |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "判断题", |
|
|
|
|
|
|
|
type = "TrueOrFalse", |
|
|
|
|
|
|
|
isActive = 0, |
|
|
|
|
|
|
|
detail= new FromGhre_QuestionQuestionTypeDetail() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
answerList=answerList1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "填空题", |
|
|
|
|
|
|
|
type = "Completion", |
|
|
|
|
|
|
|
isActive = 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "简答题", |
|
|
|
|
|
|
|
type = "ShortAnswer", |
|
|
|
|
|
|
|
isActive = 0, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
if (Id != 0) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
var question = await base.QueryById(Id); |
|
|
|
label = "判断题", |
|
|
|
data.PageData.questionType.ForEach(x => x.isActive = 0); |
|
|
|
type = "TrueOrFalse", |
|
|
|
data.PageData.baseData.questionNo = question.QuestionNo; |
|
|
|
isActive = 0, |
|
|
|
data.PageData.baseData.courseID.Add(question.CourseId); |
|
|
|
detail= new FromGhre_QuestionQuestionTypeDetail() |
|
|
|
|
|
|
|
|
|
|
|
var questionType = data.PageData.questionType.Where(x => x.type == question.QuestionType).FirstOrDefault(); |
|
|
|
|
|
|
|
if (questionType != null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
var answers = await _ghre_QuestionAnswerServices.Query(x => x.QuestionId == Id, "TaxisNo ASC"); |
|
|
|
answerList=answerList1 |
|
|
|
questionType.isActive = 1; |
|
|
|
|
|
|
|
questionType.detail.difficulty = question.DifficultyLevel; |
|
|
|
|
|
|
|
questionType.detail.answer = answers.Where(x => x.IsCorrect == true).FirstOrDefault()?.QuestionNo; |
|
|
|
|
|
|
|
questionType.detail.answer1 = answers.Where(x => x.IsCorrect == true).Select(x => x.QuestionNo).ToList(); |
|
|
|
|
|
|
|
questionType.detail.answer1 = answers.Where(x => x.IsCorrect == true).Select(x => x.QuestionNo).ToList(); |
|
|
|
|
|
|
|
questionType.detail.content = question.QuestionContent; |
|
|
|
|
|
|
|
questionType.detail.RemarkSz = question.QuestionAnalysis; |
|
|
|
|
|
|
|
questionType.detail.answerList = answers.Select(x => new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
No = x.QuestionNo, |
|
|
|
|
|
|
|
label = x.AnswerContent, |
|
|
|
|
|
|
|
imageUrl = x.ImageUrl, |
|
|
|
|
|
|
|
imgWidthPc = x.ImageWidthPc, |
|
|
|
|
|
|
|
imgWidthApp = x.ImageWidthApp, |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "填空题", |
|
|
|
|
|
|
|
type = "Completion", |
|
|
|
|
|
|
|
isActive = 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
new FromGhre_QuestionQuestionType() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
label = "简答题", |
|
|
|
|
|
|
|
type = "ShortAnswer", |
|
|
|
|
|
|
|
isActive = 0, |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult<FromGhre_QuestionInput>.OprateSuccess("查询成功!", data); |
|
|
|
if (Id != 0) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> InsertFrom(FromGhre_QuestionPageData insertModel) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
var questionType = insertModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); |
|
|
|
var question = await base.QueryById(Id); |
|
|
|
string questionTypeName = string.Empty; |
|
|
|
data.PageData.questionType.ForEach(x => x.isActive = 0); |
|
|
|
if (questionType.type == "Single") |
|
|
|
data.PageData.baseData.questionNo = question.QuestionNo; |
|
|
|
questionTypeName = "单选题"; |
|
|
|
data.PageData.baseData.courseID.Add(question.CourseId); |
|
|
|
else if (questionType.type == "Multiple") |
|
|
|
|
|
|
|
questionTypeName = "多选题"; |
|
|
|
|
|
|
|
else if (questionType.type == "TrueOrFalse") |
|
|
|
|
|
|
|
questionTypeName = "判断题"; |
|
|
|
|
|
|
|
else if (questionType.type == "Completion") |
|
|
|
|
|
|
|
questionTypeName = "填空题"; |
|
|
|
|
|
|
|
else if (questionType.type == "ShortAnswer") |
|
|
|
|
|
|
|
questionTypeName = "简答题"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 判断是否重复 |
|
|
|
|
|
|
|
for (int j = 0; j < insertModel.baseData.courseID.Count; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var courseID = insertModel.baseData.courseID[j]; |
|
|
|
|
|
|
|
string sql = "SELECT * FROM Ghre_Question where QuestionType='{0}' and CourseId='{1}' and QuestionContent ='{2}'"; |
|
|
|
|
|
|
|
sql = string.Format(sql, questionType.type, courseID, questionType.detail.content); |
|
|
|
|
|
|
|
DataTable dt = Db.Ado.GetDataTable(sql); |
|
|
|
|
|
|
|
if (dt.Rows.Count > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var course = await _ghre_CourseServices.QueryById(courseID); |
|
|
|
|
|
|
|
throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < insertModel.baseData.courseID.Count; j++) |
|
|
|
var questionType = data.PageData.questionType.Where(x => x.type == question.QuestionType).FirstOrDefault(); |
|
|
|
|
|
|
|
if (questionType != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var courseID = insertModel.baseData.courseID[j]; |
|
|
|
var answers = await _ghre_QuestionAnswerServices.Query(x => x.QuestionId == Id, "TaxisNo ASC"); |
|
|
|
var insert = new InsertGhre_QuestionInput(); |
|
|
|
questionType.isActive = 1; |
|
|
|
insert.CourseId = courseID; |
|
|
|
questionType.detail.difficulty = question.DifficultyLevel; |
|
|
|
|
|
|
|
questionType.detail.answer = answers.Where(x => x.IsCorrect == true).FirstOrDefault()?.QuestionNo; |
|
|
|
insert.QuestionType = questionType.type; |
|
|
|
questionType.detail.answer1 = answers.Where(x => x.IsCorrect == true).Select(x => x.QuestionNo).ToList(); |
|
|
|
insert.DifficultyLevel = questionType.detail.difficulty; |
|
|
|
questionType.detail.answer1 = answers.Where(x => x.IsCorrect == true).Select(x => x.QuestionNo).ToList(); |
|
|
|
insert.QuestionContent = questionType.detail.content; |
|
|
|
questionType.detail.content = question.QuestionContent; |
|
|
|
insert.QuestionAnalysis = questionType.detail.RemarkSz; |
|
|
|
questionType.detail.RemarkSz = question.QuestionAnalysis; |
|
|
|
insert.QuestionNo = GenerateContinuousSequence(insert.QuestionType.Substring(0, 1)); |
|
|
|
questionType.detail.answerList = answers.Select(x => new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
|
|
|
|
|
|
|
var id = await base.Add(insert); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
QuestionNo = x.No, |
|
|
|
No = x.QuestionNo, |
|
|
|
AnswerContent = x.label, |
|
|
|
label = x.AnswerContent, |
|
|
|
ImageUrl = x.imageUrl, |
|
|
|
imageUrl = x.ImageUrl, |
|
|
|
ImageWidthPc = x.imgWidthPc, |
|
|
|
imgWidthPc = x.ImageWidthPc, |
|
|
|
ImageWidthApp = x.imgWidthApp, |
|
|
|
imgWidthApp = x.ImageWidthApp, |
|
|
|
}).ToList(); |
|
|
|
}).ToList(); |
|
|
|
int i = 100; |
|
|
|
|
|
|
|
insertAnswers.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.TaxisNo = i; |
|
|
|
|
|
|
|
x.QuestionId = id; |
|
|
|
|
|
|
|
if (questionType.detail.answer == x.QuestionNo && insert.QuestionType == "Single") |
|
|
|
|
|
|
|
x.IsCorrect = true; |
|
|
|
|
|
|
|
i = i + 100; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await _ghre_QuestionAnswerServices.Add(insertAnswers); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("新增成功!"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult<FromGhre_QuestionInput>.OprateSuccess("查询成功!", data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> UpdareFrom(long Id, FromGhre_QuestionPageData editModel) |
|
|
|
public async Task<ServiceResult> InsertFrom(FromGhre_QuestionPageData insertModel) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var questionType = insertModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); |
|
|
|
|
|
|
|
string questionTypeName = ConvertQuestionType(questionType.type); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 判断是否重复 |
|
|
|
|
|
|
|
for (int j = 0; j < insertModel.baseData.courseID.Count; j++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var questionType = editModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); |
|
|
|
var courseID = insertModel.baseData.courseID[j]; |
|
|
|
string questionTypeName = string.Empty; |
|
|
|
string sql = "SELECT * FROM Ghre_Question where QuestionType='{0}' and CourseId='{1}' and QuestionContent ='{2}'"; |
|
|
|
if (questionType.type == "Single") |
|
|
|
sql = string.Format(sql, questionType.type, courseID, questionType.detail.content); |
|
|
|
questionTypeName = "单选题"; |
|
|
|
DataTable dt = Db.Ado.GetDataTable(sql); |
|
|
|
else if (questionType.type == "Multiple") |
|
|
|
if (dt.Rows.Count > 0) |
|
|
|
questionTypeName = "多选题"; |
|
|
|
|
|
|
|
else if (questionType.type == "TrueOrFalse") |
|
|
|
|
|
|
|
questionTypeName = "判断题"; |
|
|
|
|
|
|
|
else if (questionType.type == "Completion") |
|
|
|
|
|
|
|
questionTypeName = "填空题"; |
|
|
|
|
|
|
|
else if (questionType.type == "ShortAnswer") |
|
|
|
|
|
|
|
questionTypeName = "简答题"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 判断是否重复 |
|
|
|
|
|
|
|
for (int j = 0; j < editModel.baseData.courseID.Count; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
var courseID = editModel.baseData.courseID[j]; |
|
|
|
var course = await _ghre_CourseServices.QueryById(courseID); |
|
|
|
string sql = "SELECT * FROM Ghre_Question where QuestionType='{0}' and CourseId='{1}' and QuestionContent ='{2}' AND Id !='{3}'"; |
|
|
|
throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); |
|
|
|
sql = string.Format(sql, questionType.type, courseID, questionType.detail.content, Id); |
|
|
|
|
|
|
|
DataTable dt = Db.Ado.GetDataTable(sql); |
|
|
|
|
|
|
|
if (dt.Rows.Count > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var course = await _ghre_CourseServices.QueryById(courseID); |
|
|
|
|
|
|
|
throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
var data = await base.QueryById(Id); |
|
|
|
for (int j = 0; j < insertModel.baseData.courseID.Count; j++) |
|
|
|
await _ghre_QuestionAnswerServices.Delete(x => x.QuestionId == Id); |
|
|
|
{ |
|
|
|
var edit = Mapper.Map(data).ToANew<EditGhre_QuestionInput>(); |
|
|
|
var courseID = insertModel.baseData.courseID[j]; |
|
|
|
edit.CourseId = editModel.baseData.courseID[0]; |
|
|
|
var insert = new InsertGhre_QuestionInput(); |
|
|
|
|
|
|
|
insert.CourseId = courseID; |
|
|
|
|
|
|
|
|
|
|
|
edit.QuestionType = questionType.type; |
|
|
|
insert.QuestionType = questionType.type; |
|
|
|
edit.DifficultyLevel = questionType.detail.difficulty; |
|
|
|
insert.DifficultyLevel = questionType.detail.difficulty; |
|
|
|
edit.QuestionContent = questionType.detail.content; |
|
|
|
insert.QuestionContent = questionType.detail.content; |
|
|
|
edit.QuestionAnalysis = questionType.detail.RemarkSz; |
|
|
|
insert.QuestionAnalysis = questionType.detail.RemarkSz; |
|
|
|
|
|
|
|
insert.QuestionNo = GenerateContinuousSequence(insert.QuestionType.Substring(0, 1)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var id = await base.Add(insert); |
|
|
|
|
|
|
|
|
|
|
|
await base.Update(Id, edit); |
|
|
|
|
|
|
|
var insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput() |
|
|
|
var insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QuestionNo = x.No, |
|
|
|
QuestionNo = x.No, |
|
|
@ -346,113 +253,182 @@ namespace Tiobon.Core.Services |
|
|
|
insertAnswers.ForEach(x => |
|
|
|
insertAnswers.ForEach(x => |
|
|
|
{ |
|
|
|
{ |
|
|
|
x.TaxisNo = i; |
|
|
|
x.TaxisNo = i; |
|
|
|
x.QuestionId = Id; |
|
|
|
x.QuestionId = id; |
|
|
|
if (questionType.detail.answer == x.QuestionNo && edit.QuestionType == "Single") |
|
|
|
if (questionType.detail.answer == x.QuestionNo && insert.QuestionType == "Single") |
|
|
|
x.IsCorrect = true; |
|
|
|
x.IsCorrect = true; |
|
|
|
i = i + 100; |
|
|
|
i = i + 100; |
|
|
|
}); |
|
|
|
}); |
|
|
|
await _ghre_QuestionAnswerServices.Add(insertAnswers); |
|
|
|
await _ghre_QuestionAnswerServices.Add(insertAnswers); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("新增成功!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> UpdareFrom(long Id, FromGhre_QuestionPageData editModel) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var questionType = editModel.questionType.Where(x => x.isActive == 1).FirstOrDefault(); |
|
|
|
|
|
|
|
string questionTypeName = ConvertQuestionType(questionType.type); |
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < editModel.baseData.courseID.Count; j++) |
|
|
|
#region 判断是否重复 |
|
|
|
|
|
|
|
for (int j = 0; j < editModel.baseData.courseID.Count; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var courseID = editModel.baseData.courseID[j]; |
|
|
|
|
|
|
|
string sql = "SELECT * FROM Ghre_Question where QuestionType='{0}' and CourseId='{1}' and QuestionContent ='{2}' AND Id !='{3}'"; |
|
|
|
|
|
|
|
sql = string.Format(sql, questionType.type, courseID, questionType.detail.content, Id); |
|
|
|
|
|
|
|
DataTable dt = Db.Ado.GetDataTable(sql); |
|
|
|
|
|
|
|
if (dt.Rows.Count > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (j == 0) |
|
|
|
var course = await _ghre_CourseServices.QueryById(courseID); |
|
|
|
continue; |
|
|
|
throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
var courseID = editModel.baseData.courseID[j]; |
|
|
|
var data = await base.QueryById(Id); |
|
|
|
var insert = new InsertGhre_QuestionInput(); |
|
|
|
await _ghre_QuestionAnswerServices.Delete(x => x.QuestionId == Id); |
|
|
|
insert.CourseId = courseID; |
|
|
|
var edit = Mapper.Map(data).ToANew<EditGhre_QuestionInput>(); |
|
|
|
|
|
|
|
edit.CourseId = editModel.baseData.courseID[0]; |
|
|
|
|
|
|
|
|
|
|
|
insert.QuestionType = questionType.type; |
|
|
|
edit.QuestionType = questionType.type; |
|
|
|
insert.DifficultyLevel = questionType.detail.difficulty; |
|
|
|
edit.DifficultyLevel = questionType.detail.difficulty; |
|
|
|
insert.QuestionContent = questionType.detail.content; |
|
|
|
edit.QuestionContent = questionType.detail.content; |
|
|
|
insert.QuestionAnalysis = questionType.detail.RemarkSz; |
|
|
|
edit.QuestionAnalysis = questionType.detail.RemarkSz; |
|
|
|
insert.QuestionNo = GenerateContinuousSequence(insert.QuestionType.Substring(0, 1)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var id = await base.Add(insert); |
|
|
|
await base.Update(Id, edit); |
|
|
|
|
|
|
|
var insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QuestionNo = x.No, |
|
|
|
|
|
|
|
AnswerContent = x.label, |
|
|
|
|
|
|
|
ImageUrl = x.imageUrl, |
|
|
|
|
|
|
|
ImageWidthPc = x.imgWidthPc, |
|
|
|
|
|
|
|
ImageWidthApp = x.imgWidthApp, |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
int i = 100; |
|
|
|
|
|
|
|
insertAnswers.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.TaxisNo = i; |
|
|
|
|
|
|
|
x.QuestionId = Id; |
|
|
|
|
|
|
|
if (questionType.detail.answer == x.QuestionNo && edit.QuestionType == "Single") |
|
|
|
|
|
|
|
x.IsCorrect = true; |
|
|
|
|
|
|
|
i = i + 100; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await _ghre_QuestionAnswerServices.Add(insertAnswers); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < editModel.baseData.courseID.Count; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (j == 0) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput() |
|
|
|
var courseID = editModel.baseData.courseID[j]; |
|
|
|
{ |
|
|
|
var insert = new InsertGhre_QuestionInput(); |
|
|
|
QuestionNo = x.No, |
|
|
|
insert.CourseId = courseID; |
|
|
|
AnswerContent = x.label, |
|
|
|
|
|
|
|
ImageUrl = x.imageUrl, |
|
|
|
|
|
|
|
ImageWidthPc = x.imgWidthPc, |
|
|
|
|
|
|
|
ImageWidthApp = x.imgWidthApp, |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
i = 100; |
|
|
|
|
|
|
|
insertAnswers.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.TaxisNo = i; |
|
|
|
|
|
|
|
x.QuestionId = id; |
|
|
|
|
|
|
|
if (questionType.detail.answer == x.QuestionNo && insert.QuestionType == "Single") |
|
|
|
|
|
|
|
x.IsCorrect = true; |
|
|
|
|
|
|
|
i = i + 100; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await _ghre_QuestionAnswerServices.Add(insertAnswers); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("更新成功!"); |
|
|
|
insert.QuestionType = questionType.type; |
|
|
|
} |
|
|
|
insert.DifficultyLevel = questionType.detail.difficulty; |
|
|
|
|
|
|
|
insert.QuestionContent = questionType.detail.content; |
|
|
|
|
|
|
|
insert.QuestionAnalysis = questionType.detail.RemarkSz; |
|
|
|
|
|
|
|
insert.QuestionNo = GenerateContinuousSequence(insert.QuestionType.Substring(0, 1)); |
|
|
|
|
|
|
|
|
|
|
|
public static string GenerateContinuousSequence(string prefixTemp) |
|
|
|
var id = await base.Add(insert); |
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput() |
|
|
|
{ |
|
|
|
{ |
|
|
|
string result = string.Empty; |
|
|
|
QuestionNo = x.No, |
|
|
|
string tableCode = "Ghre_Question"; |
|
|
|
AnswerContent = x.label, |
|
|
|
string columnCode = "QuestionNo"; |
|
|
|
ImageUrl = x.imageUrl, |
|
|
|
int length = 7; |
|
|
|
ImageWidthPc = x.imgWidthPc, |
|
|
|
int tempLength = 6; |
|
|
|
ImageWidthApp = x.imgWidthApp, |
|
|
|
int sequence; |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
i = 100; |
|
|
|
|
|
|
|
insertAnswers.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.TaxisNo = i; |
|
|
|
|
|
|
|
x.QuestionId = id; |
|
|
|
|
|
|
|
if (questionType.detail.answer == x.QuestionNo && insert.QuestionType == "Single") |
|
|
|
|
|
|
|
x.IsCorrect = true; |
|
|
|
|
|
|
|
i = i + 100; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await _ghre_QuestionAnswerServices.Add(insertAnswers); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 查询 |
|
|
|
return ServiceResult.OprateSuccess("更新成功!"); |
|
|
|
DbSelect dbSelect = new DbSelect(tableCode + " A", "A", null); |
|
|
|
} |
|
|
|
dbSelect.IsInitDefaultValue = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string GenerateContinuousSequence(string prefixTemp) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string result = string.Empty; |
|
|
|
|
|
|
|
string tableCode = "Ghre_Question"; |
|
|
|
|
|
|
|
string columnCode = "QuestionNo"; |
|
|
|
|
|
|
|
int length = 7; |
|
|
|
|
|
|
|
int tempLength = 6; |
|
|
|
|
|
|
|
int sequence; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 查询 |
|
|
|
|
|
|
|
DbSelect dbSelect = new DbSelect(tableCode + " A", "A", null); |
|
|
|
|
|
|
|
dbSelect.IsInitDefaultValue = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
|
|
|
|
dbSelect.Select("MAX(SUBSTRING(A." + columnCode + "," + (prefixTemp.Length + 1).ToString() + "," + tempLength.ToString() + "))"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
dbSelect.Select("MAX(A." + columnCode + ")"); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
//dbSelect.Select("MAX(CONVERT(DECIMAL,SUBSTRING(A.ISSUE_NO," + (prefix.Length + dateString.Length + 1).ToString() + "," + tempLength.ToString() + ")))"); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
|
|
|
|
dbSelect.Where("SUBSTRING(A." + columnCode + ",1," + (prefixTemp.Length).ToString() + ")", " = ", prefixTemp); |
|
|
|
|
|
|
|
dbSelect.Where("LEN(A." + columnCode + ")", "=", length); |
|
|
|
|
|
|
|
string sql = dbSelect.GetSql(); |
|
|
|
|
|
|
|
string maxSequence = Convert.ToString(DbAccess.Instance.ExecuteScalar(sql)); |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
//tempLength = tempLength - dateString.Length; |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(maxSequence)) |
|
|
|
|
|
|
|
result = prefixTemp + Convert.ToString(1).PadLeft(tempLength, '0'); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
dbSelect.Select("MAX(SUBSTRING(A." + columnCode + "," + (prefixTemp.Length + 1).ToString() + "," + tempLength.ToString() + "))"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
dbSelect.Select("MAX(A." + columnCode + ")"); |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
//dbSelect.Select("MAX(CONVERT(DECIMAL,SUBSTRING(A.ISSUE_NO," + (prefix.Length + dateString.Length + 1).ToString() + "," + tempLength.ToString() + ")))"); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
|
|
|
|
dbSelect.Where("SUBSTRING(A." + columnCode + ",1," + (prefixTemp.Length).ToString() + ")", " = ", prefixTemp); |
|
|
|
|
|
|
|
dbSelect.Where("LEN(A." + columnCode + ")", "=", length); |
|
|
|
|
|
|
|
string sql = dbSelect.GetSql(); |
|
|
|
|
|
|
|
string maxSequence = Convert.ToString(DbAccess.Instance.ExecuteScalar(sql)); |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
//tempLength = tempLength - dateString.Length; |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(maxSequence)) |
|
|
|
|
|
|
|
result = prefixTemp + Convert.ToString(1).PadLeft(tempLength, '0'); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(prefixTemp)) |
|
|
|
if (int.TryParse(maxSequence, out sequence)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (int.TryParse(maxSequence, out sequence)) |
|
|
|
sequence += 1; |
|
|
|
{ |
|
|
|
if (sequence.ToString().Length > tempLength) |
|
|
|
sequence += 1; |
|
|
|
throw new Exception("自动生成字串长度已经超过设定长度!"); |
|
|
|
if (sequence.ToString().Length > tempLength) |
|
|
|
|
|
|
|
throw new Exception("自动生成字串长度已经超过设定长度!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
throw new Exception("表中的数据无法进行自动编号,请联系软件开发商!"); |
|
|
|
|
|
|
|
result = prefixTemp + sequence.ToString().PadLeft(tempLength, '0'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
throw new Exception("表中的数据无法进行自动编号,请联系软件开发商!"); |
|
|
|
|
|
|
|
result = prefixTemp + sequence.ToString().PadLeft(tempLength, '0'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (int.TryParse(maxSequence, out sequence)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (int.TryParse(maxSequence, out sequence)) |
|
|
|
sequence += 1; |
|
|
|
{ |
|
|
|
if (sequence.ToString().Length > length) |
|
|
|
sequence += 1; |
|
|
|
throw new Exception("自动生成字串长度已经超过设定长度!"); |
|
|
|
if (sequence.ToString().Length > length) |
|
|
|
|
|
|
|
throw new Exception("自动生成字串长度已经超过设定长度!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
throw new Exception("表中的数据无法进行自动编号,请联系软件开发商!"); |
|
|
|
|
|
|
|
result = sequence.ToString().PadLeft(length, '0'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
throw new Exception("表中的数据无法进行自动编号,请联系软件开发商!"); |
|
|
|
|
|
|
|
result = sequence.ToString().PadLeft(length, '0'); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception) { throw; } |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception) { throw; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string ConvertQuestionType(string type) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string questionTypeName = string.Empty; |
|
|
|
|
|
|
|
if (type == "Single") |
|
|
|
|
|
|
|
questionTypeName = "单选题"; |
|
|
|
|
|
|
|
else if (type == "Multiple") |
|
|
|
|
|
|
|
questionTypeName = "多选题"; |
|
|
|
|
|
|
|
else if (type == "TrueOrFalse") |
|
|
|
|
|
|
|
questionTypeName = "判断题"; |
|
|
|
|
|
|
|
else if (type == "Completion") |
|
|
|
|
|
|
|
questionTypeName = "填空题"; |
|
|
|
|
|
|
|
else if (type == "ShortAnswer") |
|
|
|
|
|
|
|
questionTypeName = "简答题"; |
|
|
|
|
|
|
|
return questionTypeName; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |