Translation

"bd0d11a9-9e71-4980-9265-c4a037432d48";"Dialogberechtigte";"Dialog authorized";"";"";"";"False";"0"

Aktion

Interface IOrmSecurityHandler hinzufügen

public bool CanHandleOrm(object DataObject, OrmBABase orm)
{
    bool canHandle;
    if (orm != null)
        canHandle = orm.IsAllowed(EnumTableOperations.Edit);
    else
    {
        OrmEntityConfiguration entityConfig = Api.Config.OrmEntity(EnumDataSourceExtension.Engine.ValueGuid);
        canHandle = entityConfig.IsAllowed(EnumTableOperations.Edit) != EnumTableOperations.Denied;
    }
    AdditionalClientData.AddOrUpdate("UserHasRole", canHandle);
    return canHandle;
}

Dynamische Sichtbarkeit

DynamicClientVisibility.Add(EnumActionVisibility.IfUserHasRole);

Eigenschaft

[TokenboxControl]
[CDPRolesProviderProperties(dataSources: new[] { EnumDataSource.RoleGuid })]
[DisplayName("BD0D11A9-9E71-4980-9265-C4A037432D48")]
public RoleSet DialogRoles { get; set; }

AdditionalRibbonButtonAssignment

AdditionalClientData.AddOrUpdate("DialogAuthorized", Api.User.CurrentUserIsInRole(DialogRoles, false));

Igniter

public override ActionResult Ignite()
{
    if (SomethingSelected)
    {
        if (IgnitionModel.Parameters.TryGetValue("RemarkMessage", out object remarkObj) && remarkObj is string remark && !string.IsNullOrWhiteSpace(remark))
        {
            DateTime date;
            if (IgnitionModel.Parameters.TryGetValue("ServiceDate", out object dateObj) && dateObj is DateTime)
                date = (DateTime)dateObj;
            else
                date = DateTime.Now;

            int successful = 0;
            int missingRights = 0;
            Session session = Api.ORM.GetNewSession();
            IEnumerable<Guid> oids = Records.Select(ff => ff.Oid);
            IQueryable<OrmEngine> engines = Api.ORM.GetQuery<OrmEngine>(session).Where(ff => oids.Contains(ff.Oid));
            foreach (OrmEngine engine in engines)
            {
                if (engine.IsAllowed(EnumTableOperations.Edit))
                {
                    OrmSubEngineServices service = engine.Services.AddNewObject();
                    service.SortOrder = engine.Services.Count() - 1;
                    service.ServiceDate = date;
                    service.Remark = remark;
                    engine.Save();
                    successful++;
                }
                else
                    missingRights++;
            }

            if (missingRights == 0)
                Api.ClientCommunication.CreateSuccess(Api.User.CurrentUserGuid(), "dd1ceadc-6808-4583-b6b7-dda73188b5a8".Translate(successful));
            else
                Api.ClientCommunication.CreateSuccess(Api.User.CurrentUserGuid(), "e3f652e7-8019-4444-9e6c-f3c30528e862".Translate(successful, missingRights));
            return new JsonResult() { Data = new JsonFormResult() { RefreshGrid = true } };
        }
        else
            Api.ClientCommunication.CreateError(Api.User.CurrentUserGuid(), "d49ef787-3ad1-4f66-bb12-b2660fd71738".Translate());
    }

    return null;
}

Type Script

public static ClientActionAddService(event: any, customData: CustomData) {
    if (customData.DialogAuthorized) {
        let paramter: CustomData = {};
        paramter.RemarkMessage = customData.RemarkMessage;
        paramter.ServiceDate = customData.ServiceDate;
        BA.Ui.Dialog.DialogManager.OpenDialog("BA.Training.AddServiceDialog", customData, customData,
            function (result: BA.Ui.Dialog.DialogResult, customData: CustomData) {
                if (result.ButtonId == 'okButton') {
                    Actions.StartAddServiceMassOperation(event, customData, result.Data.Remark, result.Data.Date);
                }
            }
        );
    } else if (!customData.RemarkMessage || customData.RemarkMessage == "")
        BA.Ui.Translations.TranslationTools.GetTranslation("d49ef787-3ad1-4f66-bb12-b2660fd71738", function (result) {
            BA.Ui.Toast.Warning(result);
        });
    else
        Actions.StartAddServiceMassOperation(event, customData, customData.RemarkMessage, customData.ServiceDate);
}

public static StartAddServiceMassOperation(event: any, customData: CustomData, remark: any, date: any) {
    let igniterParams: CustomData = {};
    igniterParams.RemarkMessage = remark;
    igniterParams.ServiceDate = date;
    customData["MassOperationIgniterParameters"] = JSON.stringify(igniterParams);
    BA.Ui.Actions.GridActions.StartMassOperation(event, customData);
}