public static MachineDTO GetMachine(int machineId) { MachineDTO retVal = null; using (VpnManagerEntities entities = new VpnManagerEntities()) { string tbName = TargetTable.Machine.ToString(); retVal = (from m in entities.Machine where m.Id == machineId select new MachineDTO { Id = m.Id, Name = m.Name, IPAddress = m.IpAddress, Username = m.Username, Password = m.Password, PingResponseEnabled = m.PingResponseEnabled.Value, IdLastConnectedUser = m.IdLastConnectedUser.HasValue ? m.IdLastConnectedUser.Value : 0, LastSuccessfullConnection = m.LastSuccessfulConnection.Value, IdPreferredConnectionType = m.IdPreferredConnectionType, ExtensionCollection = (from eo in entities.ExtensionObjects where eo.IdTargetElement == m.Id && eo.TargetTableName == tbName select new ExtensionObjectDTO { Name = eo.Name, Value = eo.Value }) }).FirstOrDefault(); } return(retVal); }
public MachineUIDM LoadMachine(NZString MachineNo) { MachineBIZ biz = new MachineBIZ(); MachineDTO dto = biz.LoadMachine(MachineNo); return(MapDTOToModel(dto)); }
public IActionResult changeMachineTypeOfaMachine([FromRoute] String machineName, [FromRoute] String machineTypeName) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var machineDB = _IMachineRepository.SelectByName(machineName); if (machineDB != null) { var machineTypeDB = _IMachineTypeRepository.SelectByName(machineTypeName); if (machineTypeDB != null) { machineDB.machineType = machineTypeDB; bool update = _IMachineRepository.Update(machineDB); if (update) { MachineDTO machineDTO = MachineDTO.generateDto(machineDB); return(Ok(machineDTO)); } } } return(NotFound()); }
public int AddNew(MachineDTO dtoMachine) { MachineValidator validator = new MachineValidator(); validator.ValidateBeforeSaveNew(dtoMachine); Database db = CommonLib.Common.CurrentDatabase; db.KeepConnection = true; db.BeginTransaction(); try { MachineDAO daoMachine = new MachineDAO(CommonLib.Common.CurrentDatabase); daoMachine.AddNew(null, dtoMachine); db.Commit(); return(1); } catch (Exception err) { db.Rollback(); throw err; } finally { if (db.DBConnectionState == ConnectionState.Open) { db.Close(); } } }
public ActionResult <MachineDTO> GetMachineByName(String id) { var machine = _IMachineRepository.SelectByName(id); MachineDTO p = MachineDTO.generateDto(machine); return(Ok(p)); }
public List <MachineDTO> SelectAll(List <string> machindIDs) { List <MachineDTO> list = new List <MachineDTO>(); // 매개변수 생성 StringBuilder sbValues = new StringBuilder(); foreach (string item in machindIDs) { sbValues.Append(string.Format("OR MachineID = '{0}' ", item)); } StringBuilder sb = new StringBuilder(); sb.Append("SELECT MachineID, isRunning, ifnull(runningTodo, 0) runningTodo, ifnull(defectRateAlarm, 0) defectRateAlarm FROM MACHINE WHERE 1=0 "); sb.Append(sbValues.ToString() + "; "); MySqlCommand comm = new MySqlCommand(sb.ToString(), conn); MySqlDataReader reader = comm.ExecuteReader(); MachineDTO dto; while (reader.Read()) { dto = new MachineDTO() { MachineID = reader["MachineID"].ToString(), IsRunning = Convert.ToInt32(reader["isRunning"]), RunningTodo = Convert.ToInt32(reader["runningTodo"]), defectRateAlarm = Convert.ToDouble(reader["defectRateAlarm"]) }; list.Add(dto); } return(list); }
private void frm_OnClientConnection(int IdMachine) { if (_connetion != null) { MachineDTO machine = Machines[IdMachine];//(from x in Machines where Machines.Keys == IdMachine).ToList().FirstOrDefault(); ConnectionTypeDTO conntype = ListConnectionsType.Values.Where(f => f.Id == machine.IdPreferredConnectionType).FirstOrDefault(); if (conntype.Name.ToUpper() == "RDP") { if (conntype.Extensions.Keys.Contains("cmdstart")) { OnInfoFromCore(String.Format("Try to connecting with {0}", machine.Name), false); Process.Start(conntype.Extensions["cmdstart"].ToString(), string.Format("/v:{0}", machine.IPAddress)); } } else { if (conntype.Name.ToUpper() == "VNC") { if (conntype.Extensions.Keys.Contains("cmdstart")) { OnInfoFromCore(String.Format("Try to connecting with {0}", machine.Name), false); Process.Start(conntype.Extensions["cmdstart"].ToString(), machine.IPAddress.ToString() + " -password " + machine.Password.ToString()); } } } } else { OnInfoFromCore("Controller: You're not Connected to any VPN!", false); } }
public void SaveChanges() { Logger.AddTrace("Saving Machines Configuration"); MachineManagerServiceClient proxy = new MachineManagerServiceClient(); try { proxy.DeleteAllMachines(); foreach (Machine machine in this.Machines.Items) { ObjectMapper mapper = new ObjectMapper(typeof(Machine), typeof(MachineDTO)); MachineDTO machineDTO = mapper.Map(machine, false) as MachineDTO; bool machineSaved = proxy.AddMachine(machineDTO); Logger.AddTrace(string.Format("Machine {0} saved: {1}", machine.Name, machineSaved)); } bool saved = proxy.SaveChanges(); Logger.AddTrace(string.Format("Machines saved: {0}", saved)); } catch (Exception e) { Logger.AddException(e); } finally { proxy.Close(); } }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <exception cref="EVOFramework.ValidateException"><c>ValidateException</c>.</exception> /// <exception cref="EVOFramework.BusinessException"><c>BusinessException</c>.</exception> public void SaveUpdate(MachineUIDM data) { MachineDTO dto = MapModelToDTO(data); MachineBIZ biz = new MachineBIZ(); biz.SaveUpdate(dto); }
public ActionResult <MachineDTO> PostMachine(MachineDTO machineDTO) { MachineType machineType = _IMachineTypeRepository.Select(machineDTO.machineTypeId); Machine machine = new Machine(new Designation(machineDTO.designation), machineType, new Model(machineDTO.model), new Location(machineDTO.location_factory, machineDTO.location_floor, machineDTO.location_section), new Position(machineDTO.position), new Capacity(machineDTO.capacity)); _IMachineRepository.Insert(machine); return(CreatedAtAction(nameof(GetMachineByID), new { id = machine.Id }, machine)); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <exception cref="EVOFramework.ValidateException"><c>ValidateException</c>.</exception> /// <exception cref="EVOFramework.BusinessException"><c>BusinessException</c>.</exception> public void SaveNew(MachineUIDM data) { MachineDTO dto = MapModelToDTO(data); MachineBIZ biz = new MachineBIZ(); biz.AddNew(dto); }
public ActionResult <Machine> PostMachine(MachineDTO DTO) { Machine machine = new Machine(DTO.MachineTypeId, DTO.ProductionLineId); _machineRepository.Add(machine); _machineRepository.SaveChanges(); return(CreatedAtAction(nameof(GetMachine), new { id = machine.Id }, machine)); }
public int SaveUpdate(MachineDTO data) { MachineValidator validator = new MachineValidator(); validator.ValidateBeforeSaveUpdate(data); MachineDAO dao = new MachineDAO(CommonLib.Common.CurrentDatabase); return(dao.UpdateWithoutPK(null, data)); }
/// <summary> /// Insert new record into database. /// </summary> /// <param name="database"></param> /// <param name="data"></param> /// <returns></returns> public int AddNew(Database database, MachineDTO data) { Database db = UseDatabase(database); StringBuilder sb = new StringBuilder(); #region SQL Statement sb.AppendLine(" INSERT INTO " + data.TableName + "("); sb.AppendLine(" " + MachineDTO.eColumns.CRT_BY); sb.AppendLine(" ," + MachineDTO.eColumns.CRT_DATE); sb.AppendLine(" ," + MachineDTO.eColumns.CRT_MACHINE); sb.AppendLine(" ," + MachineDTO.eColumns.UPD_BY); sb.AppendLine(" ," + MachineDTO.eColumns.UPD_DATE); sb.AppendLine(" ," + MachineDTO.eColumns.UPD_MACHINE); sb.AppendLine(" ," + MachineDTO.eColumns.MACHINE_CD); sb.AppendLine(" ," + MachineDTO.eColumns.MACHINE_TYPE); sb.AppendLine(" ," + MachineDTO.eColumns.PROCESS_CD); sb.AppendLine(" ," + MachineDTO.eColumns.MACHINE_GROUP); sb.AppendLine(" ," + MachineDTO.eColumns.PROJECT); sb.AppendLine(" ," + MachineDTO.eColumns.REMARK); sb.AppendLine(" ," + MachineDTO.eColumns.OLD_DATA); sb.AppendLine(") VALUES("); sb.AppendLine(" @CRT_BY"); sb.AppendLine(" ,GETDATE()"); sb.AppendLine(" ,@CRT_MACHINE"); sb.AppendLine(" ,@UPD_BY"); sb.AppendLine(" ,GETDATE()"); sb.AppendLine(" ,@UPD_MACHINE"); sb.AppendLine(" ,@MACHINE_CD"); sb.AppendLine(" ,@MACHINE_TYPE"); sb.AppendLine(" ,@PROCESS_CD"); sb.AppendLine(" ,@MACHINE_GROUP"); sb.AppendLine(" ,@PROJECT"); sb.AppendLine(" ,@REMARK"); sb.AppendLine(" ,@OLD_DATA"); sb.AppendLine(" )"); #endregion DataRequest req = new DataRequest(sb.ToString()); #region Parameters req.Parameters.Add("@CRT_BY", DataType.NVarChar, data.CRT_BY.Value); req.Parameters.Add("@CRT_MACHINE", DataType.NVarChar, data.CRT_MACHINE.Value); req.Parameters.Add("@UPD_BY", DataType.NVarChar, data.UPD_BY.Value); req.Parameters.Add("@UPD_MACHINE", DataType.NVarChar, data.UPD_MACHINE.Value); req.Parameters.Add("@MACHINE_CD", DataType.NVarChar, data.MACHINE_CD.Value); req.Parameters.Add("@MACHINE_TYPE", DataType.NVarChar, data.MACHINE_TYPE.Value); req.Parameters.Add("@PROCESS_CD", DataType.NVarChar, data.PROCESS_CD.Value); req.Parameters.Add("@MACHINE_GROUP", DataType.NVarChar, data.MACHINE_GROUP.Value); req.Parameters.Add("@PROJECT", DataType.NVarChar, data.PROJECT.Value); req.Parameters.Add("@REMARK", DataType.NVarChar, data.REMARK.Value); req.Parameters.Add("@OLD_DATA", DataType.Default, data.OLD_DATA.Value); #endregion return(db.ExecuteNonQuery(req)); }
public List <MachineDTO> GetAllMachine() { var q = _IMachineRepository.SelectAll().ToList(); List <MachineDTO> list = new List <MachineDTO>(); foreach (Machine p in q) { list.Add(MachineDTO.generateDto(p)); } return(list); }
/// <summary> /// Check exist before manipulate data. If found record will update data. Otherwise insert new data. /// </summary> /// <param name="database"></param> /// <param name="data"></param> /// <returns></returns> public int AddNewOrUpdate(Database database, MachineDTO data) { Database db = UseDatabase(database); if (Exist(database, data.MACHINE_CD)) { return(UpdateWithoutPK(db, data)); } return(AddNew(db, data)); }
public async Task <Machine> CreateMachine(MachineDTO machineDTO) { var machineTypeId = Guid.Parse(machineDTO.MachineType); var machineType = await _machineTypeService.getMachineType(machineTypeId); var machineBrand = new MachineBrand(machineDTO.MachineBrand); var machineModel = new MachineModel(machineDTO.MachineModel); var machineLocation = new MachineLocation(machineDTO.MachineLocation); var machine = new Machine(machineType, machineBrand, machineModel, machineLocation); await _machineRepository.Create(machine); return(machine); }
public IActionResult PutMachine(int id, MachineDTO DTO) { if (id != _machineRepository.GetBy(id).Id) { return(BadRequest()); } Machine machine = new Machine(DTO.MachineTypeId, DTO.ProductionLineId); machine.Position = DTO.Position; _machineRepository.Update(machine); _machineRepository.SaveChanges(); return(NoContent()); }
public bool AddMachine(MachineDTO machine) { Logger.AddTrace("Adding Machine Configuration"); try { _machines.Items.Add(machine); return(true); } catch (Exception e) { Logger.AddException(e); return(false); } }
public IEnumerable <PanneDTO> GetPanneDTO() { var listpanne = mediator.Send(new GetListGenericQuery <Panne> (condition: null, includes: null)).Result.Select(v => mapper.Map <PanneDTO>(v)); var machines = _machineRepository.GetMachines().Result.ToList(); var list = new List <PanneDTO>(); foreach (var item in listpanne) { MachineDTO machine = machines.Find(x => x.id_machine == item.id_machine); item.labelMachine = machine.label; list.Add(item); } return(list); }
private MachineDTO MapModelToDTO(MachineUIDM data) { MachineDTO dto = new MachineDTO(); dto.MACHINE_CD = data.MACHINE_CD; dto.MACHINE_TYPE = data.MACHINE_TYPE; dto.PROCESS_CD = data.PROCESS_CD; dto.MACHINE_GROUP = data.MACHINE_GROUP; dto.PROJECT = data.PROJECT; dto.REMARK = data.REMARK; dto.CRT_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dto.CRT_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine; dto.UPD_BY = CommonLib.Common.CurrentUserInfomation.UserCD; dto.UPD_MACHINE = CommonLib.Common.CurrentUserInfomation.Machine; dto.OLD_DATA = new NZInt(null, 0); return(dto); }
public async Task <ActionResult <MachineDTO> > CreateMachine(MachineDTO machineDTO) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var machine = await _serviceMachine.CreateMachine(machineDTO); return(CreatedAtAction("CreateMachine", _mapper.Map <Machine, MachineDTO>(machine))); } catch (KeyNotFoundException exception) { return(NotFound(exception.Message)); } }
private MachineUIDM MapDTOToModel(MachineDTO data) { MachineUIDM model = new MachineUIDM(); model.MACHINE_CD = data.MACHINE_CD; model.MACHINE_TYPE = data.MACHINE_TYPE; model.PROCESS_CD = data.PROCESS_CD; model.MACHINE_GROUP = data.MACHINE_GROUP; model.PROJECT = data.PROJECT; model.REMARK = data.REMARK; model.CRT_BY = data.CRT_BY; model.CRT_MACHINE = data.CRT_MACHINE; model.CRT_DATE = data.CRT_DATE; model.UPD_BY = data.UPD_BY; model.UPD_MACHINE = data.UPD_MACHINE; model.UPD_DATE = data.UPD_DATE; return(model); }
/// <summary> /// Update record by using the table's primary key. /// </summary> /// <param name="database"></param> /// <param name="data">Data which to update.</param> /// <param name="oldMACHINE_CD">Old Key #1</param> /// <returns></returns> public int UpdateWithPK(Database database, MachineDTO data, String oldMACHINE_CD) { Database db = UseDatabase(database); StringBuilder sb = new StringBuilder(); #region SQL Statement sb.AppendLine(" UPDATE " + data.TableName); sb.AppendLine(" SET "); sb.AppendLine(" " + MachineDTO.eColumns.UPD_BY + "=@UPD_BY"); sb.AppendLine(" ," + MachineDTO.eColumns.UPD_DATE + "=GETDATE()"); sb.AppendLine(" ," + MachineDTO.eColumns.UPD_MACHINE + "=@UPD_MACHINE"); sb.AppendLine(" ," + MachineDTO.eColumns.MACHINE_CD + "=@MACHINE_CD"); sb.AppendLine(" ," + MachineDTO.eColumns.MACHINE_TYPE + "=@MACHINE_TYPE"); sb.AppendLine(" ," + MachineDTO.eColumns.PROCESS_CD + "=@PROCESS_CD"); sb.AppendLine(" ," + MachineDTO.eColumns.MACHINE_GROUP + "=@MACHINE_GROUP"); sb.AppendLine(" ," + MachineDTO.eColumns.PROJECT + "=@PROJECT"); sb.AppendLine(" ," + MachineDTO.eColumns.REMARK + "=@REMARK"); sb.AppendLine(" ," + MachineDTO.eColumns.OLD_DATA + "=@OLD_DATA"); sb.AppendLine(" WHERE "); sb.AppendLine(" " + MachineDTO.eColumns.MACHINE_CD + "=@oldMACHINE_CD"); #endregion DataRequest req = new DataRequest(sb.ToString()); #region Parameters req.Parameters.Add("@UPD_BY", DataType.NVarChar, data.UPD_BY.Value); req.Parameters.Add("@UPD_MACHINE", DataType.NVarChar, data.UPD_MACHINE.Value); req.Parameters.Add("@MACHINE_CD", DataType.NVarChar, data.MACHINE_CD.Value); req.Parameters.Add("@MACHINE_TYPE", DataType.NVarChar, data.MACHINE_TYPE.Value); req.Parameters.Add("@PROCESS_CD", DataType.NVarChar, data.PROCESS_CD.Value); req.Parameters.Add("@MACHINE_GROUP", DataType.NVarChar, data.MACHINE_GROUP.Value); req.Parameters.Add("@PROJECT", DataType.NVarChar, data.PROJECT.Value); req.Parameters.Add("@REMARK", DataType.NVarChar, data.REMARK.Value); req.Parameters.Add("@OLD_DATA", DataType.Default, data.OLD_DATA.Value); req.Parameters.Add("@oldMACHINE_CD", DataType.NVarChar, oldMACHINE_CD); #endregion return(db.ExecuteNonQuery(req)); }
public List <MachineDTO> SelectAll() { List <MachineDTO> list = new List <MachineDTO>(); string sql = "SELECT MachineID, isRunning, ifnull(runningTodo, 0) runningTodo, ifnull(defectRateAlarm, 0) defectRateAlarm FROM MACHINE; "; MySqlCommand comm = new MySqlCommand(sql, conn); MySqlDataReader reader = comm.ExecuteReader(); MachineDTO dto; while (reader.Read()) { dto = new MachineDTO() { MachineID = reader["MachineID"].ToString(), IsRunning = Convert.ToInt32(reader["isRunning"]), RunningTodo = Convert.ToInt32(reader["runningTodo"]), defectRateAlarm = Convert.ToInt32(reader["defectRateAlarm"]) }; list.Add(dto); } return(list); }
public void ValidateBeforeSaveNew(MachineDTO dtoMachine) { //ValidateException validateException = new ValidateException(); //ErrorItem errorItem = null; //#region mandatory check //errorItem = CheckEmptyMachineNo(dtoMachine.MACHINE_CD); //if (errorItem != null) // validateException.AddError(errorItem); //errorItem = CheckEmptyMachineType(dtoMachine.MACHINE_TYPE); //if (errorItem != null) // validateException.AddError(errorItem); //errorItem = CheckEmptyProcess(dtoMachine.PROCESS_CD); //if (errorItem != null) // validateException.AddError(errorItem); //errorItem = CheckEmptyMachineGroup(dtoMachine.MACHINE_GROUP); //if (errorItem != null) // validateException.AddError(errorItem); //errorItem = CheckEmptyProject(dtoMachine.PROJECT); //if (errorItem != null) // validateException.AddError(errorItem); //validateException.ThrowIfHasError(); //#endregion BusinessException businessException = CheckMachineExist(dtoMachine.MACHINE_CD); if (businessException != null) { throw businessException; } }
public void Add(MachineDTO machineDTO) { var db=new DummyDatabase(); db.submit(machineDTO); }
public void submit(MachineDTO machineDTO) { }
public JsonResult Machine(int id) { MachineDTO machine = _machineRepository.LoadWithBrandSection(id); return(Json(machine, JsonHelper.SerializerSettings)); }
public string GetMachineId(MachineDTO machineDTO) { return string.Format("the machine name is {0}", machineDTO.MachineID); }
public void EnsureMachinGetSetAndDTOWorks() { List <Operations> ops = new List <Operations>(); Operations op1 = new Operations { designation = new Designation { designation = "Op2" }, ToolDetails = new Details { Det = "teste2" }, Dur = new Duration { dur = 232 } }; Operations op2 = new Operations { designation = new Designation { designation = "Op2" }, ToolDetails = new Details { Det = "teste2" }, Dur = new Duration { dur = 232 } }; Operations op3 = new Operations { designation = new Designation { designation = "Op3" }, ToolDetails = new Details { Det = "teste233" }, Dur = new Duration { dur = 2323333 } }; ops.Add(op1); ops.Add(op2); ops.Add(op3); Machine machine = new Machine( new Designation("designation1"), new MachineType(new Designation("machineType1"), ops), new Model("model1"), new Location("factory1", "floor1", "section1"), new Position(1), new Capacity(1)); MachineDTO machineDTO = new MachineDTO( machine.Id, machine.designation.designation, 1, machine.model.model, machine.location.factory, machine.location.section, machine.location.floor, machine.position.position, machine.capacity.capacity ); Assert.Equal(machine.designation.designation, machineDTO.designation); Assert.Equal(machine.model.model, machineDTO.model); Assert.Equal(machine.location.factory, machineDTO.location_factory); Assert.Equal(machine.location.floor, machineDTO.location_floor); Assert.Equal(machine.location.section, machineDTO.location_section); }
public void Update(MachineDTO item) { item.TimeStamps = DateTime.Now; _unitOfWork.EFRepository <Machine>().Update(_mapper.Map <Machine>(item)); }
public void Create(MachineDTO item) { item.Id = Guid.NewGuid().ToString(); item.TimeStamps = DateTime.Now; _unitOfWork.EFRepository <Machine>().CreateAsync(_mapper.Map <Machine>(item)); }