Merge branch 'master' of https://gitee.com/frane-yang/SGGL_CWCEC
This commit is contained in:
@@ -22,8 +22,7 @@ namespace BLL
|
||||
{
|
||||
var getUser = from x in db.SitePerson_Person
|
||||
where (x.Telephone == userInfo.Account || x.PersonName == userInfo.Account)
|
||||
&& (x.Password == Funs.EncryptionPassword(userInfo.Password)
|
||||
|| (x.IdentityCard != null && x.IdentityCard.Substring(x.IdentityCard.Length - 4) == userInfo.Password))
|
||||
&& x.Password == Funs.EncryptionPassword(userInfo.Password)
|
||||
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime >= DateTime.Now) && x.IsUsed == true
|
||||
select new Model.UserItem
|
||||
{
|
||||
@@ -812,7 +811,8 @@ namespace BLL
|
||||
{
|
||||
newPerson.IsUsed = false;
|
||||
}
|
||||
newPerson.Password = PersonService.GetPersonPassWord(person.IdentityCard);
|
||||
newPerson.RawPassword = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
|
||||
newPerson.Password = Funs.EncryptionPassword(newPerson.RawPassword);
|
||||
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
|
||||
if (!string.IsNullOrEmpty(rootUrl) && !string.IsNullOrEmpty(person.PhotoUrl))
|
||||
{
|
||||
|
||||
@@ -202,6 +202,7 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// 获取得到的单选题、多选题、判断题 数量
|
||||
int getDiffTestType1Count = sumTestType1Count - getTestTrainingItemList.Where(x => x.TestType == "1").Count();
|
||||
int getDiffTestType2Count = sumTestType2Count - getTestTrainingItemList.Where(x => x.TestType == "2").Count();
|
||||
@@ -502,11 +503,11 @@ namespace BLL
|
||||
/// </summary>
|
||||
/// <param name="testRecordItemId"></param>
|
||||
/// <param name="answerItems"></param>
|
||||
public static void getTestRecordItemAnswerBySelectedItem(Model.Training_TestRecordItem getTItemT, string selectedItem)
|
||||
public static void getTestRecordItemAnswerBySelectedItem(string testRecordItemId, string selectedItem)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == getTItemT.TestRecordItemId);
|
||||
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == testRecordItemId);
|
||||
if (getTItem != null)
|
||||
{
|
||||
getTItem.SubjectScore = 0;
|
||||
@@ -588,28 +589,31 @@ namespace BLL
|
||||
/// <param name="testRecord"></param>
|
||||
public static string getResitTestRecord(Model.Training_TestRecord getTestRecord)
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestRecord.ProjectId,
|
||||
TestPlanId = getTestRecord.TestPlanId,
|
||||
TestManId = getTestRecord.TestManId,
|
||||
TestType = getTestRecord.TestType,
|
||||
TemporaryUser = getTestRecord.TemporaryUser,
|
||||
Duration = getTestRecord.Duration,
|
||||
// TestStartTime = DateTime.Now,
|
||||
};
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestRecord.ProjectId,
|
||||
TestPlanId = getTestRecord.TestPlanId,
|
||||
TestManId = getTestRecord.TestManId,
|
||||
TestType = getTestRecord.TestType,
|
||||
TemporaryUser = getTestRecord.TemporaryUser,
|
||||
Duration = getTestRecord.Duration,
|
||||
// TestStartTime = DateTime.Now,
|
||||
};
|
||||
|
||||
Funs.DB.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
||||
Funs.DB.SubmitChanges();
|
||||
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
||||
db.SubmitChanges();
|
||||
|
||||
var getTestPlan = Funs.DB.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
|
||||
var person = PersonService.GetPersonByUserId(newTestRecord.TestManId, getTestPlan.ProjectId);
|
||||
if (getTestPlan != null && person != null)
|
||||
{
|
||||
CreateTestRecordItem(getTestPlan, newTestRecord.TestRecordId, person);
|
||||
var getTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
|
||||
var person =db.SitePerson_Person.FirstOrDefault(x=>x.PersonId == getTestRecord.TestManId);
|
||||
if (getTestPlan != null && person != null)
|
||||
{
|
||||
CreateTestRecordItem(getTestPlan, newTestRecord.TestRecordId, person);
|
||||
}
|
||||
return newTestRecord.TestRecordId;
|
||||
}
|
||||
return newTestRecord.TestRecordId;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -184,5 +184,96 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 将相关未做培训 但考试考生内容 写培训记录归档
|
||||
/// <summary>
|
||||
/// 将相关未做培训 但考试考生内容 写培训记录归档
|
||||
/// </summary>
|
||||
/// <param name="getTestPlan"></param>
|
||||
|
||||
public static void InsertTrainRecordNoTrainingPlan(Model.Training_TestPlan getTestPlan)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
Model.EduTrain_TrainRecord newTrainRecord = new Model.EduTrain_TrainRecord
|
||||
{
|
||||
TrainingId = SQLHelper.GetNewID(),
|
||||
TrainingCode = CodeRecordsService.ReturnCodeByMenuIdProjectId(Const.ProjectTrainRecordMenuId, getTestPlan.ProjectId, Const.UnitId_CWCEC),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TrainTitle = getTestPlan.PlanName,
|
||||
TrainContent = getTestPlan.PlanName,
|
||||
TrainStartDate = getTestPlan.TestStartTime,
|
||||
TeachHour = getTestPlan.Duration,
|
||||
TrainEndDate = getTestPlan.TestEndTime,
|
||||
TeachMan = UserService.GetUserNameByUserId(getTestPlan.PlanManId),
|
||||
TeachAddress = getTestPlan.TestPalce,
|
||||
Remark = "来源:考试计划",
|
||||
TrainTypeId = Const.EntryTrainTypeId,
|
||||
UnitIds = getTestPlan.UnitIds,
|
||||
States = Const.State_2,
|
||||
WorkPostIds = getTestPlan.WorkPostIds,
|
||||
PlanId = getTestPlan.TestPlanId,
|
||||
};
|
||||
newTrainRecord.CompileMan = newTrainRecord.TeachMan;
|
||||
///获取培训人员
|
||||
var getTestRecords = from x in db.Training_TestRecord
|
||||
where x.TestPlanId == getTestPlan.TestPlanId
|
||||
select x;
|
||||
newTrainRecord.TrainPersonNum = getTestRecords.Count();
|
||||
///新增培训记录
|
||||
db.EduTrain_TrainRecord.InsertOnSubmit(newTrainRecord);
|
||||
db.SubmitChanges();
|
||||
|
||||
////及格分数
|
||||
int passScore = 80;
|
||||
var testRule = db.Sys_TestRule.FirstOrDefault();
|
||||
if (testRule != null)
|
||||
{
|
||||
passScore = testRule.PassingScore;
|
||||
}
|
||||
|
||||
foreach (var item in getTestRecords)
|
||||
{
|
||||
var getItem = db.EduTrain_TrainRecordDetail.FirstOrDefault(x => x.PersonId == item.TestManId && x.CheckResult);
|
||||
if (getItem == null)
|
||||
{
|
||||
|
||||
decimal gScores = item.TestScores ?? 0;
|
||||
bool result = false;
|
||||
if (gScores >= passScore)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
Model.EduTrain_TrainRecordDetail newDetail = new Model.EduTrain_TrainRecordDetail
|
||||
{
|
||||
TrainDetailId = SQLHelper.GetNewID(),
|
||||
TrainingId = newTrainRecord.TrainingId,
|
||||
PersonId = item.TestManId,
|
||||
CheckScore = gScores,
|
||||
CheckResult = result,
|
||||
};
|
||||
db.EduTrain_TrainRecordDetail.InsertOnSubmit(newDetail);
|
||||
db.SubmitChanges();
|
||||
|
||||
///// 培训考试 通过 更新卡号
|
||||
if (result)
|
||||
{
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(e => e.PersonId == newDetail.PersonId);
|
||||
if (getPerson != null && string.IsNullOrEmpty(getPerson.CardNo))
|
||||
{
|
||||
getPerson.CardNo = SQLHelper.RunProcNewId("SpGetNewNumber", "SitePerson_Person", "CardNo", getPerson.ProjectId, UnitService.GetUnitCodeByUnitId(getPerson.UnitId));
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////增加一条编码记录
|
||||
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectTrainRecordMenuId, newTrainRecord.ProjectId, null, newTrainRecord.TrainingId, newTrainRecord.TrainStartDate);
|
||||
CommonService.btnSaveData(newTrainRecord.ProjectId, Const.ProjectTrainRecordMenuId, newTrainRecord.TrainingId, getTestPlan.PlanManId, true, newTrainRecord.TrainTitle, "../EduTrain/TrainRecordView.aspx?TrainingId={0}");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
+72
-1
@@ -4,8 +4,8 @@ namespace BLL
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Linq;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
@@ -146,6 +146,7 @@ namespace BLL
|
||||
//}
|
||||
|
||||
private static object locker = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 数据库上下文。
|
||||
/// </summary>
|
||||
@@ -195,6 +196,76 @@ namespace BLL
|
||||
//return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
|
||||
}
|
||||
|
||||
#region 获取用户初始密码
|
||||
/// <summary>
|
||||
/// 获取用户初始密码
|
||||
/// </summary>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
public static string getInitialPassword(string unitId, string idCard)
|
||||
{
|
||||
string prefixValue = "CWCEC";
|
||||
string suffixValue = "1234";
|
||||
//var getUnit = UnitService.GetUnitByUnitId(unitId);
|
||||
//if (getUnit != null)
|
||||
//{
|
||||
// if (!string.IsNullOrEmpty(getUnit.UnitCode))
|
||||
// {
|
||||
// if (getUnit.UnitCode.Length > 10)
|
||||
// {
|
||||
// prefixValue = getUnit.UnitCode.Substring(getUnit.UnitCode.Length - 10);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// prefixValue = getUnit.UnitCode;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
if (!string.IsNullOrEmpty(idCard))
|
||||
{
|
||||
if (idCard.Length > 4)
|
||||
{
|
||||
suffixValue = idCard.Substring(idCard.Length - 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
suffixValue = idCard;
|
||||
}
|
||||
}
|
||||
return prefixValue + "." + suffixValue;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 验证密码
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="c"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsLetter(char c)
|
||||
{
|
||||
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
||||
}
|
||||
|
||||
public static bool IsDigit(char c)
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
static bool IsSymbol(char c)
|
||||
{
|
||||
return c > 32 && c < 127 && !IsDigit(c) && !IsLetter(c);
|
||||
}
|
||||
|
||||
public static bool IsValIDPassword(string password)
|
||||
{
|
||||
return
|
||||
password.Any(c => IsLetter(c)) &&
|
||||
password.Any(c => IsDigit(c)) &&
|
||||
password.Any(c => IsSymbol(c));
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 为目标下拉框加上 "请选择" 项
|
||||
/// </summary>
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace BLL
|
||||
/// <returns></returns>
|
||||
public static Model.Training_TestPlan GetTestPlanByPlanId(string planId)
|
||||
{
|
||||
return Funs.DB.Training_TestPlan.FirstOrDefault(x => x.PlanId == planId);
|
||||
return Funs.DB.Training_TestPlan.FirstOrDefault(x => x.PlanId == planId || x.TestPlanId ==planId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ namespace BLL
|
||||
return personName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 根据UserId主键获取人员信息
|
||||
/// </summary>
|
||||
@@ -437,7 +438,8 @@ namespace BLL
|
||||
ProvinceCode = person.ProvinceCode,
|
||||
IsCardNoOK=IDCardValid.CheckIDCard(person.IdentityCard),
|
||||
};
|
||||
|
||||
newPerson.RawPassword = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
|
||||
newPerson.Password = Funs.EncryptionPassword(newPerson.RawPassword);
|
||||
if (person.InTime.HasValue)
|
||||
{
|
||||
newPerson.InTime = person.InTime;
|
||||
@@ -532,11 +534,30 @@ namespace BLL
|
||||
newPerson.CountryCode = person.CountryCode;
|
||||
newPerson.ProvinceCode = person.ProvinceCode;
|
||||
newPerson.IsCardNoOK = IDCardValid.CheckIDCard(person.IdentityCard);
|
||||
|
||||
newPerson.RawPassword = Funs.getInitialPassword(person.UnitId, person.IdentityCard);
|
||||
newPerson.Password = Funs.EncryptionPassword(newPerson.RawPassword);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改密码
|
||||
/// </summary>
|
||||
/// <param name="personId"></param>
|
||||
/// <param name="password"></param>
|
||||
public static void UpdateSitePersonPassword(string personId, string password)
|
||||
{
|
||||
var m = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.PersonId == personId);
|
||||
if (m != null)
|
||||
{
|
||||
m.RawPassword = password;
|
||||
m.Password = Funs.EncryptionPassword(password);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 人员离岗
|
||||
/// </summary>
|
||||
|
||||
@@ -272,12 +272,14 @@ namespace BLL
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime dateS = DateTime.Now.AddMonths(-3);
|
||||
dateS = Funs.GetNewDateTimeOrNow(DateTime.Now.AddMonths(-3).Year + "-" + DateTime.Now.AddMonths(-3).Month + "-01");
|
||||
var getNums = from x in db.SitePerson_PersonInOutNumber
|
||||
where x.ProjectId == projectId && x.InOutDate.AddMonths(3) >= DateTime.Now
|
||||
where x.ProjectId == projectId && x.InOutDate >= dateS
|
||||
orderby x.InOutDate
|
||||
select x;
|
||||
select x;
|
||||
var getInouts = from x in db.SitePerson_PersonInOut
|
||||
where x.ProjectId == projectId && x.ChangeTime.Value.AddMonths(3) >= DateTime.Now
|
||||
where x.ProjectId == projectId && x.ChangeTime.Value >= dateS
|
||||
select x;
|
||||
int SafeHours = 0;
|
||||
foreach (var itemNum in getNums)
|
||||
@@ -287,7 +289,7 @@ namespace BLL
|
||||
var getAllPersonInOutList = from x in getInouts
|
||||
where x.ChangeTime > date.AddDays(-1) && x.ChangeTime < date.AddDays(1)
|
||||
select x;
|
||||
|
||||
|
||||
if (getAllPersonInOutList.Count() > 0)
|
||||
{
|
||||
/// 出场记录
|
||||
@@ -301,13 +303,16 @@ namespace BLL
|
||||
{
|
||||
SafeHours = getMaxInOutDate.WorkHours ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SafeHours = db.SitePerson_PersonInOutNumber.Where(x => x.ProjectId == projectId && x.InOutDate < dateS).Max(x => x.WorkHours) ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
int getOutPersonCount = getPersonOutTimes.Select(x => x.PersonId).Distinct().Count();
|
||||
SafeHours += getOutPersonCount * 8;
|
||||
}
|
||||
|
||||
|
||||
//SafeHours = Convert.ToInt32(SafeHours * 1.0 / 60);
|
||||
if (itemNum != null)
|
||||
{
|
||||
|
||||
@@ -13,13 +13,17 @@
|
||||
/// <returns></returns>
|
||||
public static int getPassScore()
|
||||
{
|
||||
int passScore = 80;
|
||||
var testRule = Funs.DB.Sys_TestRule.FirstOrDefault();
|
||||
if (testRule != null)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
passScore = testRule.PassingScore;
|
||||
int passScore = 80;
|
||||
var testRule =db.Sys_TestRule.FirstOrDefault();
|
||||
if (testRule != null)
|
||||
{
|
||||
passScore = testRule.PassingScore;
|
||||
}
|
||||
|
||||
return passScore;
|
||||
}
|
||||
return passScore;
|
||||
}
|
||||
|
||||
#region 菜单编码模板
|
||||
|
||||
@@ -176,12 +176,12 @@ namespace BLL
|
||||
/// <param name="password"></param>
|
||||
public static void UpdatePassword(string userId, string password)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.Sys_User m = db.Sys_User.FirstOrDefault(e => e.UserId == userId);
|
||||
Model.Sys_User m = Funs.DB.Sys_User.FirstOrDefault(e => e.UserId == userId);
|
||||
if (m != null)
|
||||
{
|
||||
m.RawPassword = password;
|
||||
m.Password = Funs.EncryptionPassword(password);
|
||||
db.SubmitChanges();
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +199,7 @@ namespace BLL
|
||||
Account = user.Account,
|
||||
UserName = user.UserName,
|
||||
UserCode = user.UserCode,
|
||||
RawPassword = user.RawPassword,
|
||||
Password = user.Password,
|
||||
UnitId = user.UnitId,
|
||||
RoleId = user.RoleId,
|
||||
|
||||
Reference in New Issue
Block a user