/// <summary>
 /// Delete record from table role_action
 /// </summary>
 /// <param name="RoleId"></param>
 /// <param name="DelActionId"></param>
 /// <returns></returns>
 public ActionResult DropActionRole(string RoleId = "", string ActionId = "")
 {
     try
     {
         Init("cabinet_role");
         if (RoleId == "")
         {
             return(RedirectToAction("Role", "Cabinet"));
         }
         if (ActionId == "")
         {
             return(RedirectToAction("RoleAction", "Cabinet", new { RoleId = RoleId }));
         }
         RoleAction roleAction = new RoleAction(shared);
         roleAction.DeleteRoleAction(RoleId, ActionId);
         if (shared.error.AnyError())
         {
             return(RedirectToAction("RoleAction", "Cabinet", new { RoleId = RoleId }));
         }
         return(RedirectToAction("RoleAction", "Cabinet", new { RoleId = RoleId }));
     }
     catch (Exception ex)
     {
         return(ShowError(ex));
     }
 }
示例#2
0
        public ActionResult Create(RoleActionDTO roleAction)
        {
            MethodBase method = MethodBase.GetCurrentMethod();

            try
            {
                RoleAction newRoleAction = Mapper.Map <RoleAction>(roleAction);
                newRoleAction.IsValid = true;
                newRoleAction.Id      = 0;
                var response = RoleActionRepo.Create(newRoleAction);
                if (response > 0)
                {
                    CreateLog(Enums.Success, GetMethodCode(method), LogLevel.Information);
                    return(Ok(response));
                }
                else
                {
                    CreateLog(Enums.BadRequest, GetMethodCode(method), LogLevel.Warning);
                    return(BadRequest(response));
                }
            }
            catch (Exception ex)
            {
                return(HandleError(ex.Message, GetMethodCode(method)));
            }
        }
        public ActionResult Edit(EditRoleActionViewModel editUser, params string[] selectedRole)
        {
            var roleaction = _dbContext.RoleActions.Where(a => a.RoleId == editUser.Id).ToList();

            for (int i = 0; i < roleaction.Count(); i++)
            {
                _dbContext.RoleActions.Remove(roleaction[i]);
                _dbContext.SaveChanges();
            }

            if (ModelState.IsValid)
            {
                selectedRole = selectedRole ?? new string[] { };
                for (int i = 0; i < selectedRole.Length; i++)
                {
                    var temp_role = selectedRole[i];
                    var action    = _dbContext.Actions.Where(a => a.Name == temp_role).Select(a => a.Id).Single();
                    var role      = new RoleAction()
                    {
                        ActionId = action,
                        RoleId   = editUser.Id
                    };
                    _dbContext.RoleActions.Add(role);
                    _dbContext.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Something failed.");
            return(View());
        }
示例#4
0
 public int UpdateRole(Role role)
 {
     using (OracleConnection conn = DapperHelper.GetConnString())
     {
         string executeSql = @" Update Role set RoleName=:RoleName,PowerId=:PowerId,PowerName=:PowerName,ModifyTime=:ModifyTime where Id=:Id";
         role.ModifyTime = Convert.ToString(System.DateTime.Now);
         var Collectlist = new { RoleName = role.RoleName, PowerId = role.PowerId, PowerName = role.PowerName, ModifyTime = role.ModifyTime, Id = role.Id };
         int result      = conn.Execute(executeSql, Collectlist);
         if (result > 0)
         {
             string sql          = @"select Id from Role where RoleName=:rowname";
             var    a            = new { rowname = role.RoleName };
             var    Ids          = conn.Query(sql, a).FirstOrDefault();
             string executeSqls  = @"delete from RoleAction where RoleId=:Id";
             var    Collectlists = new { Id = role.Id };
             int    results      = conn.Execute(executeSqls, Collectlists);
             var    PowerIds     = role.PowerId.Split(',');
             for (int i = 0; i < PowerIds.Length; i++)
             {
                 RoleAction roleAction = new RoleAction();
                 roleAction.RoleId     = int.Parse(Ids.Values.FirstOrDefault().ToString());
                 roleAction.PowerId    = Convert.ToInt32(PowerIds[i]);
                 roleAction.ModifyTime = System.DateTime.Now;
                 string sql1    = @"insert into RoleAction (RoleId,PowerId,ModifyTime) VALUES (:RoleId,:PowerId,:ModifyTime)";
                 int    result1 = conn.Execute(sql1, roleAction);
             }
         }
         return(result);
     }
 }
示例#5
0
        private void action1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ra = new RoleAction
            {
                ActionType = 1,
                Roles      = roleSelector1.SelectedRoles,
                Principals = principalSelector1.SelectedItems
            };

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Adding roles to principal(s)...",
                AsyncArgument = ra,
                Work          = (bw, evt) =>
                {
                    var action = (RoleAction)evt.Argument;

                    var rManager = new RoleManager(Service);
                    rManager.AddRolesToPrincipals(action.Roles, action.Principals, allRoles, bw);
                },
                PostWorkCallBack = evt =>
                {
                    if (evt.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + evt.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                },
                ProgressChanged = evt => { SetWorkingMessage(string.Format(evt.UserState.ToString(), evt.ProgressPercentage)); }
            });
        }
示例#6
0
    /// <summary>
    /// To be used for in all page_load events of all pages to grant\access action within the page
    /// to the user.
    /// </summary>
    /// <param name="actionName">Name of page's action user wants to perform.</param>
    /// <returns>True when the page's action is loaded, and false otherwise</returns>
    /// <remarks>By 'LOAD' i mean set visible to the user</remarks>
    public static bool LoadActions(string actionName)
    {
        //  return true;

        if (LoggedUser == null)
        {
            return(false);
        }

        Actions         dtAction = GIIS.DataLayer.Actions.GetActionsByName(actionName);
        List <UserRole> dt       = UserRole.GetUserRoleListByUserId(LoggedUser.Id);
        int             actionId = 0;

        if (dtAction == null)
        {
            return(false);
        }
        else
        {
            actionId = dtAction.Id;
        }

        foreach (UserRole userrole in dt)
        {
            if (RoleAction.Exists(userrole.RoleId, actionId) > 0)
            {
                return(true);
            }
        }

        return(false);
    }
        public void Setup()
        {
            // Mock
            _configuration  = new Mock <IConfiguration>(MockBehavior.Loose);
            _roleActionRepo = new Mock <IRoleActionRepo>(MockBehavior.Loose);
            _logger         = new Mock <ILogger <RoleActionController> >(MockBehavior.Loose);

            // Mapper
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperConfig());
            });

            _mapper = new Mapper(config);

            // Config
            Filler <RoleAction>    pFiller    = new Filler <RoleAction>();
            Filler <RoleActionDTO> pFillerDTO = new Filler <RoleActionDTO>();

            roleAction    = pFiller.Create();
            roleActionDTO = pFillerDTO.Create();

            // Service under test
            _roleActionController = new RoleActionController(_configuration.Object, _mapper, _roleActionRepo.Object, _logger.Object);
        }
示例#8
0
    protected void btnRemoveAll_Click(object sender, EventArgs e)
    {
        try
        {
            if (Page.IsValid)
            {
                int    userId      = CurrentEnvironment.LoggedUser.Id;
                string machineName = Request.ServerVariables["REMOTE_HOST"].ToString();
                int    i           = 0;
                if ((lbRoleActions.Items.Count > 0))
                {
                    int roleId = int.Parse(ddlRole.SelectedValue);
                    for (int j = 0; j <= lbRoleActions.Items.Count - 1; j++)
                    {
                        int actionId = int.Parse(lbRoleActions.Items[j].Value.ToString());
                        i = RoleAction.DeleteByActionAndRole(roleId, actionId);
                    }

                    _actions = Actions.GetLeftActionsOfRole(roleId);
                    BindLeftActionsOfRole(_actions);

                    _roleActions = Actions.GetActionsOfRole(roleId);
                    BindActionsOfRole(_roleActions);
                }
            }
        }
        catch (Exception ex)
        {
            lblSuccess.Visible = false;
            lblWarning.Visible = false;
            lblError.Visible   = true;
        }
    }
示例#9
0
        /// <summary>
        /// Remove all Roles from the User/Team, then add the selected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void actionRemoveAddToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!PromptContinue())
            {
                return;
            }
            var ra = new RoleAction
            {
                ActionType = 3,
                Roles      = roleSelector.SelectedRoles,
                Principals = principalSelector.SelectedItems,
                BatchSize  = int.Parse(toolStripComboBatchSize.Text)
            };

            if (ra.Principals.Any(p => p.Id == currentUserId))
            {
                MessageBox.Show(this,
                                "You can't remove roles from your own profile. Your profile will be removed from the principals list",
                                "Warning",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);

                ra.Principals.Remove(ra.Principals.First(r => r.Id == currentUserId));
            }

            ToggleToolButtons(true);

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Removing roles from principal(s)...",
                AsyncArgument = ra,
                IsCancelable  = true,
                Work          = (bw, evt) =>
                {
                    var action = (RoleAction)evt.Argument;
                    // set the batch size for this instance
                    var rManager = new RoleManager(Service)
                    {
                        BatchSize = action.BatchSize
                    };

                    rManager.RemoveExistingRolesFromPrincipals(action.Principals);

                    bw.ReportProgress(0, "Adding roles to principals ({0} %)...");

                    rManager.AddRolesToPrincipals(action.Roles, action.Principals, allRoles, bw);
                },
                PostWorkCallBack = evt =>
                {
                    if (evt.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + evt.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }

                    ToggleToolButtons(false);
                },
                ProgressChanged = evt => { SetWorkingMessage(string.Format(evt.UserState.ToString(), evt.ProgressPercentage)); }
            });
        }
示例#10
0
 public bool AddAction(Guid roleId, Guid actionId)
 {
     try
     {
         var roleActionBO  = new RoleActionBO();
         var roleOperation = roleActionBO.Get(this.ConnectionHandler, roleId, actionId);
         if (roleOperation == null)
         {
             var roleAction = new RoleAction {
                 ActionId = actionId, RoleId = roleId
             };
             if (!roleActionBO.Insert(this.ConnectionHandler, roleAction))
             {
                 throw new Exception("خطایی در ذخیره عملیات نقش  وجود دارد");
             }
         }
         return(true);
     }
     catch (KnownException ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace);
         throw new KnownException(ex.Message, ex);
     }
 }
示例#11
0
 public int AddRole(Role r)
 {
     using (OracleConnection conn = DapperHelper.GetConnString())
     {
         string executeSql = @" INSERT INTO Role (RoleName,PowerId,PowerName,CreateTime) VALUES (:RoleName,:PowerId,:PowerName,:CreateTime)";
         r.CreateTime = Convert.ToString(System.DateTime.Now);
         var Collectlist = new { RoleName = r.RoleName, PowerId = r.PowerId, PowerName = r.PowerName, CreateTime = r.CreateTime };
         int result      = conn.Execute(executeSql, Collectlist);
         if (result > 0)
         {
             string sql     = @"select Id from Role where RoleName=:rowname";
             var    a       = new { rowname = r.RoleName };
             var    Id      = conn.Query(sql, a).FirstOrDefault();
             var    PowerId = r.PowerId.Split(',');
             for (int i = 0; i < PowerId.Length; i++)
             {
                 RoleAction roleAction = new RoleAction();
                 roleAction.RoleId     = int.Parse(Id.Values.FirstOrDefault().ToString());
                 roleAction.PowerId    = Convert.ToInt32(PowerId[i]);
                 roleAction.CreateTime = System.DateTime.Now;
                 string sql1    = @"insert into RoleAction (RoleId,PowerId,CreateTime) VALUES (:RoleId,:PowerId,:CreateTime)";
                 int    result1 = conn.Execute(sql1, roleAction);
             }
         }
         return(result);
     }
 }
示例#12
0
 protected override IApiOut Initialize(AshxRouteData ashxRoute)
 {
     if (!ashxRoute.HttpContext.Session.IsAvailable)
     {
         return(ApiOut.View("500.html"));
     }
     return(RoleAction.Initialize(ashxRoute));
 }
示例#13
0
        public async Task ManageLogout(string UserName)
        {
            AjaxJson _ajv = new();

            _ajv.code = RoleAction.Logout(UserName) ? 0 : 1;
            _ajv.msg  = "成功";//_ajv.code == 1 ? "失败" : "成功";
            await JsonAsync(_ajv);
        }
示例#14
0
        public int InsertRoleAction(RoleAction roleAction)
        {
            RoleAction item = new RoleAction();

            item.ActionId = roleAction.ActionId;
            item.RoleId   = roleAction.RoleId;
            item.IsTrue   = true;
            context.RoleActions.Add(item);
            return(context.SaveChanges());
        }
        public void CreateRoleAction(string role, string action)
        {
            var roleAction = new RoleAction()
            {
                Role = role,
                Action = action
            };

            _roleActionSecurityStorageProvider.Add(roleAction);
        }
示例#16
0
        /// <summary>
        /// 权限与接口关联配置 获取某一个菜单的某一个功能配置的接口列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <List <SystemPageAction> > GetRoleActions(RoleAction model)
        {
            if (model == null || model.MenuId < 1 || string.IsNullOrEmpty(model.ActionId))
            {
                return(new List <SystemPageAction>());
            }

            var list = await Entitys.SystemPageAction.Where(r => r.MenuTid.Equals(model.MenuId) && r.ActionId.Equals(model.ActionId)).ToListAsync();

            return(list);
        }
示例#17
0
 public async Task ChangeRoles(SocketGuildUser usr, IRole role, RoleAction act)
 {
     if (act == RoleAction.Add)
     {
         await usr.AddRoleAsync(role);
     }
     if (act == RoleAction.Remove)
     {
         await usr.RemoveRoleAsync(role);
     }
 }
示例#18
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Create the administrator role and user.
            RoleAction roleActions = new RoleAction();

            roleActions.createAdmin();
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Create custom role
            RoleAction roleAction = new RoleAction();
            //roleAction.addUserAndRole();
        }
示例#20
0
        /// <summary>
        /// 权限与接口关联配置
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <JsonResult> GetRoleActions(RoleAction model)
        {
            var result            = new ResultJsonInfo <List <APIDescription> >();
            var respositoryResult = await RoleRespository.GetRoleActions(model);

            var allDescriptions = APIAttibuteHelper.GetAllDescriptions(null, respositoryResult);

            result.Status = ResultConfig.Ok;
            result.Info   = ResultConfig.SuccessfulMessage;
            result.Data   = allDescriptions;
            return(Json(result));
        }
示例#21
0
        public List <RoleAction> GetTbl_Action_MasterId(int R_ID, int PId)
        {
            List <RoleAction> Tbl_Action_MasterList = new List <RoleAction>();
            ActionTaken       RoleAccess            = new ActionTaken();

            try
            {
                con = Utility.Util.Connection("DBEntities");
                string     result = "";
                SqlCommand cmd    = new SqlCommand("SP_ChkRoleAction", con);
                con.Open();

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@UserId", R_ID);
                cmd.Parameters.AddWithValue("@ProcessId", PId);
                result = cmd.ExecuteScalar().ToString();
                if (result.Equals(null))
                {
                    return(null);
                }
                SqlDataAdapter da = new SqlDataAdapter();

                da.SelectCommand = cmd;
                DataSet ds = new DataSet();

                da.Fill(ds);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    RoleAction RoleAction = new RoleAction();
                    RoleAction.ActionId   = Convert.ToInt32(ds.Tables[0].Rows[i]["ActionId"].ToString());
                    RoleAction.RoleId     = Convert.ToInt32(ds.Tables[0].Rows[i]["RoleId"].ToString());
                    RoleAction.ActionDesc = ds.Tables[0].Rows[i]["ActionDesc"].ToString();
                    roleDesc = ds.Tables[0].Rows[i]["RoleName"].ToString();
                    Tbl_Action_MasterList.Add(RoleAction);
                }
            }

            catch (Exception ex)
            {
                ex.Message.ToString();
            }

            finally
            {
                con.Close();
            }


            return(Tbl_Action_MasterList);
        }
示例#22
0
        public async Task IsggCodes(string iscode, string url)
        {
            AjaxJson _ajv = new();

            if (Session.TryGetValue("IdentAdmin", out anmininfo))
            {
                GoogleAuthenticator authenticator = new(30, key : $"{anmininfo.BaseName}{anmininfo.ID}{8}");
                var mobileKey = authenticator.GenerateCode();
#if DEBUG
                mobileKey = iscode;
#endif
                if (!RoleAction.IsRepeatLogin(anmininfo.BaseName))
                {
                    _ajv.code = 105;
                    _ajv.msg  = "您的账号已登录,请联系超管!";
                }
                else if (iscode == mobileKey)
                {
                    if (anmininfo.IsIdent == 0)
                    {
                        FacadeManage.AideAdminFacade.SetBaseIsIdent(anmininfo.ID.ToString(), 1);//首次绑定成功后 更新绑定状态
                        //加入操作日志
                        AddBaseLog("Edit", "管理员绑定两步认证");
                    }

                    _ajv.code = 0;
                    _ajv.msg  = "验证成功!";
                    AddBaseLog("Login", "认证成功");//加入认证日志

                    //登录成功保存用户信息
                    RoleAction.Login(Session, anmininfo);
                    EditLoginMsg(anmininfo.ID);
                    Session.Remove("IdentAdmin");

                    url = string.IsNullOrWhiteSpace(url) ? "#/Welcome" : url.StringDecode();
                    _ajv.SetDataItem("url", url);
                }
                else
                {
                    _ajv.code = 1;
                    _ajv.msg  = "验证失败,请稍候再试!";
                }
            }
            else
            {
                _ajv.code = 1;
                _ajv.msg  = "请刷新界面重新登录!";
            }
            await JsonAsync(_ajv);
        }
示例#23
0
 private void ChangeRoleAction(RoleAction action)
 {
     m_RoleAction = action;
     if (m_RoleAction == RoleAction.USESKILL)
     {
         m_fUsesKillTime = UnityEngine.Time.realtimeSinceStartup;
     }
     if (m_CombatRobotMono != null)
     {
         m_CombatRobotMono.m_RoleAction = m_RoleAction;
     }
     if (m_RoleAction == RoleAction.NONE)
     {
         //Engine.Utility.Log.Error("CombatRobot -> ChangeStatus: {0}", m_RoleAction.ToString());
     }
 }
示例#24
0
        /// <summary>
        /// The Add
        /// </summary>
        /// <param name="entity">The entity<see cref="Roles"/></param>
        public override void Add(Roles entity)
        {
            base.Add(entity);
            DbContext.SaveChanges();
            int           idRole      = this.GetRoleIdByName(entity.RoleName);
            List <Action> listActions = (from s in DbContext.Actions select s).ToList();

            foreach (var action in listActions)
            {
                RoleAction roleAction = new RoleAction();
                roleAction.ActionId = action.ActionId;
                roleAction.RoleId   = idRole;
                roleAction.IsTrue   = false;
                DbContext.RoleActions.Add(roleAction);
                DbContext.SaveChanges();
            }
        }
示例#25
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            // Initialize the product database
            Database.SetInitializer(new ProductDatabaseInitializer());

            // Create the custom role and user
            RoleAction roleAction = new RoleAction();

            roleAction.AddUserAndRole();

            // Add Routes
            RegisterCustomRoutes(RouteTable.Routes);
        }
示例#26
0
        private void action3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ra = new RoleAction
            {
                ActionType = 3,
                Roles      = roleSelector1.SelectedRoles,
                Principals = principalSelector1.SelectedItems
            };

            if (ra.Principals.Any(p => p.Id == currentUserId))
            {
                MessageBox.Show(this,
                                "You can't remove roles from your own profile. Your profile will be removed from the principals list",
                                "Warning",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);

                ra.Principals.Remove(ra.Principals.First(r => r.Id == currentUserId));
            }

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Removing roles from principal(s)...",
                AsyncArgument = ra,
                Work          = (bw, evt) =>
                {
                    var action = (RoleAction)evt.Argument;

                    var rManager = new RoleManager(Service);
                    rManager.RemoveExistingRolesFromPrincipals(action.Principals);

                    bw.ReportProgress(0, "Adding roles to principals ({0} %)...");

                    rManager.AddRolesToPrincipals(action.Roles, action.Principals, allRoles, bw);
                },
                PostWorkCallBack = evt =>
                {
                    if (evt.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + evt.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                },
                ProgressChanged = evt => { SetWorkingMessage(string.Format(evt.UserState.ToString(), evt.ProgressPercentage)); }
            });
        }
示例#27
0
    private static int SetAttackCombo(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            RoleAction roleAction = (RoleAction)ToLua.CheckObject(L, 1, typeof(RoleAction));
            roleAction.SetAttackCombo();
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
示例#28
0
    private static int ResetToIdleImmediate(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 1);
            RoleAction roleAction = (RoleAction)ToLua.CheckObject(L, 1, typeof(RoleAction));
            roleAction.ResetToIdleImmediate();
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
示例#29
0
        public async Task <JsonResult> AddRoleActions([ModelBinder(typeof(JsonNetBinder)), FromForm] RoleAction model)
        {
            var result            = new ResultJsonNoDataInfo();
            var respositoryResult = await RoleRespository.AddRoleActions(model);

            if (string.IsNullOrEmpty(respositoryResult))
            {
                result.Status = ResultConfig.Ok;
                result.Info   = ResultConfig.SuccessfulMessage;
            }
            else
            {
                result.Status = ResultConfig.Fail;
                result.Info   = string.IsNullOrEmpty(respositoryResult) ? ResultConfig.FailMessage : respositoryResult;
            }
            return(Json(result));
        }
示例#30
0
        /// <summary>
        /// Add the selected Roles to the selected Users or Teams
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void actionAddSelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!PromptContinue())
            {
                return;
            }

            var ra = new RoleAction
            {
                ActionType = 1,
                Roles      = roleSelector.SelectedRoles,
                Principals = principalSelector.SelectedItems,
                BatchSize  = int.Parse(toolStripComboBatchSize.Text)
            };

            ToggleToolButtons(true);

            WorkAsync(new WorkAsyncInfo
            {
                Message       = "Adding roles to principal(s)...",
                AsyncArgument = ra,
                IsCancelable  = true,
                Work          = (bw, evt) =>
                {
                    var action = (RoleAction)evt.Argument;
                    // set the batch size for this instance
                    var rManager = new RoleManager(Service)
                    {
                        BatchSize = action.BatchSize
                    };
                    rManager.AddRolesToPrincipals(action.Roles, action.Principals, allRoles, bw);
                },
                PostWorkCallBack = evt =>
                {
                    if (evt.Error != null)
                    {
                        MessageBox.Show(this, "An error occured: " + evt.Error.Message, "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }

                    ToggleToolButtons(false);
                },
                ProgressChanged = evt => { SetWorkingMessage(string.Format(evt.UserState.ToString(), evt.ProgressPercentage)); }
            });
        }
示例#31
0
    private static int ResetLingQinAnimation(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 2);
            RoleAction roleAction = (RoleAction)ToLua.CheckObject(L, 1, typeof(RoleAction));
            GameObject model      = (GameObject)ToLua.CheckUnityObject(L, 2, typeof(GameObject));
            roleAction.ResetLingQinAnimation(model);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }
示例#32
0
 /// <summary>
 /// The AddActionToRole
 /// </summary>
 /// <param name="idAction">The idAction<see cref="int"/></param>
 /// <param name="idRole">The idRole<see cref="int"/></param>
 public void AddActionToRole(int idAction, int idRole)
 {
     try
     {
         RoleAction roleAction =
             (from s in DbContext.RoleActions where (s.ActionId == idAction && s.RoleId == idRole) select s)
             .FirstOrDefault();
         roleAction.IsTrue = true;
         DbContext.RoleActions.Attach(roleAction);
         DbContext.Entry(roleAction).State = EntityState.Modified;
         DbContext.SaveChanges();
     }
     catch (Exception e)
     {
         ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
         logger.Debug(e.Message);
     }
 }
 public RoleAction Add(RoleAction entity)
 {
     return _roleActionStorageApplication.Add(entity);
 }
 public void Delete(RoleAction entity)
 {
     _roleActionStorageApplication.Delete(entity);
 }
 public void Update(RoleAction entity)
 {
     _roleActionStorageApplication.Update(entity);
 }
        private void saveRoleActions(int clientID, int roleID)
        {
            RoleAction roleAction = null;

            using (ActionManager repository = new ActionManager()) {
                repository.DeleteAll(clientID, roleID);

                foreach (ListItem item in cblRoleActions.Items) {
                    if (item.Selected) {
                        roleAction = new RoleAction();
                        roleAction.ClientID = clientID;
                        roleAction.RoleID = roleID;
                        roleAction.ActionID = Convert.ToInt32(item.Value);

                        repository.Save(roleAction);
                    }
                }
            }
        }
    void SetAction(RoleAction _act)
    {
        switch(_act)
        {
        case RoleAction.Dive:
            SetDive();
            break;

        case RoleAction.Fight:
            SetAttack();
            break;
        }
    }
 void AddAction(RoleAction _act)
 {
     mActQueue.Enqueue (_act);
 }