public RespSchedule(IDbName database, string line, int month, string poNumber) { try { BeamCutQuery = new BeamCutQuery(database); ScheduleQuery = new ScheduleQuery(database); BuildingQuery = new BuildingQuery(database); var productionLine = BuildingQuery.FindProductionLine(line); if (productionLine == null) { Exception = new RespException(true, "Line name is not found", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } DateTime SearchTime = new DateTime(DateTime.Now.Year, month, DateTime.Now.Day); var scheduleclass = ScheduleQuery.GetScheduleClass(SearchTime); if (scheduleclass == null) { Exception = new RespException(true, "Invalid schedule time", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } var schedules = ScheduleQuery.GetSchedules(poNumber); if (schedules == null) { Exception = new RespException(true, "Sequence have no item", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } //var temp = schedules.Where(i => i.ScheduleClass_Id == scheduleclass.id); //if (temp.Count() > 0) // schedules = temp.ToList(); List <Schedule> newSchedule = new List <Schedule>(); foreach (var item in productionLine) { schedules.Where(i => i.ProductionLine_Id == item.id); if (schedules.Count() > 0) { newSchedule.AddRange(schedules.ToList()); } } newSchedule = newSchedule.Take(15).ToList(); ScheduleList = new List <Schedule_t>(); foreach (var item in newSchedule) { ScheduleList.Add(new Schedule_t(database, item)); } Exception = new RespException(false, "Get schedule: OK", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } }
public RespSchedule(IDbName database, string line, string poNumber) { try { BeamCutQuery = new BeamCutQuery(database); ScheduleQuery = new ScheduleQuery(database); BuildingQuery = new BuildingQuery(database); var productionLine = BuildingQuery.FindProductionLine(line); if (productionLine == null) { Exception = new RespException(true, "Line name is not found", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } var schedules = ScheduleQuery.GetSchedules(poNumber); if (schedules == null) { Exception = new RespException(true, "Sequence have no item", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } List <Schedule> newSchedule = new List <Schedule>(); foreach (var item in productionLine) { schedules.Where(i => i.ProductionLine_Id == item.id); if (schedules.Count() > 0) { newSchedule.AddRange(schedules.ToList()); } } newSchedule = newSchedule.Take(15).ToList(); ScheduleList = new List <Schedule_t>(); foreach (var item in newSchedule) { ScheduleList.Add(new Schedule_t(database, item)); } Exception = new RespException(false, "Get schedule: OK", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } }
public RespSchedule(IDbName database, string line, int month, int startId) { try { BeamCutQuery = new BeamCutQuery(database); ScheduleQuery = new ScheduleQuery(database); BuildingQuery = new BuildingQuery(database); var productionLine = BuildingQuery.FindProductionLine(line); DateTime SearchTime = new DateTime(DateTime.Now.Year, month, DateTime.Now.Day); if (productionLine == null) { Exception = new RespException(true, "Line name is not found", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } var schedules = ScheduleQuery.GetSchedules(SearchTime); if (schedules == null) { Exception = new RespException(true, $"Can not find the schedule for month:{month}", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } List <Schedule> newSchedule = new List <Schedule>(); foreach (var item in productionLine) { var temp = schedules.Where(i => i.ProductionLine_Id == item.id); if (temp.Count() > 0) { newSchedule.AddRange(temp.ToList()); } } ScheduleList = new List <Schedule_t>(); var tempSch = newSchedule.Where(i => i.id > startId).Take(15).ToList(); if (tempSch.Count() > 0) { newSchedule = newSchedule.Where(i => i.id > startId).Take(15).ToList(); } else { newSchedule = newSchedule.Take(15).ToList(); } ScheduleList = new List <Schedule_t>(); foreach (var item in newSchedule) { var bInterface = BeamCutQuery.GetBeamInterfaceByScheduleId(item.id); var sch = new Schedule_t(database, item); if (bInterface != null) { sch.Cutting = true; } ScheduleList.Add(sch); } Exception = new RespException(false, "Get schedule: OK", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } }