예제 #1
0
        /*Funcion: obtiene los grupos de equipos
          Param:
          Return: status
          */
        public List<EquipmentGroupView> getEquipmentGroup()
        {
            EquipmentDao Dao = new EquipmentDao();
            DataTable DaoResult = Dao.getEquipmentGroup();
            List<EquipmentGroupView> ViewList = new List<EquipmentGroupView>();

            foreach (DataRow row in DaoResult.Rows)
            {
                EquipmentGroupView x = new EquipmentGroupView();
                if (DaoResult.Columns.Contains("EquipmentGroupId") && row["EquipmentGroupId"] != DBNull.Value) { x.EquipmentGroupId = Convert.ToInt32(row["EquipmentGroupId"]); }
                if (DaoResult.Columns.Contains("EquipmentGroupName") && row["EquipmentGroupName"] != DBNull.Value) { x.EquipmentGroupName = row["EquipmentGroupName"].ToString(); }

                ViewList.Add(x);
            }
            return ViewList;
        }
예제 #2
0
        /*Funcion: inserta una nueva marca
          Param: brand, audit
          Return: status
          */
        public CUDView insertBrand(string brand, AuditDataFromWeb audit)
        {
            EquipmentDao Dao = new EquipmentDao();
            String state = Dao.insertBrand(brand);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new Brand";
                String NewValues = "Brand: " + brand;
                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
예제 #3
0
 public List<EquipmentView> getEquipments()
 {
     EquipmentDao Dao = new EquipmentDao();
     DataTable DaoResult = Dao.getEquipments();
     return buildEquipment(DaoResult);
 }
예제 #4
0
        /*Funcion: actualizar equipos por grupos
          Param: EquipmentGroupView,AuditDataFromWeb
          Return: status
          */
        public CUDView UpdateEquipmentGroup(EquipmentGroupView groupEquipment, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getEquipmentGroupOldValues(groupEquipment.EquipmentGroupId);
            String OldValues = "EquipmentGroupId: " + groupEquipment.EquipmentGroupId;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("EquipmentGroupName") && row["EquipmentGroupName"] != DBNull.Value) { OldValues = OldValues + ", EquipmentGroupName: " + row["EquipmentGroupName"].ToString(); }
            }

            EquipmentDao Dao = new EquipmentDao();
            String state = Dao.updateEquipmentGroup(groupEquipment);
            logic= CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update EquipmentGroup";
                String newValues = "EquipmentGroupId: " + groupEquipment.EquipmentGroupId;
                newValues = newValues + ", EquipmentGroupName: " + groupEquipment.EquipmentGroupName;

                auditservice.formUpdate(Action, newValues, OldValues, audit);
            }

            return logic;
        }
예제 #5
0
        /*Funcion: actualizar equipos
          Param: EquipmentUpdateView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateEquipment(EquipmentUpdateView equipment, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getEquipmentOldValues(equipment.Id);
            String OldValues = "EquipmentId: " + equipment.Id;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("HMI") && row["HMI"] != DBNull.Value) { OldValues = OldValues + ", HMIAddress: " + row["HMI"].ToString(); }
                if (auditDaoResult.Columns.Contains("Location") && row["Location"] != DBNull.Value) { OldValues = OldValues + ", Location: " + row["Location"].ToString(); }
                if (auditDaoResult.Columns.Contains("PLC") && row["PLC"] != DBNull.Value) { OldValues = OldValues + ", PLCAddress: " + row["PLC"].ToString(); }
                if (auditDaoResult.Columns.Contains("PLCLink") && row["PLCLink"] != DBNull.Value) { OldValues = OldValues + ", PLCLink: " + row["PLCLink"].ToString(); }
                if (auditDaoResult.Columns.Contains("Enabled") && row["Enabled"] != DBNull.Value) { OldValues = OldValues + ", Status: " + row["Enabled"].ToString(); }
            }

            EquipmentDao Dao = new EquipmentDao();
            String state = Dao.updateEquipment(equipment);
            logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update Equipment";
                String newValues = "EquipmentId: " + equipment.Id;
                newValues = newValues + ", HMIAddress: " + equipment.HMIAddress;
                newValues = newValues + ", Location: " + equipment.Location;
                newValues = newValues + ", PLCAddress: " + equipment.PLCAddress;
                newValues = newValues + ", PLCLink: " + equipment.PLCLink;
                newValues = newValues + ", Status: " + equipment.Status;

                auditservice.formUpdate(Action, newValues, OldValues, audit);
            }

            return logic;
        }
예제 #6
0
 /*Funcion: buscar los equipos por el parametro de busqueda
   Param: parametro de busqueda
   Return: Lista de Equipos
   */
 public List<EquipmentView> searchEquipment(string partial)
 {
     EquipmentDao Dao = new EquipmentDao();
     DataTable DaoResult = Dao.searchEquipment(partial);
     return buildEquipment(DaoResult);
 }
예제 #7
0
        /*Funcion: Inserta Nuevos grupos de usuario
          Param: equipmentgroup, audit
          Return: status
          */
        public CUDView insertEquipmentGroup(string EquipmentGroup, AuditDataFromWeb audit)
        {
            EquipmentDao Dao = new EquipmentDao();
            String state = Dao.insertEquipmentGroup(EquipmentGroup);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new Equipment Group";
                String NewValues = "Equipment Group: " + EquipmentGroup;
                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
예제 #8
0
        /*Funcion: Insertar nuevos equipos
          Param: EquipmentInsertView,AuditDataFromWeb
          Return: status
          */
        public CUDView insertEquipment(EquipmentInsertView equipment, AuditDataFromWeb audit)
        {
            int isValid = 0;
            EquipmentDao Dao = new EquipmentDao();
            DataTable isEquipmentValid = Dao.isEquipmentValid(equipment);

            foreach (DataRow row in isEquipmentValid.Rows)
            {
                if (isEquipmentValid.Columns.Contains("equipmentInserted") && row["equipmentInserted"] != DBNull.Value) { isValid = Convert.ToInt32(row["equipmentInserted"]); }

            }

            //Se comprueba que no exista un EquipmentPLCAdress y un EquipmentHMIAdressIguales

            if (isValid == 1)
            {
                String state = Dao.insertEquipment(equipment);
                CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

                if (logic.insert == true)
                {
                    AuditService auditservice = new AuditService();
                    String Action = "Insert new equipment";
                    String NewValues = "EquipmentId: " + equipment.Id
                        + ", GroupId: " + equipment.GroupId
                        + ", HMIAddress: " + equipment.HMIAddress
                        + ", Location: " + equipment.Location
                        + ", Model: " + equipment.Model
                        + ", PLCAddress: " + equipment.PLCAddress
                        + ", PLCLink: " + equipment.PLCLink
                        + ", Status: " + equipment.Status;

                    auditservice.formInsert(Action, NewValues, audit);
                }
                return logic;
            }
            else
            {
                CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", "errHMIPLC");
                return logic;
            }
        }