Beispiel #1
0
        /*
        Metodo que verifica que el usuario este autorizado en el active para ingresar al sistema
        */
        protected void buttonLogin_Click(object sender, EventArgs e)
        {
            String adPath = "LDAP://bsci.bossci.com"; //Fully-qualified Domain Name
            LdapAuthentication adAuth = new LdapAuthentication(adPath);
            try
            {
                if (true == adAuth.IsAuthenticated("BSCI", Login.Text, Password.Text))
                {
                    String groups = adAuth.GetGroups();

                    //Create the ticket, and add the groups.
                    bool isCookiePersistent = false;
                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, Login.Text,
                    DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent, groups);

                    //Encrypt the ticket.
                    String encryptedTicket = FormsAuthentication.Encrypt(authTicket);

                    //Create a cookie, and then add the encrypted ticket to the cookie as data.
                    HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

                    if (true == isCookiePersistent)
                        authCookie.Expires = authTicket.Expiration;

                    //Add the cookie to the outgoing cookies collection.
                    Response.Cookies.Add(authCookie);

                    //Save data in server audit trail
                    InsertActionServerAuditTrailView view = new InsertActionServerAuditTrailView();
                    AuditService auditService = new AuditService();
                    String reason = "User Log In";
                    String user = Context.User.Identity.Name;
                    view.Reason = reason;
                    view.StationIP = General.getIp(this.Page);
                    view.UserName = Login.Text;
                    view.Action = "Login user";
                    view.NewValues = "N/A";
                    auditService.insertAuditTrail(view);

                    //Redirect now.
                    Response.Redirect("~/Default.aspx",false);
                }
                else
                {
                    errorLabel.Text = "Authentication did not succeed. Check user name and password.";
                }
            }
            catch (Exception ex)
            {
                errorLabel.Text = "Error authenticating. " + ex.Message;
            }
        }
        /*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 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 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;
            }
        }
        /*Funcion: actualizar parametros
          Param: ParameterUpdateView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateParameter(ParameterUpdateView parameter, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getParameterByParameterID(parameter.ParameterId);
            String OldValues = "ParameterId: " + parameter.ParameterId;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("ParameterMinValue") && row["ParameterMinValue"] != DBNull.Value) { OldValues = OldValues + ", ParameterMinValue: " + Convert.ToDouble(row["ParameterMinValue"]); }
                if (auditDaoResult.Columns.Contains("ParameterName") && row["ParameterName"] != DBNull.Value) { OldValues = OldValues + ", ParameterName: " + row["ParameterName"].ToString(); }
                if (auditDaoResult.Columns.Contains("ParameterXPlot") && row["ParameterXPlot"] != DBNull.Value) { OldValues = OldValues + ", ParameterXPlot: " + (bool)row["ParameterXPlot"]; }
                if (auditDaoResult.Columns.Contains("ParameterYPlot") && row["ParameterYPlot"] != DBNull.Value) { OldValues = OldValues + ", ParameterYPlot: " + (bool)row["ParameterYPlot"]; }
                if (auditDaoResult.Columns.Contains("ParameterYPlotRange") && row["ParameterYPlotRange"] != DBNull.Value) { OldValues = OldValues + ", ParameterYPlotRange: " + Convert.ToInt32(row["ParameterYPlotRange"]); }
                if (auditDaoResult.Columns.Contains("ProcessId") && row["ProcessId"] != DBNull.Value) { OldValues = OldValues + ", ProcessId: " + Convert.ToInt32(row["ProcessId"]); }
                if (auditDaoResult.Columns.Contains("UnitId") && row["UnitId"] != DBNull.Value) { OldValues = OldValues + ", UnitId: " + row["UnitId"].ToString(); }

            }

            ParameterDao Dao = new ParameterDao();
            String state = Dao.updateParameter(parameter);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update parameter";
                String NewValues = "ParameterId: " + parameter.ParameterId
                    + ", ParameterMinValue: " + parameter.ParameterMinValue
                    + ", ParameterName: " + parameter.ParameterName
                    + ", ParameterXPlot: " + parameter.ParameterXPlot
                    + ", ParameterYPlot: " + parameter.ParameterYPlot
                    + ", ParameterYPlotRange: " + parameter.ParameterYPlotRange
                    + ", ProcessId: " + parameter.ProcessId
                    + ", UnitId: " + parameter.UnitId;
                auditservice.formUpdate(Action, NewValues, OldValues, 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: actualizar equipos de la receta
          Param: RecipeEquipmentView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipeEquipment(RecipeEquipmentView recipe, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeEquipmentByRecipeEquipMentIdAndRecipeId(recipe.RecipeId, recipe.RecipeEquipmentId);
            String OldValues = "RecipeId: " + recipe.RecipeId;
            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("RecipeEquipmentId") && row["RecipeEquipmentId"] != DBNull.Value) { OldValues = OldValues + ", RecipeEquipmentId: " + Convert.ToInt32(row["RecipeEquipmentId"]); }

                if (auditDaoResult.Columns.Contains("Link") && row["Link"] != DBNull.Value) { OldValues = OldValues + ", Link: " + (bool)row["Link"]; }

            }

            //Update
            RecipeDao Dao = new RecipeDao();
            String state = Dao.updateRecipeEquipment(recipe);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);
            //Fin update

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe equipment";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", RecipeEquipmentId: " + recipe.RecipeEquipmentId
                    + ", Link: " + recipe.Link;
                auditservice.formUpdate(Action, NewValues, OldValues, 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;
        }
Beispiel #9
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 #10
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: 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;
        }
        /*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;
        }
        /*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 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;
        }
Beispiel #16
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;
        }
        /*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;
        }
Beispiel #18
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;
        }
        /*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;
        }
        /*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: actualizar datos receta
          Param: RecipeUpdateValueView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipeValue(RecipeUpdateValueView recipe, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeParameterByRecipeIdAndParameterId(recipe.RecipeId, recipe.ParameterId);
            String OldValues = "RecipeId: " + recipe.RecipeId;

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

            }

            //Update
            RecipeDao Dao = new RecipeDao();
            String state = Dao.updateRecipeValue(recipe);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);
            //Fin update

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe parameter value";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", ParameterId: " + recipe.ParameterId
                    + ", ParameterValue: " + recipe.ParameterValue;

                auditservice.formUpdate(Action, NewValues, OldValues, 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;
        }
        /*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: 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;
        }
        /*Funcion: Actualizar Units
          Param: UnitView,AuditDataFromWeb
          Return: Status
          */
        public CUDView updateUnits(UnitView unit, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getUnitByUnitId(unit.UnitId);
            String OldValues = "UnitId: " + unit.UnitId;

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

            }

            ParameterDao Dao = new ParameterDao();
            String state = Dao.updateUnits(unit);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

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

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

            return logic;
        }
 private void accessReport(String report)
 {
     InsertActionServerAuditTrailView view = new InsertActionServerAuditTrailView();
     AuditService auditService = new AuditService();
     String reason = "User access " + report;
     String user = Context.User.Identity.Name;
     view.Reason = reason;
     view.StationIP = General.getIp(this.Page);
     view.UserName = user;
     view.Action = "View Report";
     view.NewValues = "N/A";
     auditService.insertAuditTrail(view);
 }