Пример #1
0
	private bool CreateTask()
	{
		try
		{
			if (!currentUserCanModifySettings)
				throw new Exception(GetMessageRaw("ExceptionText.YouDontHaveRightsToCreateTask"));

			task = BXRoleTaskManager.Create(tbTaskName.Text, tbTaskTitle.Text, tbComment.Text);
			if (task == null)
				throw new Exception(GetMessageRaw("ExceptionText.CreationOfTaskFailed"));

			taskId = task.TaskId;
			hfTaskId.Value = taskId.ToString();

            BXRoleOperationCollection operationsTmp =
            BXRoleOperationManager.GetList(null, null);

            List<string> addOper = new List<string>();

            foreach (BXRoleOperation op in operationsTmp)
            {
                CheckBox cb = FindOperationCheckBox(op.OperationId);

                if (cb != null)
                {
                    if (cb.Checked)
                    {
                        addOper.Add(op.OperationName);
                    }
                }

            }

            if (addOper.Count > 0) task.AddToOperations(addOper.ToArray());

			return true;
		}
		catch (Exception e)
		{
			errorMessage.AddErrorMessage(e.Message);
		}
		return false;
	}
Пример #2
0
	protected void Page_Init(object sender, EventArgs e)
	{
        cbOperationCollection = new List<CheckBox>();
		taskId = base.GetRequestInt("id");
		hfTaskId.Value = Request.Form[hfTaskId.UniqueID];
		if (taskId > 0)
			hfTaskId.Value = taskId.ToString();
		Int32.TryParse(hfTaskId.Value, out taskId);
		if (taskId > 0)
		{
			task = BXRoleTaskManager.GetById(taskId);
			if (task == null)
			{
				taskId = 0;
				hfTaskId.Value = taskId.ToString();
			}
		}

		if (taskId <= 0)
		{
			string taskName = base.GetRequestString("name");
			if (!String.IsNullOrEmpty(taskName))
			{
				task = BXRoleTaskManager.GetByName(taskName);
				if (task != null)
				{
					taskId = task.TaskId;
					hfTaskId.Value = taskId.ToString();
				}
			}
		}

		if (!this.BXUser.IsCanOperate(BXRoleOperation.Operations.AuthorizationSettingsView))
			BXAuthentication.AuthenticationRequired();

		currentUserCanModifySettings = this.BXUser.IsCanOperate(BXRoleOperation.Operations.AuthorizationSettingsManage);
	}