本文整理汇总了C#中UnitOfWork.SetCorrectOrgStructureID方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.SetCorrectOrgStructureID方法的具体用法?C# UnitOfWork.SetCorrectOrgStructureID怎么用?C# UnitOfWork.SetCorrectOrgStructureID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.SetCorrectOrgStructureID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeWorkday
//.........这里部分代码省略.........
if (!isPreWorkday)
{
workday.WorkDate = date;
workday.InTimeRoot = workday.InTime1;
workday.OutTimeRoot = workday.OutTime1;
}
if (shiftID1 != null && shiftID1 != Guid.Empty)
{
workday.ShiftID = shiftID1.Value;
workday.ShiftActual = shiftID1.Value;
workday.ShiftApprove = shiftID1.Value;
}
if (shiftID2 != null && shiftID2 != Guid.Empty)
{
workday.Shift2ID = shiftID2.Value;
workday.ShiftActual2 = shiftID2.Value;
workday.ShiftApprove2 = shiftID2.Value;
}
if (actualShiftID1.HasValue && actualShiftID1 != Guid.Empty)
{
workday.ShiftActual = actualShiftID1;
workday.ShiftApprove = actualShiftID1;
}
if (actualShiftID2.HasValue && actualShiftID2 != Guid.Empty)
{
workday.ShiftActual2 = actualShiftID2;
workday.ShiftApprove2 = actualShiftID2;
}
var listLeaveDayByProfile = listLeaveDay.Where(d => d.ProfileID == profile.ID).ToList();
var leaveDayID1 = listLeaveDayByProfile.Where(d => workday.WorkDate >= d.DateStart
&& workday.WorkDate <= d.DateEnd).Select(d => d.ID).FirstOrDefault();
var leaveDayID2 = listLeaveDayByProfile.Where(d => d.ID != workday.LeaveDayID1 && workday.WorkDate
>= d.DateStart && workday.WorkDate <= d.DateEnd).Select(d => d.ID).FirstOrDefault();
workday.LeaveDayID1 = leaveDayID1 != Guid.Empty ? (Guid?)leaveDayID1 : null;
workday.LeaveDayID2 = leaveDayID2 != Guid.Empty ? (Guid?)leaveDayID2 : null;
workday.MissInOutReason = listLeaveDayType.Where(d => listLeaveDayByProfile.Any(p => p.LeaveDayTypeID == d.ID)
&& d.MissInOutReasonID != null).Select(d => d.MissInOutReasonID).FirstOrDefault();
listWorkday.Add(workday);
}
}
#endregion
#region Chia thành nhiều giai đoạn lưu ngày công
//Nên submit lần đầu tiên khi đã tính được 5 profile
bool firstSubmit = listProfile.ToList().IndexOf(profile) == 5;
firstSubmit = totalComputed >= 5 ? false : firstSubmit;//đã chạy 1 lần
totalComputedProfileForSubmit++;
totalComputed++;
if (firstSubmit || totalComputedProfileForSubmit >= totalComputedProfileMustSubmit)
{
listWorkdayAnalyze = listWorkday.Where(d => !listWorkdayChecked.Contains(d)).ToList();
listWorkdayChecked.AddRange(listWorkdayAnalyze);
leavedayServices.AnalyzeLeaveLate(listWorkdayAnalyze, lstPrenancy, lstLateEarlyRule,
listShift, lstGrade, lstGradeConfig, lstDayOff);
totalComputedProfileForSubmit = firstSubmit ? totalComputedProfileForSubmit : 0;
dataErrorCode = unitOfWork.SaveChanges(userID);
if (dataErrorCode == DataErrorCode.Locked)
{
break;
}
}
#endregion
}
}
#endregion
#region Lưu kết quả tổng hợp in out
listWorkdayAnalyze = listWorkday.Where(d => !listWorkdayChecked.Contains(d)).ToList();
listWorkdayChecked.AddRange(listWorkdayAnalyze);
leavedayServices.AnalyzeLeaveLate(listWorkdayAnalyze, lstPrenancy, lstLateEarlyRule,
listShift, lstGrade, lstGradeConfig, lstDayOff);
unitOfWork.SetCorrectOrgStructureID(listWorkday);
dataErrorCode = unitOfWork.SaveChanges(userID);
#endregion
}
return listWorkday.Count();
}
示例2: SaveRoster
//.........这里部分代码省略.........
WedShiftID = d.WedShiftID,
ThuShiftID = d.ThuShiftID,
FriShiftID = d.FriShiftID,
SatShiftID = d.SatShiftID,
SunShiftID = d.SunShiftID,
Type = RosterType.E_DEFAULT.ToString(),
Status = RosterStatus.E_APPROVED.ToString()
}).ToArray();
if (ImportType == ImportRosterType.OverrideMonth)
{
var listProfileID = listRoster.Select(d => d.ProfileID).Distinct().ToList();
var dateStart = listRoster.Where(d => d.DateStart > SqlDateTime.MinValue.Value).Select(d => d.DateStart.Date).OrderBy(d => d).FirstOrDefault();
var dateEnd = dateStart.AddMonths(1).Date;//Sau này nếu nghiệp vụ thay đổi chỉ xóa những ngày khai báo thì lấy max của cột DateEnd trong danh sách
//Không xóa theo kiểu miền giao DateStart và DateEnd -> có thể sai trường hợp roster dài nhiều tháng
unitOfWork.Delete<Att_Roster>(unitOfWork.CreateQueryable<Att_Roster>(d => d.DateStart >= dateStart
&& d.DateEnd <= dateEnd && listProfileID.Contains(d.ProfileID)));
}
else if (ImportType == ImportRosterType.OverrideHasValue)
{
var listProfileID = listRoster.Select(d => d.ProfileID).Distinct().ToList();
var dateStart = listRoster.Where(d => d.DateStart > SqlDateTime.MinValue.Value).Select(d => d.DateStart.Date).OrderBy(d => d).FirstOrDefault();
var dateEnd = listRoster.Where(d => d.DateEnd > SqlDateTime.MinValue.Value).Select(d => d.DateEnd.Date).OrderBy(d => d).LastOrDefault();
var listOldRoster = unitOfWork.CreateQueryable<Att_Roster>(Guid.Empty, d => d.DateStart <= dateEnd
&& d.DateEnd >= dateStart && listProfileID.Contains(d.ProfileID)).ToList<Att_Roster>();
foreach (var roster in listRoster)
{
DateTime rosterStart = roster.DateStart.Date;
DateTime rosterEnd = roster.DateEnd.Date;
for (DateTime date = rosterStart; date <= rosterEnd; date = date.AddDays(1))
{
var oldRoster = listOldRoster.Where(d => d.DateStart.Date <= date &&
d.DateEnd.Date >= date && d.ProfileID == roster.ProfileID).FirstOrDefault();
if (oldRoster != null)
{
if (date.DayOfWeek == DayOfWeek.Monday && roster.MonShiftID.HasValue)
{
oldRoster.MonShiftID = roster.MonShiftID;
roster.MonShiftID = null;
}
else if (date.DayOfWeek == DayOfWeek.Tuesday && roster.TueShiftID.HasValue)
{
oldRoster.TueShiftID = roster.TueShiftID;
roster.TueShiftID = null;
}
else if (date.DayOfWeek == DayOfWeek.Wednesday && roster.WedShiftID.HasValue)
{
oldRoster.WedShiftID = roster.WedShiftID;
roster.WedShiftID = null;
}
else if (date.DayOfWeek == DayOfWeek.Thursday && roster.ThuShiftID.HasValue)
{
oldRoster.ThuShiftID = roster.ThuShiftID;
roster.ThuShiftID = null;
}
else if (date.DayOfWeek == DayOfWeek.Friday && roster.FriShiftID.HasValue)
{
oldRoster.FriShiftID = roster.FriShiftID;
roster.FriShiftID = null;
}
else if (date.DayOfWeek == DayOfWeek.Saturday && roster.SatShiftID.HasValue)
{
oldRoster.SatShiftID = roster.SatShiftID;
roster.SatShiftID = null;
}
else if (date.DayOfWeek == DayOfWeek.Sunday && roster.SunShiftID.HasValue)
{
oldRoster.SunShiftID = roster.SunShiftID;
roster.SunShiftID = null;
}
}
}
if ((!roster.MonShiftID.HasValue && !roster.TueShiftID.HasValue && !roster.WedShiftID.HasValue
&& !roster.ThuShiftID.HasValue && !roster.FriShiftID.HasValue && !roster.SatShiftID.HasValue
&& !roster.SunShiftID.HasValue) || roster.DateStart > roster.DateEnd)
{
listDuplicate.Add(roster);
}
}
}
var listImported = listRoster.Where(d => !listDuplicate.Contains(d));
unitOfWork.SetCorrectOrgStructureID(listImported.ToList());
unitOfWork.AddObject(listImported.ToArray());
dataErrorCode = unitOfWork.SaveChanges(LoginUserID);
RemoveImportObject();
RemoveInvalidObject();
}
}
return dataErrorCode;
}