20220424 清日志、清考勤定时器,考试生成试卷接口方法修改
This commit is contained in:
@@ -99,14 +99,32 @@ namespace BLL
|
||||
if (item == null)
|
||||
{
|
||||
List<Model.Training_TestTrainingItem> getTestTrainingItemList = new List<Model.Training_TestTrainingItem>();
|
||||
//// 计划考试中单选、多选、判断题总数
|
||||
int sumTestType1Count =0;
|
||||
int sumTestType2Count = 0;
|
||||
int sumTestType3Count = 0;
|
||||
|
||||
var testPlanTrainings = from x in db.Training_TestPlanTraining
|
||||
where x.TestPlanId == getTestPlan.TestPlanId
|
||||
select x;
|
||||
//// 计划考试中单选、多选、判断题总数
|
||||
int sumTestType1Count = testPlanTrainings.Sum(x => x.TestType1Count) ?? 0;
|
||||
int sumTestType2Count = testPlanTrainings.Sum(x => x.TestType2Count) ?? 0;
|
||||
int sumTestType3Count = testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
|
||||
|
||||
if (testPlanTrainings.Count() > 0)
|
||||
{
|
||||
//// 计划考试中单选、多选、判断题总数
|
||||
sumTestType1Count = testPlanTrainings.Sum(x => x.TestType1Count) ?? 0;
|
||||
sumTestType2Count = testPlanTrainings.Sum(x => x.TestType2Count) ?? 0;
|
||||
sumTestType3Count = testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var getTestRule = db.Sys_TestRule.FirstOrDefault();
|
||||
if (getTestRule != null)
|
||||
{
|
||||
sumTestType1Count = getTestRule.SCount;
|
||||
sumTestType2Count = getTestRule.MCount;
|
||||
sumTestType3Count = getTestRule.JCount;
|
||||
}
|
||||
}
|
||||
|
||||
////获取类型下适合岗位试题集合
|
||||
var getTestTrainingItemALLs = from x in db.Training_TestTrainingItem
|
||||
where x.TrainingId != null && (x.WorkPostIds == null || (x.WorkPostIds.Contains(person.WorkPostId) && person.WorkPostId != null))
|
||||
@@ -331,38 +349,64 @@ namespace BLL
|
||||
|
||||
#region 根据TestRecordId获取试卷题目列表
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int geTestRecordItemCount
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据TestRecordId获取试卷题目列表
|
||||
/// </summary>
|
||||
/// <param name="testPlanId"></param>
|
||||
/// <returns>考试人员</returns>
|
||||
public static List<Model.TestRecordItemItem> geTestRecordItemListByTestRecordId(string testRecordId)
|
||||
public static List<Model.TestRecordItemItem> geTestRecordItemListByTestRecordId(string testRecordId, int pageIndex)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getDataLists = (from x in db.Training_TestRecordItem
|
||||
where x.TestRecordId == testRecordId
|
||||
orderby x.TestType, x.TrainingItemCode
|
||||
select new Model.TestRecordItemItem
|
||||
{
|
||||
TestRecordItemId = x.TestRecordItemId,
|
||||
TestRecordId = x.TestRecordId,
|
||||
TrainingItemCode = x.TrainingItemCode,
|
||||
TrainingItemName = x.TrainingItemName,
|
||||
Abstracts = x.Abstracts,
|
||||
AttachUrl = x.AttachUrl.Replace("\\", "/") ?? "",
|
||||
TestType = x.TestType,
|
||||
TestTypeName = x.TestType == "1" ? "单选题" : (x.TestType == "2" ? "多选题" : "判断题"),
|
||||
AItem = x.AItem ?? "",
|
||||
BItem = x.BItem ?? "",
|
||||
CItem = x.CItem ?? "",
|
||||
DItem = x.DItem ?? "",
|
||||
EItem = x.EItem ?? "",
|
||||
AnswerItems = x.AnswerItems ?? "",
|
||||
Score = x.Score ?? 0,
|
||||
SubjectScore = x.SubjectScore ?? 0,
|
||||
SelectedItem = x.SelectedItem ?? "",
|
||||
}).ToList();
|
||||
return getDataLists;
|
||||
var getDatas= from x in db.Training_TestRecordItem
|
||||
where x.TestRecordId == testRecordId
|
||||
select x;
|
||||
geTestRecordItemCount = getDatas.Count();
|
||||
if (geTestRecordItemCount == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var getDataLists = from x in getDatas
|
||||
orderby x.TestType, x.TrainingItemCode
|
||||
select new Model.TestRecordItemItem
|
||||
{
|
||||
TestRecordItemId = x.TestRecordItemId,
|
||||
TestRecordId = x.TestRecordId,
|
||||
TrainingItemCode = x.TrainingItemCode,
|
||||
TrainingItemName = x.TrainingItemName,
|
||||
Abstracts = x.Abstracts,
|
||||
AttachUrl = x.AttachUrl.Replace("\\", "/") ?? "",
|
||||
TestType = x.TestType,
|
||||
TestTypeName = x.TestType == "1" ? "单选题" : (x.TestType == "2" ? "多选题" : "判断题"),
|
||||
AItem = x.AItem ?? "",
|
||||
BItem = x.BItem ?? "",
|
||||
CItem = x.CItem ?? "",
|
||||
DItem = x.DItem ?? "",
|
||||
EItem = x.EItem ?? "",
|
||||
AnswerItems = x.AnswerItems ?? "",
|
||||
Score = x.Score ?? 0,
|
||||
SubjectScore = x.SubjectScore ?? 0,
|
||||
SelectedItem = x.SelectedItem ?? "",
|
||||
};
|
||||
|
||||
if (pageIndex > 0)
|
||||
{
|
||||
return getDataLists.Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return getDataLists.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -176,5 +176,196 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 启动监视器 定时清理推送日志
|
||||
/// <summary>
|
||||
/// 监视组件
|
||||
/// </summary>
|
||||
private static Timer messageTimer1;
|
||||
|
||||
/// <summary>
|
||||
/// 定时清理推送日志
|
||||
/// </summary>
|
||||
public static void StartMonitorDeletePushLog()
|
||||
{
|
||||
int adTimeJ = 60 * 12;
|
||||
if (messageTimer1 != null)
|
||||
{
|
||||
messageTimer1.Stop();
|
||||
messageTimer1.Dispose();
|
||||
messageTimer1 = null;
|
||||
}
|
||||
if (adTimeJ > 0)
|
||||
{
|
||||
messageTimer1 = new Timer
|
||||
{
|
||||
AutoReset = true
|
||||
};
|
||||
messageTimer1.Elapsed += new ElapsedEventHandler(DeletePushLog);
|
||||
messageTimer1.Interval = 1000 * 60 * adTimeJ;// 60分钟 60000 * adTimeJ;
|
||||
messageTimer1.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 流程确认 定时执行 系统启动5分钟
|
||||
/// </summary>
|
||||
/// <param name="sender">Timer组件</param>
|
||||
/// <param name="e">事件参数</param>
|
||||
private static void DeletePushLog(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
/// 3天推送实名制日志
|
||||
var getPushLogs = Funs.DB.RealName_PushLog.Where(x => x.PushTime.Value.AddDays(3) < DateTime.Now);
|
||||
if (getPushLogs.Count() > 0)
|
||||
{
|
||||
Funs.DB.RealName_PushLog.DeleteAllOnSubmit(getPushLogs);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
/// 3个月操作日志
|
||||
var getSys_Logs = Funs.DB.Sys_Log.Where(x => x.OperationTime.Value.AddMonths(3) < DateTime.Now);
|
||||
if (getSys_Logs.Count() > 0)
|
||||
{
|
||||
Funs.DB.Sys_Log.DeleteAllOnSubmit(getSys_Logs);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
/// 1个月推送消息日志
|
||||
var getSys_HttpLogs = Funs.DB.Sys_HttpLog.Where(x => x.LogTime.Value.AddMonths(1) < DateTime.Now);
|
||||
if (getSys_HttpLogs.Count() > 0)
|
||||
{
|
||||
Funs.DB.Sys_HttpLog.DeleteAllOnSubmit(getSys_HttpLogs);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 启动监视器 定时清理推送日志
|
||||
/// <summary>
|
||||
/// 监视组件
|
||||
/// </summary>
|
||||
private static Timer messageTimer2;
|
||||
|
||||
/// <summary>
|
||||
/// 定时清理推送日志
|
||||
/// </summary>
|
||||
public static void StartMonitorCleanAttendance()
|
||||
{
|
||||
int adTimeJ = 60 * 12;
|
||||
if (messageTimer2 != null)
|
||||
{
|
||||
messageTimer2.Stop();
|
||||
messageTimer2.Dispose();
|
||||
messageTimer2 = null;
|
||||
}
|
||||
if (adTimeJ > 0)
|
||||
{
|
||||
messageTimer2 = new Timer
|
||||
{
|
||||
AutoReset = true
|
||||
};
|
||||
messageTimer2.Elapsed += new ElapsedEventHandler(CleanAttendance);
|
||||
messageTimer2.Interval = 1000 * 60 * adTimeJ;// 60分钟 60000 * adTimeJ;
|
||||
messageTimer2.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 流程确认 定时执行 系统启动5分钟
|
||||
/// </summary>
|
||||
/// <param name="sender">Timer组件</param>
|
||||
/// <param name="e">事件参数</param>
|
||||
private static void CleanAttendance(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
/// 清理出入记录
|
||||
var getRecords = from x in Funs.DB.T_d_facerecord where x.DateTimeRecord.Value.AddDays(1) < DateTime.Now select x;
|
||||
if (getRecords.Count() > 0)
|
||||
{
|
||||
foreach (var item in getRecords)
|
||||
{
|
||||
if (item.InOrOut == "进门")
|
||||
{
|
||||
var getDelRecordsIn = from x in Funs.DB.T_d_facerecord
|
||||
where x.ProjectId == item.ProjectId && x.EmployNO == item.EmployNO && x.InOrOut == item.InOrOut
|
||||
&& x.DateTimeRecord.Value.Year == item.DateTimeRecord.Value.Year
|
||||
&& x.DateTimeRecord.Value.Month == item.DateTimeRecord.Value.Month
|
||||
&& x.DateTimeRecord.Value.Day == item.DateTimeRecord.Value.Day
|
||||
&& x.DateTimeRecord > item.DateTimeRecord
|
||||
select x;
|
||||
if (getDelRecordsIn.Count() > 0)
|
||||
{
|
||||
Funs.DB.T_d_facerecord.DeleteAllOnSubmit(getDelRecordsIn);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var getDelRecordsOut = from x in Funs.DB.T_d_facerecord
|
||||
where x.ProjectId == item.ProjectId && x.EmployNO == item.EmployNO && x.InOrOut == item.InOrOut
|
||||
&& x.DateTimeRecord.Value.Year == item.DateTimeRecord.Value.Year
|
||||
&& x.DateTimeRecord.Value.Month == item.DateTimeRecord.Value.Month
|
||||
&& x.DateTimeRecord.Value.Day == item.DateTimeRecord.Value.Day
|
||||
&& x.DateTimeRecord < item.DateTimeRecord
|
||||
select x;
|
||||
if (getDelRecordsOut.Count() > 0)
|
||||
{
|
||||
Funs.DB.T_d_facerecord.DeleteAllOnSubmit(getDelRecordsOut);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var getVRecords = from x in Funs.DB.T_d_validcardevent
|
||||
where x.RecordDateTime.Value.AddDays(1) < DateTime.Now
|
||||
select x;
|
||||
if (getVRecords.Count() > 0)
|
||||
{
|
||||
foreach (var item in getVRecords)
|
||||
{
|
||||
if (item.InOrOut == 1)
|
||||
{
|
||||
var getDelVRecordsIn = from x in Funs.DB.T_d_validcardevent
|
||||
where x.ProjectId == item.ProjectId && x.IDCardNo == item.IDCardNo && x.InOrOut == item.InOrOut
|
||||
&& x.RecordDateTime.Value.Year == item.RecordDateTime.Value.Year
|
||||
&& x.RecordDateTime.Value.Month == item.RecordDateTime.Value.Month
|
||||
&& x.RecordDateTime.Value.Day == item.RecordDateTime.Value.Day
|
||||
&& x.RecordDateTime > item.RecordDateTime
|
||||
select x;
|
||||
if (getDelVRecordsIn.Count() > 0)
|
||||
{
|
||||
Funs.DB.T_d_validcardevent.DeleteAllOnSubmit(getDelVRecordsIn);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var getDelVRecordsOut = from x in Funs.DB.T_d_validcardevent
|
||||
where x.ProjectId == item.ProjectId && x.IDCardNo == item.IDCardNo && x.InOrOut == item.InOrOut
|
||||
&& x.RecordDateTime.Value.Year == item.RecordDateTime.Value.Year
|
||||
&& x.RecordDateTime.Value.Month == item.RecordDateTime.Value.Month
|
||||
&& x.RecordDateTime.Value.Day == item.RecordDateTime.Value.Day
|
||||
&& x.RecordDateTime < item.RecordDateTime
|
||||
select x;
|
||||
if (getDelVRecordsOut.Count() > 0)
|
||||
{
|
||||
Funs.DB.T_d_validcardevent.DeleteAllOnSubmit(getDelVRecordsOut);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user