本文整理汇总了C#中UnitOfWork.CurrentDate方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.CurrentDate方法的具体用法?C# UnitOfWork.CurrentDate怎么用?C# UnitOfWork.CurrentDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.CurrentDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SyncTAMLog
public void SyncTAMLog(Guid userID, Guid taskID, bool isExcept,
DateTime dateFrom, DateTime dateTo, List<Guid> listProfileID)
{
using (var context = new VnrHrmDataContext())
{
IUnitOfWork unitOfWork = new UnitOfWork(context);
Sys_AsynTask asynTask = null;
int pageSize = 200;
if (taskID != Guid.Empty)
{
asynTask = unitOfWork.CreateQueryable<Sys_AsynTask>(Guid.Empty,
d => d.ID == taskID).FirstOrDefault();
}
if (listProfileID != null && listProfileID.Count() > 0)
{
double totalComputed = 0;
foreach (var listSplitProfileID in listProfileID.Chunk(pageSize))
{
string serverTamLogConfig1 = string.Empty;
string serverTamLogConfig2 = string.Empty;
totalComputed += listSplitProfileID.Count();
if (IsConnected(AppConfig.HRM_SYS_CAN_TAMSCANLOG_1_, true, ref serverTamLogConfig1))
{
SyncTAMLog(userID, isExcept, dateFrom, dateTo, serverTamLogConfig1, listSplitProfileID.ToList());
}
if (IsConnected(AppConfig.HRM_SYS_CAN_TAMSCANLOG_2_, true, ref serverTamLogConfig2))
{
//Nếu có sử dụng 2 database chấm công thì đẩy dữ liệu vào cả 2
SyncTAMLog(userID, isExcept, dateFrom, dateTo, serverTamLogConfig2, listSplitProfileID.ToList());
}
if (asynTask != null)
{
asynTask.PercentComplete = totalComputed / (double)listProfileID.Count;
unitOfWork.SaveChanges(userID);
}
}
}
if (asynTask != null)
{
asynTask.Status = AsynTaskStatus.Done.ToString();
asynTask.PercentComplete = 1D;//Không cần nhân với 100
asynTask.TimeEnd = unitOfWork.CurrentDate();
unitOfWork.SaveChanges(userID);
}
}
}
示例2: CheckData
private void CheckData(List<ImportRosterModel> listRoster, bool check12Hours, bool isAllowEditFutureRoster,
bool isAllowEditPastRoster, List<string> listProfileCode, List<Cat_Shift> listShiftInfo)
{
#region Kiểm tra dữ liệu lỗi
using (var context = new VnrHrmDataContext())
{
IUnitOfWork unitOfWork = new UnitOfWork(context);
var listRosterCorrect = ImportObjects[LoginUserID];
var listRosterError = InvalidObjects[LoginUserID];
var listProfileInfo = unitOfWork.CreateQueryable<Hre_Profile>(LoginUserID,
d => listProfileCode.Contains(d.CodeEmp.ToUpper())).Select(d => new { d.ID, d.CodeEmp }).ToList();
var listProfileID = listProfileInfo.Select(d => d.ID).Distinct().ToList();
var dateStart = listRoster.Select(d => d.DateStart).OrderBy(d => d).FirstOrDefault();
var dateEnd = listRoster.Select(d => d.DateEnd).OrderBy(d => d).LastOrDefault();
var monthStart = dateStart.Date.AddDays(1 - dateStart.Day);
var monthEnd = monthStart.AddMonths(1).AddSeconds(-1);
var checkDate = dateStart.AddDays(-1);
string cancelStatus = RosterStatus.E_CANCEL.ToString();
string rejectStatus = RosterStatus.E_REJECTED.ToString();
var currentDate = unitOfWork.CurrentDate();
var listOldRoster = unitOfWork.CreateQueryable<Att_Roster>(Guid.Empty, d => d.Status != cancelStatus
&& d.Status != rejectStatus && listProfileID.Contains(d.ProfileID) && d.DateStart <= dateEnd
&& d.DateEnd >= checkDate).Select(d => new
{
d.ProfileID,
d.DateStart,
d.DateEnd,
d.MonShiftID,
d.TueShiftID,
d.WedShiftID,
d.ThuShiftID,
d.FriShiftID,
d.SatShiftID,
d.SunShiftID,
d.Status,
d.Type
}).ToList();
foreach (var roster in listRoster)
{
var profileInfo = listProfileInfo.Where(d => d.CodeEmp != null
&& d.CodeEmp.ToUpper() == roster.CodeEmp).FirstOrDefault();
if (profileInfo != null)
{
roster.ProfileID = profileInfo.ID;
string shiftNotFound = string.Empty;
var listShiftNotFound = new List<string>();
if (!string.IsNullOrWhiteSpace(roster.MonShift))
{
var shiftInfo = listShiftInfo.Where(d =>
d.Code == roster.MonShift).FirstOrDefault();
if (shiftInfo != null)
{
roster.MonShiftID = shiftInfo.ID;
}
else
{
if (!listShiftNotFound.Contains(roster.MonShift))
{
listShiftNotFound.Add(roster.MonShift);
shiftNotFound += (string.IsNullOrWhiteSpace(shiftNotFound)
? string.Empty : ",") + roster.MonShift;
}
}
}
if (!string.IsNullOrWhiteSpace(roster.TueShift))
{
var shiftInfo = listShiftInfo.Where(d =>
d.Code == roster.TueShift).FirstOrDefault();
if (shiftInfo != null)
{
roster.TueShiftID = shiftInfo.ID;
}
else
{
if (!listShiftNotFound.Contains(roster.TueShift))
{
listShiftNotFound.Add(roster.TueShift);
shiftNotFound += (string.IsNullOrWhiteSpace(shiftNotFound)
? string.Empty : ",") + roster.TueShift;
}
}
}
if (!string.IsNullOrWhiteSpace(roster.WedShift))
{
var shiftInfo = listShiftInfo.Where(d =>
d.Code == roster.WedShift).FirstOrDefault();
if (shiftInfo != null)
//.........这里部分代码省略.........