예제 #1
0
        private static int DeleteRecordsByController(Controller controller)
        {
            int ret = 0;

            using (TransactionalDbClient tc = ionixFactory.CreateTransactionalDbClient())
            {
                ControllerRepository        controllerRepository = new ControllerRepository(tc.Cmd);
                ActionRepository            actionRepository     = new ActionRepository(tc.Cmd);
                List <Server.Models.Action> controllerActions    = actionRepository.SelectByControllerId(controller.Id).ToList();

                if (!controllerActions.IsEmptyList())
                {
                    List <int> controllerActionIds = new List <int>(controllerActions.Count);
                    controllerActions.ForEach((aa) => controllerActionIds.Add(aa.Id));

                    //RoleControllerAction Siliniyor.
                    RoleActionRepository roleControllerActionRepository = new RoleActionRepository(tc.Cmd);
                    ret += roleControllerActionRepository.DeleteByControllerActionIds(controllerActionIds);

                    //controllerAction Siliniyor.
                    ret += actionRepository.DeleteByControllerId(controller.Id);
                }
                //controller Siliniyor.
                ret += controllerRepository.Delete(controller);

                tc.Commit();
            }

            return(ret);
        }
예제 #2
0
        public int ClearNonExistRecords()
        {
            int ret = 0;
            using (DbClient client = DataFactory.CretDbClient())
            {
                ControllerRepository controllerRepository = new ControllerRepository(client.Cmd);
                List<Controller> controllers = controllerRepository.Select().ToList();

                if (controllers.Count > 0)
                {
                    ActionRepository actionRepository = new ActionRepository(client.Cmd);

                    ControllerActionsList reflecteds = ControllerActionsList.Create<ReflectControllerApi, ReflectControllerMvc>(AppDomain.CurrentDomain.GetAssemblies());

                    foreach (Controller controller in controllers)
                    {
                        ControllerActions ca = reflecteds.FirstOrDefault((item) => String.Equals(controller.Name, item.ControllerType.Name.Replace("Controller", "")));
                        if (null != ca)
                        {
                            List<Models.Action> actions = actionRepository.SelectByControllerId(controller.Id).ToList();
                            foreach (Models.Action action in actions)
                            {
                                ActionMethodInfo ami = ca[action.Name];
                                if (null == ami)//Mesela method silindi veya ismi değiştirildi.
                                {
                                    ret = DeleteRecordsByControllerAction(action);
                                }
                            }
                        }
                        else
                        {
                            ret += DeleteRecordsByController(controller);
                        }

                    }
                }
            }

            return ret;
        }
예제 #3
0
        public int ClearNonExistRecords()
        {
            int ret = 0;

            using (DbClient client = ionixFactory.CreateDbClient())
            {
                ControllerRepository controllerRepository = new ControllerRepository(client.Cmd);
                List <Controller>    controllers          = controllerRepository.Select().ToList();

                if (controllers.Count > 0)
                {
                    ActionRepository actionRepository = new ActionRepository(client.Cmd);

                    ControllerActionsList reflecteds = AuthorizationValidator.ControllerActionsList;// ControllerActionsList.Create<ReflectController>(AppDomain.CurrentDomain.GetAssemblies());

                    foreach (Controller controller in controllers)
                    {
                        ControllerActions ca = reflecteds.FirstOrDefault((item) => String.Equals(controller.Name, item.ControllerType.Name.Replace("Controller", "")));
                        if (null != ca)
                        {
                            List <Server.Models.Action> actions = actionRepository.SelectByControllerId(controller.Id).ToList();
                            foreach (Server.Models.Action action in actions)
                            {
                                MethodInfo mi = ca[action.Name];
                                if (null == mi)//Mesela method silindi veya ismi değiştirildi.
                                {
                                    ret = DeleteRecordsByControllerAction(action);
                                }
                            }
                        }
                        else
                        {
                            ret += DeleteRecordsByController(controller);
                        }
                    }
                }
            }

            return(ret);
        }
예제 #4
0
        private static int DeleteRecordsByController(Controller controller)
        {
            int ret = 0;
            using (TransactionalDbClient tc = DataFactory.CreateTransactionalDbClient())
            {
                ControllerRepository controllerRepository = new ControllerRepository(tc.Cmd);
                ActionRepository actionRepository = new ActionRepository(tc.Cmd);
                List<Models.Action> controllerActions = actionRepository.SelectByControllerId(controller.Id).ToList();

                if (!controllerActions.IsEmptyList())
                {
                    List<int> controllerActionIds = new List<int>(controllerActions.Count);
                    controllerActions.ForEach((aa) => controllerActionIds.Add(aa.Id));

                    //RoleControllerAction Siliniyor.
                    RoleActionRepository roleControllerActionRepository = new RoleActionRepository(tc.Cmd);
                    ret += roleControllerActionRepository.DeleteByControllerActionIds(controllerActionIds);

                    //controllerAction Siliniyor.
                    ret += actionRepository.DeleteByControllerId(controller.Id);
                }
                //controller Siliniyor.
                ret += controllerRepository.Delete(controller);

                tc.Commit();
            }

            return ret;
        }