public RespUserInfo(IDbName database, string rfid) { employeeQuery = new EmployeeQuery(database); var employee = employeeQuery.GetEmployee(rfid); if (employee == null) { Exception = new RespException(true, "Invalid RFID number", EKB_SYS_REQUEST.GET_USER_INFO); return; } id = employee.id; UserName = ShareFuncs.ConvertToUnSign(employee.Name); Pass = true; UserCode = employee.UserCode; UserRFID = employee.RFID_Code; Department = employee.Department.Code; JobTitle = employee.JobTitle.Job; }
public RespUserInfo(IDbName database, NewUser new_user) { employeeQuery = new EmployeeQuery(database); var checkUser = employeeQuery.GetEmployee(new_user.RFID); if (checkUser != null) { Exception = new RespException(true, "Worker has been added", EKB_SYS_REQUEST.GET_USER_INFO); return; } var temp1 = employeeQuery.GetEmployee(new_user.Code); int id = 0; if (temp1 != null) { temp1.RFID_Code = new_user.RFID; employeeQuery.UpdateEmployee(temp1); id = temp1.id; } else { var dep = employeeQuery.GetDepartment(new_user.Dep); if (dep == null) { dep = employeeQuery.AddNewDepartment(new_user.Dep); if (dep == null) { Exception = new RespException(true, "Can not add new department", EKB_SYS_REQUEST.GET_USER_INFO); return; } } Employee employee = new Employee { Name = new_user.Name, RFID_Code = new_user.RFID, Department_Id = dep.id, Position_Id = 3, JobTitle_Id = 2, Building_Id = 1, UserCode = new_user.Code, }; var NewEmployee = employeeQuery.AddNewBeamWorker(employee); if (NewEmployee == null) { Exception = new RespException(true, "Can not add new user", EKB_SYS_REQUEST.GET_USER_INFO); return; } id = NewEmployee.id; } var empl = employeeQuery.GetEmployee(id); id = empl.id; UserName = ShareFuncs.ConvertToUnSign(empl.Name); Pass = true; UserCode = empl.UserCode; UserRFID = empl.RFID_Code; Department = empl.Department.Code; JobTitle = empl.JobTitle.Job; }
// start cutting construction public RespCutting(IDbName database, int deviceId, int workerId, int clonePoId, int seq1Id, int seq2Id, int binterfaceId) { BeamCutQuery = new BeamCutQuery(database); StockQuery = new StockQuery(database); EmployeeQuery = new EmployeeQuery(database); SequenceQuery = new SequenceQuery(database); ScheduleQuery = new ScheduleQuery(database); ComponentQuery = new ComponentQuery(database); try { var worker = EmployeeQuery.GetEmployee(workerId); if (worker == null) { Exception = new RespException(true, "Invalid worker Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var bdevice = BeamCutQuery.GetBeamCutDevice(deviceId); if (bdevice == null) { Exception = new RespException(true, "Invalid device Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var clonePo = BeamCutQuery.GetBeamCutPo(clonePoId); if (clonePo == null) { Exception = new RespException(true, "Invalid clone Po Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var originalPo = SequenceQuery.GetOriginalPo(clonePo.OriginalPo_Id); if (originalPo == null) { Exception = new RespException(true, "Can not find original po", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var component = ComponentQuery.GetShoeComponent(clonePo.Component_Id); if (component == null) { Exception = new RespException(true, "Can not find component", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var schedule = ScheduleQuery.GetSchedule(originalPo); if (schedule == null) { Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var order = BeamCutQuery.GetBDeviceOrder(originalPo, deviceId); var startSeq = BeamCutQuery.GetBeamCutSeq(seq1Id); var stopSeq = BeamCutQuery.GetBeamCutSeq(seq2Id); if (startSeq == null || stopSeq == null) { Exception = new RespException(true, "Invalid clone Seq Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } int[] qty = BeamCutQuery.GetTotalSelectSequenceQty(startSeq, stopSeq); if (qty == null) { qty = new int[] { 0, 0 } } ; int bId = binterfaceId; BeamCutInterface binterface = BeamCutQuery.GetBeamInterfaceById(binterfaceId); int scheduleId = 0; if (schedule != null) { scheduleId = schedule.id; } if (binterface == null) { binterface = new BeamCutInterface { Employee_Id = workerId, BeamCutDevice_Id = deviceId, BeamCutPo_Id = clonePoId, OriginalPo_Id = clonePo.OriginalPo_Id, BeamCutStartSeq_Id = seq1Id, BeamCutStopSeq_Id = seq2Id, TotalSelectedQty = qty[0], TotalSelectCutQty = qty[1], Schedule_Id = scheduleId, StartSeqNo = startSeq.SequenceNo, StopSeqNo = stopSeq.SequenceNo, StartCutTime = DateTime.Now, CuttingQty = 0, BeamCutCounter = 0, BDeviceOrder_Id = order != null ? order.id : 0, }; var beamInterface = BeamCutQuery.AddNewBeamCutInterface(binterface); if (beamInterface == null) { Exception = new RespException(true, "Add new BInterface error", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } bId = beamInterface.id; } StockMeasure stockMeasure = StockQuery.GetStockMeasure(schedule); if (stockMeasure == null) { var stock = StockQuery.AddNewStockMeasure(schedule); } Exception = new RespException(false, "Start cutting: OK", EKB_SYS_REQUEST.BEAM_START_CUTTING); InterfaceId = bId; } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_START_CUTTING); } }