Share workflow runtime with diagnostics tool
This commit is contained in:
@@ -449,23 +449,18 @@ namespace C4IT.LIAM.Activities
|
||||
|
||||
EnsureDataProviders(context);
|
||||
|
||||
var result = cloneTeam(ConfigID.Get(context), TeamId.Get(context), Name.Get(context), Description.Get(context), Visibility.Get(context), PartsToClone.Get(context), AdditionalMembers.Get(context), AdditionalOwners.Get(context)).GetAwaiter().GetResult();
|
||||
Success.Set(context, result != null);
|
||||
|
||||
if (result?.Result?.targetResourceId != null)
|
||||
{
|
||||
string idString = result.Result.targetResourceId.ToString();
|
||||
if (Guid.TryParse(idString, out Guid teamGuid))
|
||||
{
|
||||
CreatedTeamId.Set(context, teamGuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogEntry($"targetResourceId '{idString}' is not a valid Guid.", LogLevels.Warning);
|
||||
// Optional: alternativ hier einen Fehler werfen oder Guid.Empty zuweisen
|
||||
CreatedTeamId.Set(context, Guid.Empty);
|
||||
}
|
||||
}
|
||||
var providerEntry = getDataProvider(ConfigID.Get(context));
|
||||
var result = LiamWorkflowRuntime.CloneTeamAsync(
|
||||
providerEntry?.Provider,
|
||||
TeamId.Get(context),
|
||||
Name.Get(context),
|
||||
Description.Get(context),
|
||||
Visibility.Get(context),
|
||||
PartsToClone.Get(context),
|
||||
AdditionalMembers.Get(context),
|
||||
AdditionalOwners.Get(context)).GetAwaiter().GetResult();
|
||||
Success.Set(context, result != null && result.Success);
|
||||
CreatedTeamId.Set(context, result?.CreatedTeamId ?? Guid.Empty);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
@@ -606,45 +601,17 @@ namespace C4IT.LIAM.Activities
|
||||
ErrorMessage.Set(context, string.Empty);
|
||||
|
||||
var entry = getDataProvider(ConfigID.Get(context));
|
||||
if (entry != null && entry.Provider is cLiamProviderExchange ex)
|
||||
{
|
||||
var result = ex.exchangeManager.CreateDistributionGroupWithOwnershipGroups(
|
||||
Name.Get(context),
|
||||
Alias.Get(context),
|
||||
DistributionListDisplayName.Get(context),
|
||||
PrimarySmtpAddress.Get(context),
|
||||
out string errorCode,
|
||||
out string errorMessage
|
||||
);
|
||||
ErrorCode.Set(context, errorCode);
|
||||
ErrorMessage.Set(context, errorMessage);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
Success.Set(context, true);
|
||||
ObjectGuid.Set(context, result.Item1);
|
||||
CreatedGroups.Set(context, result.Item2);
|
||||
LogEntry(
|
||||
$"Distribution group creation succeeded. ObjectGuid='{result.Item1}', CreatedGroups='{result.Item2?.Count ?? 0}'",
|
||||
LogLevels.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
Success.Set(context, false);
|
||||
LogEntry(
|
||||
$"Distribution group creation failed [{errorCode}] {errorMessage}",
|
||||
LogLevels.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Success.Set(context, false);
|
||||
ErrorCode.Set(context, "WF_PROVIDER_INVALID");
|
||||
ErrorMessage.Set(context, $"Provider is not a cLiamProviderExchange for config '{ConfigID.Get(context)}'.");
|
||||
LogEntry(
|
||||
$"Distribution group creation failed [WF_PROVIDER_INVALID] Provider is not a cLiamProviderExchange for config '{ConfigID.Get(context)}'.",
|
||||
LogLevels.Error);
|
||||
}
|
||||
var result = LiamWorkflowRuntime.CreateDistributionGroup(
|
||||
entry?.Provider,
|
||||
Name.Get(context),
|
||||
Alias.Get(context),
|
||||
DistributionListDisplayName.Get(context),
|
||||
PrimarySmtpAddress.Get(context));
|
||||
Success.Set(context, result.Success);
|
||||
ObjectGuid.Set(context, result.ObjectGuid);
|
||||
CreatedGroups.Set(context, result.CreatedGroups);
|
||||
ErrorCode.Set(context, result.ErrorCode);
|
||||
ErrorMessage.Set(context, result.ErrorMessage);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -729,45 +696,17 @@ namespace C4IT.LIAM.Activities
|
||||
ErrorMessage.Set(context, string.Empty);
|
||||
|
||||
var entry = getDataProvider(ConfigID.Get(context));
|
||||
if (entry != null && entry.Provider is cLiamProviderExchange ex)
|
||||
{
|
||||
var result = ex.exchangeManager.CreateSharedMailboxWithOwnershipGroups(
|
||||
Name.Get(context),
|
||||
Alias.Get(context),
|
||||
MailboxDisplayName.Get(context),
|
||||
PrimarySmtpAddress.Get(context),
|
||||
out string errorCode,
|
||||
out string errorMessage
|
||||
);
|
||||
ErrorCode.Set(context, errorCode);
|
||||
ErrorMessage.Set(context, errorMessage);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
Success.Set(context, true);
|
||||
ObjectGuid.Set(context, result.Item1);
|
||||
CreatedGroups.Set(context, result.Item2);
|
||||
LogEntry(
|
||||
$"Shared mailbox creation succeeded. ObjectGuid='{result.Item1}', CreatedGroups='{result.Item2?.Count ?? 0}'",
|
||||
LogLevels.Info);
|
||||
}
|
||||
else
|
||||
{
|
||||
Success.Set(context, false);
|
||||
LogEntry(
|
||||
$"Shared mailbox creation failed [{errorCode}] {errorMessage}",
|
||||
LogLevels.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Success.Set(context, false);
|
||||
ErrorCode.Set(context, "WF_PROVIDER_INVALID");
|
||||
ErrorMessage.Set(context, $"Provider is not a cLiamProviderExchange for config '{ConfigID.Get(context)}'.");
|
||||
LogEntry(
|
||||
$"Shared mailbox creation failed [WF_PROVIDER_INVALID] Provider is not a cLiamProviderExchange for config '{ConfigID.Get(context)}'.",
|
||||
LogLevels.Error);
|
||||
}
|
||||
var result = LiamWorkflowRuntime.CreateSharedMailbox(
|
||||
entry?.Provider,
|
||||
Name.Get(context),
|
||||
Alias.Get(context),
|
||||
MailboxDisplayName.Get(context),
|
||||
PrimarySmtpAddress.Get(context));
|
||||
Success.Set(context, result.Success);
|
||||
ObjectGuid.Set(context, result.ObjectGuid);
|
||||
CreatedGroups.Set(context, result.CreatedGroups);
|
||||
ErrorCode.Set(context, result.ErrorCode);
|
||||
ErrorMessage.Set(context, result.ErrorMessage);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -892,15 +831,16 @@ namespace C4IT.LIAM.Activities
|
||||
var ownerList = OwnerSids.Expression != null ? OwnerSids.Get(context) : null;
|
||||
var memberList = MemberSids.Expression != null ? MemberSids.Get(context) : null;
|
||||
|
||||
var groups = adProv.CreateServiceGroups(
|
||||
var result = LiamWorkflowRuntime.CreateAdServiceGroups(
|
||||
adProv,
|
||||
svcName,
|
||||
desc,
|
||||
scopeEnum,
|
||||
typeEnum,
|
||||
ownerList,
|
||||
memberList);
|
||||
Success.Set(context, groups != null);
|
||||
CreatedGroups.Set(context, groups);
|
||||
Success.Set(context, result.Success);
|
||||
CreatedGroups.Set(context, result.CreatedGroups);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -937,9 +877,9 @@ namespace C4IT.LIAM.Activities
|
||||
{
|
||||
EnsureDataProviders(context);
|
||||
var cfgId = ConfigID.Get(context);
|
||||
var provider = getDataProvider(cfgId).Provider as cLiamProviderNtfs;
|
||||
// evtl. CustomTags, OwnerSIDs etc. aus Activity-Inputs holen
|
||||
var res = provider.CreateDataAreaAsync(
|
||||
var provider = getDataProvider(cfgId)?.Provider;
|
||||
var result = LiamWorkflowRuntime.CreateDataAreaAsync(
|
||||
provider,
|
||||
NewFolderPath.Get(context),
|
||||
ParentFolderPath.Get(context),
|
||||
/*customTags*/null,
|
||||
@@ -947,7 +887,7 @@ namespace C4IT.LIAM.Activities
|
||||
/*readerSids*/null,
|
||||
/*writerSids*/null
|
||||
).GetAwaiter().GetResult();
|
||||
ResultToken.Set(context, JsonValue.Parse(JsonConvert.SerializeObject(res)));
|
||||
ResultToken.Set(context, JsonValue.Parse(JsonConvert.SerializeObject(result.ResultToken)));
|
||||
}
|
||||
private void EnsureDataProviders(NativeActivityContext context)
|
||||
{
|
||||
@@ -1002,45 +942,22 @@ namespace C4IT.LIAM.Activities
|
||||
EnsureDataProviders(context);
|
||||
|
||||
var cfgId = ConfigID.Get(context);
|
||||
var providerEntry = getDataProvider(cfgId);
|
||||
var provider = providerEntry?.Provider as cLiamProviderNtfs;
|
||||
var folderPath = FolderPath.Get(context);
|
||||
if (provider == null || string.IsNullOrWhiteSpace(folderPath))
|
||||
{
|
||||
Success.Set(context, false);
|
||||
ResultToken.Set(context, JsonValue.Parse(JsonConvert.SerializeObject(new ResultToken(GetType().Name)
|
||||
{
|
||||
resultErrorId = 1,
|
||||
resultMessage = provider == null ? "Configured provider is not NTFS or not initialized." : "Folder path is missing."
|
||||
})));
|
||||
return;
|
||||
}
|
||||
|
||||
var ownerSids = OwnerSids.Expression != null ? OwnerSids.Get(context) : null;
|
||||
var readerSids = ReaderSids.Expression != null ? ReaderSids.Get(context) : null;
|
||||
var writerSids = WriterSids.Expression != null ? WriterSids.Get(context) : null;
|
||||
|
||||
var result = provider.EnsureMissingPermissionGroupsAsync(
|
||||
folderPath,
|
||||
var providerEntry = getDataProvider(cfgId);
|
||||
var result = LiamWorkflowRuntime.EnsureNtfsPermissionGroupsAsync(
|
||||
providerEntry?.Provider,
|
||||
FolderPath.Get(context),
|
||||
null,
|
||||
NormalizeSidList(ownerSids),
|
||||
NormalizeSidList(readerSids),
|
||||
NormalizeSidList(writerSids),
|
||||
ownerSids,
|
||||
readerSids,
|
||||
writerSids,
|
||||
EnsureTraverse.Get(context)).GetAwaiter().GetResult();
|
||||
|
||||
Success.Set(context, result != null && result.resultErrorId == 0);
|
||||
ResultToken.Set(context, JsonValue.Parse(JsonConvert.SerializeObject(result)));
|
||||
}
|
||||
|
||||
private IEnumerable<string> NormalizeSidList(IEnumerable<string> rawSids)
|
||||
{
|
||||
if (rawSids == null)
|
||||
return Enumerable.Empty<string>();
|
||||
|
||||
return rawSids
|
||||
.Select(i => i?.Trim())
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase);
|
||||
Success.Set(context, result.Success);
|
||||
ResultToken.Set(context, JsonValue.Parse(JsonConvert.SerializeObject(result.ResultToken)));
|
||||
}
|
||||
|
||||
private void EnsureDataProviders(NativeActivityContext context)
|
||||
|
||||
Reference in New Issue
Block a user