修改公司级培训
This commit is contained in:
@@ -74,29 +74,46 @@ namespace WebAPI.Controllers
|
||||
/// <param name="trainingPlanId">培训计划ID</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getSaveTestPlanByTrainingPlanId(string trainingPlanId,string userId)
|
||||
public Model.ResponeData getSaveTestPlanByTrainingPlanId(string trainingPlanId, string userId)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getTasks = new Model.SGGLDB(Funs.ConnString).Training_Task.FirstOrDefault(x => x.PlanId == trainingPlanId);
|
||||
if (getTasks != null)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
if (CommonService.IsMainUnitOrAdmin(userId))
|
||||
var getTasks = db.Training_Task.FirstOrDefault(x => x.PlanId == trainingPlanId);
|
||||
if (getTasks != null)
|
||||
{
|
||||
responeData.data = APITestPlanService.SaveTestPlanByTrainingPlanId(trainingPlanId, userId);
|
||||
bool result = false;
|
||||
if (userId == Const.sysglyId || userId == Const.hfnbdId)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var user = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
|
||||
if (user != null && user.UnitId == CommonService.GetThisUnitId())
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
if (result)
|
||||
//if (CommonService.IsMainUnitOrAdmin(userId))
|
||||
{
|
||||
responeData.data = APITestPlanService.SaveTestPlanByTrainingPlanId(trainingPlanId, userId);
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "非本单位用户,不能生成考试计划!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "非本单位用户,不能生成考试计划!";
|
||||
responeData.message = "培训计划下没有培训人员,不能生成考试计划!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "培训计划下没有培训人员,不能生成考试计划!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -192,45 +209,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 = 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 = 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.AddTestRecordForApi(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.AddTestRecordForApi(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (responeData.code == 1)
|
||||
@@ -292,6 +353,83 @@ namespace WebAPI.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
public Model.ResponeData getTrainingPlanTestRecordItemByTestPlanIdPersonId(string companyTrainingItemCode, string personId, string projectId)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (var db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getCompanyTraining = db.Training_CompanyTrainingItem.FirstOrDefault(e => e.CompanyTrainingItemCode == companyTrainingItemCode);
|
||||
if (getCompanyTraining != null)
|
||||
{
|
||||
var user = db.Sys_User.FirstOrDefault(x => x.UserId == personId);
|
||||
Model.SitePerson_Person person;
|
||||
if (user != null)
|
||||
{
|
||||
person = db.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == projectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == projectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
|
||||
}
|
||||
if (person != null || user != null)
|
||||
{
|
||||
var testRecord = db.Training_TestRecord.FirstOrDefault(x => x.CompanyTrainingItemId == getCompanyTraining.CompanyTrainingItemId && x.TestManId == personId && !x.TestEndTime.HasValue);
|
||||
if (testRecord != null)
|
||||
{
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getCompanyTraining, testRecord.TestRecordId, person, user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
else if (person != null)
|
||||
{
|
||||
var testRecord2 = db.Training_TestRecord.FirstOrDefault(x => x.CompanyTrainingItemId == getCompanyTraining.CompanyTrainingItemId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
|
||||
if (testRecord2 != null)
|
||||
{
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getCompanyTraining, testRecord2.TestRecordId, person, user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.Training_TestRecord training_TestRecord = new Model.Training_TestRecord();
|
||||
training_TestRecord.TestRecordId = Guid.NewGuid().ToString();
|
||||
training_TestRecord.ProjectId = projectId;
|
||||
training_TestRecord.CompanyTrainingItemId = getCompanyTraining.CompanyTrainingItemId;
|
||||
training_TestRecord.TestManId = person.PersonId;
|
||||
db.Training_TestRecord.InsertOnSubmit(training_TestRecord);
|
||||
db.SubmitChanges();
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getCompanyTraining, training_TestRecord.TestRecordId, person, user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Model.Training_TestRecord training_TestRecord = new Model.Training_TestRecord();
|
||||
training_TestRecord.TestRecordId = Guid.NewGuid().ToString();
|
||||
training_TestRecord.ProjectId = projectId;
|
||||
training_TestRecord.CompanyTrainingItemId = getCompanyTraining.CompanyTrainingItemId;
|
||||
training_TestRecord.TestManId = user.UserId;
|
||||
db.Training_TestRecord.InsertOnSubmit(training_TestRecord);
|
||||
db.SubmitChanges();
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getCompanyTraining, training_TestRecord.TestRecordId, person, user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
using BLL;
|
||||
using Model;
|
||||
|
||||
namespace WebAPI.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
@@ -267,25 +272,129 @@ namespace WebAPI.Controllers
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId);
|
||||
if (getItem != null)
|
||||
if (!string.IsNullOrEmpty(testRecordItemId) && !string.IsNullOrEmpty(selectedItem))
|
||||
{
|
||||
//更新没有结束时间且超时的考试记录
|
||||
int closeCount = TestRecordService.UpdateTestEndTimeNull(getItem.TestRecordId);
|
||||
if (closeCount > 0)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
responeData.code = 2;
|
||||
responeData.message = "本次考试已结束,系统自动交卷!";
|
||||
}
|
||||
else
|
||||
{
|
||||
APITestRecordService.getTestRecordItemAnswerBySelectedItem(getItem, selectedItem);
|
||||
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == testRecordItemId);
|
||||
if (getTItem != null)
|
||||
{
|
||||
getTItem.SubjectScore = 0;
|
||||
getTItem.SelectedItem = selectedItem;
|
||||
if (!string.IsNullOrEmpty(selectedItem))
|
||||
{
|
||||
if (getTItem.AnswerItems == selectedItem)
|
||||
{
|
||||
getTItem.SubjectScore = getTItem.Score ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var listA = Funs.GetStrListByStr(getTItem.AnswerItems.ToUpper(), ',');
|
||||
var listS = Funs.GetStrListByStr(selectedItem.ToUpper(), ',');
|
||||
if (getTItem.TestType == "2" && listA.Count >= listS.Count)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in listS)
|
||||
{
|
||||
if (!listA.Contains(item))
|
||||
{
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
if (listA.Count == listS.Count)
|
||||
{
|
||||
getTItem.SubjectScore = getTItem.Score ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
getTItem.SubjectScore = Convert.ToDecimal((getTItem.Score ?? 0) * 1.0 / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "试题有问题!";
|
||||
responeData.message = "答题为空选项!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
public Model.ResponeData getTestRecordItemAnswerBySelectedItem(string testRecordId, string testRecordItemId, string selectedItem)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(testRecordId) && !string.IsNullOrEmpty(testRecordItemId) && !string.IsNullOrEmpty(selectedItem))
|
||||
{
|
||||
BLL.RedisHelper redis = new RedisHelper();
|
||||
var trainingTestRecordItems = redis.GetObjString<List<Training_TestRecordItem>>(testRecordId); //根据试卷ID获取试卷题目列表
|
||||
var getTItem = trainingTestRecordItems?.FirstOrDefault(x => x.TestRecordItemId == testRecordItemId); //获取试题
|
||||
if (getTItem == null)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "答题为空选项!";
|
||||
return responeData;
|
||||
}
|
||||
getTItem.SubjectScore = 0;
|
||||
getTItem.SelectedItem = selectedItem;
|
||||
if (!string.IsNullOrEmpty(selectedItem))
|
||||
{
|
||||
if (getTItem.AnswerItems == selectedItem)
|
||||
{
|
||||
getTItem.SubjectScore = getTItem.Score ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var listA = Funs.GetStrListByStr(getTItem.AnswerItems.ToUpper(), ',');
|
||||
var listS = Funs.GetStrListByStr(selectedItem.ToUpper(), ',');
|
||||
if (getTItem.TestType == "2" && listA.Count >= listS.Count)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in listS)
|
||||
{
|
||||
if (!listA.Contains(item))
|
||||
{
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
if (listA.Count == listS.Count)
|
||||
{
|
||||
getTItem.SubjectScore = getTItem.Score ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
getTItem.SubjectScore = Convert.ToDecimal((getTItem.Score ?? 0) * 1.0 / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
redis.SetObjString(testRecordId, getTItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "参数不足!";
|
||||
return responeData;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -349,5 +458,132 @@ namespace WebAPI.Controllers
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 交卷
|
||||
/// <summary>
|
||||
/// 交卷
|
||||
/// </summary>
|
||||
public Model.ResponeData SaveSubmitTestRecordByTestRecordId(Model.TestRecordItem testRecordItem)
|
||||
{
|
||||
string testRecordId = testRecordItem.TestRecordId;
|
||||
string Signature = testRecordItem.Signature;
|
||||
string Fingerprint = testRecordItem.Fingerprint;
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
#region 将答题记录保存到数据库
|
||||
RedisHelper redis = new RedisHelper();
|
||||
var trainingTestRecordItems = redis.GetObjString<List<Training_TestRecordItem>>(testRecordId);
|
||||
|
||||
if (trainingTestRecordItems != null)
|
||||
{
|
||||
var modeltestRecordItem = from x in db.Training_TestRecordItem
|
||||
where x.TestRecordId == testRecordId
|
||||
select x;
|
||||
if (modeltestRecordItem.Any())
|
||||
{
|
||||
db.Training_TestRecordItem.DeleteAllOnSubmit(modeltestRecordItem);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
db.Training_TestRecordItem.InsertAllOnSubmit(trainingTestRecordItems);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
|
||||
if (getTestRecord != null)
|
||||
{
|
||||
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
|
||||
string SignatureUrl = @"FileUpload\TestRecord\" + getTestRecord.TestRecordId + "~签名" + ".png";
|
||||
string FingerprintUrl = @"FileUpload\TestRecord\" + getTestRecord.TestRecordId + "~指纹" + ".png";
|
||||
string Signaturefilename = rootUrl + SignatureUrl;
|
||||
string Fingerprintfilename = rootUrl + FingerprintUrl;
|
||||
|
||||
if (!string.IsNullOrEmpty(Signature))
|
||||
{
|
||||
Signature = Signature.Replace("data:image/svg+xml;base64,", "").Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
|
||||
byte[] bytes = Convert.FromBase64String(Signature);
|
||||
|
||||
MemoryStream memStream = new MemoryStream(bytes);
|
||||
Image mImage = Image.FromStream(memStream);
|
||||
Bitmap bp = new Bitmap(mImage);
|
||||
MemoryStream ms = new MemoryStream();
|
||||
bp.Save(Signaturefilename, System.Drawing.Imaging.ImageFormat.Png);
|
||||
// System.IO.File.WriteAllBytes(Signaturefilename, Convert.FromBase64String(Signature));
|
||||
|
||||
getTestRecord.Signature = Signaturefilename.Replace(rootUrl, "");
|
||||
|
||||
}
|
||||
if (!string.IsNullOrEmpty(Fingerprint))
|
||||
{
|
||||
Fingerprint = Fingerprint.Replace("data:image/svg+xml;base64,", "").Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
|
||||
|
||||
byte[] bytes = Convert.FromBase64String(Fingerprint);
|
||||
|
||||
MemoryStream memStream = new MemoryStream(bytes);
|
||||
Image mImage = Image.FromStream(memStream);
|
||||
Bitmap bp = new Bitmap(mImage);
|
||||
MemoryStream ms = new MemoryStream();
|
||||
bp.Save(Fingerprintfilename, System.Drawing.Imaging.ImageFormat.Png);
|
||||
|
||||
getTestRecord.Fingerprint = Fingerprintfilename.Replace(rootUrl, "");
|
||||
|
||||
}
|
||||
db.SubmitChanges();
|
||||
// APITestRecordService.updateTestRecord(getTestRecord);
|
||||
string returnTestRecordId = string.Empty;
|
||||
////考试分数
|
||||
decimal getTestScores = APITestRecordService.getSubmitTestRecord(getTestRecord);
|
||||
|
||||
if (!string.IsNullOrEmpty(getTestRecord.TestPlanId))
|
||||
{ ////及格分数
|
||||
int getPassScores = 80;
|
||||
var testRule = db.Sys_TestRule.FirstOrDefault();
|
||||
if (testRule != null)
|
||||
{
|
||||
getPassScores = testRule.PassingScore;
|
||||
}
|
||||
if (getTestScores <= getPassScores)
|
||||
{
|
||||
int testCount = db.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
|
||||
if (testCount < 2)
|
||||
{
|
||||
////重新生成一条考试记录 以及考试试卷
|
||||
returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
|
||||
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。";
|
||||
}
|
||||
else
|
||||
{
|
||||
APITestRecordService.updateAll(getTestRecord.TestPlanId);
|
||||
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,请再次参加培训后补考。";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
APITestRecordService.updateAll(getTestRecord.TestPlanId);
|
||||
responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。";
|
||||
}
|
||||
responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.data = new { getTestScores };
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace WebAPI.Controllers
|
||||
/// <param name="trainTypeId">培训类型ID(可为空)</param>
|
||||
/// <param name="pageIndex">分页</param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string departIds, string trainTypeId, int pageIndex, string strParam, string InTime)
|
||||
public Model.ResponeData getTrainingPersonListByTrainTypeId(string projectId, string unitIds, string workPostIds, string trainTypeId, int pageIndex, string departIds="", string strParam="", string InTime="")
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
@@ -378,6 +378,7 @@ namespace WebAPI.Controllers
|
||||
}
|
||||
responeData.data = new { pageCount, getDataList };
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1140,6 +1141,6 @@ namespace WebAPI.Controllers
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user