private static RecordType GetEfficiencyRecordType( BusinessUnitType businessUnitType, bool hasTimesheet, bool isEmployeeTransactional, WorkcenterType workcenterType, bool isTransactionTypeMeasured) { if (hasTimesheet == false && businessUnitType == BusinessUnitType.LTL) { return(RecordType.NonTransactional); } if (isEmployeeTransactional == false) { return(RecordType.NonTransactional); } if (workcenterType == WorkcenterType.NON_TRANSACTIONAL) { return(RecordType.NonTransactional); } if (workcenterType == WorkcenterType.MONITORED) { return(RecordType.Monitored); } if (isTransactionTypeMeasured == false) { return(RecordType.Monitored); } return(RecordType.Transactional); }
public void btnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtTypeName.Text) && !string.IsNullOrEmpty(this.txtTypeCode.Text)) { using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { int id = Convert.ToInt32(Request.QueryString["BusinessUnitTypeID"]); BusinessUnitType but = db.BusinessUnitType.SingleOrDefault(a => a.BusinessUnitTypeID == id); but.BusinessUnitTypeName = this.txtTypeName.Text.Trim(); BusinessUnitType code = db.BusinessUnitType.SingleOrDefault(u => u.BusinessUnitTypeCode == this.txtTypeCode.Text.Trim()); if (code == null) { but.BusinessUnitTypeCode = this.txtTypeCode.Text.Trim(); } else { if (but.BusinessUnitTypeID == code.BusinessUnitTypeID) { but.BusinessUnitTypeCode = this.txtTypeCode.Text.Trim(); } else { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('单位类别代码重复! ');</script>"); return; } } but.Remark = this.txtRemark.Text.Trim(); db.SubmitChanges(); Response.Redirect("BusinessTypeManage.aspx"); } } }
public EfficiencyShift( [CanBeNull] Employee employee, bool isLtl, string siteCode, IReadOnlyCollection <string> siteEmployeeCodes, EfficiencyTransactionType[] transactionTypes, BusinessUnitType businessUnitType, [CanBeNull] EmployeeShiftSupevisor employeeShiftSupevisor = null) : this( employee, employeeShiftSupevisor, siteEmployeeCodes, transactionTypes, businessUnitType) { IsClockedIn = false; ShiftCode = null; SiteCode = siteCode; WorkedWorkCenterCode = null; TimeSheetId = null; IsTransactional = !isLtl && (employee?.IsTransactional ?? true); IsEmployeeTransactional = !isLtl && (employee?.IsTransactional ?? true); WorkcenterType = WorkcenterType.TRANSACTIONAL; }
public EfficiencyShift( [CanBeNull] Employee employee, EfficiencyTimeSheet timeSheet, DateTime siteNow, string[] siteEmployeeCodes, [CanBeNull] EmployeeShiftSupevisor employeeShiftSupevisor, EfficiencyTransactionType[] transactionTypes, BusinessUnitType businessUnitType) : this( employee, employeeShiftSupevisor, siteEmployeeCodes, transactionTypes, businessUnitType) { StartTime = timeSheet.PunchInTime; IsClockedIn = !timeSheet.PunchOutTime.HasValue || timeSheet.PunchOutTime > siteNow; EndTime = IsClockedIn ? MinDate(siteNow, timeSheet.PunchOutTime) : timeSheet.PunchOutTime.Value; OperationalDate = timeSheet.OperationalDate; ShiftCode = timeSheet.ShiftCode; SiteCode = timeSheet.SiteCode; WorkedWorkCenterCode = timeSheet.WorkedWorkCenterCode; TimeSheetId = timeSheet.TimeSheetId; IsTransactional = employee?.IsTransactional == true && timeSheet.IsTransactionalWorkCenter != false; IsEmployeeTransactional = employee?.IsTransactional ?? true; //Chandra; WorkcenterType = timeSheet.WorkcenterType ?? WorkcenterType.TRANSACTIONAL; //Chandra }
public EfficiencyRecordType([NotNull] EfficiencyShift shift, string transactionTypeCode) { _transactionTypes = shift.TransactionTypes; _isEmployeeTransactional = shift.IsEmployeeTransactional; _workcenterType = shift.WorkcenterType; _hasTimesheet = shift.TimeSheetId.HasValue; _businessUnitType = shift.BusinessUnitType; TransactionTypeCode = transactionTypeCode; _isRecordTypeComputed = true; }
private IEnumerable <EfficiencyShift> GetOrphanedShifts([NotNull] string siteCode, bool isLtl, [NotNull] IReadOnlyCollection <string> siteEmployeeCodes, [NotNull] IEnumerable <EfficiencyTimeSheet> knownTimeSheets, DateTime startTime, DateTime endTime, EfficiencyTransactionType[] transactionTypes, BusinessUnitType businessUnitType, [CanBeNull] Employee employee = null, [CanBeNull] EmployeeShiftSupevisor employeeShiftSupevisor = null) { var transactionCacheRepository = _transactionCacheRepositoryFactory.GetCurrent(); var transactions = transactionCacheRepository.GetTransactionsByDateRange(siteCode, siteEmployeeCodes, startTime, endTime); EfficiencyShift ShiftFactory() => new EfficiencyShift(employee, isLtl, siteCode, siteEmployeeCodes, transactionTypes, businessUnitType, employeeShiftSupevisor); return(TimeSheetShiftHelpers.GetOrphanShifts(ShiftFactory, knownTimeSheets, transactions.OrderBy(t => t.TransactionDate))); }
private void LoadData() { using (db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { int id = Convert.ToInt32(Request.QueryString["BusinessUnitTypeID"]); BusinessUnitType bui = db.BusinessUnitType.SingleOrDefault(a => a.BusinessUnitTypeID == id); if (bui != null) { this.txtTypeName.Text = bui.BusinessUnitTypeName.ToString(); this.txtTypeCode.Text = bui.BusinessUnitTypeCode.ToString(); this.txtRemark.Text = bui.Remark.ToString(); } else { ClientScript.RegisterClientScriptBlock(typeof(string), "ShowMessage", "<script>alert('记录不存在! ');</script>"); Response.Redirect("BusinessTypeManage.aspx"); } } }
private EfficiencyShift( [CanBeNull] Employee employee, [CanBeNull] EmployeeShiftSupevisor employeeShiftSupevisor, IReadOnlyCollection <string> siteEmployeeCodes, [CanBeNull] EfficiencyTransactionType[] transactionTypes, BusinessUnitType businessUnitType) { EmployeeNumber = employee?.Number; EmployeeFullName = employee?.FullName; Supervisor = employee?.SupervisorFullName; ShiftSupervisor = employeeShiftSupevisor?.Supervisor?.FullName; EmployeeJobCode = employee?.JobCode; SalaryClassCode = employee?.SalaryClassCode; IsPartTimeEmployee = employee?.IsPartTime ?? false; SiteEmployeeCodes = siteEmployeeCodes.Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); TransactionTypes = transactionTypes ?? new EfficiencyTransactionType[0]; BusinessUnitType = businessUnitType; }
private string InsertData(Net.SourceForge.Koogra.Excel.Row row) { string strResult = ""; using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString)) { //检查往来单位类别 if (row.Cells[0] == null || row.Cells[1] == null) { return("往来单位类别信息不完整"); } //写入往来单位类别信息 BusinessUnitType but; //检查往来单位类别是否存在 if (!db.BusinessUnitType.Any(a => a.BusinessUnitTypeName == row.Cells[1].Value.ToString())) { but = new BusinessUnitType(); //MT.MaterialMainTypeCode = but.BusinessUnitTypeCode = row.Cells[0].Value.ToString(); but.BusinessUnitTypeName = row.Cells[1].Value.ToString(); but.Remark = row.Cells[2] == null ? "" : row.Cells[2].Value.ToString(); db.BusinessUnitType.InsertOnSubmit(but); db.SubmitChanges(); } else { but = db.BusinessUnitType.SingleOrDefault(a => a.BusinessUnitTypeName == row.Cells[1].Value.ToString()); but.BusinessUnitTypeCode = row.Cells[0].Value.ToString(); but.BusinessUnitTypeName = row.Cells[1].Value.ToString(); but.Remark = row.Cells[2] == null ? "" : row.Cells[2].Value.ToString(); db.SubmitChanges(); } //*************************************************************************** //写入单位信息 if (row.Cells[3] == null || row.Cells[4] == null) { return("单位信息不完整"); } //写入单位信息 BusinessUnitInfo bui; //检查单位是否存在 if (!db.BusinessUnitInfo.Any(a => a.BusinessUnitCode == row.Cells[3].Value.ToString())) { bui = new BusinessUnitInfo(); //MT.MaterialMainTypeCode = bui.BusinessUnitCode = row.Cells[3].Value.ToString(); bui.BusinessUnitName = row.Cells[4].Value.ToString(); bui.Remark = row.Cells[5] == null ? "" : row.Cells[5].Value.ToString(); bui.BusinessUnitTypeID = but.BusinessUnitTypeID; db.BusinessUnitInfo.InsertOnSubmit(bui); db.SubmitChanges(); } else { bui = db.BusinessUnitInfo.SingleOrDefault(a => a.BusinessUnitCode == row.Cells[3].Value.ToString()); bui.BusinessUnitCode = row.Cells[3].Value.ToString(); bui.BusinessUnitName = row.Cells[4].Value.ToString(); bui.BusinessUnitTypeID = but.BusinessUnitTypeID; bui.Remark = row.Cells[5] == null ? "" : row.Cells[5].Value.ToString(); db.SubmitChanges(); } //*************************************************************************** //写项目信息 if (row.Cells[6] == null || row.Cells[7] == null) { return("项目信息不完整"); } ProjectInfo pi; //检查生产厂商类别是否存在 if (!db.ProjectInfo.Any(a => a.ProjectCode == row.Cells[6].Value.ToString())) { pi = new ProjectInfo(); //MT.MaterialMainTypeCode = pi.ProjectCode = row.Cells[6].Value.ToString(); pi.ProjectName = row.Cells[7].Value.ToString(); pi.Remark = row.Cells[8] == null ? "" : row.Cells[8].Value.ToString(); pi.Owner = bui.BusinessUnitID; db.ProjectInfo.InsertOnSubmit(pi); db.SubmitChanges(); } else { pi = db.ProjectInfo.SingleOrDefault(a => a.ProjectCode == row.Cells[6].Value.ToString()); pi.ProjectCode = row.Cells[6].Value.ToString(); pi.ProjectName = row.Cells[7].Value.ToString(); pi.Remark = row.Cells[8] == null ? "" : row.Cells[8].Value.ToString(); pi.Owner = bui.BusinessUnitID; db.SubmitChanges(); } } return(strResult); }
private IEnumerable <EfficiencyShift> GetOrphanedShiftsFromTransactions( [NotNull] string siteCode, [NotNull] Employee[] employees, bool isLtl, DateTime startTime, DateTime endTime, [NotNull] ICollection <EfficiencyTimeSheet> knownTimeSheets, EfficiencyTransactionType[] transactionTypes, BusinessUnitType businessUnitType, [CanBeNull] IEnumerable <string> siteEmployeeCodesFilter = null, [CanBeNull] EmployeeShiftSupevisor[] employeeShiftSupevisors = null) { var results = new List <EfficiencyShift>(); var transactionCacheRepository = _transactionCacheRepositoryFactory.GetCurrent(); var filteredSiteEmployeeCodes = siteEmployeeCodesFilter?.ToArray() ?? transactionCacheRepository.GetTransactionSiteEmployeeCodes(siteCode).ToArray(); var mappedSiteEmployeeCodes = new HashSet <string>(StringComparer.OrdinalIgnoreCase); // Mapped employees. Bucket everything by the EmployeeNumber. foreach (var employee in employees) { var siteEmployeeCodes = employee.SiteEmployees.Select(e => e.SiteEmployeeCode) .Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); var employeeShiftSupevisor = employeeShiftSupevisors?.FirstOrDefault(x => x.Employee.TnaEmployeeCode.IgnoreCaseEquals(employee.TnaEmployeeCode)); foreach (var siteEmployeeCode in filteredSiteEmployeeCodes) { if (siteEmployeeCode.ExistsInArray(siteEmployeeCodes)) { mappedSiteEmployeeCodes.AddIfNotContains(siteEmployeeCode); } } if (!filteredSiteEmployeeCodes.Any(x => x.ExistsInArray(siteEmployeeCodes))) { continue; } var orphanedShifts = GetOrphanedShifts(siteCode, isLtl, siteEmployeeCodes, knownTimeSheets.Where(x => x.TnaEmployeeCode.IgnoreCaseEquals(employee.TnaEmployeeCode)), startTime, endTime, transactionTypes, businessUnitType, employee, employeeShiftSupevisor); results.AddRange(orphanedShifts.Where(x => Math.Abs((x.EndTime - x.StartTime).TotalHours) <= 24)); var orphanShiftsToSplit = orphanedShifts.Where(x => Math.Abs((x.EndTime - x.StartTime).TotalHours) > 24); AddMultiDayShifts(orphanShiftsToSplit, results, _mapper); } // Unmapped employees. Bucket everything under the SiteEmployeeCode. foreach (var siteEmployeeCode in filteredSiteEmployeeCodes) { if (mappedSiteEmployeeCodes.Contains(siteEmployeeCode)) { // Already mapped continue; } var orphanedShifts = GetOrphanedShifts(siteCode, isLtl, new[] { siteEmployeeCode }, new EfficiencyTimeSheet[0], startTime, endTime, transactionTypes, businessUnitType); results.AddRange(orphanedShifts.Where(x => Math.Abs((x.EndTime - x.StartTime).TotalHours) <= 24)); var orphanShiftsToSplit = orphanedShifts.Where(x => Math.Abs((x.EndTime - x.StartTime).TotalHours) > 24); AddMultiDayShifts(orphanShiftsToSplit, results, _mapper); } return(results); }
internal static IEnumerable <EfficiencyShift> MapTimeSheetShifts([NotNull] this IEnumerable <EfficiencyTimeSheet> timeSheets, string siteCode, DateTime siteNow, [NotNull] Employee[] employees, [CanBeNull] EmployeeShiftSupevisor[] employeeShiftSupevisors, BusinessUnitType businessUnitType, IEnumerable <string> filteredSiteEmployeeCodes = null, EfficiencyTransactionType[] transactionTypes = null) { foreach (var timeSheet in timeSheets.Where(x => x.PunchInTime < siteNow)) { var employee = employees.FirstOrDefault(x => x.TnaEmployeeCode.IgnoreCaseEquals(timeSheet.TnaEmployeeCode)); var employeeShiftSupevisor = employeeShiftSupevisors?.FirstOrDefault(x => x.Employee.TnaEmployeeCode.IgnoreCaseEquals(timeSheet.TnaEmployeeCode)); var siteEmployeeCodes = employee?.SiteEmployees?.Where(x => x.SiteCode.IgnoreCaseEquals(siteCode))?.Select(x => x.SiteEmployeeCode) .Distinct(StringComparer.OrdinalIgnoreCase).ToArray() ?? new string[0]; if (siteEmployeeCodes.IsNotNullOrEmptyElements() && (filteredSiteEmployeeCodes == null || siteEmployeeCodes.Any(x => x.ExistsInArray(filteredSiteEmployeeCodes.ToArray())))) { yield return(new EfficiencyShift(employee, timeSheet, siteNow, siteEmployeeCodes, employeeShiftSupevisor, transactionTypes, businessUnitType)); } } }