protected void Page_Init(object sender, EventArgs e) { operationId = base.GetRequestInt("id"); hfOperationId.Value = Request.Form[hfOperationId.UniqueID]; if (operationId > 0) hfOperationId.Value = operationId.ToString(); Int32.TryParse(hfOperationId.Value, out operationId); if (operationId > 0) { operation = BXRoleOperationManager.GetById(operationId); if (operation == null) { operationId = 0; hfOperationId.Value = operationId.ToString(); } } if (operationId <= 0) { string operationName = base.GetRequestString("name"); if (!String.IsNullOrEmpty(operationName)) { operation = BXRoleOperationManager.GetByName(operationName); if (operation != null) { operationId = operation.OperationId; hfOperationId.Value = operationId.ToString(); } } } if (!this.BXUser.IsCanOperate(BXRoleOperation.Operations.AuthorizationSettingsView)) BXAuthentication.AuthenticationRequired(); currentUserCanModifySettings = this.BXUser.IsCanOperate(BXRoleOperation.Operations.AuthorizationSettingsManage); }
private bool CreateOperation() { try { if (!currentUserCanModifySettings) throw new Exception(GetMessageRaw("ExceptionText.YouDontHaveRightsToCreateOperation")); operation = BXRoleOperationManager.Create(tbOperationName.Text, tbOperationType.Text, ddlModuleId.SelectedValue, tbComment.Text); if (operation == null) throw new Exception(GetMessageRaw("ExceptionText.CreationHasFailed")); operationId = operation.OperationId; hfOperationId.Value = operationId.ToString(); return true; } catch (Exception e) { errorMessage.AddErrorMessage(e.Message); } return false; }