Multiuserkonflikt erkennen
Vorab: Leider geht das nur per API, nicht im Scripting.
Die Ermittlung der User ist schnell gemacht, hab aber noch einen Dialog dazu gepackt, welcher Infos über die User anzeigt:
public static bool IsMultiUserConflict(Project project, bool showDialog = false)
{
var currentUsers = project.CurrentUsers.ToList();
// No conflict
if (currentUsers.Count <= 1)
{
return false;
}
// Conflict
if (showDialog)
{
StringBuilder sb = new StringBuilder();
foreach (var user in currentUsers)
{
if (!string.IsNullOrEmpty(user.Name) && !string.IsNullOrEmpty(user.Identification))
{
sb.AppendLine(user.ComputerName + " / " + user.Name + " / " + user.Identification);
}
else if (!string.IsNullOrEmpty(user.Name))
{
sb.AppendLine(user.ComputerName + " / " + user.Name);
}
else if (!string.IsNullOrEmpty(user.Identification))
{
sb.AppendLine(user.ComputerName + " / " + user.Identification);
}
else
{
sb.AppendLine(user.ComputerName);
}
}
MessageBox.Show(sb.ToString(), "Multi user conflict", MessageBoxButton.OK, MessageBoxImage.Warning);
}
return true;
}
