Using the UiPath.Activities.API package from the Official feed (https://pkgs.dev.azure.com/uipath/Public.Feeds/_packaging/UiPath-Official/nuget/v3/index.json
), you can create and add your own custom activity project settings in Studio. For information on how to use the API, see About the Activities SDK.
Wichtig!
Das UiPath.Activities.API-Paket muss als Entwicklungsabhängigkeit in Ihrem benutzerdefinierten Projekt verwendet werden. Lesen Sie mehr über Entwicklungsabhängigkeiten.
Activity project settings encompass a set of options that can be adjusted on a project level directly from the Project Settings window.

Aktivitätseinstellungen erstellen
Im folgenden Beispiel wird eine Reihe von Einstellungen für eine Musikplayer-Beispielaktivität erstellt.
Registerkarte und Abschnitt hinzufügen
using UiPath.Studio.Activities.Api;
using UiPath.Studio.Activities.Api.Settings;
namespace MyCustomActivityPack
{
public static class SettingsCreator
{
// This is the key used to reference a tab, even across packages.
internal const string CategoryKey = "DemoTabUniqueKey";
// This is the key used to reference the setting, even across packages.
internal const string CommentTextKey = CategoryKey + ".Comment";
internal const string PresetKey = CategoryKey + ".Preset";
internal const string ShuffleKey = CategoryKey + ".Shuffle";
public static void CreateSettings(IWorkflowDesignApi workflowDesignApi)
{
var settingsApi = workflowDesignApi.Settings;
// Add the category (a tab in the settings page)
var category = new SettingsCategory()
{
Description = "Settings Sample",
Header = "Settings Sample",
Key = CategoryKey
};
settingsApi.AddCategory(category);
AddMusicPlayerSection(settingsApi, category);
AddMiscSettings(settingsApi, category);
Dadurch werden dem Fenster Aktivitätsprojekteinstellungen eine Registerkarte und ein Abschnitt hinzugefügt. Die Registerkartenbeschreibung ist sichtbar, wenn Sie den Mauszeiger über die QuickInfo der Registerkarte bewegen:

Einstellungen hinzufügen
- Abschnitt „Erweiterbare Einstellungen“:
private static SettingsSection AddMusicPlayerSection(IActivitiesSettingsService settingsApi, SettingsCategory category)
{
var section = new SettingsSection()
{
Description = "Settings for a music player",
IsExpanded = true, //set this to control default expansion
Title = "Music Player Settings",
// the key of a section has to be unique only within the category
Key = "Player"
};
settingsApi.AddSection(category, section);
AddSimpleBoolean(settingsApi, section);
AddSingleChoice(settingsApi, section);
return section;
}
Dies führt zu:

- Optionsfeld für boolesche Werte:
private static void AddSimpleBoolean(IActivitiesSettingsService settingsApi, SettingsSection section)
{
var booleanSetting = new SingleValueEditorDescription<bool>
{
DefaultValue = true,
Description = "If active, the playlist is shuffled",
// The value returned by GetDisplayValue should be localized
GetDisplayValue = b => b ? "On" : "Off",
Key = ShuffleKey,
Label = "Shuffle"
};
settingsApi.AddSetting(section, booleanSetting);
}
Dies führt zu:

- Multiple-Choice-Liste der Werte:
private static void AddSingleChoice(IActivitiesSettingsService settingsApi, SettingsSection category)
{
var booleanSetting = new SingleValueSelectorDescription
{
DefaultValue = "pop",
Values = new[] { "classic", "pop", "rock" },
Description = "Sample single choice setting",
// The value returned by GetDisplayValue should be localized
GetDisplayValue = choice => choice + " music",
Key = PresetKey,
Label = "Mixer Preset"
};
settingsApi.AddSetting(category, booleanSetting);
}
Dies führt zu:

- Eingabetextfeld mit Validierung:
private static void AddSimpleString(IActivitiesSettingsService settingsApi, SettingsSection section)
{
var simpleStringSetting = new SingleValueEditorDescription<string>()
{
Description = "A free text comment that can't contain the word 'invalid'",
// The GetDisplayValue obtains a localized screen representation of the underlying setting value.
GetDisplayValue = LocalizeSimpleSettingValue,
IsReadOnly = false,
DefaultValue = "There is no comment",
Label = "Comment",
Validate = ValidateSimpleStringSetting,
Key = CommentTextKey
};
// Add the setting to the section.
// A setting may also be directly added on a category. It will appear as a setting without a section (top level setting)
settingsApi.AddSetting(section, simpleStringSetting);
}
private static string LocalizeSimpleSettingValue(string s) => $"A localized value of `{s}`";
private static string ValidateSimpleStringSetting(string arg)
{
if (arg?.ToLowerInvariant().Contains("invalid") == true)
{
return "The sample string setting is invalid if it contains the `invalid` keyword";
}
return string.Empty;
}
Dies führt zu:

Prozess-ID und Protokolle abrufen
Mithilfe von Methoden, die auf die IExecutorRuntime
-Referenz angewendet werden, können Sie Informationen über die Prozess-ID abrufen, die vom Roboter ausgeführt wird, sowie Ausführungsprotokolle. Es können die folgenden Methoden verwendet werden:
IRunningJobInformation
– sammelt Informationen über den ausgeführten Prozess und unterstützt die folgenden Eigenschaften:JobID
– ruft die Prozess-ID abProcessName
– ruft den Prozessnamen abProcessVersion
– ruft die Prozessversion abWorkflowFilePath
– ruft den vollständigen Pfad des Prozesses abInitiatedBy
: ruft die Quelle eines Auftrags ab (Roboter, Studio, Orchestrator usw.)FolderId
- retrieves the folder id of the processFolderName
- retrieves the folder name of the processTenantId
- retrieves the tenant idTenantKey
- retrieves the tenant keyTenantName
- retrieves the tenant nameRobotName
- retrieves the robot nameLicenseType
- retrieves the robot license typeRuntimeGovernanceEnabled
- provides info if runtime governance is enabled or notInternalArguments
- retrieves any internal arguments of the processOrganizationId
- retrieves the organization idPictureInPictureMode
- retrieves the type of Picture in Picture mode used. The following values are available:Main
- the process runs in the main Windows sessionPictureInPictureSession
- the process runs in the PiP sessionPictureInPictureDesktop
- the process runs in PiP virtual desktop mode
LogMessage
- Generates Robot Execution Logs according to a Logging Level you specify. Read more about logs on this page. The following properties are supported:EventType
– die abzurufende ProtokollierungsebeneMessage
– die anzuzeigende Meldung
Der folgende Code veranschaulicht die Verwendung der LogMessage
-Methode:
public class MyLogMessageActivity : CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
var executorRuntime = context.GetExtension<IExecutorRuntime>();
var jobInfo = executorRuntime.RunningJobInformation;
executorRuntime.LogMessage(new LogMessage
{
EventType = TraceEventType.Warning,
Message = $"Job {jobInfo.JobId}: My log message from workflow {jobInfo.WorkflowFilePath}"
});
}
}
Projekt zu Studio hinzufügen
Um die Einstellungen in Studio im Fenster Aktivitätsprojekteinstellungen sichtbar zu machen, müssen Sie Ihre benutzerdefinierten Aktivitäten in einem NuGet-Paket veröffentlichen und für einen Feed verfügbar machen, der in Studio, Version 2019.10.1 oder höher, definiert ist.
Erstellen des NuGet-Pakets (NuGet Package)

- NuGet-Paket-Explorer starten (Launch NuGet Package Explorer).
- Klicken Sie auf Ein neues Paket erstellen (Strg + N) (Create a new package (Ctrl + N)). Ein geteiltes Fenster wird angezeigt, in dem Paketmetadaten (Package metadata)und Paketinhalt (Package contents) angezeigt werden. Im letzten Abschnitt müssen alle Abhängigkeiten hinzugefügt werden.
- Klicken Sie mit der rechten Maustaste auf den Abschnitt Paketinhalte (Package contents). Ein Kontextmenü wird angezeigt.
- Klicken Sie auf lib-Ordner hinzufügen (Add lib folder). Ein neues lib (lib)-Element wurde im Bereich Paketinhalt (Package contents) erstellt.
- Drücken Sie die rechte Maustaste auf lib (lib) und wählen Sie Bestehende Datei hinzufügen (Add Existing File)….
- Laden Sie die externe Zusammenstellung (.dll) Ihres Projekts.
- Klicken Sie auf > Bearbeiten; Metadaten bearbeiten (Edit > Edit Metadata). Der Bereich Paketmetadaten (Package metadata) wird angezeigt.
- Befüllen Sie die Felder, um Ihr Projekt sinnvoll beschreiben zu können.
- Füllen Sie das Feld Id aus und geben Sie das Schlüsselwort "Aktivitäten" ein, damit das Paket in Studio im Fenster "Pakete verwalten" angezeigt werden kann.
- Klicken Sie auf Datei > Speichern (File > Save). In unserem Fall wird die Datei
.nupkg
erstellt.
Hinweis:
Erstellen Sie eine intuitive Ordnerstruktur für Ihre Aktivitäten. Alle leeren Ordner in Ihrer benutzerdefinierten Aktivität werden bei der Verwendung mit dem Orchestrator entfernt.
Installieren Sie das NuGet-Paket in UiPath Studio
Once the .nupkg
file is created, add it to a custom feed in Studio, as explained here.
Open the Manage Packages window and install the package. Make sure the custom feed is enabled in Studio.
Beispieleinstellungen
Zusammengenommen sind die oben erstellte Registerkarte, der Abschnitt und die Einstellungen im Fenster Aktivitätsprojekteinstellungen sichtbar:

Simply follow the link below to download the sample, which also contains an example of creating wizards.
Aktualisiert vor 2 Monaten
Siehe auch
Activities Project Settings Reference |