合并最新
This commit is contained in:
@@ -192,45 +192,89 @@ namespace WebAPI.Controllers
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getTestPlan = new Model.SGGLDB(Funs.ConnString).Training_TestPlan.FirstOrDefault(e => e.TestPlanId == testPlanId && e.States != "3" && e.TestStartTime <= DateTime.Now && e.TestEndTime >= DateTime.Now);
|
||||
if (getTestPlan != null)
|
||||
using (var db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var person = PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
if (person != null )
|
||||
var getTestPlan = db.Training_TestPlan.FirstOrDefault(e => e.TestPlanId == testPlanId && e.States != "3" && e.TestStartTime <= DateTime.Now && e.TestEndTime >= DateTime.Now);
|
||||
if (getTestPlan != null)
|
||||
{
|
||||
//2-考试中;生成考试试卷
|
||||
if (getTestPlan.States == "2" )
|
||||
var user = db.Sys_User.FirstOrDefault(x=>x.UserId==personId);
|
||||
Model.SitePerson_Person person;
|
||||
if (user != null)
|
||||
{
|
||||
var testRecord = new Model.SGGLDB(Funs.ConnString).Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
|
||||
if (testRecord != null)
|
||||
{
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
person = Funs.DB.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
|
||||
person = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
|
||||
}
|
||||
if (person != null || user != null)
|
||||
{
|
||||
//2-考试中;生成考试试卷
|
||||
if (getTestPlan.States == "2")
|
||||
{
|
||||
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
||||
var testTRecord = new Model.SGGLDB(Funs.ConnString).Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == personId);
|
||||
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
|
||||
var testRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == personId && !x.TestEndTime.HasValue);
|
||||
if (testRecord != null)
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person,user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
else if(person !=null)
|
||||
{
|
||||
var testRecord2 = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
|
||||
if (testRecord2 != null)
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord2.TestRecordId, person, user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (person!=null&&string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
|
||||
{
|
||||
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
||||
var testTRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == person.PersonId);
|
||||
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null && string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(user.UnitId) && (getTestPlan.DepartIds == null || getTestPlan.DepartIds.Contains(user.DepartId)))
|
||||
{
|
||||
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
||||
var testTRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == personId);
|
||||
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (responeData.code == 1)
|
||||
|
||||
Reference in New Issue
Block a user