예제 #1
0
 public static CUDView verifierInsertPKReturnMSQL(String action, List<String> result)
 {
     CUDView view = new CUDView();
     switch (action)
     {
         case "insert":
             if (result[1] == "sucess") { view.insert = true; view.insertPK = result[0]; }
             else { view.insert = false; view.errorMessage = result[0]; }
             break;
         default:
             break;
     }
     return view;
 }
예제 #2
0
 public static CUDView verifierInsertDeleteUpdate(String action, String result)
 {
     CUDView view = new CUDView();
     switch (action)
     {
         case "insert":
             if (result != "sucess") { view.insert = false; view.errorMessage = result; }
             else{ view.insert = true; }
             break;
         case "delete":
             if (result != "sucess") { view.delete = false; view.errorMessage = result; }
             else{ view.delete = true; }
             break;
         case "update":
             if (result != "sucess") { view.update = false; view.errorMessage = result; }
             else { view.update = true; }
             break;
         default:
             break;
     }
     return view;
 }
예제 #3
0
        /*Funcion: actualizar una receta
          Param: recipeId,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipe(RecipeUpdateView recipe, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeOldValues(recipe.RecipeId);
            String OldValues = "RecipeId: " + recipe.RecipeId;

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

            RecipeDao Dao = new RecipeDao();
            String state = Dao.updateRecipe(recipe);
            logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", RecipeEnable: " + recipe.RecipeEnable
                    ;
                auditservice.formUpdate(Action, NewValues, OldValues, audit);
            }

            return logic;
        }
예제 #4
0
        /*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;
        }
예제 #5
0
        /*Funcion: actualizar productos
          Param: ProductUpdateView,AuditDataFromWeb
          Return: Lista Units
          */
        public CUDView updateProduct(ProductUpdateView product, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getProductsOldValues(product.ProductLineId);
            String OldValues = "ProductId: " + product.ProductLineId;

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

            ProcessDao Dao = new ProcessDao();
            String state = Dao.updateProduct(product);
            logic=CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update Product";
                String newValues = "ProductId: " + product.ProductLineId;
                newValues = newValues + ", Product: " + product.ProductLineName;

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

            return logic;
        }
예제 #6
0
        /*Funcion: actualiza un Upn por operacion
          Param:  upnUpdateView, AuditDataFromWeb
          Return: Status
          */
        public CUDView updateUpnOperation(UpnOperationView upnUpdateView, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getUpnOperatoinOldValues(upnUpdateView.UpnId,upnUpdateView.ProcessId,upnUpdateView.OperationId);
            String OldValues = "UpnId: " + upnUpdateView.UpnId;

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

            UpnDao Dao = new UpnDao();
            String state = Dao.updateUpnOperation(upnUpdateView);
            logic=CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update upnOperation";
                String newValues = "UpnId: " + upnUpdateView.UpnId;
                newValues = newValues + ", RecipeId: " + upnUpdateView.RecipeId;
                newValues = newValues + ", Enable: " + upnUpdateView.Enable;

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

            return logic;
        }
예제 #7
0
        /*Funcion: actualiza un Upn
          Param:  UpnUpdateView, AuditDataFromWeb
          Return: Status
          */
        public CUDView updateUpn(UpnUpdateView upnUpdateView, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getUpnOldValues(upnUpdateView.UpnId);
            String OldValues = "UpnId: " + upnUpdateView.UpnId;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("UPNStatus") && row["UPNStatus"] != DBNull.Value) { OldValues = OldValues + ", Enable: " + (bool)row["UPNStatus"]; }
                if (auditDaoResult.Columns.Contains("UpnMultipleSessions") && row["UpnMultipleSessions"] != DBNull.Value) { OldValues = OldValues + ", UpnMultipleSession: " + (bool)row["UpnMultipleSessions"]; }
            }

            UpnDao Dao = new UpnDao();
            String state = Dao.updateUpn(upnUpdateView);
            logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update Upn";
                String NewValues = "UpnId: " + upnUpdateView.UpnId
                    + ", Enable: " + upnUpdateView.UpnStatus
                    + ", UpnMultipleSession: " + upnUpdateView.Multisession;

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

            return logic;
        }
예제 #8
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;
        }
예제 #9
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;
        }