Exemplo n.º 1
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                RSMDataModelDataContext context = new RSMDataModelDataContext();
                RoleAssignmentEngine    engine  = new RoleAssignmentEngine(context);
                int count = engine.FlagPeopleWithRule(id, bool.Parse(ConfigurationManager.AppSettings["RequireAccessApproval"]));


                context.DeleteRule(id);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                var context = new RSMDataModelDataContext();
                var engine  = new RoleAssignmentEngine(context);

                var reqApproval = Settings.GetValueAsBool("R1SM", "RequireAccessApproval");

                var count = engine.FlagPeopleWithRule(id, reqApproval);

                context.DeleteRule(id);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 3
0
        int UpdateRule(int id, string jobCode, string deptID, int location, List <GridDataRow> roles)
        {
            JCLRoleRule rule;
            var         context = new RSMDataModelDataContext();
            var         action  = "modified";

            if (id > 0)
            {
                rule = (from r in context.JCLRoleRules
                        where r.ID == id
                        select r).Single();
            }
            else
            {
                action = "created";
                rule   = new JCLRoleRule();
                context.JCLRoleRules.InsertOnSubmit(rule);
            }

            rule.JobCode  = jobCode;
            rule.DeptID   = deptID;
            rule.Location = location;

            var thisRuleRoles = from r in context.JCLRoles
                                where r.RuleID == id
                                select r;

            if (thisRuleRoles.Any())
            {
                context.JCLRoles.DeleteAllOnSubmit(thisRuleRoles);
            }

            context.SubmitChanges();

            foreach (var row in roles)
            {
                var role = new JCLRole {
                    RoleID = int.Parse(row.ID), RuleID = id
                };

                rule.JCLRoles.Add(role);
            }

            context.SubmitChanges();

            //bool reqApproval = bool.Parse( ConfigurationManager.AppSettings["RequireAccessApproval"]);
            var reqApproval = Settings.GetValueAsBool("R1SM", "RequireAccessApproval");

            var engine = new RoleAssignmentEngine(context);
            var count  = engine.FlagPeopleWithRule(rule.ID, reqApproval);

            //context.Syslog(RSMDataModelDataContext.LogSources.USER,
            //               RSMDataModelDataContext.LogSeverity.INFO,
            //               string.Format("{0} {1} rule for {2}, {3}, {4}",
            //                             User.Identity.Name,
            //                             action,
            //                             rule.Job.DisplayName,
            //                             rule.Departments.DisplayName,
            //                             rule.Locations.LocationName),
            //               string.Format("The {0} associates affected by last rule edit will be processed by the rule engine next pass.", count));

            var logger = new Logger();

            logger.LogUserActivity(Severity.Informational,
                                   string.Format("{0} {1} rule for {2}, {3}, {4}",
                                                 User.Identity.Name,
                                                 action,
                                                 rule.Job.DisplayName,
                                                 rule.Departments.DisplayName,
                                                 rule.Locations.LocationName),
                                   string.Format("The {0} associates affected by last rule edit will be processed by the rule engine next pass.", count));

            return(rule.ID);
        }