修改公司级培训
This commit is contained in:
parent
f4e6755b17
commit
70ff1350bb
DataBase/版本日志
SGGL
BLL
FineUIPro.Web
Model
WebAPI
Controllers
Properties/PublishProfiles
|
@ -0,0 +1,2 @@
|
||||||
|
alter table Training_TestRecord
|
||||||
|
add CompanyTrainingItemId nvarchar(50) null;
|
|
@ -109,9 +109,13 @@ namespace BLL
|
||||||
UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds),
|
UnitNames = UnitService.getUnitNamesUnitIds(x.UnitIds),
|
||||||
WorkPostIds = x.WorkPostIds,
|
WorkPostIds = x.WorkPostIds,
|
||||||
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostIds),
|
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(x.WorkPostIds),
|
||||||
|
DepartIds = x.DepartIds,
|
||||||
|
DepartNames = WorkPostService.getDepartNamesByIdsForApi(x.DepartIds),
|
||||||
States = x.States,
|
States = x.States,
|
||||||
QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'),
|
QRCodeUrl = x.QRCodeUrl.Replace('\\', '/'),
|
||||||
TrainingPlanId = x.PlanId,
|
TrainingPlanId = x.PlanId,
|
||||||
|
TrainTypeId = x.TrainTypeId,
|
||||||
|
TrainTypeName = db.Base_TrainType.Where(xx => xx.TrainTypeId == x.TrainTypeId).Select(xx => xx.TrainTypeName).FirstOrDefault()
|
||||||
};
|
};
|
||||||
return getDataLists.FirstOrDefault();
|
return getDataLists.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
@ -259,8 +263,9 @@ namespace BLL
|
||||||
////新增考试人员明细
|
////新增考试人员明细
|
||||||
foreach (var item in getTestPlan.TestRecordItems)
|
foreach (var item in getTestPlan.TestRecordItems)
|
||||||
{
|
{
|
||||||
|
var user = db.Sys_User.FirstOrDefault(e => e.UserId == item.TestManId);
|
||||||
var person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == item.TestManId);
|
var person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == item.TestManId);
|
||||||
if (person != null)
|
if (user != null || person != null)
|
||||||
{
|
{
|
||||||
Model.Training_TestRecord newTrainDetail = new Model.Training_TestRecord
|
Model.Training_TestRecord newTrainDetail = new Model.Training_TestRecord
|
||||||
{
|
{
|
||||||
|
@ -383,9 +388,11 @@ namespace BLL
|
||||||
TestStartTime = DateTime.Now,
|
TestStartTime = DateTime.Now,
|
||||||
TestPalce = getTrainingPlan.TeachAddress,
|
TestPalce = getTrainingPlan.TeachAddress,
|
||||||
UnitIds = getTrainingPlan.UnitIds,
|
UnitIds = getTrainingPlan.UnitIds,
|
||||||
UnitNames = UnitService.getUnitNamesUnitIds(getTrainingPlan.UnitIds),
|
UnitNames = UnitService.getUnitNamesUnitIdsForApi(getTrainingPlan.UnitIds),
|
||||||
WorkPostIds = getTrainingPlan.WorkPostId,
|
WorkPostIds = getTrainingPlan.WorkPostId,
|
||||||
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIds(getTrainingPlan.WorkPostId),
|
WorkPostNames = WorkPostService.getWorkPostNamesWorkPostIdsForApi(getTrainingPlan.WorkPostId),
|
||||||
|
DepartIds = getTrainingPlan.DepartIds,
|
||||||
|
DepartNames = WorkPostService.getDepartNamesByIdsForApi(getTrainingPlan.DepartIds),
|
||||||
PlanId = getTrainingPlan.PlanId,
|
PlanId = getTrainingPlan.PlanId,
|
||||||
States = "0",
|
States = "0",
|
||||||
};
|
};
|
||||||
|
@ -441,7 +448,7 @@ namespace BLL
|
||||||
{
|
{
|
||||||
db.Training_TestPlan.InsertOnSubmit(newTestPlan);
|
db.Training_TestPlan.InsertOnSubmit(newTestPlan);
|
||||||
db.SubmitChanges();
|
db.SubmitChanges();
|
||||||
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, null, testPlanId, newTestPlan.PlanDate);
|
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitIdForApi(Const.ProjectTestPlanMenuId, newTestPlan.ProjectId, null, testPlanId, newTestPlan.PlanDate);
|
||||||
///培训人员
|
///培训人员
|
||||||
var getTrainingTask = (from x in db.Training_Task where x.PlanId == trainingPlanId select x).ToList();
|
var getTrainingTask = (from x in db.Training_Task where x.PlanId == trainingPlanId select x).ToList();
|
||||||
foreach (var itemTask in getTrainingTask)
|
foreach (var itemTask in getTrainingTask)
|
||||||
|
@ -452,7 +459,7 @@ namespace BLL
|
||||||
ProjectId = getTrainingPlan.ProjectId,
|
ProjectId = getTrainingPlan.ProjectId,
|
||||||
TestPlanId = testPlanId,
|
TestPlanId = testPlanId,
|
||||||
TestManId = itemTask.UserId,
|
TestManId = itemTask.UserId,
|
||||||
TestType= db.Base_TrainType.First(z=>z.TrainTypeId == getTrainingPlan.TrainTypeId).TrainTypeName,
|
TestType = db.Base_TrainType.First(z => z.TrainTypeId == getTrainingPlan.TrainTypeId).TrainTypeName,
|
||||||
};
|
};
|
||||||
|
|
||||||
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace BLL
|
||||||
ProjectId = x.ProjectId,
|
ProjectId = x.ProjectId,
|
||||||
TestPlanId = x.TestPlanId,
|
TestPlanId = x.TestPlanId,
|
||||||
TestManId = x.TestManId,
|
TestManId = x.TestManId,
|
||||||
TestManName = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == x.TestManId).PersonName,
|
TestManName = getPname(x.TestManId),
|
||||||
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
|
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
|
||||||
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
|
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
|
||||||
TestScores = x.TestScores ?? 0,
|
TestScores = x.TestScores ?? 0,
|
||||||
|
@ -39,6 +39,26 @@ namespace BLL
|
||||||
return getDataLists;
|
return getDataLists;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string getPname(string TestManId) {
|
||||||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) {
|
||||||
|
var pname = "";
|
||||||
|
var personModel = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == TestManId);
|
||||||
|
if (personModel==null)
|
||||||
|
{
|
||||||
|
var unameModel = db.Sys_User.FirstOrDefault(p=>p.UserId== TestManId);
|
||||||
|
if (unameModel!=null)
|
||||||
|
{
|
||||||
|
pname = unameModel.UserName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pname = personModel.PersonName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pname;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 根据试卷ID获取试卷记录详细
|
#region 根据试卷ID获取试卷记录详细
|
||||||
|
@ -81,7 +101,7 @@ namespace BLL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="testPlanId"></param>
|
/// <param name="testPlanId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string CreateTestRecordItem(Model.Training_TestPlan getTestPlan, string testRecordId, Model.SitePerson_Person person)
|
public static string CreateTestRecordItem(Model.Training_TestPlan getTestPlan, string testRecordId, Model.SitePerson_Person person, Model.Sys_User user)
|
||||||
{
|
{
|
||||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
{
|
{
|
||||||
|
@ -108,9 +128,22 @@ namespace BLL
|
||||||
int sumTestType3Count = testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
|
int sumTestType3Count = testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
|
||||||
|
|
||||||
////获取类型下适合岗位试题集合
|
////获取类型下适合岗位试题集合
|
||||||
var getTestTrainingItemALLs = from x in db.Training_TestTrainingItem
|
List<Model.Training_TestTrainingItem> getTestTrainingItemALLs;
|
||||||
where x.TrainingId != null && (x.WorkPostIds == null || (x.WorkPostIds.Contains(person.WorkPostId) && person.WorkPostId != null))
|
string WorkPostId = "";
|
||||||
select x;
|
string DepartId = "";
|
||||||
|
if (person != null)
|
||||||
|
{
|
||||||
|
WorkPostId = person.WorkPostId;
|
||||||
|
}
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
DepartId = user.DepartId;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTestTrainingItemALLs = (from x in db.Training_TestTrainingItem
|
||||||
|
where x.TrainingId != null && (x.WorkPostIds == null || string.IsNullOrEmpty(WorkPostId) || x.WorkPostIds.Contains(WorkPostId)) || (x.DepartIds == null || string.IsNullOrEmpty(DepartId) || x.DepartIds.Contains(DepartId))
|
||||||
|
|
||||||
|
select x).ToList();
|
||||||
foreach (var itemT in testPlanTrainings)
|
foreach (var itemT in testPlanTrainings)
|
||||||
{
|
{
|
||||||
//// 获取类型下的题目
|
//// 获取类型下的题目
|
||||||
|
@ -201,12 +234,170 @@ namespace BLL
|
||||||
|
|
||||||
db.Training_TestRecordItem.InsertAllOnSubmit(getItems);
|
db.Training_TestRecordItem.InsertAllOnSubmit(getItems);
|
||||||
db.SubmitChanges();
|
db.SubmitChanges();
|
||||||
|
BLL.RedisHelper redis = new BLL.RedisHelper();
|
||||||
|
redis.SetObjString(testRecordId, getItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return testRecordId;
|
return testRecordId;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static string CreateTestRecordItem(Model.Training_CompanyTrainingItem getCompanyTraining, string testRecordId, Model.SitePerson_Person person, Model.Sys_User user)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
|
{
|
||||||
|
var trainingIds = getCompanyTraining.TestTrainingIds.Split(',');
|
||||||
|
var testTrainings = db.Training_TestTraining.Where(x => trainingIds.Contains(x.TrainingId));
|
||||||
|
var getTestRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == testRecordId);
|
||||||
|
if (getTestRecord != null && !getTestRecord.TestStartTime.HasValue)
|
||||||
|
{
|
||||||
|
////考试时长
|
||||||
|
getTestRecord.Duration = 120;
|
||||||
|
getTestRecord.TestStartTime = DateTime.Now;
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
////当前人考试记录 未加入考试计划的 当考试开始扫码时 不允许再参与考试
|
||||||
|
var item = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordId == getTestRecord.TestRecordId);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
List<Model.Training_TestTrainingItem> getTestTrainingItemList = new List<Model.Training_TestTrainingItem>();
|
||||||
|
//var testPlanTrainings = from x in db.Training_TestPlanTraining
|
||||||
|
// where x.TestPlanId == getTestPlan.TestPlanId
|
||||||
|
// select x;
|
||||||
|
//// 计划考试中单选、多选、判断题总数
|
||||||
|
var sysTestRule = Funs.DB.Sys_TestRule.FirstOrDefault();
|
||||||
|
|
||||||
|
int sumTestType1Count = 0;// testPlanTrainings.Sum(x => x.TestType1Count) ?? 0;
|
||||||
|
int sumTestType2Count = 0;//testPlanTrainings.Sum(x => x.TestType2Count) ?? 0;
|
||||||
|
int sumTestType3Count = 0;//testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
|
||||||
|
if (sysTestRule != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
sumTestType1Count = sysTestRule.SCount;
|
||||||
|
sumTestType2Count = sysTestRule.MCount;
|
||||||
|
sumTestType3Count = sysTestRule.JCount;
|
||||||
|
}
|
||||||
|
////获取类型下适合岗位试题集合
|
||||||
|
List<Model.Training_TestTrainingItem> getTestTrainingItemALLs;
|
||||||
|
string WorkPostId = "";
|
||||||
|
string DepartId = "";
|
||||||
|
if (person != null)
|
||||||
|
{
|
||||||
|
WorkPostId = person.WorkPostId;
|
||||||
|
}
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
DepartId = user.DepartId;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTestTrainingItemALLs = (from x in db.Training_TestTrainingItem
|
||||||
|
where x.TrainingId != null && (x.WorkPostIds == null || string.IsNullOrEmpty(WorkPostId) || x.WorkPostIds.Contains(WorkPostId)) || (x.DepartIds == null || string.IsNullOrEmpty(DepartId) || x.DepartIds.Contains(DepartId))
|
||||||
|
select x).ToList();
|
||||||
|
foreach (var itemT in testTrainings)
|
||||||
|
{
|
||||||
|
//// 获取类型下的题目
|
||||||
|
var getTestTrainingItems = getTestTrainingItemALLs.Where(x => x.TrainingId == itemT.TrainingId).ToList();
|
||||||
|
if (getTestTrainingItems.Count() > 0)
|
||||||
|
{
|
||||||
|
////单选题
|
||||||
|
var getSItem = getTestTrainingItems.Where(x => x.TestType == "1").OrderBy(x => Guid.NewGuid()).Take(sumTestType1Count);
|
||||||
|
if (getSItem.Count() > 0)
|
||||||
|
{
|
||||||
|
getTestTrainingItemList.AddRange(getSItem);
|
||||||
|
}
|
||||||
|
///多选题
|
||||||
|
var getMItem = getTestTrainingItems.Where(x => x.TestType == "2").OrderBy(x => Guid.NewGuid()).Take(sumTestType2Count);
|
||||||
|
if (getMItem.Count() > 0)
|
||||||
|
{
|
||||||
|
getTestTrainingItemList.AddRange(getMItem);
|
||||||
|
}
|
||||||
|
///判断题
|
||||||
|
var getJItem = getTestTrainingItems.Where(x => x.TestType == "3").OrderBy(x => Guid.NewGuid()).Take(sumTestType3Count);
|
||||||
|
if (getJItem.Count() > 0)
|
||||||
|
{
|
||||||
|
getTestTrainingItemList.AddRange(getJItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//// 获取得到的单选题、多选题、判断题 数量
|
||||||
|
int getDiffTestType1Count = sumTestType1Count - getTestTrainingItemList.Where(x => x.TestType == "1").Count();
|
||||||
|
int getDiffTestType2Count = sumTestType2Count - getTestTrainingItemList.Where(x => x.TestType == "2").Count();
|
||||||
|
int getDiffTestType3Count = sumTestType3Count - getTestTrainingItemList.Where(x => x.TestType == "3").Count();
|
||||||
|
if (getDiffTestType1Count > 0 || getDiffTestType2Count > 0 || getDiffTestType3Count > 0)
|
||||||
|
{
|
||||||
|
var getTestTrainingItemNulls = getTestTrainingItemALLs.Where(x => x.WorkPostIds == null).ToList();
|
||||||
|
if (getTestTrainingItemNulls.Count() > 0)
|
||||||
|
{
|
||||||
|
/// 通用且未选择的题目
|
||||||
|
var getTestTrainingItemDiffs = getTestTrainingItemNulls.Except(getTestTrainingItemList).ToList();
|
||||||
|
////单选题
|
||||||
|
if (getDiffTestType1Count > 0)
|
||||||
|
{
|
||||||
|
var getSItemD = getTestTrainingItemDiffs.Where(x => x.TestType == "1").OrderBy(x => Guid.NewGuid()).Take(getDiffTestType1Count);
|
||||||
|
if (getSItemD.Count() > 0)
|
||||||
|
{
|
||||||
|
getTestTrainingItemList.AddRange(getSItemD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///多选题
|
||||||
|
if (getDiffTestType2Count > 0)
|
||||||
|
{
|
||||||
|
var getMItemD = getTestTrainingItemDiffs.Where(x => x.TestType == "2").OrderBy(x => Guid.NewGuid()).Take(getDiffTestType2Count);
|
||||||
|
if (getMItemD.Count() > 0)
|
||||||
|
{
|
||||||
|
getTestTrainingItemList.AddRange(getMItemD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
///判断题
|
||||||
|
if (getDiffTestType3Count > 0)
|
||||||
|
{
|
||||||
|
var getJItemD = getTestTrainingItemDiffs.Where(x => x.TestType == "3").OrderBy(x => Guid.NewGuid()).Take(getDiffTestType3Count);
|
||||||
|
if (getJItemD.Count() > 0)
|
||||||
|
{
|
||||||
|
getTestTrainingItemList.AddRange(getJItemD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getTestTrainingItemList.Count() > 0)
|
||||||
|
{
|
||||||
|
var getItems = from x in getTestTrainingItemList
|
||||||
|
select new Model.Training_TestRecordItem
|
||||||
|
{
|
||||||
|
TestRecordItemId = SQLHelper.GetNewID(),
|
||||||
|
TestRecordId = getTestRecord.TestRecordId,
|
||||||
|
TrainingItemName = x.TrainingItemName,
|
||||||
|
TrainingItemCode = x.TrainingItemCode,
|
||||||
|
Abstracts = x.Abstracts,
|
||||||
|
AttachUrl = x.AttachUrl,
|
||||||
|
TestType = x.TestType,
|
||||||
|
AItem = x.AItem,
|
||||||
|
BItem = x.BItem,
|
||||||
|
CItem = x.CItem,
|
||||||
|
DItem = x.DItem,
|
||||||
|
EItem = x.EItem,
|
||||||
|
AnswerItems = x.AnswerItems,
|
||||||
|
Score = x.TestType == "1" ? sysTestRule.SValue : (x.TestType == "2" ? sysTestRule.MValue : sysTestRule.JValue),
|
||||||
|
};
|
||||||
|
|
||||||
|
db.Training_TestRecordItem.InsertAllOnSubmit(getItems);
|
||||||
|
db.SubmitChanges();
|
||||||
|
BLL.RedisHelper redis = new BLL.RedisHelper();
|
||||||
|
redis.SetObjString(testRecordId, getItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return testRecordId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region 根据PersonId、TestPlanId生成试卷 扫码生成试卷
|
#region 根据PersonId、TestPlanId生成试卷 扫码生成试卷
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据PersonId、TestPlanId生成试卷 扫码生成试卷
|
/// 根据PersonId、TestPlanId生成试卷 扫码生成试卷
|
||||||
|
@ -672,6 +863,8 @@ namespace BLL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="testRecord"></param>
|
/// <param name="testRecord"></param>
|
||||||
public static string getResitTestRecord(Model.Training_TestRecord getTestRecord)
|
public static string getResitTestRecord(Model.Training_TestRecord getTestRecord)
|
||||||
|
{
|
||||||
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
||||||
{
|
{
|
||||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||||
{
|
{
|
||||||
|
@ -685,17 +878,19 @@ namespace BLL
|
||||||
// TestStartTime = DateTime.Now,
|
// TestStartTime = DateTime.Now,
|
||||||
};
|
};
|
||||||
|
|
||||||
Funs.DB.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
||||||
Funs.DB.SubmitChanges();
|
db.SubmitChanges();
|
||||||
|
|
||||||
var getTestPlan = Funs.DB.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
|
var getTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
|
||||||
var person = PersonService.GetPersonByUserId(newTestRecord.TestManId, getTestPlan.ProjectId);
|
var user = db.Sys_User.FirstOrDefault(x => x.UserId == newTestRecord.TestManId);
|
||||||
|
var person = PersonService.GetPersonByUserIdForApi(newTestRecord.TestManId, getTestPlan.ProjectId);
|
||||||
if (getTestPlan != null && person != null)
|
if (getTestPlan != null && person != null)
|
||||||
{
|
{
|
||||||
CreateTestRecordItem(getTestPlan, newTestRecord.TestRecordId, person);
|
CreateTestRecordItem(getTestPlan, newTestRecord.TestRecordId, person, user);
|
||||||
}
|
}
|
||||||
return newTestRecord.TestRecordId;
|
return newTestRecord.TestRecordId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static List<Model.TestRecordItem> getTrainingTestRecordListByDepartId(string unitId, string departId, string strPass, string strParam)
|
public static List<Model.TestRecordItem> getTrainingTestRecordListByDepartId(string unitId, string departId, string strPass, string strParam)
|
||||||
|
@ -765,5 +960,7 @@ namespace BLL
|
||||||
return getDataLists.ToList();
|
return getDataLists.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -71,6 +71,8 @@ namespace BLL
|
||||||
GetDataService.CreateTrainingTaskItemByTaskId(taskId);
|
GetDataService.CreateTrainingTaskItemByTaskId(taskId);
|
||||||
|
|
||||||
var getDataLists = (from x in db.Training_TaskItem
|
var getDataLists = (from x in db.Training_TaskItem
|
||||||
|
join y in db.Training_CompanyTrainingItem on x.TrainingItemCode equals y.CompanyTrainingItemCode into temp
|
||||||
|
from y in temp.DefaultIfEmpty()
|
||||||
where x.TaskId == taskId
|
where x.TaskId == taskId
|
||||||
orderby x.TrainingItemCode
|
orderby x.TrainingItemCode
|
||||||
select new Model.TrainingTaskItemItem
|
select new Model.TrainingTaskItemItem
|
||||||
|
@ -78,11 +80,12 @@ namespace BLL
|
||||||
TaskItemId = x.TaskItemId,
|
TaskItemId = x.TaskItemId,
|
||||||
TaskId = x.TaskId,
|
TaskId = x.TaskId,
|
||||||
PlanId = x.PlanId,
|
PlanId = x.PlanId,
|
||||||
PersonId = x.PersonId,
|
|
||||||
StartTime = x.StartTime,
|
StartTime = x.StartTime,
|
||||||
EndTime = x.EndTime,
|
EndTime = x.EndTime,
|
||||||
LearnTime = x.LearnTime,
|
LearningTime = x.LearnTime,
|
||||||
|
AttachTime = y.LearningTime,
|
||||||
VideoProgress = x.VideoProgress,
|
VideoProgress = x.VideoProgress,
|
||||||
|
PersonId = x.PersonId,
|
||||||
TrainingItemCode = x.TrainingItemCode,
|
TrainingItemCode = x.TrainingItemCode,
|
||||||
TrainingItemName = x.TrainingItemName,
|
TrainingItemName = x.TrainingItemName,
|
||||||
AttachUrl = x.AttachUrl.Replace('\\', '/'),
|
AttachUrl = x.AttachUrl.Replace('\\', '/'),
|
||||||
|
@ -273,18 +276,40 @@ namespace BLL
|
||||||
item.StartTime = startTime;
|
item.StartTime = startTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (!item.LearnTime.HasValue)
|
||||||
|
//{
|
||||||
|
// item.LearnTime = 0;
|
||||||
|
//}
|
||||||
|
if (!string.IsNullOrEmpty(VideoProgress))
|
||||||
|
{
|
||||||
|
//if (!item.VideoProgress.HasValue)
|
||||||
|
//{
|
||||||
|
// item.VideoProgress = 0;
|
||||||
|
//}
|
||||||
|
item.VideoProgress = int.Parse(VideoProgress);
|
||||||
|
}
|
||||||
|
var span = endTime.Subtract(startTime);
|
||||||
if (!item.LearnTime.HasValue)
|
if (!item.LearnTime.HasValue)
|
||||||
{
|
{
|
||||||
item.LearnTime = 0;
|
item.LearnTime = 0;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(VideoProgress))
|
item.LearnTime = item.LearnTime.Value + (int)span.TotalSeconds;
|
||||||
{
|
|
||||||
item.VideoProgress = int.Parse(VideoProgress);
|
|
||||||
}
|
|
||||||
var span = endTime.Subtract(startTime);
|
|
||||||
item.LearnTime = item.LearnTime.Value + (int)span.TotalMinutes;
|
|
||||||
item.EndTime = endTime;
|
item.EndTime = endTime;
|
||||||
|
|
||||||
db.SubmitChanges();
|
db.SubmitChanges();
|
||||||
|
|
||||||
|
var companyTrainingItem = db.Training_CompanyTrainingItem.FirstOrDefault(x => x.CompanyTrainingItemCode == item.TrainingItemCode);
|
||||||
|
int companyTrainingItemLearnTime = companyTrainingItem?.LearningTime ?? 0; //培训教材时长(秒)
|
||||||
|
|
||||||
|
|
||||||
|
//如果学习时长大于培训教材时长,则关闭状态
|
||||||
|
if (item.LearnTime > companyTrainingItemLearnTime)
|
||||||
|
{
|
||||||
|
var taskModel = db.Training_Task.FirstOrDefault(x => x.TaskId == item.TaskId);
|
||||||
|
taskModel.States = "2";
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
<SccProvider>
|
<SccProvider>
|
||||||
</SccProvider>
|
</SccProvider>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
@ -66,8 +68,11 @@
|
||||||
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.2.1.1\lib\netstandard2.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
|
<HintPath>..\packages\Microsoft.Office.Interop.Excel.15.0.4795.1001\lib\net20\Microsoft.Office.Interop.Excel.dll</HintPath>
|
||||||
|
@ -100,12 +105,18 @@
|
||||||
<HintPath>..\packages\MicrosoftOfficeCore.15.0.0\lib\net35\Office.dll</HintPath>
|
<HintPath>..\packages\MicrosoftOfficeCore.15.0.0\lib\net35\Office.dll</HintPath>
|
||||||
<EmbedInteropTypes>False</EmbedInteropTypes>
|
<EmbedInteropTypes>False</EmbedInteropTypes>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.2.8\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Quartz, Version=3.7.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
|
<Reference Include="Quartz, Version=3.7.0.0, Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Quartz.3.7.0\lib\netstandard2.0\Quartz.dll</HintPath>
|
<HintPath>..\packages\Quartz.3.7.0\lib\netstandard2.0\Quartz.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
<Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath>
|
<HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\StackExchange.Redis.2.8.16\lib\net461\StackExchange.Redis.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||||
|
@ -122,6 +133,14 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.DirectoryServices" />
|
<Reference Include="System.DirectoryServices" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.IO.Pipelines, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.IO.Pipelines.5.0.1\lib\net461\System.IO.Pipelines.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" />
|
||||||
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
|
||||||
|
@ -138,6 +157,11 @@
|
||||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Security" />
|
<Reference Include="System.Security" />
|
||||||
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
@ -151,6 +175,12 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.ServiceModel" />
|
<Reference Include="System.ServiceModel" />
|
||||||
<Reference Include="System.ServiceProcess" />
|
<Reference Include="System.ServiceProcess" />
|
||||||
|
<Reference Include="System.Threading.Channels, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Threading.Channels.5.0.0\lib\net461\System.Threading.Channels.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Transactions" />
|
<Reference Include="System.Transactions" />
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Web.DataVisualization" />
|
<Reference Include="System.Web.DataVisualization" />
|
||||||
|
@ -269,6 +299,9 @@
|
||||||
<Compile Include="Common\NPOIHelper.cs" />
|
<Compile Include="Common\NPOIHelper.cs" />
|
||||||
<Compile Include="Common\PrinterDocService.cs" />
|
<Compile Include="Common\PrinterDocService.cs" />
|
||||||
<Compile Include="Common\ProjectDataFlowSetService.cs" />
|
<Compile Include="Common\ProjectDataFlowSetService.cs" />
|
||||||
|
<Compile Include="Common\Redis\ICache.cs" />
|
||||||
|
<Compile Include="Common\Redis\Redis.cs" />
|
||||||
|
<Compile Include="Common\Redis\RedisHelper.cs" />
|
||||||
<Compile Include="Common\UploadFileService.cs" />
|
<Compile Include="Common\UploadFileService.cs" />
|
||||||
<Compile Include="Common\UpLoadImageService.cs" />
|
<Compile Include="Common\UpLoadImageService.cs" />
|
||||||
<Compile Include="Common\UserShowColumnsService.cs" />
|
<Compile Include="Common\UserShowColumnsService.cs" />
|
||||||
|
@ -1142,6 +1175,13 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Import Project="..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets" Condition="Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets'))" />
|
||||||
|
</Target>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
|
|
@ -468,5 +468,135 @@ namespace BLL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static string InsertCodeRecordsByMenuIdProjectIdUnitIdForApi(string menuId, string projectId, string unitId, string dataId, DateTime? compileDate)
|
||||||
|
{
|
||||||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
|
{
|
||||||
|
string ruleCode = string.Empty;
|
||||||
|
var IsHaveCodeRecords = db.Sys_CodeRecords.FirstOrDefault(x => x.DataId == dataId);
|
||||||
|
if (IsHaveCodeRecords == null) ///是否已存在编码
|
||||||
|
{
|
||||||
|
string ruleCodeower = string.Empty;
|
||||||
|
int digit = 4; ///流水位数
|
||||||
|
string symbolower = "-"; ///业主间隔符
|
||||||
|
int digitower = 4; ///业主流水位数
|
||||||
|
string symbol = "-"; ///间隔符
|
||||||
|
var project = db.Base_Project.FirstOrDefault(e => e.ProjectId == projectId); ////项目
|
||||||
|
if (project != null && !string.IsNullOrEmpty(dataId))
|
||||||
|
{
|
||||||
|
string projectCode = project.ProjectCode; ///项目编号
|
||||||
|
////编码规则表
|
||||||
|
var sysCodeTemplateRule = db.ProjectData_CodeTemplateRule.FirstOrDefault(x => x.MenuId == menuId && x.ProjectId == projectId);
|
||||||
|
if (sysCodeTemplateRule != null)
|
||||||
|
{
|
||||||
|
symbol = sysCodeTemplateRule.Symbol;
|
||||||
|
symbolower = sysCodeTemplateRule.OwerSymbol;
|
||||||
|
|
||||||
|
if (sysCodeTemplateRule.Digit.HasValue)
|
||||||
|
{
|
||||||
|
digit = sysCodeTemplateRule.Digit.Value;
|
||||||
|
}
|
||||||
|
if (sysCodeTemplateRule.OwerDigit.HasValue)
|
||||||
|
{
|
||||||
|
digitower = sysCodeTemplateRule.OwerDigit.Value;
|
||||||
|
}
|
||||||
|
if (sysCodeTemplateRule.IsProjectCode == true)
|
||||||
|
{
|
||||||
|
ruleCode = projectCode + symbol;
|
||||||
|
}
|
||||||
|
if (sysCodeTemplateRule.OwerIsProjectCode == true)
|
||||||
|
{
|
||||||
|
ruleCodeower = projectCode + symbolower;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(sysCodeTemplateRule.Prefix))
|
||||||
|
{
|
||||||
|
ruleCode += sysCodeTemplateRule.Prefix + symbol;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(sysCodeTemplateRule.OwerPrefix))
|
||||||
|
{
|
||||||
|
ruleCodeower += sysCodeTemplateRule.OwerPrefix + symbolower;
|
||||||
|
}
|
||||||
|
if (sysCodeTemplateRule.IsUnitCode == true || sysCodeTemplateRule.OwerIsUnitCode == true)
|
||||||
|
{
|
||||||
|
var unit = db.Base_Unit.FirstOrDefault(x => x.UnitId == unitId);
|
||||||
|
if (unit != null)
|
||||||
|
{
|
||||||
|
if (sysCodeTemplateRule.IsUnitCode == true)
|
||||||
|
{ ruleCode = unit.UnitCode + symbol; }
|
||||||
|
|
||||||
|
if (sysCodeTemplateRule.OwerIsUnitCode == true)
|
||||||
|
{
|
||||||
|
ruleCodeower = unit.UnitCode + symbolower;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////获取编码记录表最大排列序号
|
||||||
|
int maxNewSortIndex = 0;
|
||||||
|
if (!String.IsNullOrEmpty(projectId))
|
||||||
|
{
|
||||||
|
var maxSortIndex = db.Sys_CodeRecords.Where(x => x.ProjectId == projectId && x.MenuId == menuId).Select(x => x.SortIndex).Max();
|
||||||
|
if (maxSortIndex.HasValue)
|
||||||
|
{
|
||||||
|
maxNewSortIndex = maxSortIndex.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var maxSortIndexNull = db.Sys_CodeRecords.Where(x => x.MenuId == menuId).Select(x => x.SortIndex).Max();
|
||||||
|
if (maxSortIndexNull.HasValue)
|
||||||
|
{
|
||||||
|
maxNewSortIndex = maxSortIndexNull.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maxNewSortIndex = maxNewSortIndex + 1;
|
||||||
|
////插入数据库
|
||||||
|
Model.Sys_CodeRecords newCodeRecords = new Model.Sys_CodeRecords
|
||||||
|
{
|
||||||
|
CodeRecordId = SQLHelper.GetNewID(typeof(Model.Sys_CodeRecords))
|
||||||
|
};
|
||||||
|
if (project != null)
|
||||||
|
{
|
||||||
|
newCodeRecords.ProjectId = project.ProjectId;
|
||||||
|
}
|
||||||
|
newCodeRecords.MenuId = menuId;
|
||||||
|
newCodeRecords.DataId = dataId;
|
||||||
|
newCodeRecords.UnitId = unitId;
|
||||||
|
newCodeRecords.SortIndex = maxNewSortIndex;
|
||||||
|
newCodeRecords.CompileDate = compileDate;
|
||||||
|
newCodeRecords.RuleCodes = ruleCode;
|
||||||
|
newCodeRecords.Digit = digit;
|
||||||
|
newCodeRecords.OwnerRuleCodes = ruleCodeower;
|
||||||
|
newCodeRecords.OwerDigit = digitower;
|
||||||
|
if (!string.IsNullOrEmpty(ruleCode))
|
||||||
|
{
|
||||||
|
newCodeRecords.Code = ruleCode + (maxNewSortIndex.ToString().PadLeft(digit, '0')); ///字符自动补零 编码
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newCodeRecords.Code = (maxNewSortIndex.ToString().PadLeft(digit, '0'));
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(ruleCodeower))
|
||||||
|
{
|
||||||
|
newCodeRecords.OwnerCode = ruleCodeower + (maxNewSortIndex.ToString().PadLeft(digitower, '0')); ///字符自动补零 业主编码
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newCodeRecords.OwnerCode = (maxNewSortIndex.ToString().PadLeft(digitower, '0'));
|
||||||
|
}
|
||||||
|
db.Sys_CodeRecords.InsertOnSubmit(newCodeRecords);
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ruleCode = IsHaveCodeRecords.Code;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ruleCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
using System;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
|
||||||
|
namespace BLL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 接口
|
||||||
|
/// </summary>
|
||||||
|
public interface ICache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存过期时间
|
||||||
|
/// </summary>
|
||||||
|
int TimeOut { set; get; }
|
||||||
|
/// <summary>
|
||||||
|
/// 获得指定键的缓存值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存键</param>
|
||||||
|
/// <returns>缓存值</returns>
|
||||||
|
object Get(string key);
|
||||||
|
/// <summary>
|
||||||
|
/// 获得指定键的缓存值
|
||||||
|
/// </summary>
|
||||||
|
T Get<T>(string key);
|
||||||
|
/// <summary>
|
||||||
|
/// 从缓存中移除指定键的缓存值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存键</param>
|
||||||
|
void Remove(string key);
|
||||||
|
/// <summary>
|
||||||
|
/// 清空所有缓存对象
|
||||||
|
/// </summary>
|
||||||
|
//void Clear();
|
||||||
|
/// <summary>
|
||||||
|
/// 将指定键的对象添加到缓存中
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存键</param>
|
||||||
|
/// <param name="data">缓存值</param>
|
||||||
|
void Insert(string key, object data);
|
||||||
|
/// <summary>
|
||||||
|
/// 将指定键的对象添加到缓存中
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存键</param>
|
||||||
|
/// <param name="data">缓存值</param>
|
||||||
|
void Insert<T>(string key, T data);
|
||||||
|
/// <summary>
|
||||||
|
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存键</param>
|
||||||
|
/// <param name="data">缓存值</param>
|
||||||
|
/// <param name="cacheTime">缓存过期时间(秒钟)</param>
|
||||||
|
void Insert(string key, object data, int cacheTime);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存键</param>
|
||||||
|
/// <param name="data">缓存值</param>
|
||||||
|
/// <param name="cacheTime">缓存过期时间(秒钟)</param>
|
||||||
|
void Insert<T>(string key, T data, int cacheTime);
|
||||||
|
/// <summary>
|
||||||
|
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存键</param>
|
||||||
|
/// <param name="data">缓存值</param>
|
||||||
|
/// <param name="cacheTime">缓存过期时间</param>
|
||||||
|
void Insert(string key, object data, DateTime cacheTime);
|
||||||
|
/// <summary>
|
||||||
|
/// 将指定键的对象添加到缓存中,并指定过期时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">缓存键</param>
|
||||||
|
/// <param name="data">缓存值</param>
|
||||||
|
/// <param name="cacheTime">缓存过期时间</param>
|
||||||
|
void Insert<T>(string key, T data, DateTime cacheTime);
|
||||||
|
/// <summary>
|
||||||
|
/// 判断key是否存在
|
||||||
|
/// </summary>
|
||||||
|
bool Exists(string key);
|
||||||
|
/// <summary>
|
||||||
|
/// 右侧入队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName"></param>
|
||||||
|
/// <param name="redisValue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
long EnqueueListRightPush(RedisKey queueName, RedisValue redisValue);
|
||||||
|
/// <summary>
|
||||||
|
/// 左侧入队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName"></param>
|
||||||
|
/// <param name="redisvalue"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
long EnqueueListLeftPush(RedisKey queueName, RedisValue redisvalue);
|
||||||
|
/// <summary>
|
||||||
|
/// 获取队列长度
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
long EnqueueListLength(RedisKey queueName);
|
||||||
|
/// <summary>
|
||||||
|
/// 左侧出队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string DequeueListPopLeft(RedisKey queueName);
|
||||||
|
/// <summary>
|
||||||
|
/// 右侧出队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string DequeueListPopRight(RedisKey queueName);
|
||||||
|
/// <summary>
|
||||||
|
/// 分布式加锁
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">键</param>
|
||||||
|
/// <param name="data">值</param>
|
||||||
|
/// <param name="seconds">过期时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool LockTake(string key, string data, TimeSpan seconds, int db = 0);
|
||||||
|
/// <summary>
|
||||||
|
/// 解锁
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">键</param>
|
||||||
|
/// <param name="data">值</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool LockRelease(string key, string data, int db = -1);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,308 @@
|
||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
|
||||||
|
namespace BLL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class Redis : ICache
|
||||||
|
{
|
||||||
|
int Default_Timeout = 600;//默认超时时间(单位秒)
|
||||||
|
string address;
|
||||||
|
JsonSerializerSettings jsonConfig = new JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, NullValueHandling = NullValueHandling.Ignore };
|
||||||
|
ConnectionMultiplexer connectionMultiplexer;
|
||||||
|
IDatabase database;
|
||||||
|
|
||||||
|
class CacheObject<T>
|
||||||
|
{
|
||||||
|
public int ExpireTime { get; set; }
|
||||||
|
public bool ForceOutofDate { get; set; }
|
||||||
|
public T Value { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dbbase"></param>
|
||||||
|
public Redis(int dbbase = 0)
|
||||||
|
{
|
||||||
|
this.address = this.address = ConfigurationManager.AppSettings["RedisHosts"];
|
||||||
|
|
||||||
|
if (this.address == null || string.IsNullOrWhiteSpace(this.address.ToString()))
|
||||||
|
throw new ApplicationException("配置文件中未找到RedisServer的有效配置");
|
||||||
|
connectionMultiplexer = ConnectionMultiplexer.Connect(address);
|
||||||
|
database = connectionMultiplexer.GetDatabase(dbbase);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 连接超时设置
|
||||||
|
/// </summary>
|
||||||
|
public int TimeOut
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Default_Timeout;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
Default_Timeout = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public object Get(string key)
|
||||||
|
{
|
||||||
|
return Get<object>(key);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public T Get<T>(string key)
|
||||||
|
{
|
||||||
|
|
||||||
|
DateTime begin = DateTime.Now;
|
||||||
|
var cacheValue = database.StringGet(key);
|
||||||
|
DateTime endCache = DateTime.Now;
|
||||||
|
var value = default(T);
|
||||||
|
if (!cacheValue.IsNull)
|
||||||
|
{
|
||||||
|
var cacheObject = JsonConvert.DeserializeObject<CacheObject<T>>(cacheValue, jsonConfig);
|
||||||
|
if (!cacheObject.ForceOutofDate)
|
||||||
|
database.KeyExpire(key, new TimeSpan(0, 0, cacheObject.ExpireTime));
|
||||||
|
value = cacheObject.Value;
|
||||||
|
}
|
||||||
|
DateTime endJson = DateTime.Now;
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
public void Insert(string key, object data)
|
||||||
|
{
|
||||||
|
var jsonData = GetJsonData(data, TimeOut, false);
|
||||||
|
database.StringSet(key, jsonData);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="cacheTime"></param>
|
||||||
|
public void Insert(string key, object data, int cacheTime)
|
||||||
|
{
|
||||||
|
var timeSpan = TimeSpan.FromSeconds(cacheTime);
|
||||||
|
var jsonData = GetJsonData(data, TimeOut, true);
|
||||||
|
database.StringSet(key, jsonData, timeSpan);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="cacheTime"></param>
|
||||||
|
public void Insert(string key, object data, DateTime cacheTime)
|
||||||
|
{
|
||||||
|
var timeSpan = cacheTime - DateTime.Now;
|
||||||
|
var jsonData = GetJsonData(data, TimeOut, true);
|
||||||
|
database.StringSet(key, jsonData, timeSpan);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
public void Insert<T>(string key, T data)
|
||||||
|
{
|
||||||
|
var jsonData = GetJsonData<T>(data, TimeOut, false);
|
||||||
|
database.StringSet(key, jsonData);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="cacheTime"></param>
|
||||||
|
public void Insert<T>(string key, T data, int cacheTime)
|
||||||
|
{
|
||||||
|
var timeSpan = TimeSpan.FromSeconds(cacheTime);
|
||||||
|
var jsonData = GetJsonData<T>(data, TimeOut, true);
|
||||||
|
database.StringSet(key, jsonData, timeSpan);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="cacheTime"></param>
|
||||||
|
public void Insert<T>(string key, T data, DateTime cacheTime)
|
||||||
|
{
|
||||||
|
var timeSpan = cacheTime - DateTime.Now;
|
||||||
|
var jsonData = GetJsonData<T>(data, TimeOut, true);
|
||||||
|
database.StringSet(key, jsonData, timeSpan);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="cacheTime"></param>
|
||||||
|
/// <param name="forceOutOfDate"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string GetJsonData(object data, int cacheTime, bool forceOutOfDate)
|
||||||
|
{
|
||||||
|
var cacheObject = new CacheObject<object>() { Value = data, ExpireTime = cacheTime, ForceOutofDate = forceOutOfDate };
|
||||||
|
return JsonConvert.SerializeObject(cacheObject, jsonConfig);//序列化对象
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="cacheTime"></param>
|
||||||
|
/// <param name="forceOutOfDate"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string GetJsonData<T>(T data, int cacheTime, bool forceOutOfDate)
|
||||||
|
{
|
||||||
|
var cacheObject = new CacheObject<T>() { Value = data, ExpireTime = cacheTime, ForceOutofDate = forceOutOfDate };
|
||||||
|
return JsonConvert.SerializeObject(cacheObject, jsonConfig);//序列化对象
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
public void Remove(string key)
|
||||||
|
{
|
||||||
|
database.KeyDelete(key, CommandFlags.HighPriority);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断key是否存在
|
||||||
|
/// </summary>
|
||||||
|
public bool Exists(string key)
|
||||||
|
{
|
||||||
|
return database.KeyExists(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 右侧入队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName">队列名称</param>
|
||||||
|
/// <param name="redisValue">值</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public long EnqueueListRightPush(RedisKey queueName, RedisValue redisValue)
|
||||||
|
{
|
||||||
|
return database.ListRightPush(queueName, redisValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 左侧入队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName">队列名称</param>
|
||||||
|
/// <param name="redisvalue">队列值</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public long EnqueueListLeftPush(RedisKey queueName, RedisValue redisvalue)
|
||||||
|
{
|
||||||
|
return database.ListLeftPush(queueName, redisvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取队列长度
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName">队列名称</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public long EnqueueListLength(RedisKey queueName)
|
||||||
|
{
|
||||||
|
if (database.KeyExists(queueName))
|
||||||
|
{
|
||||||
|
return database.ListLength(queueName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 左侧出队
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queueName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string DequeueListPopLeft(RedisKey queueName)
|
||||||
|
{
|
||||||
|
int count = database.ListRange(queueName).Length;
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
string redisValue = database.ListLeftPop(queueName);
|
||||||
|
if (!string.IsNullOrEmpty(redisValue))
|
||||||
|
return redisValue;
|
||||||
|
else
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "-1";
|
||||||
|
throw new Exception($"队列{queueName}数据为零");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 右侧出队
|
||||||
|
/// </summary>
|
||||||
|
public string DequeueListPopRight(RedisKey queueName)
|
||||||
|
{
|
||||||
|
int count = database.ListRange(queueName).Length;
|
||||||
|
if (count > 0)
|
||||||
|
{
|
||||||
|
string redisValue = database.ListRightPop(queueName);
|
||||||
|
if (!string.IsNullOrEmpty(redisValue))
|
||||||
|
return redisValue;
|
||||||
|
else
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "-1";
|
||||||
|
throw new Exception($"队列{queueName}数据为零");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分布式加锁
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">键</param>
|
||||||
|
/// <param name="data">值</param>
|
||||||
|
/// <param name="seconds">过期时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool LockTake(string key, string data, TimeSpan seconds, int db = 0)
|
||||||
|
{
|
||||||
|
return database.LockTake(key, data, seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解锁
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">键</param>
|
||||||
|
/// <param name="data">值</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool LockRelease(string key, string data, int db = -1)
|
||||||
|
{
|
||||||
|
return database.LockRelease(key, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -152,5 +152,37 @@ namespace BLL
|
||||||
}
|
}
|
||||||
return icount;
|
return icount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddTestRecordForApi(Model.Training_TestRecord testRecord)
|
||||||
|
{
|
||||||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
|
{
|
||||||
|
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||||
|
{
|
||||||
|
TestRecordId = testRecord.TestRecordId,
|
||||||
|
ProjectId = testRecord.ProjectId,
|
||||||
|
TestPlanId = testRecord.TestPlanId,
|
||||||
|
TestManId = testRecord.TestManId,
|
||||||
|
TestType = testRecord.TestType,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(newTestRecord.TestType))
|
||||||
|
{
|
||||||
|
var getTrainTypeName = (from x in db.Training_TestPlan
|
||||||
|
join y in db.Training_Plan on x.PlanId equals y.PlanId
|
||||||
|
join z in db.Base_TrainType on y.TrainTypeId equals z.TrainTypeId
|
||||||
|
where x.TestPlanId == testRecord.TestPlanId
|
||||||
|
select z).FirstOrDefault();
|
||||||
|
|
||||||
|
if (getTrainTypeName != null)
|
||||||
|
{
|
||||||
|
testRecord.TestType = getTrainTypeName.TrainTypeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -750,5 +750,23 @@ namespace BLL
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public static Model.SitePerson_Person GetPersonByUserIdForApi(string userId, string projectId)
|
||||||
|
{
|
||||||
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
||||||
|
{
|
||||||
|
var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == userId);
|
||||||
|
if (getPerson == null)
|
||||||
|
{
|
||||||
|
var getUser = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
|
||||||
|
if (getUser != null)
|
||||||
|
{
|
||||||
|
getPerson = db.SitePerson_Person.FirstOrDefault(e => e.IdentityCard == getUser.IdentityCard && e.ProjectId == projectId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getPerson;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,34 @@ namespace BLL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
var getSysuser = db.Sys_User.FirstOrDefault(e => e.UserId == item.UserId);
|
||||||
|
if (getSysuser!=null)
|
||||||
|
{
|
||||||
|
////获取计划下 人员培训教材明细
|
||||||
|
var getDataList = db.Sp_GetTraining_TaskItemTraining(item.PlanId, getSysuser.WorkPostId);
|
||||||
|
foreach (var dataItem in getDataList)
|
||||||
|
{
|
||||||
|
Model.Training_TaskItem newTaskItem = new Model.Training_TaskItem
|
||||||
|
{
|
||||||
|
TaskId = item.TaskId,
|
||||||
|
PlanId = item.PlanId,
|
||||||
|
PersonId = item.UserId,
|
||||||
|
TrainingItemCode = dataItem.TrainingItemCode,
|
||||||
|
TrainingItemName = dataItem.TrainingItemName,
|
||||||
|
AttachUrl = dataItem.AttachUrl,
|
||||||
|
};
|
||||||
|
|
||||||
|
var getTaskItem = db.Training_TaskItem.FirstOrDefault(x => x.TaskId == item.TaskId && x.TrainingItemName == newTaskItem.TrainingItemName && x.AttachUrl == newTaskItem.AttachUrl);
|
||||||
|
if (getTaskItem == null)
|
||||||
|
{
|
||||||
|
newTaskItem.TaskItemId = SQLHelper.GetNewID();
|
||||||
|
db.Training_TaskItem.InsertOnSubmit(newTaskItem);
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////更新培训任务
|
////更新培训任务
|
||||||
item.States = Const.State_1;
|
item.States = Const.State_1;
|
||||||
|
|
|
@ -1224,3 +1224,9 @@ IP地址:::1
|
||||||
通用定时器结束!
|
通用定时器结束!
|
||||||
环境数据同步开始!
|
环境数据同步开始!
|
||||||
环境数据同步结束!
|
环境数据同步结束!
|
||||||
|
环境数据同步开始!
|
||||||
|
环境数据同步结束!
|
||||||
|
通用定时器开启!
|
||||||
|
启用环境定时器开始!
|
||||||
|
启用环境定时器结束!
|
||||||
|
通用定时器结束!
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<Items>
|
<Items>
|
||||||
<f:Grid ID="Grid1" Width="850px" ShowBorder="true" ShowHeader="false" EnableCollapse="true" ForceFit="true"
|
<f:Grid ID="Grid1" Width="850px" ShowBorder="true" ShowHeader="false" EnableCollapse="true" ForceFit="true"
|
||||||
runat="server" BoxFlex="1" DataKeyNames="CompanyTrainingItemIdNum" DataIDField="CompanyTrainingItemIdNum"
|
runat="server" BoxFlex="1" DataKeyNames="CompanyTrainingItemIdNum" DataIDField="CompanyTrainingItemIdNum"
|
||||||
AllowSorting="true" SortField="CompanyTrainingItemCode" OnRowCommand="Grid1_RowCommand"
|
AllowSorting="true" SortField="CompileDate" OnRowCommand="Grid1_RowCommand"
|
||||||
SortDirection="DESC" OnSort="Grid1_Sort" AllowPaging="true" IsDatabasePaging="true"
|
SortDirection="DESC" OnSort="Grid1_Sort" AllowPaging="true" IsDatabasePaging="true"
|
||||||
PageSize="10" OnPageIndexChange="Grid1_PageIndexChange" EnableRowDoubleClickEvent="true"
|
PageSize="10" OnPageIndexChange="Grid1_PageIndexChange" EnableRowDoubleClickEvent="true"
|
||||||
OnRowDoubleClick="Grid1_RowDoubleClick" EnableTextSelection="True" EnableColumnLines="true">
|
OnRowDoubleClick="Grid1_RowDoubleClick" EnableTextSelection="True" EnableColumnLines="true">
|
||||||
|
|
|
@ -41,12 +41,14 @@
|
||||||
</f:FormRow>
|
</f:FormRow>
|
||||||
<f:FormRow>
|
<f:FormRow>
|
||||||
<Items>
|
<Items>
|
||||||
<f:NumberBox ID="txtLearningTime" Label="时长(分钟)" runat="server" DecimalPrecision="0" NoDecimal="true" NoNegative="true" ></f:NumberBox>
|
<f:NumberBox ID="txtLearningTime" Label="时长(分钟)" Required="true"
|
||||||
|
ShowRedStar="true" runat="server" DecimalPrecision="0" NoDecimal="true" NoNegative="true" ></f:NumberBox>
|
||||||
</Items>
|
</Items>
|
||||||
</f:FormRow>
|
</f:FormRow>
|
||||||
<f:FormRow>
|
<f:FormRow>
|
||||||
<Items>
|
<Items>
|
||||||
<f:DropDownBox runat="server" ID="ddTestTraining" Label="考试题库" EnableMultiSelect="true" CustomData="true">
|
<f:DropDownBox runat="server" ID="ddTestTraining" Required="true"
|
||||||
|
ShowRedStar="true" Label="考试题库" EnableMultiSelect="true" CustomData="true">
|
||||||
<PopPanel>
|
<PopPanel>
|
||||||
<f:Tree ID="treeTestTraining" ShowHeader="false" Hidden="true" runat="server" EnableCheckBox="true" CascadeCheck="true">
|
<f:Tree ID="treeTestTraining" ShowHeader="false" Hidden="true" runat="server" EnableCheckBox="true" CascadeCheck="true">
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
<f:MenuButton ID="btnMenuView" OnClick="btnMenuView_Click" EnablePostBack="true"
|
<f:MenuButton ID="btnMenuView" OnClick="btnMenuView_Click" EnablePostBack="true"
|
||||||
runat="server" Text="查看" Icon="Find">
|
runat="server" Text="查看" Icon="Find">
|
||||||
</f:MenuButton>
|
</f:MenuButton>
|
||||||
<f:MenuButton ID="btnPrinter" EnablePostBack="true" runat="server"
|
<f:MenuButton ID="btnPrinter" EnablePostBack="true" runat="server" Hidden="true"
|
||||||
Text="导出" Icon="Printer" OnClick="btnPrint_Click" EnableAjax="false" DisableControlBeforePostBack="false">
|
Text="导出" Icon="Printer" OnClick="btnPrint_Click" EnableAjax="false" DisableControlBeforePostBack="false">
|
||||||
</f:MenuButton>
|
</f:MenuButton>
|
||||||
<%--<f:MenuButton ID="btnFile" OnClick="btnMenuFile_Click" EnablePostBack="true"
|
<%--<f:MenuButton ID="btnFile" OnClick="btnMenuFile_Click" EnablePostBack="true"
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace FineUIPro.Web.Person.EduTrain
|
||||||
LEFT JOIN dbo.Training_TestTraining AS Training ON Training.TrainingId = TestRecord.TestType
|
LEFT JOIN dbo.Training_TestTraining AS Training ON Training.TrainingId = TestRecord.TestType
|
||||||
LEFT JOIN dbo.Sys_User AS Person ON Person.UserId = TestRecord.TestManId
|
LEFT JOIN dbo.Sys_User AS Person ON Person.UserId = TestRecord.TestManId
|
||||||
LEFT JOIN dbo.Base_Unit AS Unit ON Person.UnitId=Unit.UnitId
|
LEFT JOIN dbo.Base_Unit AS Unit ON Person.UnitId=Unit.UnitId
|
||||||
WHERE (isFiled IS NULL OR isFiled = 0) and TestRecord.ProjectId is null ";
|
WHERE (isFiled IS NULL OR isFiled = 0) and (TestRecord.ProjectId is null or TestRecord.ProjectId='' ) ";
|
||||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||||
if (!string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
if (!string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -245,5 +245,18 @@ namespace Model
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 培训类型ID
|
||||||
|
/// </summary>
|
||||||
|
public string TrainTypeId
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
public string TrainTypeName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,19 @@ namespace Model
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 签名
|
||||||
|
/// </summary>
|
||||||
|
public string Signature
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
public string Fingerprint
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,21 @@ namespace Model
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 学习时长(秒)
|
||||||
|
/// </summary>
|
||||||
|
public int? LearningTime
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 教材时长(秒)
|
||||||
|
/// </summary>
|
||||||
|
public int? AttachTime
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -398792,6 +398792,8 @@ namespace Model
|
||||||
|
|
||||||
private string _Fingerprint;
|
private string _Fingerprint;
|
||||||
|
|
||||||
|
private string _CompanyTrainingItemId;
|
||||||
|
|
||||||
private EntityRef<Base_Project> _Base_Project;
|
private EntityRef<Base_Project> _Base_Project;
|
||||||
|
|
||||||
private EntityRef<SitePerson_Person> _SitePerson_Person;
|
private EntityRef<SitePerson_Person> _SitePerson_Person;
|
||||||
|
@ -398830,6 +398832,8 @@ namespace Model
|
||||||
partial void OnSignatureChanged();
|
partial void OnSignatureChanged();
|
||||||
partial void OnFingerprintChanging(string value);
|
partial void OnFingerprintChanging(string value);
|
||||||
partial void OnFingerprintChanged();
|
partial void OnFingerprintChanged();
|
||||||
|
partial void OnCompanyTrainingItemIdChanging(string value);
|
||||||
|
partial void OnCompanyTrainingItemIdChanged();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public Training_TestRecord()
|
public Training_TestRecord()
|
||||||
|
@ -399113,6 +399117,26 @@ namespace Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CompanyTrainingItemId", DbType="NVarChar(50)")]
|
||||||
|
public string CompanyTrainingItemId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._CompanyTrainingItemId;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._CompanyTrainingItemId != value))
|
||||||
|
{
|
||||||
|
this.OnCompanyTrainingItemIdChanging(value);
|
||||||
|
this.SendPropertyChanging();
|
||||||
|
this._CompanyTrainingItemId = value;
|
||||||
|
this.SendPropertyChanged("CompanyTrainingItemId");
|
||||||
|
this.OnCompanyTrainingItemIdChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Training_TestRecord_Base_Project", Storage="_Base_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true)]
|
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_Training_TestRecord_Base_Project", Storage="_Base_Project", ThisKey="ProjectId", OtherKey="ProjectId", IsForeignKey=true)]
|
||||||
public Base_Project Base_Project
|
public Base_Project Base_Project
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,15 +74,31 @@ namespace WebAPI.Controllers
|
||||||
/// <param name="trainingPlanId">培训计划ID</param>
|
/// <param name="trainingPlanId">培训计划ID</param>
|
||||||
/// <param name="userId">用户ID</param>
|
/// <param name="userId">用户ID</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Model.ResponeData getSaveTestPlanByTrainingPlanId(string trainingPlanId,string userId)
|
public Model.ResponeData getSaveTestPlanByTrainingPlanId(string trainingPlanId, string userId)
|
||||||
{
|
{
|
||||||
var responeData = new Model.ResponeData();
|
var responeData = new Model.ResponeData();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var getTasks = new Model.SGGLDB(Funs.ConnString).Training_Task.FirstOrDefault(x => x.PlanId == trainingPlanId);
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
|
{
|
||||||
|
var getTasks = db.Training_Task.FirstOrDefault(x => x.PlanId == trainingPlanId);
|
||||||
if (getTasks != null)
|
if (getTasks != null)
|
||||||
{
|
{
|
||||||
if (CommonService.IsMainUnitOrAdmin(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);
|
responeData.data = APITestPlanService.SaveTestPlanByTrainingPlanId(trainingPlanId, userId);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +114,7 @@ namespace WebAPI.Controllers
|
||||||
responeData.message = "培训计划下没有培训人员,不能生成考试计划!";
|
responeData.message = "培训计划下没有培训人员,不能生成考试计划!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
responeData.code = 0;
|
responeData.code = 0;
|
||||||
|
@ -192,29 +209,51 @@ namespace WebAPI.Controllers
|
||||||
var responeData = new Model.ResponeData();
|
var responeData = new Model.ResponeData();
|
||||||
try
|
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);
|
using (var db = new Model.SGGLDB(Funs.ConnString))
|
||||||
|
{
|
||||||
|
var getTestPlan = db.Training_TestPlan.FirstOrDefault(e => e.TestPlanId == testPlanId && e.States != "3" && e.TestStartTime <= DateTime.Now && e.TestEndTime >= DateTime.Now);
|
||||||
if (getTestPlan != null)
|
if (getTestPlan != null)
|
||||||
{
|
{
|
||||||
var person = PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
var user = db.Sys_User.FirstOrDefault(x => x.UserId == personId);
|
||||||
if (person != null )
|
Model.SitePerson_Person person;
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
person = db.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
person = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (person != null || user != null)
|
||||||
{
|
{
|
||||||
//2-考试中;生成考试试卷
|
//2-考试中;生成考试试卷
|
||||||
if (getTestPlan.States == "2" )
|
if (getTestPlan.States == "2")
|
||||||
{
|
{
|
||||||
var testRecord = new Model.SGGLDB(Funs.ConnString).Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
|
var testRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == personId && !x.TestEndTime.HasValue);
|
||||||
if (testRecord != null)
|
if (testRecord != null)
|
||||||
{
|
{
|
||||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person);
|
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)
|
||||||
|
{
|
||||||
|
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord2.TestRecordId, person, user);
|
||||||
responeData.code = 2;
|
responeData.code = 2;
|
||||||
responeData.data = new { testRecordId };
|
responeData.data = new { testRecordId };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
|
if (person != null && string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
|
||||||
{
|
{
|
||||||
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
||||||
var testTRecord = new Model.SGGLDB(Funs.ConnString).Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == personId);
|
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))
|
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
|
||||||
{
|
{
|
||||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||||
|
@ -224,11 +263,33 @@ namespace WebAPI.Controllers
|
||||||
TestPlanId = getTestPlan.TestPlanId,
|
TestPlanId = getTestPlan.TestPlanId,
|
||||||
TestManId = personId,
|
TestManId = personId,
|
||||||
};
|
};
|
||||||
TestRecordService.AddTestRecord(newTestRecord);
|
TestRecordService.AddTestRecordForApi(newTestRecord);
|
||||||
responeData.code = 3;
|
responeData.code = 3;
|
||||||
responeData.message = "您已加入考试计划!";
|
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 = "您已加入考试计划!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,6 +353,83 @@ namespace WebAPI.Controllers
|
||||||
}
|
}
|
||||||
#endregion
|
#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;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
using BLL;
|
using BLL;
|
||||||
|
using Model;
|
||||||
|
|
||||||
namespace WebAPI.Controllers
|
namespace WebAPI.Controllers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -267,25 +272,129 @@ namespace WebAPI.Controllers
|
||||||
var responeData = new Model.ResponeData();
|
var responeData = new Model.ResponeData();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId);
|
if (!string.IsNullOrEmpty(testRecordItemId) && !string.IsNullOrEmpty(selectedItem))
|
||||||
if (getItem != null)
|
|
||||||
{
|
{
|
||||||
//更新没有结束时间且超时的考试记录
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
int closeCount = TestRecordService.UpdateTestEndTimeNull(getItem.TestRecordId);
|
|
||||||
if (closeCount > 0)
|
|
||||||
{
|
{
|
||||||
responeData.code = 2;
|
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == testRecordItemId);
|
||||||
responeData.message = "本次考试已结束,系统自动交卷!";
|
if (getTItem != null)
|
||||||
|
{
|
||||||
|
getTItem.SubjectScore = 0;
|
||||||
|
getTItem.SelectedItem = selectedItem;
|
||||||
|
if (!string.IsNullOrEmpty(selectedItem))
|
||||||
|
{
|
||||||
|
if (getTItem.AnswerItems == selectedItem)
|
||||||
|
{
|
||||||
|
getTItem.SubjectScore = getTItem.Score ?? 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
APITestRecordService.getTestRecordItemAnswerBySelectedItem(getItem, selectedItem);
|
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
|
else
|
||||||
{
|
{
|
||||||
responeData.code = 0;
|
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)
|
catch (Exception ex)
|
||||||
|
@ -349,5 +458,132 @@ namespace WebAPI.Controllers
|
||||||
return responeData;
|
return responeData;
|
||||||
}
|
}
|
||||||
#endregion
|
#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="trainTypeId">培训类型ID(可为空)</param>
|
||||||
/// <param name="pageIndex">分页</param>
|
/// <param name="pageIndex">分页</param>
|
||||||
/// <returns></returns>
|
/// <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();
|
var responeData = new Model.ResponeData();
|
||||||
try
|
try
|
||||||
|
@ -378,6 +378,7 @@ namespace WebAPI.Controllers
|
||||||
}
|
}
|
||||||
responeData.data = new { pageCount, getDataList };
|
responeData.data = new { pageCount, getDataList };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||||
-->
|
-->
|
||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DeleteExistingFiles>False</DeleteExistingFiles>
|
<DeleteExistingFiles>True</DeleteExistingFiles>
|
||||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
|
|
Loading…
Reference in New Issue