/*Funcion: insertar procesos
          Param: ProcessInsertView,AuditDataFromWeb
          Return: status
          */
        public CUDView insertProcess(ProcessInsertView process, AuditDataFromWeb audit)
        {
            ProcessDao Dao = new ProcessDao();
            String state = Dao.insertProcess(process);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new process";
                String NewValues = "ProcessName: " + process.ProcessName
                    + ", ProcessParameterSet: " + process.ProcessParameterSet
                    + ", ProcessPlotEnable: " + process.ProcessPlotEnable
                    + ", ProductLineId: " + process.ProductLineId;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
        /*Funcion: Insertar Units
          Param: UnitsInsertView,AuditDataFromWeb
          Return: Lista Units
          */
        public CUDView insertUnits(UnitsInsertView unit, AuditDataFromWeb audit)
        {
            ParameterDao Dao = new ParameterDao();
            String state = Dao.insertUnits(unit);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new unit";
                String NewValues = "UnitName: " + unit.UnitName
                    + ", UnitSymbol: " + unit.UnitSymbol;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
        /*Funcion: insertar parametros
          Param: ParameterInsertView,AuditDataFromWeb
          Return: status
          */
        public CUDView insertParameter(ParameterInsertView parameter, AuditDataFromWeb audit)
        {
            ParameterDao Dao = new ParameterDao();
            String state = Dao.insertParameter(parameter);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new parameter";
                String NewValues = "ParameterName: " + parameter.ParameterName
                    + ", ParameterMinValue: " + parameter.ParameterMinValue
                    + ", ParameterXPlot: " + parameter.ParameterXPlot
                    + ", ParameterYPlot: " + parameter.ParameterYPlot
                    + ", ParameterYPlotRange: " + parameter.ParameterYPlotRange
                    + ", ProcessId: " + parameter.ProcessId
                    + ", UnitId: " + parameter.UnitId;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
        /*Funcion: Insertar un parametro para la receta
          Param: RecipeParameterInsertView,AuditDataFromWeb
          Return: Status
          */
        public CUDView InsertRecipeParameter(RecipeParameterInsertView parameter, AuditDataFromWeb audit)
        {
            RecipeDao Dao = new RecipeDao();
            String state = Dao.InsertRecipeParameter(parameter);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert recipe parameter";

                String NewValues = "RecipeId: " + parameter.RecipeId
                    + ", ParameterId: " + parameter.ParameterId
                    + ", ParameterValue: " + parameter.ParameterValue;

                auditservice.formInsert(Action, NewValues, audit);
            }

            return logic;
        }
        /*Funcion: Insertar el equipo para una receta
          Param: RecipeEquipmentInsertView, AuditDataFromWeb
          Return: Status
          */
        public CUDView insertRecipeEquipment(RecipeEquipmentInsertView recipeEquipmentInsertView, AuditDataFromWeb audit)
        {
            RecipeDao Dao = new RecipeDao();
            String state = Dao.insertRecipeEquipment(recipeEquipmentInsertView);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert recipe equipment";

                String NewValues = "RecipeId: " + recipeEquipmentInsertView.RecipeId
                    + ", EquipmentId: " + recipeEquipmentInsertView.EquipmentId
                    + ", OperationId: " + recipeEquipmentInsertView.OperationId
                    + ", Link: " + recipeEquipmentInsertView.Link;

                auditservice.formInsert(Action, NewValues, audit);
            }

            return logic;
        }
        /*Funcion: insertar una receta
          Param: RecipeInsertView,AuditDataFromWeb
          Return: Lista RecipeParameterView
          */
        public CUDView insertRecipe(RecipeInsertView recipe, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            RecipeDao Dao = new RecipeDao();

            int operationProcessID = 0;
            DataTable DaoResultIsTest = Dao.isTest(recipe.OperationId);

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

            if (operationProcessID == 0)
            {
                int countRecipeTest = 0;
                DataTable DaoResultCountRecipeTest = Dao.hasRecipeTest();

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

                if (countRecipeTest > 0)
                {
                    logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", "There is already a recipe with 'test' operation.");
                }
                else
                {
                    List<String> state = Dao.insertRecipe(recipe);
                    logic = CUDVerifyLogic.verifierInsertPKReturnMSQL("insert", state);
                }
            }
            else
            {
                List<String> state = Dao.insertRecipe(recipe);
                logic = CUDVerifyLogic.verifierInsertPKReturnMSQL("insert", state);

            }
            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new recipe";

                String NewValues = "RecipeId: " + logic.insertPK
                    + ", RecipeEnable: " + recipe.RecipeEnable
                    + ", OperationId: " + recipe.OperationId
                    + ", ProcessId: " + recipe.ProcessId;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
        /*Funcion: Insertar productos
          Param: ProductLineName,AuditDataFromWeb
          Return: status
          */
        public CUDView insertProduct(String ProductLineName, AuditDataFromWeb audit)
        {
            ProcessDao Dao = new ProcessDao();
            String state = Dao.insertProduct(ProductLineName);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new ProductLineName";
                String NewValues = "ProductLineName: " + ProductLineName;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
        /*Funcion: Insertar una operaciom
          Param: OperationInsertView, AuditDataFromWeb
          Return: status
          */
        public CUDView insertOperation(OperationInsertView operation, AuditDataFromWeb audit)
        {
            OperationDao Dao = new OperationDao();

            operation.ID = getOperationID(operation);

            operation.OperationProcessId = getOperationProcessIdByLastProduct(operation);

            List<String> state = Dao.insertOperation(operation);

            CUDView logic = CUDVerifyLogic.verifierInsertPKReturnMSQL("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new operation";
                String NewValues = "OperationId: " + logic.insertPK
                     + ", ID: " + operation.ID
                    + ", OperationName: " + operation.OperationName
                    + ", OperationProcessId: " + operation.OperationProcessId
                    + ", OperationTypeId: " + operation.OperationTypeId
                    + ", ProcessId: " + operation.ProcessId
                    + ", ProductLineId: " + operation.ProductLineId;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
        /*Funcion: Insertar operacion de un equipo
          Param: OperationEquipmentInsertView, AuditDataFromWeb
          Return: status
          */
        public CUDView insertOperationEquipment(OperationEquipmentInsertView operation, AuditDataFromWeb audit)
        {
            OperationDao Dao = new OperationDao();
            String state = Dao.insertOperationEquipment(operation);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new equipment for operation";
                String NewValues = "OperationId: " + operation.OperationId
                    + ", EquipmentId: " + operation.EquipmentId;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
Beispiel #10
0
        /*Funcion: Inserta una operacion Upn
          Param:  UpnInsertOperationView, AuditDataFromWeb
          Return: Lista UpnOperationView
          */
        public CUDView insertUpnOperation(UpnInsertOperationView upnOperationView, AuditDataFromWeb audit)
        {
            UpnDao Dao = new UpnDao();
             String state = Dao.insertUpnOperation(upnOperationView);
             CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);
             if (logic.insert == true)
             {
             AuditService auditservice = new AuditService();
             String Action = "Insert new upn operation";
             String NewValues = "UpnId: " + upnOperationView.UpnId
                 + ", RecipeId: " + upnOperationView.RecipeId
                 + ", ProcessId: " + upnOperationView.ProcessId
                 + ", OperationId: " + upnOperationView.OperationId
                 + ", OperationEnable: " + upnOperationView.OperationEnable;

             auditservice.formInsert(Action, NewValues, audit);
             }
             return logic;
        }
Beispiel #11
0
        /*Funcion: Inserta un Upn
          Param:  upnInsertView, AuditDataFromWeb
          Return: status
          */
        public CUDView insertUpn(UpnInsertView upnInsertView, AuditDataFromWeb audit)
        {
            UpnDao Dao = new UpnDao();
            String state = Dao.insertUpn(upnInsertView);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state);

            if (logic.insert == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Insert new UPN";
                String NewValues = "UpnId: " + upnInsertView.UpnId
                    + ", ProductLineId: " + upnInsertView.ProductLineId
                    + ", UPNStatus: " + upnInsertView.UPNStatus
                    + ", UpnTypeId: " + upnInsertView.UpnTypeId
                    + ", UpnMultipleSession: " + upnInsertView.Multisession;

                auditservice.formInsert(Action, NewValues, audit);
            }
            return logic;
        }
        /*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;
        }
        /*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;
        }
        /*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;
            }
        }