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); } }
// stop cut public RespCutting(IDbName database, int binterfaceId, int beamCounter) { 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 bInterface = BeamCutQuery.GetBeamInterfaceById(binterfaceId); if (bInterface == null) { Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_STOP_CUTTING); return; } bInterface.Finish = true; bInterface.BeamCutCounter = beamCounter; bInterface.StopCutTime = DateTime.Now; if (!BeamCutQuery.UpdateBeamInterface(bInterface)) { Exception = new RespException(true, "Can not update BInterface", EKB_SYS_REQUEST.BEAM_STOP_CUTTING); return; } Exception = new RespException(false, "Stop cutting: OK", EKB_SYS_REQUEST.BEAM_STOP_CUTTING); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_STOP_CUTTING); } }
public RespSchedule(IDbName database, int machineId, int workerid) { BeamCutQuery = new BeamCutQuery(database); ScheduleQuery = new ScheduleQuery(database); BuildingQuery = new BuildingQuery(database); var orders = BeamCutQuery.GetBDeviceOrder(machineId, workerid, DateTime.Now.ToString("dd/MM/yyyy")); if (orders == null) { Exception = new RespException(true, "Order is empty", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } List <Schedule> schedules = new List <Schedule>(); foreach (var item in orders) { var temp = ScheduleQuery.GetSchedule(item); if (temp != null) { schedules.Add(temp); } } ScheduleList = new List <Schedule_t>(); foreach (var item in schedules) { ScheduleList.Add(new Schedule_t(database, item)); } Exception = new RespException(false, "Get Order: OK", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); }
/// <inheritdoc/> protected override string GetUpdateQuery( IDbName table, IColumnList columns, IColumn idColumn, object id, IColumn?versionColumn ) { // Get set list var set = GetSetListForUpdateQuery(columns); // Add version AddVersionToSetList(set, versionColumn); // Begin query var sql = $"UPDATE {Escape(table)} " + $"SET {JoinList(set, false)} " + $"WHERE {Escape(idColumn)} = {id}" ; // Add WHERE Version sql = AddVersionToWhere(sql, versionColumn); // Return query return($"{sql};"); }
public Schedule_t(IDbName database, int _id, string _poNumber, int _poQty, bool _finish = false) { id = _id; PoNumber = _poNumber; PoQty = _poQty; Cutting = _finish; }
/// <inheritdoc/> protected override string GetUpdateQuery( IDbName table, IColumnList columns, IColumn idColumn, object id ) => GetUpdateQuery(table, columns, idColumn, id, null);
public Unblock(IDbName _database) { database = _database; BuildingQuery = new BuildingQuery(database); SequenceQuery = new SequenceQuery(database); SysHistoryQuery = new SysHistoryQuery(database); ComponentQuery = new ComponentQuery(database); }
public EkanbanHisControl(EKanbanHis ekanbanHis, EKanbanDevice eKanbanDevice, IDbName _database) { InitializeComponent(); EKanbanHis = new EKanbanHis(); EKanbanHis = ekanbanHis; eKanbanTaskQuery = new EKanbanTaskQuery(_database); SysHistoryQuery = new SysHistoryQuery(_database); lbCartName.Text = eKanbanDevice.Name; }
public PoInfo(IDbName _database, Schedule _schedule) { BuildingQuery buildingQuery = new BuildingQuery(_database); id = _schedule.id; PoNumber = _schedule.PoNumber; Model = _schedule.Model; Article = _schedule.Article; ModelName = _schedule.ModelName; Quantity = _schedule.Quantity != null ? (int)_schedule.Quantity : 0; Line = buildingQuery.GetProductionLine(ShareFuncs.GetInt(_schedule.ProductionLine_Id)).LineName; }
public RespComponent(IDbName _database, int _scheduleId, int originalPoId) { try { ComponentQuery componentQuery = new ComponentQuery(_database); ScheduleQuery scheduleQuery = new ScheduleQuery(_database); SequenceQuery SequenceQuery = new SequenceQuery(_database); var schedule = scheduleQuery.GetSchedule(_scheduleId); var originalPo = SequenceQuery.GetOriginalPo(originalPoId); if (schedule == null) { if (originalPo == null) { Exception = new RespException(true, "Can not find original po", EKB_SYS_REQUEST.BEAM_GET_COMPONENT); return; } schedule = scheduleQuery.GetSchedule(originalPo); if (schedule == null) { Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_COMPONENT); return; } } var components = componentQuery.GetModelComponents(schedule.Model); if (components == null) { Exception = new RespException(true, "Can not find component list", EKB_SYS_REQUEST.BEAM_GET_COMPONENT); return; } components = components.OrderByDescending(i => i.CuttingType.id).ToList(); ComponentList = new List <Component_t>(); foreach (var item in components) { ComponentList.Add(new Component_t(item)); } Exception = new RespException(false, "Get component: Ok", EKB_SYS_REQUEST.BEAM_GET_COMPONENT); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_COMPONENT); } }
public Schedule_t(IDbName database, Schedule _scheule) { SequenceQuery sequenceQuery = new SequenceQuery(database); var po = sequenceQuery.GetOriginalPo(_scheule); if (po != null) { OriginalPoId = po.id; } id = _scheule.id; PoNumber = _scheule.PoNumber; PoQty = ShareFuncs.GetInt(_scheule.Quantity); }
public BDeviceCutTime(IDbName database, int deviceId, int totalCutTime) { BeamCutQuery = new BeamCutQuery(database); var statistic = BeamCutQuery.GetBMachineStatistic(deviceId, DateTime.Now); if (statistic == null) { statistic = BeamCutQuery.AddNewBcutStatistic(deviceId, DateTime.Now); } if (statistic.BDeviceCutTimeRecords != null) { foreach (var item in statistic.BDeviceCutTimeRecords) { TotalCutTime += ShareFuncs.GetInt(item.TotalCutTime); } } var lastRecord = BeamCutQuery.Get_DeviceLastRecord(deviceId); if (lastRecord != null) { DateTime updateTime = (DateTime)lastRecord.UpdateTime; if (updateTime.DayOfYear == DateTime.Now.DayOfYear && updateTime.Minute == DateTime.Now.Minute && updateTime.Hour == DateTime.Now.Hour) { // duplicate update detected Exception = new RespException(false, "The cut time has been recorded", EKB_SYS_REQUEST.CUT_TIME_RECORD); return; } } BDeviceCutTimeRecord record = new BDeviceCutTimeRecord { TotalCutTime = totalCutTime, BeamCutDevice_Id = deviceId, BMachineStatistic_Id = statistic.id, }; if (!BeamCutQuery.AddNewBCutTimeRecord(record)) { Exception = new RespException(true, "Add new record failed", EKB_SYS_REQUEST.CUT_TIME_RECORD); return; } TotalCutTime += totalCutTime; }
/// <inheritdoc/> protected override string GetCreateQuery( IDbName table, IColumnList columns ) { // Get columns var(col, par) = GetColumnsForCreateQuery(columns); // Build and return query return ($"INSERT INTO {Escape(table)} {JoinList(col, true)} " + $"VALUES {JoinList(par, true)}; " + "SELECT LASTVAL();" ); }
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); } }
/// <inheritdoc/> protected override string GetDeleteQuery( IDbName table, IColumn idColumn, object id, IColumn?versionColumn ) { // Begin query var sql = $"DELETE FROM {Escape(table)} " + $"WHERE {Escape(idColumn)} = {id}" ; // Add WHERE Version return(AddVersionToWhere(sql, versionColumn)); }
/// <inheritdoc/> protected override string GetRetrieveQuery( IDbName table, IColumnList columns, IColumn idColumn, object id ) { // Get columns var col = GetColumnsForRetrieveQuery(columns); // Build and return query return ($"SELECT {JoinList(col, false)} " + $"FROM {Escape(table)} " + $"WHERE {Escape(idColumn)} = {id};" ); }
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 RespBeamDevice(IDbName database, string sysCode, string name) { try { BeamCutQuery BeamCutQuery = new BeamCutQuery(database); var bdevice = BeamCutQuery.GetBeamCutDevice(sysCode, name); if (bdevice == null) { Exception = new RespException(true, "Beam machine not found", SYS_MODELS._ENUM.EKB_SYS_REQUEST.GET_DEVICE_INFO); return; } SystemCode = bdevice.MachineCode; Name = bdevice.Name; id = bdevice.id; } catch (Exception e) { Exception = new RespException(true, e.Message, SYS_MODELS._ENUM.EKB_SYS_REQUEST.GET_DEVICE_INFO); } }
public RespSize(IDbName _database, int seq1Id, int seq2Id) { try { SequenceQuery sequenceQuery = new SequenceQuery(_database); BeamCutQuery beamCutQuery = new BeamCutQuery(_database); List <OriginalPOsequence> SeqList = new List <OriginalPOsequence>(); var CloneSizes = beamCutQuery.GetBeamCutSizes(seq1Id, seq2Id); if (CloneSizes == null) { Exception = new RespException(true, "CloneSizes is NULL", EKB_SYS_REQUEST.BEAM_GET_SIZE); return; } SizeList = new List <Size_t>(); foreach (var size in CloneSizes) { SizeList.Add(new Size_t { SizeId = ShareFuncs.GetInt(size.SizeId), SizeQty = ShareFuncs.GetInt(size.SizeQty), CuttingQty = ShareFuncs.GetInt(size.CutQty), Finish = (size.SizeQty == size.CutQty ? true : false) }); RespTotalCuttingQty += ShareFuncs.GetInt(size.CutQty); RespTotalQty += ShareFuncs.GetInt(size.SizeQty); } Exception = new RespException(false, "Get Size: OK", EKB_SYS_REQUEST.BEAM_GET_SIZE); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_SIZE); } }
public SequenceQuery(IDbName _database) { database = _database; }
public SequenceContext(IDbName _database) : base(_database._SEQUENCE) { }
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); } }
public StockQuery(IDbName _database) { database = _database; }
public AutoScheule(IDbName _database) { database = _database; }
public ShoeContext(IDbName _database) : base(_database._COMPONENT) { }
public BLastCut(IDbName database, int bdeviceId, 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 bInterface = BeamCutQuery.GetLastInterface(bdeviceId); if (bInterface == null) { Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); bInterface = BeamCutQuery.GetBeamInterfaceById(bInterfaceId); if (bInterface == null) { Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); return; } } var bpo = BeamCutQuery.GetBeamCutPo(ShareFuncs.GetInt(bInterface.BeamCutPo_Id)); if (bpo == null) { Exception = new RespException(true, "Can not find clone Po", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); return; } var originalPo = SequenceQuery.GetOriginalPo(ShareFuncs.GetInt(bInterface.OriginalPo_Id)); if (originalPo == null) { Exception = new RespException(true, "Can not find Po", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); return; } BinterfaceId = bInterface.id; PoNumber = originalPo.PoNumber; StartSeq = ShareFuncs.GetInt(bInterface.StartSeqNo); StopSeq = ShareFuncs.GetInt(bInterface.StopSeqNo); if (bInterface.StartCutTime != null) { StartTime = ((DateTime)bInterface.StartCutTime).ToString("hh:mm tt, dd/MM/yyyy"); } if (bInterface.StopCutTime != null) { StopTime = ((DateTime)bInterface.StopCutTime).ToString("hh:mm tt, dd/MM/yyyy"); } CutQty = ShareFuncs.GetInt(bInterface.CuttingQty); CutTime = ShareFuncs.GetInt(bInterface.BeamCutCounter); Employee_Id = ShareFuncs.GetInt(bInterface.Employee_Id); Schedule_Id = ShareFuncs.GetInt(bInterface.Schedule_Id); BeamCutPo_Id = ShareFuncs.GetInt(bInterface.BeamCutPo_Id); BeamCutStartSeq_Id = ShareFuncs.GetInt(bInterface.BeamCutStartSeq_Id); Component_Id = ShareFuncs.GetInt(bpo.Component_Id); BeamCutStopSeq_Id = ShareFuncs.GetInt(bInterface.BeamCutStopSeq_Id); Finish = bInterface.Finish != null ? (bool)bInterface.Finish : false; PoQty = ShareFuncs.GetInt(originalPo.Quantity); OriginalPo_Id = ShareFuncs.GetInt(bInterface.OriginalPo_Id); var component = ComponentQuery.GetShoeComponent(ShareFuncs.GetInt(bpo.Component_Id)); if (component != null) { string comp = ShareFuncs.ConvertToUnSign(component.Reference); Component = comp; } Exception = new RespException(false, "Get last cut: OK", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); } }
public EmployeeContext(IDbName _database) : base(_database._EMPLOYEE) { }
public BuildingQuery(IDbName _database) { database = _database; }
public EKanbanResponse(IDbName _database, int _ekanbanDeviceId) { EKanbanTaskQuery eKanbanTaskQuery = new EKanbanTaskQuery(_database); SequenceQuery sequenceQuery = new SequenceQuery(_database); ComponentQuery componentQuery = new ComponentQuery(_database); var ekanbanDevice = eKanbanTaskQuery.GetEKanbanDevice(_ekanbanDeviceId); var _Interface = eKanbanTaskQuery.GetLastEKanbanInterface(_ekanbanDeviceId); SizeList = new List <SizeInfo>(); PartList = new List <PartInfo>(); List <OriginalSize> originalSizes = new List <OriginalSize>(); foreach (var item in _Interface.EKanbanLoadings) { var Seq = sequenceQuery.GetOriginalSequence(ShareFuncs.GetInt(item.OriginalSequence_Id)); TotalCartQty += ShareFuncs.GetInt(Seq.Quantity); foreach (var size in Seq.OriginalSizes) { originalSizes.Add(size); } } foreach (var item in originalSizes) { var foundSizes = SizeList.Where(i => i.SizeId == item.SizeId); if (foundSizes.Count() > 0) { foundSizes.First().SizeQty += ShareFuncs.GetInt(item.Quantity); } else { SizeList.Add(new SizeInfo(ShareFuncs.GetInt(item.SizeId), ShareFuncs.GetInt(item.Quantity))); } } Interface = new InterfaceInfo(_Interface); foreach (var item in _Interface.EkanbanComponents) { var Component = componentQuery.GetShoeComponent(ShareFuncs.GetInt(item.ShoeComponent_Id)); PartList.Add(new PartInfo(ShareFuncs.ConvertToUnSign(Component.Reference))); } //if (DateTime.Now.Hour == 17) //{ // if (DateTime.Now.Minute > 50) // { // ScreenOff = true; // ekanbanDevice.ScreenOff = true; // } //} //else //{ // if (DateTime.Now.Hour > 17) // { // ScreenOff = true; // ekanbanDevice.ScreenOff = true; // } //} //if (DateTime.Now.Hour == 6 && DateTime.Now.Minute < 45) //{ // ScreenOff = false; // ekanbanDevice.ScreenOff = false; //} ekanbanDevice.NetworkStatus = (int)SYS_MODELS._ENUM.SysActionCode.ONLINE; ekanbanDevice.LastOnline = DateTime.Now; eKanbanTaskQuery.UpdateEKanbanDevice(ekanbanDevice); if (ekanbanDevice.ScreenOff == null) { ScreenOff = false; } else { ScreenOff = (bool)ekanbanDevice.ScreenOff; } }
/// <inheritdoc/> protected override (string query, IQueryParametersDictionary param) GetQuery( IDbName table, IColumnList columns, IImmutableList <(IColumn column, Compare cmp, dynamic value)> predicates