本文整理汇总了C#中UnitOfWork.CheckLock方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.CheckLock方法的具体用法?C# UnitOfWork.CheckLock怎么用?C# UnitOfWork.CheckLock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.CheckLock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeWorkday
private int ComputeWorkday(Guid asynTaskID, Guid userID, int totalProfile, int totalComputed, double timeoutMinutes,
DateTime dateFrom, DateTime dateTo, out DataErrorCode dataErrorCode, params Hre_ProfileEntity[] listProfile)
{
List<Att_Workday> listWorkday = new List<Att_Workday>();
List<Att_Workday> listWorkdayChecked = new List<Att_Workday>();
List<Att_Workday> listWorkdayAnalyze = new List<Att_Workday>();
dateFrom = dateFrom <= DateTime.MinValue ? DateTime.Now : dateFrom;
dateTo = dateTo <= DateTime.MinValue ? DateTime.Now : dateTo;
DateTime dateStart = dateFrom.AddDays(-1);
DateTime dateEnd = dateTo.AddDays(1);
using (var context = new VnrHrmDataContext())
{
var workHistoryServices = new Hre_WorkHistoryServices();
var leavedayServices = new Att_LeavedayServices();
var unitOfWork = new UnitOfWork(context);
string waitStatus = ProfileStatusSyn.E_WAITING.ToString();
string rosterStatus = RosterStatus.E_APPROVED.ToString();
string leaveDayStatus = LeaveDayStatus.E_APPROVED.ToString();
String appConfigInfo = AppConfig.E_SERVER_TAM.ToString();
string E_LEAVE_EARLY = PregnancyType.E_LEAVE_EARLY.ToString();
string workdaySrcType = WorkdaySrcType.E_MANUAL.ToString();
string workdayStatus1 = WorkdayStatus.E_APPROVED.ToString();
string workdayStatus2 = WorkdayStatus.E_WAIT_APPROVED.ToString();
var listProfileID = listProfile.Select(d => d.ID).ToArray();
#region Delete Workday đã tổng hợp trước đó
if (unitOfWork.CheckLock(typeof(Att_Workday), dateFrom, dateTo))
{
dataErrorCode = DataErrorCode.Locked;
CompleteComputingTask(asynTaskID, userID,
totalComputed, totalProfile, dataErrorCode);
return listWorkday.Count();
}
else
{
Task task = Task.Run(() => DeleteWorkday(userID, dateFrom, dateTo,
workdaySrcType, workdayStatus1, workdayStatus2, listProfileID));
}
#endregion
#region Khởi tạo dữ liệu cho lần tổng hợp
var tamScanLogQueryable = unitOfWork.CreateQueryable<Att_TAMScanLog>(Guid.Empty, d => d.ProfileID.HasValue
&& listProfileID.Contains(d.ProfileID.Value) && d.TimeLog.HasValue && d.TimeLog >= dateStart && d.TimeLog <= dateEnd);
//Danh sách quẹt thẻ theo điều kiện được chọn
var listAllTamScanLog = tamScanLogQueryable.Select(d => new Att_TAMScanLogEntity
{
ID = d.ID,
ProfileID = d.ProfileID,
CardCode = d.CardCode,
CodeEmp = d.CodeEmp,
TimeLog = d.TimeLog,
SrcType = d.SrcType,
Type = d.Type
}).ToList();
var listRoster = unitOfWork.CreateQueryable<Att_Roster>(Guid.Empty, d => d.Status == rosterStatus && d.DateStart <= dateEnd
&& d.DateEnd >= dateStart.Date && listProfileID.Contains(d.ProfileID)).Select(d => new Att_RosterEntity
{
ID = d.ID,
ProfileID = d.ProfileID,
RosterGroupName = d.RosterGroupName,
Type = d.Type,
Status = d.Status,
DateEnd = d.DateEnd,
DateStart = d.DateStart,
MonShiftID = d.MonShiftID,
TueShiftID = d.TueShiftID,
WedShiftID = d.WedShiftID,
ThuShiftID = d.ThuShiftID,
FriShiftID = d.FriShiftID,
SatShiftID = d.SatShiftID,
SunShiftID = d.SunShiftID,
MonShift2ID = d.MonShiftID,
TueShift2ID = d.TueShift2ID,
WedShift2ID = d.WedShift2ID,
ThuShift2ID = d.ThuShift2ID,
FriShift2ID = d.FriShift2ID,
SatShift2ID = d.SatShift2ID,
SunShift2ID = d.SunShift2ID
}).ToList();
var listRosterGroup = unitOfWork.CreateQueryable<Att_RosterGroup>(Guid.Empty, m => m.DateStart != null && m.DateEnd != null
&& m.DateStart <= dateEnd && m.DateEnd >= dateStart.Date).Select(d => new Att_RosterGroupEntity
{
ID = d.ID,
DateEnd = d.DateEnd,
DateStart = d.DateStart,
MonShiftID = d.MonShiftID,
TueShiftID = d.TueShiftID,
WedShiftID = d.WedShiftID,
//.........这里部分代码省略.........