Added ClearSingleValeAttribute. Moving to Tracer for logging

master
Granfeldt_cp 2015-12-16 04:20:36 -08:00
parent c48ad73f33
commit 9e36140077
40 changed files with 4428 additions and 231 deletions

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,197 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class BackReferenceUpdateMemberActivity : SequenceActivity
{
public BackReferenceUpdateMemberActivity()
{
InitializeComponent();
}
public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(BackReferenceUpdateMemberActivity));
[Description("Title")]
[Category("Title Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Title
{
get
{
return ((string)(base.GetValue(BackReferenceUpdateMemberActivity.TitleProperty)));
}
set
{
base.SetValue(BackReferenceUpdateMemberActivity.TitleProperty, value);
}
}
public static DependencyProperty ActionProperty = DependencyProperty.Register("Action", typeof(string), typeof(BackReferenceUpdateMemberActivity));
[Description("Action")]
[Category("Action Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Action
{
get
{
return ((string)(base.GetValue(BackReferenceUpdateMemberActivity.ActionProperty)));
}
set
{
base.SetValue(BackReferenceUpdateMemberActivity.ActionProperty, value);
}
}
public static DependencyProperty SourceProperty = DependencyProperty.Register("Source", typeof(string), typeof(BackReferenceUpdateMemberActivity));
[Description("Source")]
[Category("Source Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Source
{
get
{
return ((string)(base.GetValue(BackReferenceUpdateMemberActivity.SourceProperty)));
}
set
{
base.SetValue(BackReferenceUpdateMemberActivity.SourceProperty, value);
}
}
public static DependencyProperty DestinationProperty = DependencyProperty.Register("Destination", typeof(string), typeof(BackReferenceUpdateMemberActivity));
[Description("Destination")]
[Category("Destination Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Destination
{
get
{
return ((string)(base.GetValue(BackReferenceUpdateMemberActivity.DestinationProperty)));
}
set
{
base.SetValue(BackReferenceUpdateMemberActivity.DestinationProperty, value);
}
}
public List<Guid> GroupToUpdate = null;
public Guid CurrentGroupToUpdate;
private void ForEveryAdd_Condition(object sender, ConditionalEventArgs e)
{
Debugging.Log("Enter::ForEveryAdd_Condition");
// if not initialized, then initialize and load value into List
if (GroupToUpdate == null)
{
GroupToUpdate = new List<Guid>(this.GetReferenceUpdates.AddedReferences);
}
Debugging.Log(string.Format("Count: {0}", GroupToUpdate.Count));
if (GroupToUpdate.Count > 0)
{
// removed processed item
CurrentGroupToUpdate = GroupToUpdate[0];
GroupToUpdate.RemoveAt(0);
e.Result = true;
}
else
{
// no more items to process
e.Result = false;
}
Debugging.Log("Exit::ForEveryAdd_Condition");
}
private void PrepareGroupOperation_ExecuteCode(object sender, EventArgs e)
{
Debugging.Log("Enter::PrepareGroupOperation_ExecuteCode");
try
{
// since we're in a while loop, we have to grab the instantiated workflow activity UpdateResourceActivity
SequenceActivity currentParentSequenceActivity = (SequenceActivity)((CodeActivity)sender).Parent;
UpdateReferenceAttributesAsNeededActivity currentUpdateResourceActivity = currentParentSequenceActivity.Activities.OfType<UpdateReferenceAttributesAsNeededActivity>().First();
SequentialWorkflow containingWorkflow = null;
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
{
throw new InvalidOperationException("Could not get parent workflow!");
}
Debugging.Log(string.Format("Resource Id: {0}", CurrentGroupToUpdate));
currentUpdateResourceActivity.ActorId = WellKnownGuids.BuiltInSynchronizationAccount;
currentUpdateResourceActivity.ResourceId = CurrentGroupToUpdate;
currentUpdateResourceActivity.AttributeName = this.Destination;
if (this.Action.ToLower() == "add")
{
Debugging.Log(string.Format("Add member: {0}", this.GetReferenceUpdates.ResourceId.ToString()));
currentUpdateResourceActivity.UpdateMode = UpdateMode.Insert;
}
else
{
Debugging.Log(string.Format("Remove member: {0}", this.GetReferenceUpdates.ResourceId.ToString()));
currentUpdateResourceActivity.UpdateMode = UpdateMode.Remove;
}
currentUpdateResourceActivity.Values = new Guid[] { this.GetReferenceUpdates.ResourceId };
}
catch (Exception ex)
{
Debugging.Log(string.Format("Error: {0}", ex.Message));
}
Debugging.Log("Exit::PrepareGroupOperation_ExecuteCode");
}
private void SetupClearMV_ExecuteCode(object sender, EventArgs e)
{
Debugging.Log("Enter::SetupClearMV_ExecuteCode");
try
{
SequentialWorkflow containingWorkflow = null;
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
{
throw new InvalidOperationException("Could not get parent workflow!");
}
ClearMVOnResource.ActorId = WellKnownGuids.BuiltInSynchronizationAccount;
ClearMVOnResource.ResourceId = containingWorkflow.TargetId;
int numOfElements = this.GetReferenceUpdates.AddedReferences.ToList().Count;
Debugging.Log(string.Format("List count: {0}", this.GetReferenceUpdates.AddedReferences.ToList().Count));
Debugging.Log(string.Format("Remove elements: {0}", numOfElements));
List<UpdateRequestParameter> ps = new List<UpdateRequestParameter>();
foreach (Guid value in this.GetReferenceUpdates.AddedReferences.ToList())
{
Debugging.Log(string.Format("Removing: {0}", value));
UpdateRequestParameter p = new UpdateRequestParameter();
p.PropertyName = this.Source;
p.Mode = UpdateMode.Remove;
p.Value = value;
ps.Add(p);
}
ClearMVOnResource.UpdateParameters = ps.ToArray();
}
catch (Exception ex)
{
Debugging.Log(string.Format("Error: {0}", ex.Message));
}
Debugging.Log("Exit::SetupClearMV_ExecuteCode");
}
}
}

View File

@ -0,0 +1,206 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Reflection;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class BackReferenceUpdateMemberActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
[System.CodeDom.Compiler.GeneratedCode("", "")]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
System.Workflow.Activities.CodeCondition codecondition2 = new System.Workflow.Activities.CodeCondition();
System.Workflow.Activities.Rules.RuleConditionReference ruleconditionreference1 = new System.Workflow.Activities.Rules.RuleConditionReference();
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
this.RemoveFromTarget = new Granfeldt.FIM.ActivityLibrary.UpdateReferenceAttributesAsNeededActivity();
this.PrepareGroupRemoveOperation = new System.Workflow.Activities.CodeActivity();
this.AddToTarget = new Granfeldt.FIM.ActivityLibrary.UpdateReferenceAttributesAsNeededActivity();
this.PrepareGroupAddOperation = new System.Workflow.Activities.CodeActivity();
this.RemoveActivity = new System.Workflow.Activities.SequenceActivity();
this.AddingActivity = new System.Workflow.Activities.SequenceActivity();
this.ForEachMemberToRemove = new System.Workflow.Activities.WhileActivity();
this.ForEachMemberToAdd = new System.Workflow.Activities.WhileActivity();
this.ClearMVOnResource = new Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity();
this.SetupClearMV = new System.Workflow.Activities.CodeActivity();
this.Remove = new System.Workflow.Activities.IfElseBranchActivity();
this.Add = new System.Workflow.Activities.IfElseBranchActivity();
this.ClearMultivalueAttribute = new System.Workflow.Activities.SequenceActivity();
this.ifElseActivity1 = new System.Workflow.Activities.IfElseActivity();
this.GetReferenceUpdates = new Granfeldt.FIM.ActivityLibrary.GetUpdatesToReferenceAttributeActivity();
//
// RemoveFromTarget
//
this.RemoveFromTarget.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.RemoveFromTarget.AttributeName = null;
this.RemoveFromTarget.Name = "RemoveFromTarget";
this.RemoveFromTarget.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.RemoveFromTarget.UpdateMode = Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode.Modify;
this.RemoveFromTarget.Values = null;
//
// PrepareGroupRemoveOperation
//
this.PrepareGroupRemoveOperation.Name = "PrepareGroupRemoveOperation";
this.PrepareGroupRemoveOperation.ExecuteCode += new System.EventHandler(this.PrepareGroupOperation_ExecuteCode);
//
// AddToTarget
//
this.AddToTarget.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.AddToTarget.AttributeName = null;
this.AddToTarget.Name = "AddToTarget";
this.AddToTarget.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.AddToTarget.UpdateMode = Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode.Modify;
this.AddToTarget.Values = null;
//
// PrepareGroupAddOperation
//
this.PrepareGroupAddOperation.Name = "PrepareGroupAddOperation";
this.PrepareGroupAddOperation.ExecuteCode += new System.EventHandler(this.PrepareGroupOperation_ExecuteCode);
//
// RemoveActivity
//
this.RemoveActivity.Activities.Add(this.PrepareGroupRemoveOperation);
this.RemoveActivity.Activities.Add(this.RemoveFromTarget);
this.RemoveActivity.Name = "RemoveActivity";
//
// AddingActivity
//
this.AddingActivity.Activities.Add(this.PrepareGroupAddOperation);
this.AddingActivity.Activities.Add(this.AddToTarget);
this.AddingActivity.Name = "AddingActivity";
//
// ForEachMemberToRemove
//
this.ForEachMemberToRemove.Activities.Add(this.RemoveActivity);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.ForEveryAdd_Condition);
this.ForEachMemberToRemove.Condition = codecondition1;
this.ForEachMemberToRemove.Name = "ForEachMemberToRemove";
//
// ForEachMemberToAdd
//
this.ForEachMemberToAdd.Activities.Add(this.AddingActivity);
codecondition2.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.ForEveryAdd_Condition);
this.ForEachMemberToAdd.Condition = codecondition2;
this.ForEachMemberToAdd.Name = "ForEachMemberToAdd";
//
// ClearMVOnResource
//
this.ClearMVOnResource.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ClearMVOnResource.Name = "ClearMVOnResource";
this.ClearMVOnResource.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ClearMVOnResource.UpdateParameters = null;
//
// SetupClearMV
//
this.SetupClearMV.Name = "SetupClearMV";
this.SetupClearMV.ExecuteCode += new System.EventHandler(this.SetupClearMV_ExecuteCode);
//
// Remove
//
this.Remove.Activities.Add(this.ForEachMemberToRemove);
this.Remove.Name = "Remove";
//
// Add
//
this.Add.Activities.Add(this.ForEachMemberToAdd);
ruleconditionreference1.ConditionName = "Condition1";
this.Add.Condition = ruleconditionreference1;
this.Add.Name = "Add";
//
// ClearMultivalueAttribute
//
this.ClearMultivalueAttribute.Activities.Add(this.SetupClearMV);
this.ClearMultivalueAttribute.Activities.Add(this.ClearMVOnResource);
this.ClearMultivalueAttribute.Name = "ClearMultivalueAttribute";
//
// ifElseActivity1
//
this.ifElseActivity1.Activities.Add(this.Add);
this.ifElseActivity1.Activities.Add(this.Remove);
this.ifElseActivity1.Name = "ifElseActivity1";
//
// GetReferenceUpdates
//
this.GetReferenceUpdates.AddedReferences = null;
activitybind1.Name = "BackReferenceUpdateMemberActivity";
activitybind1.Path = "Source";
this.GetReferenceUpdates.ModifiedReferences = null;
this.GetReferenceUpdates.Name = "GetReferenceUpdates";
this.GetReferenceUpdates.OperationType = Microsoft.ResourceManagement.WebServices.WSResourceManagement.OperationType.Create;
this.GetReferenceUpdates.RemovedReferences = null;
this.GetReferenceUpdates.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.GetReferenceUpdates.SetBinding(Granfeldt.FIM.ActivityLibrary.GetUpdatesToReferenceAttributeActivity.AttributeNameProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
//
// BackReferenceUpdateMemberActivity
//
this.Activities.Add(this.GetReferenceUpdates);
this.Activities.Add(this.ifElseActivity1);
this.Activities.Add(this.ClearMultivalueAttribute);
this.Name = "BackReferenceUpdateMemberActivity";
this.CanModifyActivities = false;
}
#endregion
private CodeActivity SetupClearMV;
private SequenceActivity ClearMultivalueAttribute;
private Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity ClearMVOnResource;
private IfElseBranchActivity Remove;
private IfElseBranchActivity Add;
private IfElseActivity ifElseActivity1;
private UpdateReferenceAttributesAsNeededActivity RemoveFromTarget;
private CodeActivity PrepareGroupRemoveOperation;
private SequenceActivity RemoveActivity;
private WhileActivity ForEachMemberToRemove;
private UpdateReferenceAttributesAsNeededActivity AddToTarget;
private CodeActivity PrepareGroupAddOperation;
private SequenceActivity AddingActivity;
private WhileActivity ForEachMemberToAdd;
private GetUpdatesToReferenceAttributeActivity GetReferenceUpdates;
}
}

View File

@ -0,0 +1,32 @@
<RuleDefinitions xmlns="http://schemas.microsoft.com/winfx/2006/xaml/workflow">
<RuleDefinitions.Conditions>
<RuleExpressionCondition Name="Condition1">
<RuleExpressionCondition.Expression>
<ns0:CodeBinaryOperatorExpression Operator="ValueEquality" xmlns:ns0="clr-namespace:System.CodeDom;Assembly=System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<ns0:CodeBinaryOperatorExpression.Right>
<ns0:CodePrimitiveExpression>
<ns0:CodePrimitiveExpression.Value>
<ns1:String xmlns:ns1="clr-namespace:System;Assembly=mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">add</ns1:String>
</ns0:CodePrimitiveExpression.Value>
</ns0:CodePrimitiveExpression>
</ns0:CodeBinaryOperatorExpression.Right>
<ns0:CodeBinaryOperatorExpression.Left>
<ns0:CodeMethodInvokeExpression>
<ns0:CodeMethodInvokeExpression.Method>
<ns0:CodeMethodReferenceExpression MethodName="ToLower">
<ns0:CodeMethodReferenceExpression.TargetObject>
<ns0:CodePropertyReferenceExpression PropertyName="Action">
<ns0:CodePropertyReferenceExpression.TargetObject>
<ns0:CodeThisReferenceExpression />
</ns0:CodePropertyReferenceExpression.TargetObject>
</ns0:CodePropertyReferenceExpression>
</ns0:CodeMethodReferenceExpression.TargetObject>
</ns0:CodeMethodReferenceExpression>
</ns0:CodeMethodInvokeExpression.Method>
</ns0:CodeMethodInvokeExpression>
</ns0:CodeBinaryOperatorExpression.Left>
</ns0:CodeBinaryOperatorExpression>
</RuleExpressionCondition.Expression>
</RuleExpressionCondition>
</RuleDefinitions.Conditions>
</RuleDefinitions>

View File

@ -0,0 +1,197 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Workflow.ComponentModel;
using Microsoft.IdentityManagement.WebUI.Controls;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
class BackReferenceUpdateMemberActivitySettingsPart : ActivitySettingsPart
{
/// <summary>
/// Creates a Table that contains the controls used by the activity UI
/// in the Workflow Designer of the FIM portal. Adds that Table to the
/// collection of Controls that defines each activity that can be selected
/// in the Workflow Designer of the FIM Portal. Calls the base class of
/// ActivitySettingsPart to render the controls in the UI.
/// </summary>
protected override void CreateChildControls()
{
Table controlLayoutTable;
controlLayoutTable = new Table();
//Width is set to 100% of the control size
controlLayoutTable.Width = Unit.Percentage(100.0);
controlLayoutTable.BorderWidth = 0;
controlLayoutTable.CellPadding = 2;
//Add a TableRow for each textbox in the UI
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Title:", "txtTitle", 400, 100, false, ""));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Source reference attribute:", "txtSource", 400, 100, false, ""));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Destination attribute:", "txtDestination", 400, 100, false, ""));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Action (type 'add' or 'remove'):", "txtAction", 400, 100, false, ""));
this.Controls.Add(controlLayoutTable);
base.CreateChildControls();
}
#region Utility Functions
//Create a TableRow that contains a label and a textbox.
private TableRow AddTableRowTextBox(String labelText, String controlID, int width, int maxLength, Boolean multiLine, String defaultValue)
{
TableRow row = new TableRow();
TableCell labelCell = new TableCell();
TableCell controlCell = new TableCell();
Label oLabel = new Label();
TextBox oText = new TextBox();
oLabel.Text = labelText;
oLabel.CssClass = base.LabelCssClass;
labelCell.Controls.Add(oLabel);
oText.ID = controlID;
oText.CssClass = base.TextBoxCssClass;
oText.Text = defaultValue;
oText.MaxLength = maxLength;
oText.Width = width;
if (multiLine)
{
oText.TextMode = TextBoxMode.MultiLine;
oText.Rows = System.Math.Min(6, (maxLength + 60) / 60);
oText.Wrap = true;
}
controlCell.Controls.Add(oText);
row.Cells.Add(labelCell);
row.Cells.Add(controlCell);
return row;
}
string GetText(string textBoxID)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
return textBox.Text ?? String.Empty;
}
void SetText(string textBoxID, string text)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
if (textBox != null)
textBox.Text = text;
else
textBox.Text = "";
}
//Set the text box to read mode or read/write mode
void SetTextBoxReadOnlyOption(string textBoxID, bool readOnly)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
textBox.ReadOnly = readOnly;
}
#endregion
/// <summary>
/// Called when a user clicks the Save button in the Workflow Designer.
/// Returns an instance of the RequestLoggingActivity class that
/// has its properties set to the values entered into the text box controls
/// used in the UI of the activity.
/// </summary>
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
{
if (!this.ValidateInputs())
{
return null;
}
BackReferenceUpdateMemberActivity ThisActivity = new BackReferenceUpdateMemberActivity();
ThisActivity.Title = this.GetText("txtTitle");
ThisActivity.Source = this.GetText("txtSource");
ThisActivity.Destination = this.GetText("txtDestination");
ThisActivity.Action = this.GetText("txtAction");
return ThisActivity;
}
public override void LoadActivitySettings(Activity activity)
{
BackReferenceUpdateMemberActivity ThisActivity = activity as BackReferenceUpdateMemberActivity;
if (ThisActivity != null)
{
this.SetText("txtTitle", ThisActivity.Title);
this.SetText("txtSource", ThisActivity.Source);
this.SetText("txtDestination", ThisActivity.Destination);
this.SetText("txtAction", ThisActivity.Action);
}
}
/// <summary>
/// Saves the activity settings.
/// </summary>
public override ActivitySettingsPartData PersistSettings()
{
ActivitySettingsPartData data = new ActivitySettingsPartData();
data["Title"] = this.GetText("txtTitle");
data["Source"] = this.GetText("txtSource");
data["Attribute"] = this.GetText("txtDestination");
data["Action"] = this.GetText("txtAction");
return data;
}
/// <summary>
/// Restores the activity settings in the UI
/// </summary>
public override void RestoreSettings(ActivitySettingsPartData data)
{
if (null != data)
{
this.SetText("txtTitle", (string)data["Title"]);
this.SetText("txtSource", (string)data["Source"]);
this.SetText("txtDestination", (string)data["Attribute"]);
this.SetText("txtAction", (string)data["Action"]);
}
}
/// <summary>
/// Switches the activity between read only and read/write mode
/// </summary>
public override void SwitchMode(ActivitySettingsPartMode mode)
{
bool readOnly = (mode == ActivitySettingsPartMode.View);
this.SetTextBoxReadOnlyOption("txtTitle", readOnly);
this.SetTextBoxReadOnlyOption("txtDestination", readOnly);
this.SetTextBoxReadOnlyOption("txtSource", readOnly);
this.SetTextBoxReadOnlyOption("txtAction", readOnly);
}
/// <summary>
/// Returns the activity name.
/// </summary>
public override string Title
{
get
{
return string.Format("Add Remove Value: {0}", this.GetText("txtTitle"));
}
}
/// <summary>
/// In general, this method should be used to validate information entered
/// by the user when the activity is added to a workflow in the Workflow
/// Designer.
/// We could add code to verify that the log file path already exists on
/// the server that is hosting the FIM Portal and check that the activity
/// has permission to write to that location. However, the code
/// would only check if the log file path exists when the
/// activity is added to a workflow in the workflow designer. This class
/// will not be used when the activity is actually run.
/// For this activity we will just return true.
/// </summary>
public override bool ValidateInputs()
{
return true;
}
}
}

View File

@ -0,0 +1,147 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
namespace Granfeldt.FIM.ActivityLibrary
{
[Designer(typeof(ActivityDesigner), typeof(IDesigner))]
public partial class GetReferenceValuesFromObjectActivity: SequenceActivity
{
#region Properties
public static DependencyProperty ObjectIDProperty = DependencyProperty.Register("ObjectID", typeof(Guid), typeof(GetReferenceValuesFromObjectActivity));
[Description("ObjectID")]
[Category("Input")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid ObjectID
{
get
{
return ((Guid)(base.GetValue(GetReferenceValuesFromObjectActivity.ObjectIDProperty)));
}
set
{
base.SetValue(GetReferenceValuesFromObjectActivity.ObjectIDProperty, value);
}
}
public static DependencyProperty AttributeNameProperty = DependencyProperty.Register("AttributeName", typeof(String), typeof(GetReferenceValuesFromObjectActivity));
[Description("AttributeName")]
[Category("Input")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public String AttributeName
{
get
{
return ((String)(base.GetValue(GetReferenceValuesFromObjectActivity.AttributeNameProperty)));
}
set
{
base.SetValue(GetReferenceValuesFromObjectActivity.AttributeNameProperty, value);
}
}
public static DependencyProperty ActorIdProperty = DependencyProperty.Register("ActorId", typeof(Guid), typeof(GetReferenceValuesFromObjectActivity));
[Description("ActorId")]
[Category("Input")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid ActorId
{
get
{
return ((Guid)(base.GetValue(GetReferenceValuesFromObjectActivity.ActorIdProperty)));
}
set
{
base.SetValue(GetReferenceValuesFromObjectActivity.ActorIdProperty, value);
}
}
public static DependencyProperty CurrentValuesProperty = DependencyProperty.Register("CurrentValues", typeof(Guid[]), typeof(GetReferenceValuesFromObjectActivity));
[Description("CurrentValues")]
[Category("Output")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid[] CurrentValues
{
get
{
return ((Guid[])(base.GetValue(GetReferenceValuesFromObjectActivity.CurrentValuesProperty)));
}
set
{
base.SetValue(GetReferenceValuesFromObjectActivity.CurrentValuesProperty, value);
}
}
#endregion
public GetReferenceValuesFromObjectActivity()
{
InitializeComponent();
}
public String[] SelectionAttributes = default(System.String[]);
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType CurrentResource = new Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType();
private void PrepareReading_ExecuteCode(object sender, EventArgs e)
{
this.SelectionAttributes = new string[] {this.AttributeName};
}
private void ProcessResults_ExecuteCode(object sender, EventArgs e)
{
object PropertyValue = this.CurrentResource[this.AttributeName];
List<Guid> currentValues = new List<Guid>();
if (null != PropertyValue)
{
if (PropertyValue.GetType().FullName.StartsWith("System.Collections.Generic.List") ||
PropertyValue.GetType().FullName.EndsWith("[]"))
{
foreach (object myObject in (IEnumerable) PropertyValue)
{
if (myObject is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
{
currentValues.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier) myObject).GetGuid());
}
if (myObject is System.Guid)
{
currentValues.Add((System.Guid) myObject);
}
}
}
else
{
if (PropertyValue is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
{
currentValues.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier) PropertyValue).GetGuid());
}
if (PropertyValue is System.Guid)
{
currentValues.Add((System.Guid) PropertyValue);
}
}
}
this.CurrentValues = currentValues.Distinct().ToArray();
}
}
}

View File

@ -0,0 +1,75 @@
using System.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class GetReferenceValuesFromObjectActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind3 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind4 = new System.Workflow.ComponentModel.ActivityBind();
this.ProcessResults = new System.Workflow.Activities.CodeActivity();
this.ReadResource = new Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity();
this.PrepareReading = new System.Workflow.Activities.CodeActivity();
//
// ProcessResults
//
this.ProcessResults.Name = "ProcessResults";
this.ProcessResults.ExecuteCode += new System.EventHandler(this.ProcessResults_ExecuteCode);
//
// ReadResource
//
activitybind1.Name = "GetReferenceValuesFromObjectActivity";
activitybind1.Path = "ActorId";
this.ReadResource.Name = "ReadResource";
activitybind2.Name = "GetReferenceValuesFromObjectActivity";
activitybind2.Path = "CurrentResource";
activitybind3.Name = "GetReferenceValuesFromObjectActivity";
activitybind3.Path = "ObjectID";
activitybind4.Name = "GetReferenceValuesFromObjectActivity";
activitybind4.Path = "SelectionAttributes";
this.ReadResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ActorIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
this.ReadResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ResourceIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind3)));
//this.ReadResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.SelectionAttributesProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind4)));
this.ReadResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ResourceProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
//
// PrepareReading
//
this.PrepareReading.Name = "PrepareReading";
this.PrepareReading.ExecuteCode += new System.EventHandler(this.PrepareReading_ExecuteCode);
//
// GetReferenceValuesFromObjectActivity
//
this.Activities.Add(this.PrepareReading);
this.Activities.Add(this.ReadResource);
this.Activities.Add(this.ProcessResults);
this.Name = "GetReferenceValuesFromObjectActivity";
this.CanModifyActivities = false;
}
#endregion
private CodeActivity PrepareReading;
private CodeActivity ProcessResults;
private Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity ReadResource;
}
}

View File

@ -0,0 +1,48 @@
using System.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class GetUpdatesToReferenceAttributeActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
this.ExtractDataFromRequest = new System.Workflow.Activities.CodeActivity();
this.GetCurrentRequest = new Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity();
//
// ExtractDataFromRequest
//
this.ExtractDataFromRequest.Name = "ExtractDataFromRequest";
this.ExtractDataFromRequest.ExecuteCode += new System.EventHandler(this.ExtractDataFromRequest_ExecuteCode);
//
// GetCurrentRequest
//
activitybind1.Name = "GetUpdatesToReferenceAttributeActivity";
activitybind1.Path = "CurrentRequest";
this.GetCurrentRequest.Name = "GetCurrentRequest";
this.GetCurrentRequest.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity.CurrentRequestProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
//
// GetUpdatesToReferenceAttributeActivity
//
this.Activities.Add(this.GetCurrentRequest);
this.Activities.Add(this.ExtractDataFromRequest);
this.Name = "GetUpdatesToReferenceAttributeActivity";
this.CanModifyActivities = false;
}
#endregion
private CodeActivity ExtractDataFromRequest;
private Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity GetCurrentRequest;
}
}

View File

@ -0,0 +1,289 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
namespace Granfeldt.FIM.ActivityLibrary
{
[Designer(typeof(ActivityDesigner), typeof(IDesigner))]
public partial class GetUpdatesToReferenceAttributeActivity : SequenceActivity
{
#region Properties
public static DependencyProperty AddedReferencesProperty = DependencyProperty.Register("AddedReferences", typeof(Guid[]), typeof(GetUpdatesToReferenceAttributeActivity));
[Description("AddedReferences")]
[Category("Output")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid[] AddedReferences
{
get
{
return ((Guid[])(base.GetValue(GetUpdatesToReferenceAttributeActivity.AddedReferencesProperty)));
}
set
{
base.SetValue(GetUpdatesToReferenceAttributeActivity.AddedReferencesProperty, value);
}
}
public static DependencyProperty ModifiedReferencesProperty = DependencyProperty.Register("ModifiedReferences", typeof(Guid[]), typeof(GetUpdatesToReferenceAttributeActivity));
[DescriptionAttribute("ModifiedReferences")]
[CategoryAttribute("Output")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public Guid[] ModifiedReferences
{
get
{
return ((Guid[])(base.GetValue(GetUpdatesToReferenceAttributeActivity.ModifiedReferencesProperty)));
}
set
{
base.SetValue(GetUpdatesToReferenceAttributeActivity.ModifiedReferencesProperty, value);
}
}
public static DependencyProperty RemovedReferencesProperty = DependencyProperty.Register("RemovedReferences", typeof(Guid[]), typeof(GetUpdatesToReferenceAttributeActivity));
public static DependencyProperty ResourceIdProperty = DependencyProperty.Register("ResourceId", typeof(Guid), typeof(GetUpdatesToReferenceAttributeActivity));
[Description("ResourceId")]
[Category("Output")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid ResourceId
{
get
{
return ((Guid)(base.GetValue(GetUpdatesToReferenceAttributeActivity.ResourceIdProperty)));
}
set
{
base.SetValue(GetUpdatesToReferenceAttributeActivity.ResourceIdProperty, value);
}
}
[Description("RemovedReferences")]
[Category("Output")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid[] RemovedReferences
{
get
{
return ((Guid[])(base.GetValue(GetUpdatesToReferenceAttributeActivity.RemovedReferencesProperty)));
}
set
{
base.SetValue(GetUpdatesToReferenceAttributeActivity.RemovedReferencesProperty, value);
}
}
public static DependencyProperty AttributeNameProperty = DependencyProperty.Register("AttributeName", typeof(string), typeof(GetUpdatesToReferenceAttributeActivity));
[Description("AttributeName")]
[Category("Input")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string AttributeName
{
get
{
return ((string)(base.GetValue(GetUpdatesToReferenceAttributeActivity.AttributeNameProperty)));
}
set
{
base.SetValue(GetUpdatesToReferenceAttributeActivity.AttributeNameProperty, value);
}
}
public static DependencyProperty OperationTypeProperty = DependencyProperty.Register("OperationType", typeof(OperationType), typeof(GetUpdatesToReferenceAttributeActivity));
[Description("OperationType")]
[Category("Output")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public OperationType OperationType
{
get
{
return ((OperationType)(base.GetValue(GetUpdatesToReferenceAttributeActivity.OperationTypeProperty)));
}
set
{
base.SetValue(GetUpdatesToReferenceAttributeActivity.OperationTypeProperty, value);
}
}
#endregion
public GetUpdatesToReferenceAttributeActivity()
{
InitializeComponent();
}
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.RequestType CurrentRequest = null;
private void ExtractDataFromRequest_ExecuteCode(object sender, EventArgs e)
{
this.ResourceId = this.CurrentRequest.Target.GetGuid();
this.OperationType = this.CurrentRequest.Operation;
List<Guid> toAdd = new List<Guid>();
List<Guid> toRemove = new List<Guid>();
List<Guid> toModify = new List<Guid>();
if (this.CurrentRequest.Operation == OperationType.Create)
{
ReadOnlyCollection<CreateRequestParameter> myParameters =
this.CurrentRequest.ParseParameters<CreateRequestParameter>();
foreach (CreateRequestParameter myParameter in myParameters)
{
if (String.Equals(this.AttributeName, myParameter.PropertyName,
StringComparison.InvariantCultureIgnoreCase))
{
if (myParameter.Value.GetType().FullName.StartsWith("System.Collections.Generic.List") ||
myParameter.Value.GetType().FullName.EndsWith("[]"))
{
foreach (object myObject in (IEnumerable)myParameter.Value)
{
if (myObject is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
toAdd.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier)myObject).GetGuid());
if (myObject is System.Guid)
toAdd.Add((System.Guid)myObject);
}
}
else
{
if (myParameter.Value is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
toAdd.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier)myParameter.Value).
GetGuid());
if (myParameter.Value is System.Guid)
toAdd.Add((System.Guid)myParameter.Value);
}
}
}
}
if (this.CurrentRequest.Operation == OperationType.Put)
{
ReadOnlyCollection<UpdateRequestParameter> myParameters =
this.CurrentRequest.ParseParameters<UpdateRequestParameter>();
foreach (UpdateRequestParameter myParameter in myParameters)
{
if (myParameter.Mode == UpdateMode.Insert)
{
if (String.Equals(this.AttributeName, myParameter.PropertyName,
StringComparison.InvariantCultureIgnoreCase))
{
if (myParameter.Value.GetType().FullName.StartsWith("System.Collections.Generic.List") ||
myParameter.Value.GetType().FullName.EndsWith("[]"))
{
foreach (object myObject in (IEnumerable)myParameter.Value)
{
if (myObject is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
toAdd.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier)myObject).
GetGuid());
if (myObject is System.Guid)
toAdd.Add((System.Guid)myObject);
}
}
else
{
if (myParameter.Value is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
toAdd.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier)myParameter.Value).
GetGuid());
if (myParameter.Value is System.Guid)
toAdd.Add((System.Guid)myParameter.Value);
}
}
}
if (myParameter.Mode == UpdateMode.Modify)
{
if (String.Equals(this.AttributeName, myParameter.PropertyName,
StringComparison.InvariantCultureIgnoreCase))
{
// Actually never going to happen, but who knows ?
if (myParameter.Value.GetType().FullName.StartsWith("System.Collections.Generic.List") ||
myParameter.Value.GetType().FullName.EndsWith("[]"))
{
foreach (object myObject in (IEnumerable)myParameter.Value)
{
if (myObject is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
toModify.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier)myObject).
GetGuid());
if (myObject is System.Guid)
toModify.Add((System.Guid)myObject);
}
}
else
{
if (myParameter.Value is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
toModify.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier)myParameter.Value).
GetGuid());
if (myParameter.Value is System.Guid)
toModify.Add((System.Guid)myParameter.Value);
}
}
}
if (myParameter.Mode == UpdateMode.Remove)
{
if (String.Equals(this.AttributeName, myParameter.PropertyName,
StringComparison.InvariantCultureIgnoreCase))
{
if (myParameter.Value.GetType().FullName.StartsWith("System.Collections.Generic.List") ||
myParameter.Value.GetType().FullName.EndsWith("[]"))
{
foreach (object myObject in (IEnumerable)myParameter.Value)
{
if (myObject is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
toRemove.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier)myObject).
GetGuid());
if (myObject is System.Guid)
toRemove.Add((System.Guid)myObject);
}
}
else
{
if (myParameter.Value is Microsoft.ResourceManagement.WebServices.UniqueIdentifier)
toRemove.Add(
((Microsoft.ResourceManagement.WebServices.UniqueIdentifier)myParameter.Value).
GetGuid());
if (myParameter.Value is System.Guid)
toRemove.Add((System.Guid)myParameter.Value);
}
}
}
}
}
this.AddedReferences=toAdd.Distinct().ToArray();
this.RemovedReferences=toRemove.Distinct().ToArray();
this.ModifiedReferences = toModify.Distinct().ToArray();
}
}
}

View File

@ -0,0 +1,90 @@
using System.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class UpdateReferenceAttributeActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind3 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
this.UpdateResource = new Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity();
this.PrepareUpdate = new System.Workflow.Activities.CodeActivity();
this.ValuesAreNotPresent = new System.Workflow.Activities.IfElseBranchActivity();
this.ValuesPresent = new System.Workflow.Activities.IfElseBranchActivity();
this.CheckIfAnyValuesPresent = new System.Workflow.Activities.IfElseActivity();
//
// UpdateResource
//
activitybind1.Name = "UpdateReferenceAttributeActivity";
activitybind1.Path = "ActorId";
this.UpdateResource.Name = "UpdateResource";
activitybind2.Name = "UpdateReferenceAttributeActivity";
activitybind2.Path = "ResourceId";
activitybind3.Name = "UpdateReferenceAttributeActivity";
activitybind3.Path = "UpdateParameters";
this.UpdateResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity.ActorIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
this.UpdateResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity.ResourceIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
this.UpdateResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity.UpdateParametersProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind3)));
//
// PrepareUpdate
//
this.PrepareUpdate.Name = "PrepareUpdate";
this.PrepareUpdate.ExecuteCode += new System.EventHandler(this.PrepareUpdate_ExecuteCode);
//
// ValuesAreNotPresent
//
this.ValuesAreNotPresent.Name = "ValuesAreNotPresent";
//
// ValuesPresent
//
this.ValuesPresent.Activities.Add(this.PrepareUpdate);
this.ValuesPresent.Activities.Add(this.UpdateResource);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.AreValuesPresent);
this.ValuesPresent.Condition = codecondition1;
this.ValuesPresent.Name = "ValuesPresent";
//
// CheckIfAnyValuesPresent
//
this.CheckIfAnyValuesPresent.Activities.Add(this.ValuesPresent);
this.CheckIfAnyValuesPresent.Activities.Add(this.ValuesAreNotPresent);
this.CheckIfAnyValuesPresent.Name = "CheckIfAnyValuesPresent";
//
// UpdateReferenceAttributeActivity
//
this.Activities.Add(this.CheckIfAnyValuesPresent);
this.Name = "UpdateReferenceAttributeActivity";
this.CanModifyActivities = false;
}
#endregion
private IfElseBranchActivity ValuesAreNotPresent;
private IfElseBranchActivity ValuesPresent;
private IfElseActivity CheckIfAnyValuesPresent;
private CodeActivity PrepareUpdate;
private Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity UpdateResource;
}
}

View File

@ -0,0 +1,133 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
namespace Granfeldt.FIM.ActivityLibrary
{
[Designer(typeof(ActivityDesigner), typeof(IDesigner))]
public partial class UpdateReferenceAttributeActivity : SequenceActivity
{
#region Properties
public static DependencyProperty ActorIdProperty = DependencyProperty.Register("ActorId", typeof(Guid), typeof(UpdateReferenceAttributeActivity));
[Description("ActorId")]
[Category("ActorId Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid ActorId
{
get
{
return ((Guid)(base.GetValue(UpdateReferenceAttributeActivity.ActorIdProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributeActivity.ActorIdProperty, value);
}
}
public static DependencyProperty ResourceIdProperty = DependencyProperty.Register("ResourceId", typeof(Guid), typeof(UpdateReferenceAttributeActivity));
[Description("ResourceId")]
[Category("ResourceId Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid ResourceId
{
get
{
return ((Guid)(base.GetValue(UpdateReferenceAttributeActivity.ResourceIdProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributeActivity.ResourceIdProperty, value);
}
}
public static DependencyProperty ValuesProperty = DependencyProperty.Register("Values", typeof(Guid[]), typeof(UpdateReferenceAttributeActivity));
public static DependencyProperty AttributeNameProperty = DependencyProperty.Register("AttributeName", typeof(string), typeof(UpdateReferenceAttributeActivity));
[Description("AttributeName")]
[Category("AttributeName Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string AttributeName
{
get
{
return ((string)(base.GetValue(UpdateReferenceAttributeActivity.AttributeNameProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributeActivity.AttributeNameProperty, value);
}
}
[Description("Values")]
[Category("Values Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid[] Values
{
get
{
return ((Guid[])(base.GetValue(UpdateReferenceAttributeActivity.ValuesProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributeActivity.ValuesProperty, value);
}
}
public static DependencyProperty UpdateModeProperty = DependencyProperty.Register("UpdateMode", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode), typeof(UpdateReferenceAttributeActivity));
[Description("UpdateMode")]
[Category("UpdateMode Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public UpdateMode UpdateMode
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode)(base.GetValue(UpdateReferenceAttributeActivity.UpdateModeProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributeActivity.UpdateModeProperty, value);
}
}
#endregion
public UpdateReferenceAttributeActivity()
{
InitializeComponent();
}
private void PrepareUpdate_ExecuteCode(object sender, EventArgs e)
{
List<UpdateRequestParameter> tempParameters = new List<UpdateRequestParameter>();
foreach (Guid guid in this.Values)
{
tempParameters.Add(new UpdateRequestParameter(this.AttributeName, this.UpdateMode, guid));
}
this.UpdateParameters = tempParameters.ToArray();
}
public UpdateRequestParameter[] UpdateParameters = null;
private void AreValuesPresent(object sender, ConditionalEventArgs e)
{
if (this.Values != null && this.Values.Length > 0)
e.Result = true;
else
e.Result = false;
}
}
}

View File

@ -0,0 +1,141 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Linq;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
namespace Granfeldt.FIM.ActivityLibrary
{
[Designer(typeof(ActivityDesigner), typeof(IDesigner))]
public partial class UpdateReferenceAttributesAsNeededActivity: SequenceActivity
{
public UpdateReferenceAttributesAsNeededActivity()
{
InitializeComponent();
}
public static DependencyProperty ActorIdProperty = DependencyProperty.Register("ActorId", typeof(System.Guid), typeof(UpdateReferenceAttributesAsNeededActivity));
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(true)]
[Category("ActorId Category")]
public Guid ActorId
{
get
{
return ((System.Guid)(base.GetValue(UpdateReferenceAttributesAsNeededActivity.ActorIdProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributesAsNeededActivity.ActorIdProperty, value);
}
}
public static DependencyProperty ResourceIdProperty = DependencyProperty.Register("ResourceId", typeof(System.Guid), typeof(UpdateReferenceAttributesAsNeededActivity));
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(true)]
[Category("ResourceId Category")]
public Guid ResourceId
{
get
{
return ((System.Guid)(base.GetValue(UpdateReferenceAttributesAsNeededActivity.ResourceIdProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributesAsNeededActivity.ResourceIdProperty, value);
}
}
public static DependencyProperty UpdateModeProperty = DependencyProperty.Register("UpdateMode", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode), typeof(UpdateReferenceAttributesAsNeededActivity));
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(true)]
[Category("UpdateMode Category")]
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode UpdateMode
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode)(base.GetValue(UpdateReferenceAttributesAsNeededActivity.UpdateModeProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributesAsNeededActivity.UpdateModeProperty, value);
}
}
public static DependencyProperty ValuesProperty = DependencyProperty.Register("Values", typeof(System.Guid[]), typeof(UpdateReferenceAttributesAsNeededActivity));
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(true)]
[Category("Values Category")]
public Guid[] Values
{
get
{
return ((System.Guid[])(base.GetValue(UpdateReferenceAttributesAsNeededActivity.ValuesProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributesAsNeededActivity.ValuesProperty, value);
}
}
public static DependencyProperty AttributeNameProperty = DependencyProperty.Register("AttributeName", typeof(System.String), typeof(UpdateReferenceAttributesAsNeededActivity));
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Browsable(true)]
[Category("AttributeName Category")]
public String AttributeName
{
get
{
return ((string)(base.GetValue(UpdateReferenceAttributesAsNeededActivity.AttributeNameProperty)));
}
set
{
base.SetValue(UpdateReferenceAttributesAsNeededActivity.AttributeNameProperty, value);
}
}
public Guid[] ValuesToSet = default(System.Guid[]);
private void FindOutIfThereIsAPointInDoingAnything(object sender, ConditionalEventArgs e)
{
if(null==this.Values || this.Values.Length==0)
{
e.Result = false;
return;
}
switch (this.UpdateMode)
{
case Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode.Insert:
this.ValuesToSet = this.Values.Except(this.CurrentValues).ToArray();
e.Result = true;
break;
case Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode.Modify:
if (this.CurrentValues.Except(this.Values).Count()>0 ||
this.Values.Except(this.CurrentValues).Count()>0)
{
this.ValuesToSet = this.Values;
e.Result = true;
}
else
{
e.Result = false;
}
break;
case Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateMode.Remove:
this.ValuesToSet = this.Values.Intersect(this.CurrentValues).ToArray();
e.Result = true;
break;
}
}
public Guid[] CurrentValues = default(System.Guid[]);
}
}

View File

@ -0,0 +1,102 @@
using System.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class UpdateReferenceAttributesAsNeededActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind3 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind4 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind5 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
System.Workflow.ComponentModel.ActivityBind activitybind6 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind7 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind8 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind9 = new System.Workflow.ComponentModel.ActivityBind();
this.UpdateReferences = new UpdateReferenceAttributeActivity();
this.NotAtAll = new System.Workflow.Activities.IfElseBranchActivity();
this.Probably = new System.Workflow.Activities.IfElseBranchActivity();
this.IsTherePointInDoingAnything = new System.Workflow.Activities.IfElseActivity();
this.GetCurrentReferences = new Granfeldt.FIM.ActivityLibrary.GetReferenceValuesFromObjectActivity();
//
// UpdateReferences
//
activitybind1.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind1.Path = "ActorId";
activitybind2.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind2.Path = "AttributeName";
this.UpdateReferences.Name = "UpdateReferences";
activitybind3.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind3.Path = "ResourceId";
activitybind4.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind4.Path = "UpdateMode";
activitybind5.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind5.Path = "ValuesToSet";
this.UpdateReferences.SetBinding(UpdateReferenceAttributeActivity.ActorIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
this.UpdateReferences.SetBinding(UpdateReferenceAttributeActivity.ResourceIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind3)));
this.UpdateReferences.SetBinding(UpdateReferenceAttributeActivity.UpdateModeProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind4)));
this.UpdateReferences.SetBinding(UpdateReferenceAttributeActivity.ValuesProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind5)));
this.UpdateReferences.SetBinding(UpdateReferenceAttributeActivity.AttributeNameProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
//
// NotAtAll
//
this.NotAtAll.Name = "NotAtAll";
//
// Probably
//
this.Probably.Activities.Add(this.UpdateReferences);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.FindOutIfThereIsAPointInDoingAnything);
this.Probably.Condition = codecondition1;
this.Probably.Name = "Probably";
//
// IsTherePointInDoingAnything
//
this.IsTherePointInDoingAnything.Activities.Add(this.Probably);
this.IsTherePointInDoingAnything.Activities.Add(this.NotAtAll);
this.IsTherePointInDoingAnything.Name = "IsTherePointInDoingAnything";
//
// GetCurrentReferences
//
activitybind6.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind6.Path = "ActorId";
activitybind7.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind7.Path = "AttributeName";
activitybind8.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind8.Path = "CurrentValues";
this.GetCurrentReferences.Name = "GetCurrentReferences";
activitybind9.Name = "UpdateReferenceAttributesAsNeededActivity";
activitybind9.Path = "ResourceId";
this.GetCurrentReferences.SetBinding(Granfeldt.FIM.ActivityLibrary.GetReferenceValuesFromObjectActivity.ActorIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind6)));
this.GetCurrentReferences.SetBinding(Granfeldt.FIM.ActivityLibrary.GetReferenceValuesFromObjectActivity.AttributeNameProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind7)));
this.GetCurrentReferences.SetBinding(Granfeldt.FIM.ActivityLibrary.GetReferenceValuesFromObjectActivity.CurrentValuesProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind8)));
this.GetCurrentReferences.SetBinding(Granfeldt.FIM.ActivityLibrary.GetReferenceValuesFromObjectActivity.ObjectIDProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind9)));
//
// UpdateReferenceAttributesAsNeededActivity
//
this.Activities.Add(this.GetCurrentReferences);
this.Activities.Add(this.IsTherePointInDoingAnything);
this.Name = "UpdateReferenceAttributesAsNeededActivity";
this.CanModifyActivities = false;
}
#endregion
private GetReferenceValuesFromObjectActivity GetCurrentReferences;
private IfElseBranchActivity NotAtAll;
private IfElseBranchActivity Probably;
private IfElseActivity IsTherePointInDoingAnything;
private UpdateReferenceAttributeActivity UpdateReferences;
}
}

View File

@ -0,0 +1,204 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Reflection;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class AddRemoveFromMultiValueActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
[System.CodeDom.Compiler.GeneratedCode("", "")]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
System.Collections.Generic.List<Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType> list_11 = new System.Collections.Generic.List<Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType>();
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind3 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind4 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind5 = new System.Workflow.ComponentModel.ActivityBind();
this.LogException = new System.Workflow.Activities.CodeActivity();
this.LogArgumentException = new System.Workflow.Activities.CodeActivity();
this.faultHandlerGeneralException = new System.Workflow.ComponentModel.FaultHandlerActivity();
this.faultHandlerArgumentException = new System.Workflow.ComponentModel.FaultHandlerActivity();
this.UpdateMVOnTarget = new Granfeldt.FIM.ActivityLibrary.AddRemoveMultiValueActivityAsNeeded();
this.faultHandlersActivity1 = new System.Workflow.ComponentModel.FaultHandlersActivity();
this.LoopAndUpdateAllTargets = new System.Workflow.Activities.WhileActivity();
this.Enumerate = new Granfeldt.FIM.ActivityLibrary.FindResourcesActivity();
this.SetupVariablesActivity = new System.Workflow.Activities.CodeActivity();
this.ResolveValueToAdd = new Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity();
this.ResolveLookupXPath = new Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity();
this.GetCurrentRequest = new Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity();
//
// LogException
//
this.LogException.Name = "LogException";
this.LogException.ExecuteCode += new System.EventHandler(this.LogException_ExecuteCode);
//
// LogArgumentException
//
this.LogArgumentException.Name = "LogArgumentException";
this.LogArgumentException.ExecuteCode += new System.EventHandler(this.LogArgumentException_ExecuteCode);
//
// faultHandlerGeneralException
//
this.faultHandlerGeneralException.Activities.Add(this.LogException);
this.faultHandlerGeneralException.FaultType = typeof(System.Exception);
this.faultHandlerGeneralException.Name = "faultHandlerGeneralException";
//
// faultHandlerArgumentException
//
this.faultHandlerArgumentException.Activities.Add(this.LogArgumentException);
this.faultHandlerArgumentException.FaultType = typeof(System.ArgumentException);
this.faultHandlerArgumentException.Name = "faultHandlerArgumentException";
//
// UpdateMVOnTarget
//
this.UpdateMVOnTarget.Action = null;
this.UpdateMVOnTarget.Destination = null;
this.UpdateMVOnTarget.Name = "UpdateMVOnTarget";
this.UpdateMVOnTarget.TargetIdToUpdate = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateMVOnTarget.TargetResource = null;
this.UpdateMVOnTarget.ValueToAddOrRemove = null;
//
// faultHandlersActivity1
//
this.faultHandlersActivity1.Activities.Add(this.faultHandlerArgumentException);
this.faultHandlersActivity1.Activities.Add(this.faultHandlerGeneralException);
this.faultHandlersActivity1.Name = "faultHandlersActivity1";
//
// LoopAndUpdateAllTargets
//
this.LoopAndUpdateAllTargets.Activities.Add(this.UpdateMVOnTarget);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.MoreTargetsToUpdate_Condition);
this.LoopAndUpdateAllTargets.Condition = codecondition1;
this.LoopAndUpdateAllTargets.Name = "LoopAndUpdateAllTargets";
//
// Enumerate
//
this.Enumerate.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.Enumerate.Attributes = null;
this.Enumerate.EnumeratedResourceIDs = null;
this.Enumerate.EnumeratedResources = list_11;
this.Enumerate.Name = "Enumerate";
this.Enumerate.PageSize = 0;
this.Enumerate.SortingAttributes = null;
this.Enumerate.TotalResultsCount = 0;
this.Enumerate.XPathFilter = null;
//
// SetupVariablesActivity
//
this.SetupVariablesActivity.Name = "SetupVariablesActivity";
this.SetupVariablesActivity.ExecuteCode += new System.EventHandler(this.SetupVariablesActivity_ExecuteCode);
//
// ResolveValueToAdd
//
activitybind1.Name = "AddRemoveFromMultiValueActivity";
activitybind1.Path = "ValueToAddRemove";
this.ResolveValueToAdd.Name = "ResolveValueToAdd";
activitybind2.Name = "AddRemoveFromMultiValueActivity";
activitybind2.Path = "ValueToAddRemoveResolved";
this.ResolveValueToAdd.WorkflowDictionaryKey = null;
this.ResolveValueToAdd.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.GrammarExpressionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
this.ResolveValueToAdd.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.ResolvedExpressionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
//
// ResolveLookupXPath
//
activitybind3.Name = "AddRemoveFromMultiValueActivity";
activitybind3.Path = "LookupXPath";
this.ResolveLookupXPath.Name = "ResolveLookupXPath";
activitybind4.Name = "AddRemoveFromMultiValueActivity";
activitybind4.Path = "ResolvedLookupXPath";
this.ResolveLookupXPath.WorkflowDictionaryKey = null;
this.ResolveLookupXPath.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.GrammarExpressionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind3)));
this.ResolveLookupXPath.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.ResolvedExpressionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind4)));
//
// GetCurrentRequest
//
activitybind5.Name = "AddRemoveFromMultiValueActivity";
activitybind5.Path = "CurrentRequest";
this.GetCurrentRequest.Name = "GetCurrentRequest";
this.GetCurrentRequest.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity.CurrentRequestProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind5)));
//
// AddRemoveFromMultiValueActivity
//
this.Activities.Add(this.GetCurrentRequest);
this.Activities.Add(this.ResolveLookupXPath);
this.Activities.Add(this.ResolveValueToAdd);
this.Activities.Add(this.SetupVariablesActivity);
this.Activities.Add(this.Enumerate);
this.Activities.Add(this.LoopAndUpdateAllTargets);
this.Activities.Add(this.faultHandlersActivity1);
this.Name = "AddRemoveFromMultiValueActivity";
this.CanModifyActivities = false;
}
#endregion
private CodeActivity LogException;
private FaultHandlerActivity faultHandlerGeneralException;
private CodeActivity LogArgumentException;
private FaultHandlerActivity faultHandlerArgumentException;
private FaultHandlersActivity faultHandlersActivity1;
private Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity ResolveValueToAdd;
private AddRemoveMultiValueActivityAsNeeded UpdateMVOnTarget;
private WhileActivity LoopAndUpdateAllTargets;
private Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity GetCurrentRequest;
private FindResourcesActivity Enumerate;
private CodeActivity SetupVariablesActivity;
private Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity ResolveLookupXPath;
}
}

View File

@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.UI.WebControls;
using System.Workflow.ComponentModel;
using Microsoft.IdentityManagement.WebUI.Controls;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
class AddRemoveFromMultiValueActivitySettingsPart : BaseActivitySettingsPart
{
const string LookupXPath = "TargetObjects";
const string ValueToAddRemove = "ValueToAddRemove";
const string MultivalueAttributeName = "TargetMultivalueAttributename";
const string HandleDuplicates = "HandleDuplicates";
const string Action = "Action";
const string Actor = "Actor";
protected override void CreateChildControls()
{
Table layoutTable;
layoutTable = new Table();
// width is set to 100% of the control size
layoutTable.Width = Unit.Percentage(100.0);
layoutTable.BorderWidth = 0;
layoutTable.CellPadding = 2;
// add a TableRow for each textbox in the UI
layoutTable.Rows.Add(this.AddTableRowTextBox("Target object(s) (XPath Filter):", "txt" + LookupXPath, 400, 1000, false, ""));
layoutTable.Rows.Add(this.AddTableRowTextBox("Value to add, i.e. [//Target/ObjectID]:", "txt" + ValueToAddRemove, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddTableRowTextBox("Target multi-value attributename:", "txt" + MultivalueAttributeName, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddAddRemoveDropDownList("Action:", "txt" + Action, 400, "Add"));
layoutTable.Rows.Add(this.AddCheckbox("Add/remove duplicates", "txt" + HandleDuplicates, false));
layoutTable.Rows.Add(this.AddActorDropDownList("Actor (run as):", "txt" + Actor, 400, WellKnownGuids.FIMServiceAccount.ToString()));
this.Controls.Add(layoutTable);
base.CreateChildControls();
}
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
{
Debugging.Log("GenerateActivityOnWorkflow");
if (!this.ValidateInputs())
{
return null;
}
AddRemoveFromMultiValueActivity act = new AddRemoveFromMultiValueActivity();
act.ValueToAddRemove = this.GetText("txt" + ValueToAddRemove);
act.LookupXPath = this.GetText("txt" + LookupXPath);
act.MultivalueAttributeName = this.GetText("txt" + MultivalueAttributeName);
act.Actor = this.GetActorDropDownList("txt" + Actor);
act.AddRemoveAction = this.GetAddRemoveDropDownList("txt" + Action);
return act;
}
public override void LoadActivitySettings(Activity activity)
{
Debugging.Log("LoadActivitySettings");
AddRemoveFromMultiValueActivity thisActivity = activity as AddRemoveFromMultiValueActivity;
if (thisActivity != null)
{
this.SetText("txt" + LookupXPath, thisActivity.LookupXPath);
this.SetText("txt" + ValueToAddRemove, thisActivity.ValueToAddRemove);
this.SetText("txt" + MultivalueAttributeName, thisActivity.MultivalueAttributeName);
this.SetActorDropDownList("txt" + Actor, thisActivity.Actor);
this.SetAddRemoveDropDownList("txt" + Action, thisActivity.AddRemoveAction);
}
}
public override ActivitySettingsPartData PersistSettings()
{
Debugging.Log("PersistSettings");
ActivitySettingsPartData data = new ActivitySettingsPartData();
data[LookupXPath] = this.GetText("txt" + LookupXPath);
data[MultivalueAttributeName] = this.GetText("txt" + MultivalueAttributeName);
data[ValueToAddRemove] = this.GetText("txt" + ValueToAddRemove);
data[Actor] = this.GetActorDropDownList("txt" + Actor);
data[Action] = this.GetAddRemoveDropDownList("txt" + Action);
return data;
}
public override void RestoreSettings(ActivitySettingsPartData data)
{
Debugging.Log("RestoreSettings");
if (null != data)
{
this.SetText("txt" + LookupXPath, (string)data[LookupXPath]);
this.SetText("txt" + MultivalueAttributeName, (string)data[MultivalueAttributeName]);
this.SetText("txt" + ValueToAddRemove, (string)data[ValueToAddRemove]);
this.SetActorDropDownList("txt" + Actor, (string)data[Actor]);
this.SetAddRemoveDropDownList("txt" + Action, (string)data[Action]);
}
}
public override void SwitchMode(ActivitySettingsPartMode mode)
{
Debugging.Log("SwitchMode");
bool isDisabled = (mode != ActivitySettingsPartMode.Edit);
this.SetTextBoxReadOnlyOption("txt" + LookupXPath, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + MultivalueAttributeName, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + ValueToAddRemove, isDisabled);
this.SetDropDownListDisabled("txt" + Actor, isDisabled);
this.SetDropDownListDisabled("txt" + Action, isDisabled);
}
public override string Title
{
get { return "Add or Remove to/from multi-value"; }
}
public override bool ValidateInputs()
{
Debugging.Log("ValidateInputs");
return true;
}
}
}

View File

@ -0,0 +1,230 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class AddRemoveFromMultiValueActivity : SequenceActivity
{
#region Properties
public AddRemoveFromMultiValueActivity()
{
InitializeComponent();
}
public static DependencyProperty HandleDuplicateProperty = DependencyProperty.Register("HandleDuplicate", typeof(string), typeof(AddRemoveFromMultiValueActivity));
[Description("HandleDuplicate")]
[Category("HandleDuplicate Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string HandleDuplicate
{
get
{
return ((string)(base.GetValue(AddRemoveFromMultiValueActivity.HandleDuplicateProperty)));
}
set
{
base.SetValue(AddRemoveFromMultiValueActivity.HandleDuplicateProperty, value);
}
}
public static DependencyProperty ActorProperty = DependencyProperty.Register("Actor", typeof(string), typeof(AddRemoveFromMultiValueActivity));
[Description("Actor")]
[Category("Actor Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Actor
{
get
{
return ((string)(base.GetValue(AddRemoveFromMultiValueActivity.ActorProperty)));
}
set
{
base.SetValue(AddRemoveFromMultiValueActivity.ActorProperty, value);
}
}
public static DependencyProperty LookupXPathProperty = DependencyProperty.Register("LookupXPath", typeof(System.String), typeof(AddRemoveFromMultiValueActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String LookupXPath
{
get
{
return ((string)(base.GetValue(LookupXPathProperty)));
}
set
{
base.SetValue(LookupXPathProperty, value);
}
}
public static DependencyProperty ResolvedLookupXPathProperty = DependencyProperty.Register("ResolvedLookupXPath", typeof(System.String), typeof(AddRemoveFromMultiValueActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String ResolvedLookupXPath
{
get
{
return ((string)(base.GetValue(AddRemoveFromMultiValueActivity.ResolvedLookupXPathProperty)));
}
set
{
base.SetValue(AddRemoveFromMultiValueActivity.ResolvedLookupXPathProperty, value);
}
}
public static DependencyProperty ValueToAddRemoveProperty = DependencyProperty.Register("ValueToAddRemove", typeof(string), typeof(AddRemoveFromMultiValueActivity));
[Description("ValueToAddRemove")]
[Category("ValueToAddRemove Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string ValueToAddRemove
{
get
{
return ((string)(base.GetValue(AddRemoveFromMultiValueActivity.ValueToAddRemoveProperty)));
}
set
{
base.SetValue(AddRemoveFromMultiValueActivity.ValueToAddRemoveProperty, value);
}
}
public static DependencyProperty MultivalueAttributeNameProperty = DependencyProperty.Register("MultivalueAttributeName", typeof(string), typeof(AddRemoveFromMultiValueActivity));
[Description("MultivalueAttributeName")]
[Category("MultivalueAttributeName Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string MultivalueAttributeName
{
get
{
return ((string)(base.GetValue(AddRemoveFromMultiValueActivity.MultivalueAttributeNameProperty)));
}
set
{
base.SetValue(AddRemoveFromMultiValueActivity.MultivalueAttributeNameProperty, value);
}
}
public static DependencyProperty AddRemoveActionProperty = DependencyProperty.Register("AddRemoveAction", typeof(string), typeof(AddRemoveFromMultiValueActivity));
[Description("AddRemoveAction")]
[Category("AddRemoveAction Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string AddRemoveAction
{
get
{
return ((string)(base.GetValue(AddRemoveFromMultiValueActivity.AddRemoveActionProperty)));
}
set
{
base.SetValue(AddRemoveFromMultiValueActivity.AddRemoveActionProperty, value);
}
}
public static DependencyProperty CurrentRequestProperty = DependencyProperty.Register("CurrentRequest", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.RequestType), typeof(AddRemoveFromMultiValueActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public RequestType CurrentRequest
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.RequestType)(base.GetValue(CurrentRequestProperty)));
}
set
{
base.SetValue(CurrentRequestProperty, value);
}
}
#endregion
private void SetupVariablesActivity_ExecuteCode(object sender, EventArgs e)
{
foreach (CreateRequestParameter u in this.CurrentRequest.ParseParameters<CreateRequestParameter>())
{
}
Debugging.Log("Enter SetupVariablesActivity_ExecuteCode");
Enumerate.ActorId = new Guid(this.Actor);
Debugging.Log("XPath (resolved)", this.ResolvedLookupXPath);
Enumerate.XPathFilter = this.ResolvedLookupXPath;
Enumerate.Attributes = new string[] { this.MultivalueAttributeName };
Enumerate.PageSize = 100;
Debugging.Log("Leave SetupVariablesActivity_ExecuteCode");
}
private void MoreTargetsToUpdate_Condition(object sender, ConditionalEventArgs e)
{
Debugging.Log("Enter SetupVariablesActivity_ExecuteCode");
// return true if there are any more source values to resolve
e.Result = Enumerate.EnumeratedResources != null ? Enumerate.EnumeratedResources.Count() > 0 : false;
if (e.Result)
{
Debugging.Log("Update target(s) left", Enumerate.EnumeratedResources.Count());
ResourceType resource = Enumerate.EnumeratedResources[0];
Enumerate.EnumeratedResources.RemoveAt(0);
UpdateMVOnTarget.Action = this.AddRemoveAction;
UpdateMVOnTarget.Destination = this.MultivalueAttributeName;
UpdateMVOnTarget.ValueToAddOrRemove = this.ValueToAddRemoveResolved;
UpdateMVOnTarget.TargetIdToUpdate = resource.ObjectID.GetGuid();
}
else
{
Debugging.Log("No more source values to resolve");
}
}
public static DependencyProperty ValueToAddRemoveResolvedProperty = DependencyProperty.Register("ValueToAddRemoveResolved", typeof(object), typeof(Granfeldt.FIM.ActivityLibrary.AddRemoveFromMultiValueActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String ValueToAddRemoveResolved
{
get
{
return ((string)(base.GetValue(Granfeldt.FIM.ActivityLibrary.AddRemoveFromMultiValueActivity.ValueToAddRemoveResolvedProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.AddRemoveFromMultiValueActivity.ValueToAddRemoveResolvedProperty, value);
}
}
private void LogArgumentException_ExecuteCode(object sender, EventArgs e)
{
Debugging.Log(sender.ToString());
Debugging.Log(faultHandlerArgumentException.Fault);
}
private void LogException_ExecuteCode(object sender, EventArgs e)
{
Debugging.Log(sender.ToString());
Debugging.Log(faultHandlerGeneralException.Fault);
}
}
}

View File

@ -0,0 +1,133 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Reflection;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class ClearSingleValuedAttributeActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
this.UpdateResource = new Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity();
this.NoActionNeeded = new System.Workflow.Activities.IfElseBranchActivity();
this.ThereWasValue = new System.Workflow.Activities.IfElseBranchActivity();
this.EndGracefully = new System.Workflow.Activities.CodeActivity();
this.IsRemovalNeeded = new System.Workflow.Activities.IfElseActivity();
this.ReadResource = new Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity();
this.PrepareReading = new System.Workflow.Activities.CodeActivity();
this.GetCurrentRequest = new Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity();
//
// UpdateResource
//
this.UpdateResource.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateResource.ApplyAuthorizationPolicy = false;
this.UpdateResource.Name = "UpdateResource";
this.UpdateResource.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateResource.UpdateParameters = null;
//
// NoActionNeeded
//
this.NoActionNeeded.Name = "NoActionNeeded";
//
// ThereWasValue
//
this.ThereWasValue.Activities.Add(this.UpdateResource);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.ThereWasValue_Condition);
this.ThereWasValue.Condition = codecondition1;
this.ThereWasValue.Name = "ThereWasValue";
//
// EndGracefully
//
this.EndGracefully.Name = "EndGracefully";
this.EndGracefully.ExecuteCode += new System.EventHandler(this.EndGracefully_ExecuteCode);
//
// IsRemovalNeeded
//
this.IsRemovalNeeded.Activities.Add(this.ThereWasValue);
this.IsRemovalNeeded.Activities.Add(this.NoActionNeeded);
this.IsRemovalNeeded.Name = "IsRemovalNeeded";
//
// ReadResource
//
this.ReadResource.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadResource.Name = "ReadResource";
this.ReadResource.Resource = null;
this.ReadResource.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadResource.SelectionAttributes = null;
//
// PrepareReading
//
this.PrepareReading.Name = "PrepareReading";
this.PrepareReading.ExecuteCode += new System.EventHandler(this.PrepareReading_ExecuteCode);
//
// GetCurrentRequest
//
activitybind1.Name = "ClearSingleValuedAttributeActivity";
activitybind1.Path = "CurrentRequest";
this.GetCurrentRequest.Name = "GetCurrentRequest";
this.GetCurrentRequest.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity.CurrentRequestProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
//
// ClearSingleValuedAttributeActivity
//
this.Activities.Add(this.GetCurrentRequest);
this.Activities.Add(this.PrepareReading);
this.Activities.Add(this.ReadResource);
this.Activities.Add(this.IsRemovalNeeded);
this.Activities.Add(this.EndGracefully);
this.Name = "ClearSingleValuedAttributeActivity";
this.CanModifyActivities = false;
}
#endregion
private Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity GetCurrentRequest;
private CodeActivity EndGracefully;
private Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity ReadResource;
private Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity UpdateResource;
private IfElseBranchActivity ThereWasValue;
private IfElseActivity IsRemovalNeeded;
private IfElseBranchActivity NoActionNeeded;
private CodeActivity PrepareReading;
}
}

View File

@ -0,0 +1,180 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.ResourceManagement.Workflow.Activities;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class ClearSingleValuedAttributeActivity : SequenceActivity
{
#region Properties
public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(System.String), typeof(ClearSingleValuedAttributeActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String Title
{
get
{
return ((string)(base.GetValue(TitleProperty)));
}
set
{
base.SetValue(TitleProperty, value);
}
}
public static DependencyProperty CurrentRequestProperty = DependencyProperty.Register("CurrentRequest", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.RequestType), typeof(ClearSingleValuedAttributeActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.RequestType CurrentRequest
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.RequestType)(base.GetValue(CurrentRequestProperty)));
}
set
{
base.SetValue(CurrentRequestProperty, value);
}
}
public static DependencyProperty AttributeNameProperty = DependencyProperty.Register("AttributeName", typeof(string), typeof(ClearSingleValuedAttributeActivity));
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Category("Properties")]
public string AttributeName
{
get
{
return (string)base.GetValue(AttributeNameProperty);
}
set
{
base.SetValue(AttributeNameProperty, value);
}
}
public static DependencyProperty TargetIdProperty = DependencyProperty.Register("TargetId", typeof(Guid), typeof(ClearSingleValuedAttributeActivity));
[Description("TargetId")]
[Category("TargetId Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid TargetId
{
get
{
return ((Guid)(base.GetValue(ClearSingleValuedAttributeActivity.TargetIdProperty)));
}
set
{
base.SetValue(ClearSingleValuedAttributeActivity.TargetIdProperty, value);
}
}
#endregion
public ClearSingleValuedAttributeActivity()
{
InitializeComponent();
}
void ActivityStatus(object sender, ActivityExecutionStatusChangedEventArgs e)
{
Tracer.TraceInformation("execution-status name: {0}, status: {1}, result: {2}", e.Activity.Name, e.ExecutionStatus, e.ExecutionResult);
}
private void PrepareReading_ExecuteCode(object sender, EventArgs e)
{
Tracer.Enter("preparereading_executecode");
try
{
ReadResource.ActorId = WellKnownGuids.FIMServiceAccount;
Tracer.TraceInformation("actor-objectid: {0}", ReadResource.ActorId);
ReadResource.ResourceId = CurrentRequest.Target.GetGuid();
Tracer.TraceInformation("target-objectid: {0}", ReadResource.ResourceId);
ReadResource.SelectionAttributes = new string[] { this.AttributeName, "DisplayName" };
Tracer.TraceInformation("attribute: {0}", ReadResource.SelectionAttributes.FirstOrDefault());
ReadResource.Executing += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
ReadResource.Faulting += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
ReadResource.StatusChanged += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
ReadResource.Canceling += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
ReadResource.Compensating += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
ReadResource.Closed += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
}
catch (Exception ex)
{
Tracer.TraceError("preparereading_executecode", ex);
}
Tracer.Exit("preparereading_executecode");
}
private void ThereWasValue_Condition(object sender, ConditionalEventArgs e)
{
try
{
Tracer.Enter("therewasvalue_condition");
object displayName = ReadResource.Resource["DisplayName"];
object myValue = ReadResource.Resource[this.AttributeName];
Tracer.TraceInformation("target-displayname {0}", displayName);
if (null != myValue)
{
Tracer.TraceInformation("current-value: {0}", ReadResource.Resource[this.AttributeName]);
UpdateResource.ActorId = WellKnownGuids.FIMServiceAccount;
Tracer.TraceInformation("actor-objectid: {0}", UpdateResource.ActorId);
UpdateResource.ResourceId = CurrentRequest.Target.GetGuid();
Tracer.TraceInformation("target-objectid: {0}", UpdateResource.ResourceId);
UpdateRequestParameter[] UpdateParameters = new UpdateRequestParameter[] {
new UpdateRequestParameter(
this.AttributeName,
UpdateMode.Remove,
myValue)};
UpdateResource.UpdateParameters = UpdateParameters;
UpdateResource.Executing += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
UpdateResource.Faulting += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
UpdateResource.StatusChanged += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
UpdateResource.Canceling += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
UpdateResource.Compensating += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
UpdateResource.Closed += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ActivityStatus);
e.Result = true;
}
else
{
Tracer.TraceInformation("no-current-value-to-remove");
e.Result = false;
}
}
catch (Exception ex)
{
Tracer.TraceError("therewasvalue_condition'", ex);
}
Tracer.Exit("therewasvalue_condition");
}
private void EndGracefully_ExecuteCode(object sender, EventArgs e)
{
Tracer.TraceInformation("done");
}
}
}

View File

@ -0,0 +1,182 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using System.Workflow.ComponentModel;
using Microsoft.IdentityManagement.WebUI.Controls;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
class ClearSingleValuedAttributeActivitySettingsPart : ActivitySettingsPart
{
/// <summary>
/// Creates a Table that contains the controls used by the activity UI
/// in the Workflow Designer of the FIM portal. Adds that Table to the
/// collection of Controls that defines each activity that can be selected
/// in the Workflow Designer of the FIM Portal. Calls the base class of
/// ActivitySettingsPart to render the controls in the UI.
/// </summary>
protected override void CreateChildControls()
{
Table controlLayoutTable;
controlLayoutTable = new Table();
//Width is set to 100% of the control size
controlLayoutTable.Width = Unit.Percentage(100.0);
controlLayoutTable.BorderWidth = 0;
controlLayoutTable.CellPadding = 2;
//Add a TableRow for each textbox in the UI
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Title:", "txtTitle", 400, 100, false, ""));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Attribute:", "txtDestination", 400, 100, false, ""));
this.Controls.Add(controlLayoutTable);
base.CreateChildControls();
}
#region Utility Functions
//Create a TableRow that contains a label and a textbox.
private TableRow AddTableRowTextBox(String labelText, String controlID, int width, int maxLength, Boolean multiLine, String defaultValue)
{
TableRow row = new TableRow();
TableCell labelCell = new TableCell();
TableCell controlCell = new TableCell();
Label oLabel = new Label();
TextBox oText = new TextBox();
oLabel.Text = labelText;
oLabel.CssClass = base.LabelCssClass;
labelCell.Controls.Add(oLabel);
oText.ID = controlID;
oText.CssClass = base.TextBoxCssClass;
oText.Text = defaultValue;
oText.MaxLength = maxLength;
oText.Width = width;
if (multiLine)
{
oText.TextMode = TextBoxMode.MultiLine;
oText.Rows = System.Math.Min(6, (maxLength + 60) / 60);
oText.Wrap = true;
}
controlCell.Controls.Add(oText);
row.Cells.Add(labelCell);
row.Cells.Add(controlCell);
return row;
}
string GetText(string textBoxID)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
return textBox.Text ?? String.Empty;
}
void SetText(string textBoxID, string text)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
if (textBox != null)
textBox.Text = text;
else
textBox.Text = "";
}
//Set the text box to read mode or read/write mode
void SetTextBoxReadOnlyOption(string textBoxID, bool readOnly)
{
TextBox textBox = (TextBox)this.FindControl(textBoxID);
textBox.ReadOnly = readOnly;
}
#endregion
/// <summary>
/// Called when a user clicks the Save button in the Workflow Designer.
/// Returns an instance of the RequestLoggingActivity class that
/// has its properties set to the values entered into the text box controls
/// used in the UI of the activity.
/// </summary>
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
{
if (!this.ValidateInputs())
{
return null;
}
ClearSingleValuedAttributeActivity ThisActivity = new ClearSingleValuedAttributeActivity();
ThisActivity.Title = this.GetText("txtTitle");
ThisActivity.AttributeName = this.GetText("txtDestination");
return ThisActivity;
}
public override void LoadActivitySettings(Activity activity)
{
ClearSingleValuedAttributeActivity ThisActivity = activity as ClearSingleValuedAttributeActivity;
if (ThisActivity != null)
{
this.SetText("txtTitle", ThisActivity.Title);
this.SetText("txtDestination", ThisActivity.AttributeName);
}
}
/// <summary>
/// Saves the activity settings.
/// </summary>
public override ActivitySettingsPartData PersistSettings()
{
ActivitySettingsPartData data = new ActivitySettingsPartData();
data["Title"] = this.GetText("txtTitle");
data["Attribute"] = this.GetText("txtDestination");
return data;
}
/// <summary>
/// Restores the activity settings in the UI
/// </summary>
public override void RestoreSettings(ActivitySettingsPartData data)
{
if (null != data)
{
this.SetText("txtTitle", (string)data["Title"]);
this.SetText("txtDestination", (string)data["Attribute"]);
}
}
/// <summary>
/// Switches the activity between read only and read/write mode
/// </summary>
public override void SwitchMode(ActivitySettingsPartMode mode)
{
bool readOnly = (mode == ActivitySettingsPartMode.View);
this.SetTextBoxReadOnlyOption("txtTitle", readOnly);
this.SetTextBoxReadOnlyOption("txtDestination", readOnly);
}
/// <summary>
/// Returns the activity name.
/// </summary>
public override string Title
{
get
{
return string.Format("Clear single-valued attribute: {0}", this.GetText("txtTitle"));
}
}
/// <summary>
/// In general, this method should be used to validate information entered
/// by the user when the activity is added to a workflow in the Workflow
/// Designer.
/// We could add code to verify that the log file path already exists on
/// the server that is hosting the FIM Portal and check that the activity
/// has permission to write to that location. However, the code
/// would only check if the log file path exists when the
/// activity is added to a workflow in the workflow designer. This class
/// will not be used when the activity is actually run.
/// For this activity we will just return true.
/// </summary>
public override bool ValidateInputs()
{
return true;
}
}
}

View File

@ -5,6 +5,8 @@
// due to clashes with built-in naming convention
// January 18, 2013 | Soren Granfeldt
// - changed update to use helper update activity
// December 16, 2015 | soren granfeldt
// - changed logging to tuse tracer
using System;
using System.CodeDom.Compiler;
@ -41,7 +43,7 @@ namespace Granfeldt.FIM.ActivityLibrary
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.TargetResourceProperty)));
return ((ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.TargetResourceProperty)));
}
set
{
@ -187,19 +189,19 @@ namespace Granfeldt.FIM.ActivityLibrary
private void MoreParametersToResolve_Condition(object sender, ConditionalEventArgs e)
{
Debugging.Log("Activity initialized");
Tracer.Enter("Activity initialized");
// we need to convert the string array to a list to
// be able to remove values
if (UnresolvedParameters == null)
{
UnresolvedParameters = this.Parameters.ToList();
Debugging.Log("Resolving parameters");
Tracer.TraceInformation("Resolving parameters");
}
e.Result = false;
if (UnresolvedParameters.Count > 0)
{
this.ResolveParameterValue.GrammarExpression = UnresolvedParameters[0];
Debugging.Log("Resolving", UnresolvedParameters[0]);
Tracer.TraceInformation("Resolving {0}", UnresolvedParameters[0]);
UnresolvedParameters.RemoveAt(0);
e.Result = true;
}
@ -208,15 +210,15 @@ namespace Granfeldt.FIM.ActivityLibrary
private void SaveResolvedValue_ExecuteCode(object sender, EventArgs e)
{
ResolvedParameters.Add(HttpUtility.HtmlDecode(this.ResolveParameterValue.ResolvedExpression));
Debugging.Log("Resolved to", HttpUtility.HtmlDecode(this.ResolveParameterValue.ResolvedExpression));
Tracer.TraceInformation("Resolved to {0}", HttpUtility.HtmlDecode(this.ResolveParameterValue.ResolvedExpression));
}
private void NonExistingGrammarException_ExecuteCode(object sender, EventArgs e)
{
// if we get here, the resolve has failed. If the value that we're
// trying to resolve doesn't exist, we also get here. We
// assume that there is no value and set value to null
Debugging.Log("Missing value or invalid XPath reference (returning [null])", this.ResolveParameterValue.GrammarExpression);
// if we get here, the resolve has failed. If the value that we're
// trying to resolve doesn't exist, we also get here. We
// assume that there is no value and set value to null
Tracer.TraceError("Missing value or invalid XPath reference (returning [null]) {0}", this.ResolveParameterValue.GrammarExpression);
ResolvedParameters.Add(null);
}
@ -246,7 +248,7 @@ namespace Granfeldt.FIM.ActivityLibrary
{
compileErrors.AppendFormat("Compile Error: {0} in Ln {2} Col {3}-{1}\r\n", ce.ErrorNumber, ce.ErrorText, ce.Line, ce.Column);
}
Debugging.Log(new Exception("Couldn't compile\r\n" + compileErrors));
Tracer.TraceError("Couldn't compile {0}\r\n" + compileErrors);
}
Assembly assembly = cr.CompiledAssembly;
compiled = assembly.CreateInstance("FIMDynamicClass");
@ -256,18 +258,18 @@ namespace Granfeldt.FIM.ActivityLibrary
{
if (compiled == null)
{
Debugging.Log(new NullReferenceException("Code must contain a class named FIMDynamicClass and that class must contain a method called FIMDynamicFunction"));
Tracer.TraceError("Code must contain a class named FIMDynamicClass and that class must contain a method called FIMDynamicFunction");
}
Debugging.Log("Parameter count", ResolvedParameters.Count);
Tracer.TraceInformation("Parameter count {0}", ResolvedParameters.Count);
foreach (object param in ResolvedParameters)
{
Debugging.Log("Adding parameter", param);
Tracer.TraceInformation("Adding parameter {0}", param);
}
MethodInfo mi = compiled.GetType().GetMethod("FIMDynamicFunction");
Debugging.Log("Executing code");
Tracer.TraceInformation("Executing code");
codeReturnValue = mi.Invoke(compiled, ResolvedParameters.ToArray());
Debugging.Log("Code executed");
Debugging.Log("Code return value", codeReturnValue);
Tracer.TraceInformation("Code executed");
Tracer.TraceInformation("Code return value {0}", codeReturnValue);
}
private void ShouldUpdateTarget_Condition(object sender, ConditionalEventArgs e)
@ -275,7 +277,9 @@ namespace Granfeldt.FIM.ActivityLibrary
// try to get parent workflow.
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
{
throw new InvalidOperationException("Could not get parent workflow");
string errorMessage = "Could not get parent workflow";
Tracer.TraceError(errorMessage);
throw new InvalidOperationException(errorMessage);
}
StringUtilities.ExtractWorkflowExpression(this.Destination, out destinationObject, out destinationAttribute);
@ -300,7 +304,7 @@ namespace Granfeldt.FIM.ActivityLibrary
}
else
{
Debugging.Log(new Exception("Could not resolved destination. Please specify as [//Target/Attribute] or [//WorkflowData/Parameter]"));
Tracer.TraceError("Could not resolved destination. Please specify as [//Target/Attribute] or [//WorkflowData/Parameter]");
}
}
@ -311,12 +315,12 @@ namespace Granfeldt.FIM.ActivityLibrary
// assume that there is no value and set source value to null
// which effectively results in a 'Delete' operation on
// the target attribute value (if present)
Debugging.Log("Error: Argument Exception");
Tracer.TraceError("Error: Argument Exception");
}
private void ExitGracefully_ExecuteCode(object sender, EventArgs e)
{
Debugging.Log("Activity exited");
Tracer.TraceInformation("Activity exited");
}
}
}

View File

@ -12,11 +12,6 @@ namespace Granfeldt.FIM.ActivityLibrary
class BaseActivitySettingsPart : ActivitySettingsPart
{
#region Utility Functions
/// <summary>
/// Create a TableRow that contains a label and a textbox.
/// </summary>
protected TableRow AddTableRowTextBox(String labelText, String controlID, int width, int maxLength, Boolean multiLine, String defaultValue)
{
TableRow row = new TableRow();
@ -45,8 +40,60 @@ namespace Granfeldt.FIM.ActivityLibrary
return row;
}
#region Lookup Action Dropdown
protected void SetDropdownSelectedValue(string dropDownListID, string value)
{
DropDownList ddl = (DropDownList)this.FindControl(dropDownListID);
if (ddl != null)
{
if (!string.IsNullOrEmpty(value))
ddl.SelectedValue = value;
}
else
Debugging.Log("Cannot find control with ID '" + dropDownListID + "'");
}
protected TableRow AddAddRemoveDropDownList(string labelText, string controlID, int width, string defaultValue)
{
TableRow row = new TableRow();
TableCell labelCell = new TableCell();
TableCell controlCell = new TableCell();
Label oLabel = new Label();
oLabel.Text = labelText;
oLabel.CssClass = base.LabelCssClass;
labelCell.Controls.Add(oLabel);
DropDownList ddl = new DropDownList();
ddl.ID = controlID;
ddl.Width = width;
ddl.Items.Add(new ListItem("Add", "Add"));
ddl.Items.Add(new ListItem("Remove", "Remove"));
ddl.SelectedValue = defaultValue;
controlCell.Controls.Add(ddl);
row.Cells.Add(labelCell);
row.Cells.Add(controlCell);
return row;
}
protected void SetAddRemoveDropDownList(string dropDownListID, string value)
{
SetDropdownSelectedValue(dropDownListID, value);
}
protected string GetAddRemoveDropDownList(string dropDownListID)
{
string g = "";
DropDownList ddl = (DropDownList)this.FindControl(dropDownListID);
if (ddl != null)
{
if (!string.IsNullOrEmpty(ddl.SelectedValue))
g = ddl.SelectedValue.ToString();
}
else
Debugging.Log("Cannot find control with ID '" + dropDownListID + "'");
return g;
}
protected TableRow AddLookupActionDropDownList(String labelText, String controlID, int width, String defaultValue)
{
TableRow row = new TableRow();
@ -91,20 +138,9 @@ namespace Granfeldt.FIM.ActivityLibrary
protected void SetLookupActionDropDownList(string dropDownListID, string value)
{
DropDownList ddl = (DropDownList)this.FindControl(dropDownListID);
if (ddl != null)
{
if (!string.IsNullOrEmpty(value))
ddl.SelectedValue = value;
}
else
Debugging.Log("Cannot find control with ID '" + dropDownListID + "'");
SetDropdownSelectedValue(dropDownListID, value);
}
#endregion
#region Actor Dropdown
protected TableRow AddActorDropDownList(String labelText, String controlID, int width, String defaultValue)
{
TableRow row = new TableRow();
@ -151,20 +187,11 @@ namespace Granfeldt.FIM.ActivityLibrary
return g;
}
protected void SetActorDropDownList(string dropDownListID, object Guid)
protected void SetActorDropDownList(string dropDownListID, object value)
{
DropDownList ddl = (DropDownList)this.FindControl(dropDownListID);
if (ddl != null)
{
if (Guid != null)
ddl.SelectedValue = Guid.ToString();
}
else
Debugging.Log("Cannot find control with ID '" + dropDownListID + "'");
SetDropdownSelectedValue(dropDownListID, value.ToString());
}
#endregion
protected TableRow AddCheckbox(String labelText, String controlID, bool defaultValue)
{
TableRow row = new TableRow();
@ -266,7 +293,6 @@ namespace Granfeldt.FIM.ActivityLibrary
Debugging.Log("Cannot find control with ID '" + dropDownListID + "'");
}
#endregion
/// <summary>
/// Called when a user clicks the Save button in the Workflow Designer.

View File

@ -7,182 +7,180 @@ using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
namespace Granfeldt.FIM.ActivityLibrary
{
public class AttributeValue
{
//Constructors
/// <summary>
/// Creates a new instance of the object type AttributeValue.
/// </summary>
public AttributeValue()
{
this.IsResolved = false;
}
/// <summary>
/// Creates a new instance of the object type AttributeValue, and sets source and target attribute name.
/// </summary>
/// <param name="sourceAttributeName">Name of the source attribute.</param>
/// <param name="targetAttributeName">Name of the target attribute.</param>
public AttributeValue(string sourceAttributeName, string targetAttributeName)
{
this.SourceAttributeName = sourceAttributeName;
this.TargetAttributeName = targetAttributeName;
this.IsResolved = false;
}
//Fields
private object _sourceAttributeValue;
public class AttributeValue
{
//Constructors
/// <summary>
/// Creates a new instance of the object type AttributeValue.
/// </summary>
public AttributeValue()
{
this.IsResolved = false;
}
/// <summary>
/// Creates a new instance of the object type AttributeValue, and sets source and target attribute name.
/// </summary>
/// <param name="sourceAttributeName">Name of the source attribute.</param>
/// <param name="targetAttributeName">Name of the target attribute.</param>
public AttributeValue(string sourceAttributeName, string targetAttributeName)
{
this.SourceAttributeName = sourceAttributeName;
this.TargetAttributeName = targetAttributeName;
this.IsResolved = false;
}
//Fields
private object _sourceAttributeValue;
//Properties
public string SourceAttributeName { get; set; }
public object SourceAttributeValue
{
get
{
return this._sourceAttributeValue;
}
set
{
this._sourceAttributeValue = value;
this.IsResolved = true;
}
}
public string TargetAttributeName { get; set; }
public object TargetAttributeValue { get; set; }
public bool IsDelete { get; private set; }
/// <summary>
/// Indicates if the SourceAttributeName have been resolved.
/// This is set when SourceAttributeValue is set.
/// </summary>
public bool IsResolved { get; private set; }
/// <summary>
/// Tells if the SourceAttributeValue should be resolved from SourceAttributeName.
/// It is decided by testing if the SourceAttributeName contains a resolveable string.
/// </summary>
public bool ShouldResolve
{
get
{
if (this.IsResolved)
{
return false;
}
else
{
if (this.SourceAttributeName != null)
return this.SourceAttributeName.Trim().Contains("[//");
else
return false;
}
}
}
//Properties
public string SourceAttributeName { get; set; }
public object SourceAttributeValue
{
get
{
return this._sourceAttributeValue;
}
set
{
this._sourceAttributeValue = value;
this.IsResolved = true;
}
}
public string TargetAttributeName { get; set; }
public object TargetAttributeValue { get; set; }
public bool IsDelete { get; private set; }
/// <summary>
/// Indicates if the SourceAttributeName have been resolved.
/// This is set when SourceAttributeValue is set.
/// </summary>
public bool IsResolved { get; private set; }
/// <summary>
/// Tells if the SourceAttributeValue should be resolved from SourceAttributeName.
/// It is decided by testing if the SourceAttributeName contains a resolveable string.
/// </summary>
public bool ShouldResolve
{
get
{
if (this.IsResolved)
{
return false;
}
else
{
if (this.SourceAttributeName != null)
return this.SourceAttributeName.Trim().Contains("[//");
else
return false;
}
}
}
#region Methods
/// <summary>
/// Returns this AttributeValue as an UpdateRequestParameter used for updating resources in FIM.
/// </summary>
/// <param name="objectId">ObjectID of the resource being updated.</param>
/// <param name="isDelete">Tells the method what type of update to return.
/// If isDelete is true a UpdateMode is set to: Remove.
/// </param>
/// <returns></returns>
public UpdateRequestParameter ToUpdateRequestParameter(Guid objectId,bool isDelete)
{
if (!isDelete)
return new UpdateRequestParameter(objectId, this.TargetAttributeName, UpdateMode.Modify, FIMAttributeUtilities.FormatValue(this.SourceAttributeValue), false);
else
{
return new UpdateRequestParameter(objectId, this.TargetAttributeName, UpdateMode.Remove, this.TargetAttributeValue, false);
}
}
/// <summary>
/// Returns this AttributeValue as an UpdateRequestParameter used for updating resources in FIM, without specifying which object to update.
/// </summary>
/// <param name="isDelete">Tells the method what type of update to return.
/// If isDelete is true a UpdateMode is set to: Remove.</param>
/// <returns></returns>
public UpdateRequestParameter ToUpdateRequestParameter(bool isDelete)
{
#region Methods
/// <summary>
/// Returns this AttributeValue as an UpdateRequestParameter used for updating resources in FIM.
/// </summary>
/// <param name="objectId">ObjectID of the resource being updated.</param>
/// <param name="isDelete">Tells the method what type of update to return.
/// If isDelete is true a UpdateMode is set to: Remove.
/// </param>
/// <returns></returns>
public UpdateRequestParameter ToUpdateRequestParameter(Guid objectId, bool isDelete)
{
if (!isDelete)
return new UpdateRequestParameter(objectId, this.TargetAttributeName, UpdateMode.Modify, FIMAttributeUtilities.FormatValue(this.SourceAttributeValue), false);
else
{
return new UpdateRequestParameter(objectId, this.TargetAttributeName, UpdateMode.Remove, this.TargetAttributeValue, false);
}
}
/// <summary>
/// Returns this AttributeValue as an UpdateRequestParameter used for updating resources in FIM, without specifying which object to update.
/// </summary>
/// <param name="isDelete">Tells the method what type of update to return.
/// If isDelete is true a UpdateMode is set to: Remove.</param>
/// <returns></returns>
public UpdateRequestParameter ToUpdateRequestParameter(bool isDelete)
{
if (!isDelete)
return new UpdateRequestParameter(this.TargetAttributeName, UpdateMode.Modify, FIMAttributeUtilities.FormatValue(this.SourceAttributeValue), false);
else
{
return new UpdateRequestParameter(this.TargetAttributeName, UpdateMode.Remove, this.TargetAttributeValue, false);
}
}
/// <summary>
/// Compares the source value with the supplied readValue parameter.
/// Also sets IsDelete to true or false
/// </summary>
/// <param name="readValue">A value to compare with the SourceValue.</param>
/// <returns></returns>
public virtual bool ShouldUpdate(object readValue)
{
if (!isDelete)
return new UpdateRequestParameter(this.TargetAttributeName, UpdateMode.Modify, FIMAttributeUtilities.FormatValue(this.SourceAttributeValue), false);
else
{
return new UpdateRequestParameter(this.TargetAttributeName, UpdateMode.Remove, this.TargetAttributeValue, false);
}
// we need the original (non-converted) value if we are doing a removal as we must specify the original value (even a local date/time)
// object originalTargetValue = this.TargetAttributeValue;
object target = FIMAttributeUtilities.FormatValue(readValue);
object source = FIMAttributeUtilities.FormatValue(this.SourceAttributeValue);
}
/// <summary>
/// Compares the source value with the supplied readValue parameter.
/// Also sets IsDelete to true or false
/// </summary>
/// <param name="readValue">A value to compare with the SourceValue.</param>
/// <returns></returns>
public virtual bool ShouldUpdate(object readValue)
{
// we need the original (non-converted) value if we are doing a removal as we must specify the original value (even a local date/time)
// object originalTargetValue = this.TargetAttributeValue;
object target = FIMAttributeUtilities.FormatValue(readValue);
object source = FIMAttributeUtilities.FormatValue(this.SourceAttributeValue);
return getShouldUpdate(target, source);
}
/// <summary>
/// Compares the Target attribute value with the existing source attribute value. If the source attribute value is not set,
/// it will be compared on as a null value.
/// </summary>
/// <returns>Result of compare</returns>
public virtual bool ShouldUpdate()
{
object target = FIMAttributeUtilities.FormatValue(this.TargetAttributeValue);
object source = FIMAttributeUtilities.FormatValue(this.SourceAttributeValue);
return getShouldUpdate(target, source);
}
/// <summary>
/// Compares the Target attribute value with the existing source attribute value. If the source attribute value is not set,
/// it will be compared on as a null value.
/// </summary>
/// <returns>Result of compare</returns>
public virtual bool ShouldUpdate()
{
object target = FIMAttributeUtilities.FormatValue(this.TargetAttributeValue);
object source = FIMAttributeUtilities.FormatValue(this.SourceAttributeValue);
Debugging.Log(String.Format("Comparing source: {0} and target: {1}, containing the values: {2} / {3}", this.SourceAttributeName, this.TargetAttributeName, this.SourceAttributeValue, this.TargetAttributeValue));
bool result = getShouldUpdate(target, source);
Debugging.Log(String.Format("Comparison resulted in: {0}",result));
return result;
}
/// <summary>
/// Private method for comparing Source and Target attributes
/// </summary>
/// <param name="target">Taget value</param>
/// <param name="source">Source value</param>
/// <returns>Whether or not the target attribute should be updated.</returns>
private bool getShouldUpdate(object target, object source)
{
if (FIMAttributeUtilities.ValuesAreDifferent(source, target))
{
if (source == null)
{
// we are in a delete state
Debugging.Log(string.Format("Deleting value '{1}' from {0}", this.TargetAttributeName, target == null ? "(null)" : target));
this.IsDelete = true;
}
else
{
// we are in an update state
Debugging.Log(string.Format("Updating {0} from '{1}' to '{2}'", this.TargetAttributeName, target == null ? "(null)" : target, source));
this.IsDelete = false;
}
return true;
}
else
{
Debugging.Log(string.Format("No need to update {0}. Value is already {1}", this.TargetAttributeName, this.TargetAttributeValue == null ? "(null)" : this.TargetAttributeValue));
this.IsDelete = false;
return false;
}
}
/// <summary>
/// Sets the TargetAttributeValue on this AttributeValue based on the it's current TargetAttributeName.
/// </summary>
/// <param name="resource">the ResourceType object to pull the attribute value from.</param>
internal virtual void SetValues(ResourceType resource)
{
TargetAttributeValue = resource[this.TargetAttributeName] != null ? resource[this.TargetAttributeName] : null;
Debugging.Log(this.TargetAttributeName, this.TargetAttributeValue);
}
#endregion
}
Debugging.Log(String.Format("Comparing source: {0} and target: {1}, containing the values: {2} / {3}", this.SourceAttributeName, this.TargetAttributeName, this.SourceAttributeValue, this.TargetAttributeValue));
bool result = getShouldUpdate(target, source);
Debugging.Log(String.Format("Comparison resulted in: {0}", result));
return result;
}
/// <summary>
/// Private method for comparing Source and Target attributes
/// </summary>
/// <param name="target">Taget value</param>
/// <param name="source">Source value</param>
/// <returns>Whether or not the target attribute should be updated.</returns>
private bool getShouldUpdate(object target, object source)
{
if (FIMAttributeUtilities.ValuesAreDifferent(source, target))
{
if (source == null)
{
// we are in a delete state
Debugging.Log(string.Format("Deleting value '{1}' from {0}", this.TargetAttributeName, target == null ? "(null)" : target));
this.IsDelete = true;
}
else
{
// we are in an update state
Debugging.Log(string.Format("Updating {0} from '{1}' to '{2}'", this.TargetAttributeName, target == null ? "(null)" : target, source));
this.IsDelete = false;
}
return true;
}
else
{
Debugging.Log(string.Format("No need to update {0}. Value is already {1}", this.TargetAttributeName, this.TargetAttributeValue == null ? "(null)" : this.TargetAttributeValue));
this.IsDelete = false;
return false;
}
}
/// <summary>
/// Sets the TargetAttributeValue on this AttributeValue based on the it's current TargetAttributeName.
/// </summary>
/// <param name="resource">the ResourceType object to pull the attribute value from.</param>
internal virtual void SetValues(ResourceType resource)
{
TargetAttributeValue = resource[this.TargetAttributeName] != null ? resource[this.TargetAttributeName] : null;
Debugging.Log(this.TargetAttributeName, this.TargetAttributeValue);
}
#endregion
}
}

View File

@ -10,7 +10,6 @@ using Microsoft.Win32;
namespace Granfeldt.FIM.ActivityLibrary
{
public class WellKnownGuids
{
public static Guid BuiltInSynchronizationAccount = new Guid("fb89aefa-5ea1-47f1-8890-abe7797d6497");

View File

@ -0,0 +1,119 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Reflection;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class AddRemoveMultiValueActivityAsNeeded
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
[System.CodeDom.Compiler.GeneratedCode("", "")]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
this.UpdateTarget = new Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity();
this.NothingToDo = new System.Workflow.Activities.IfElseBranchActivity();
this.DoUpdate = new System.Workflow.Activities.IfElseBranchActivity();
this.ShouldUpdate = new System.Workflow.Activities.IfElseActivity();
this.ReadTarget = new Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity();
this.PrepareReadResource = new System.Workflow.Activities.CodeActivity();
//
// UpdateTarget
//
this.UpdateTarget.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateTarget.ApplyAuthorizationPolicy = false;
this.UpdateTarget.Name = "UpdateTarget";
this.UpdateTarget.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateTarget.UpdateParameters = null;
//
// NothingToDo
//
this.NothingToDo.Name = "NothingToDo";
//
// DoUpdate
//
this.DoUpdate.Activities.Add(this.UpdateTarget);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.ShouldUpdate_Condition);
this.DoUpdate.Condition = codecondition1;
this.DoUpdate.Name = "DoUpdate";
//
// ShouldUpdate
//
this.ShouldUpdate.Activities.Add(this.DoUpdate);
this.ShouldUpdate.Activities.Add(this.NothingToDo);
this.ShouldUpdate.Name = "ShouldUpdate";
//
// ReadTarget
//
this.ReadTarget.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.Name = "ReadTarget";
activitybind1.Name = "AddRemoveMultiValueActivityAsNeeded";
activitybind1.Path = "TargetResource";
this.ReadTarget.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.SelectionAttributes = null;
this.ReadTarget.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ResourceProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
//
// PrepareReadResource
//
this.PrepareReadResource.Name = "PrepareReadResource";
this.PrepareReadResource.ExecuteCode += new System.EventHandler(this.PrepareReadResource_ExecuteCode);
//
// AddRemoveMultiValueActivityAsNeeded
//
this.Activities.Add(this.PrepareReadResource);
this.Activities.Add(this.ReadTarget);
this.Activities.Add(this.ShouldUpdate);
this.Name = "AddRemoveMultiValueActivityAsNeeded";
this.CanModifyActivities = false;
}
#endregion
private CodeActivity PrepareReadResource;
private Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity ReadTarget;
private IfElseBranchActivity NothingToDo;
private IfElseBranchActivity DoUpdate;
private IfElseActivity ShouldUpdate;
private Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity UpdateTarget;
}
}

View File

@ -0,0 +1,221 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.ResourceManagement.Workflow.Activities;
using System.Collections.ObjectModel;
using Microsoft.ResourceManagement.WebServices;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class AddRemoveMultiValueActivityAsNeeded : SequenceActivity
{
public static DependencyProperty ActionProperty = DependencyProperty.Register("Action", typeof(System.String), typeof(AddRemoveMultiValueActivityAsNeeded));
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(AddRemoveMultiValueActivityAsNeeded));
public static DependencyProperty DestinationProperty = DependencyProperty.Register("Destination", typeof(string), typeof(AddRemoveMultiValueActivityAsNeeded));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String Action
{
get
{
return ((string)(base.GetValue(ActionProperty)));
}
set
{
base.SetValue(ActionProperty, value);
}
}
public static DependencyProperty TargetIdToUpdateProperty = DependencyProperty.Register("TargetIdToUpdate", typeof(Guid), typeof(AddRemoveMultiValueActivityAsNeeded));
[Description("TargetIdToUpdate")]
[Category("TargetIdToUpdate Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public Guid TargetIdToUpdate
{
get
{
return ((Guid)(base.GetValue(AddRemoveMultiValueActivityAsNeeded.TargetIdToUpdateProperty)));
}
set
{
base.SetValue(AddRemoveMultiValueActivityAsNeeded.TargetIdToUpdateProperty, value);
}
}
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[Category("Properties")]
public string Destination
{
get
{
return (string)base.GetValue(DestinationProperty);
}
set
{
base.SetValue(DestinationProperty, value);
}
}
public static DependencyProperty ValueToAddOrRemoveProperty = DependencyProperty.Register("ValueToAddOrRemove", typeof(object), typeof(AddRemoveMultiValueActivityAsNeeded));
[Description("ValueToAddOrRemove")]
[Category("ValueToAddOrRemove Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public object ValueToAddOrRemove
{
get
{
return ((object)(base.GetValue(AddRemoveMultiValueActivityAsNeeded.ValueToAddOrRemoveProperty)));
}
set
{
base.SetValue(AddRemoveMultiValueActivityAsNeeded.ValueToAddOrRemoveProperty, value);
}
}
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType TargetResource
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(TargetResourceProperty)));
}
set
{
base.SetValue(TargetResourceProperty, value);
}
}
SequentialWorkflow containingWorkflow;
List<object> NewValues = new List<object>();
public AddRemoveMultiValueActivityAsNeeded()
{
InitializeComponent();
}
private void PrepareReadResource_ExecuteCode(object sender, EventArgs e)
{
Debugging.Log("Enter AddRemoveMultiValue-PrepareReadResource_ExecuteCode");
try
{
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
{
throw new InvalidOperationException("Could not get parent workflow!");
}
ReadTarget.ActorId = WellKnownGuids.FIMServiceAccount;
ReadTarget.ResourceId = this.TargetIdToUpdate;
ReadTarget.SelectionAttributes = new string[] { this.Destination };
}
catch (Exception ex)
{
Debugging.Log(string.Format("Error: '{0}'", ex.Message));
}
Debugging.Log("Exit AddRemoveMultiValue-PrepareReadResource_ExecuteCode");
}
private void ShouldUpdate_Condition(object sender, ConditionalEventArgs e)
{
Debugging.Log("Enter :: AddRemoveMultiValue-ShouldUpdate_Condition");
NewValues.Add(this.ValueToAddOrRemove);
Debugging.Log("New value", this.NewValues == null ? "(null)" : this.NewValues.FirstOrDefault().ToString());
Debugging.Log(string.Format("Action: {0}", Action));
try
{
// convert list of unique identifiers to list of guids
Debugging.Log("Begin converting to list");
List<object> currentvalues = new List<object>();
if (this.ReadTarget.Resource[this.Destination] != null)
{
Debugging.Log("Type", this.ReadTarget.Resource[this.Destination].GetType());
foreach (UniqueIdentifier u in (List<UniqueIdentifier>)this.ReadTarget.Resource[this.Destination])
{
Debugging.Log(string.Format("Guid: {0}", u.ToString()));
currentvalues.Add(u.GetGuid());
}
}
Debugging.Log("End converting to list");
e.Result = false;
if (this.Action.Equals("add", StringComparison.InvariantCultureIgnoreCase))
{
if (currentvalues == null)
{
Debugging.Log("There is an add and no current values");
e.Result = true;
}
else
{
if (NewValues.Except(currentvalues).Count() > 0)
{
Debugging.Log("There is an add");
e.Result = true;
}
else
{
Debugging.Log("There is a add but its already included");
e.Result = false;
}
}
}
else
{
if (currentvalues == null)
{
Debugging.Log("There is a remove but target value is already empty");
e.Result = false;
}
else
{
if (currentvalues.Intersect(NewValues).Count() > 0)
{
Debugging.Log("There is a remove");
e.Result = true;
}
else
{
Debugging.Log("There is a remove but target value is currently included");
e.Result = false;
}
}
}
if (e.Result)
{
// prepare update request
UpdateTarget.ActorId = WellKnownGuids.FIMServiceAccount;
UpdateTarget.ResourceId = this.TargetIdToUpdate;
UpdateRequestParameter[] UpdateParameters = new UpdateRequestParameter[] {
new Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateRequestParameter(
this.Destination,
this.Action.Equals("add", StringComparison.OrdinalIgnoreCase) ? UpdateMode.Insert : UpdateMode.Remove,
NewValues.First())};
UpdateTarget.UpdateParameters = UpdateParameters;
}
}
catch (Exception ex)
{
Debugging.Log(string.Format("AddRemoveMultiValue-ShouldUpdate_Condition, error: '{0}'", ex.Message));
}
Debugging.Log("Exit AddRemoveMultiValue-ShouldUpdate_Condition");
}
}
}

View File

@ -0,0 +1,152 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Reflection;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class ReconcileSoftwareGroupMembersActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
[System.CodeDom.Compiler.GeneratedCode("", "")]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
System.Collections.Generic.List<Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType> list_11 = new System.Collections.Generic.List<Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType>();
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
this.UpdateExplicitComputerMembers = new Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity();
this.NothingToDo = new System.Workflow.Activities.IfElseBranchActivity();
this.UpdateExplicitMember = new System.Workflow.Activities.IfElseBranchActivity();
this.EnumerateComputers = new Granfeldt.FIM.ActivityLibrary.FindResourcesActivity();
this.UpdateMembers = new System.Workflow.Activities.IfElseActivity();
this.FindUsersComputers = new System.Workflow.Activities.ReplicatorActivity();
this.ReadTarget = new Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity();
this.PrepareReadTarget = new System.Workflow.Activities.CodeActivity();
//
// UpdateExplicitComputerMembers
//
this.UpdateExplicitComputerMembers.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateExplicitComputerMembers.ApplyAuthorizationPolicy = false;
this.UpdateExplicitComputerMembers.Name = "UpdateExplicitComputerMembers";
this.UpdateExplicitComputerMembers.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateExplicitComputerMembers.UpdateParameters = null;
//
// NothingToDo
//
this.NothingToDo.Name = "NothingToDo";
//
// UpdateExplicitMember
//
this.UpdateExplicitMember.Activities.Add(this.UpdateExplicitComputerMembers);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.UpdateTarget_Condition);
this.UpdateExplicitMember.Condition = codecondition1;
this.UpdateExplicitMember.Name = "UpdateExplicitMember";
//
// EnumerateComputers
//
this.EnumerateComputers.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.EnumerateComputers.Attributes = null;
this.EnumerateComputers.EnumeratedResourceIDs = null;
this.EnumerateComputers.EnumeratedResources = list_11;
this.EnumerateComputers.Name = "EnumerateComputers";
this.EnumerateComputers.PageSize = 0;
this.EnumerateComputers.SortingAttributes = null;
this.EnumerateComputers.TotalResultsCount = 0;
this.EnumerateComputers.XPathFilter = null;
//
// UpdateMembers
//
this.UpdateMembers.Activities.Add(this.UpdateExplicitMember);
this.UpdateMembers.Activities.Add(this.NothingToDo);
this.UpdateMembers.Name = "UpdateMembers";
activitybind1.Name = "ReconcileSoftwareGroupMembersActivity";
activitybind1.Path = "usermembers";
//
// FindUsersComputers
//
this.FindUsersComputers.Activities.Add(this.EnumerateComputers);
this.FindUsersComputers.ExecutionType = System.Workflow.Activities.ExecutionType.Sequence;
this.FindUsersComputers.Name = "FindUsersComputers";
this.FindUsersComputers.ChildInitialized += new System.EventHandler<System.Workflow.Activities.ReplicatorChildEventArgs>(this.FindUsersComputers_ChildInitialized);
this.FindUsersComputers.ChildCompleted += new System.EventHandler<System.Workflow.Activities.ReplicatorChildEventArgs>(this.FindUsersComputers_ChildCompleted);
this.FindUsersComputers.Completed += new System.EventHandler(this.FindUsersComputers_Completed);
this.FindUsersComputers.Initialized += new System.EventHandler(this.FindUsersComputers_Initialized);
this.FindUsersComputers.SetBinding(System.Workflow.Activities.ReplicatorActivity.InitialChildDataProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
//
// ReadTarget
//
this.ReadTarget.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.Name = "ReadTarget";
activitybind2.Name = "ReconcileSoftwareGroupMembersActivity";
activitybind2.Path = "TargetResource";
this.ReadTarget.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.SelectionAttributes = null;
this.ReadTarget.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ResourceProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
//
// PrepareReadTarget
//
this.PrepareReadTarget.Name = "PrepareReadTarget";
this.PrepareReadTarget.ExecuteCode += new System.EventHandler(this.PrepareReadTarget_ExecuteCode);
//
// ReconcileSoftwareGroupMembersActivity
//
this.Activities.Add(this.PrepareReadTarget);
this.Activities.Add(this.ReadTarget);
this.Activities.Add(this.FindUsersComputers);
this.Activities.Add(this.UpdateMembers);
this.Name = "ReconcileSoftwareGroupMembersActivity";
this.CanModifyActivities = false;
}
#endregion
private Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity UpdateExplicitComputerMembers;
private IfElseBranchActivity NothingToDo;
private IfElseBranchActivity UpdateExplicitMember;
private IfElseActivity UpdateMembers;
private FindResourcesActivity EnumerateComputers;
private ReplicatorActivity FindUsersComputers;
private Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity ReadTarget;
private CodeActivity PrepareReadTarget;
}
}

View File

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.UI.WebControls;
using System.Workflow.ComponentModel;
using Microsoft.IdentityManagement.WebUI.Controls;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
class ReconcileSoftwareGroupMembersActivitySettingsPart : BaseActivitySettingsPart
{
const string UserMembersAttributeName = "UserMembersAttributeName";
const string ComputerMembersAttributeName = "ComputerMembersAttributeName";
protected override void CreateChildControls()
{
Table layoutTable;
layoutTable = new Table();
// width is set to 100% of the control size
layoutTable.Width = Unit.Percentage(100.0);
layoutTable.BorderWidth = 0;
layoutTable.CellPadding = 2;
// add a TableRow for each textbox in the UI
layoutTable.Rows.Add(this.AddTableRowTextBox("User members attributename:", "txt" + UserMembersAttributeName, 400, 100, false, "ExplicitMemberComputerOwners"));
layoutTable.Rows.Add(this.AddTableRowTextBox("Computer members attributename:", "txt" + ComputerMembersAttributeName, 400, 100, false, "ExplicitMember"));
this.Controls.Add(layoutTable);
base.CreateChildControls();
}
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
{
if (!this.ValidateInputs())
{
return null;
}
ReconcileSoftwareGroupMembersActivity act = new ReconcileSoftwareGroupMembersActivity();
act.ComputerMembersAttributeName = this.GetText("txt" + ComputerMembersAttributeName);
act.UserMembersAttributeName = this.GetText("txt" + UserMembersAttributeName);
return act;
}
public override void LoadActivitySettings(Activity activity)
{
ReconcileSoftwareGroupMembersActivity thisActivity = activity as ReconcileSoftwareGroupMembersActivity;
if (thisActivity != null)
{
this.SetText("txt" + UserMembersAttributeName, thisActivity.UserMembersAttributeName);
this.SetText("txt" + ComputerMembersAttributeName, thisActivity.ComputerMembersAttributeName);
}
}
public override ActivitySettingsPartData PersistSettings()
{
ActivitySettingsPartData data = new ActivitySettingsPartData();
data[UserMembersAttributeName] = this.GetText("txt" + UserMembersAttributeName);
data[ComputerMembersAttributeName] = this.GetText("txt" + ComputerMembersAttributeName);
return data;
}
public override void RestoreSettings(ActivitySettingsPartData data)
{
if (null != data)
{
this.SetText("txt" + UserMembersAttributeName, (string)data[UserMembersAttributeName]);
this.SetText("txt" + ComputerMembersAttributeName, (string)data[ComputerMembersAttributeName]);
}
}
public override void SwitchMode(ActivitySettingsPartMode mode)
{
bool isDisabled = (mode != ActivitySettingsPartMode.Edit);
this.SetTextBoxReadOnlyOption("txt" + UserMembersAttributeName, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + ComputerMembersAttributeName, isDisabled);
}
public override string Title
{
get { return "Reconcile software group members"; }
}
public override bool ValidateInputs()
{
return true;
}
}
}

View File

@ -0,0 +1,219 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.ResourceManagement.Workflow.Activities;
using System.Collections.Generic;
using Microsoft.ResourceManagement.WebServices;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class ReconcileSoftwareGroupMembersActivity : SequenceActivity
{
#region Properties
// ExplicitMemberComputerOwners
public static DependencyProperty UserMembersAttributeNameProperty = DependencyProperty.Register("UserMembersAttributeName", typeof(string), typeof(ReconcileSoftwareGroupMembersActivity));
[Description("UserMembersAttributeName")]
[Category("UserMembersAttributeName Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string UserMembersAttributeName
{
get
{
return ((string)(base.GetValue(ReconcileSoftwareGroupMembersActivity.UserMembersAttributeNameProperty)));
}
set
{
base.SetValue(ReconcileSoftwareGroupMembersActivity.UserMembersAttributeNameProperty, value);
}
}
// ExplicitMember
public static DependencyProperty ComputerMembersAttributeNameProperty = DependencyProperty.Register("ComputerMembersAttributeName", typeof(string), typeof(ReconcileSoftwareGroupMembersActivity));
[Description("ComputerMembersAttributeName")]
[Category("ComputerMembersAttributeName Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string ComputerMembersAttributeName
{
get
{
return ((string)(base.GetValue(ReconcileSoftwareGroupMembersActivity.ComputerMembersAttributeNameProperty)));
}
set
{
base.SetValue(ReconcileSoftwareGroupMembersActivity.ComputerMembersAttributeNameProperty, value);
}
}
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(Granfeldt.FIM.ActivityLibrary.ReconcileSoftwareGroupMembersActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
public Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType TargetResource
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.ReconcileSoftwareGroupMembersActivity.TargetResourceProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.ReconcileSoftwareGroupMembersActivity.TargetResourceProperty, value);
}
}
#endregion
SequentialWorkflow containingWorkflow = null;
public List<Guid> usermembers = new List<Guid>();
public List<Guid> currentcomputermembers = new List<Guid>();
public List<Guid> expectedcomputermembers = new List<Guid>();
public ReconcileSoftwareGroupMembersActivity()
{
InitializeComponent();
}
void ReadTarget_Closed(object sender, ActivityExecutionStatusChangedEventArgs e)
{
Debugging.Log(string.Format("Activity {0} result", e.Activity.Name), e.ExecutionResult);
try
{
// pick up the value of the multivalue attributes read from the target
if (this.ReadTarget.Resource[this.UserMembersAttributeName] != null)
{
foreach (UniqueIdentifier u in this.ReadTarget.Resource[this.UserMembersAttributeName] as List<UniqueIdentifier>)
{
Debugging.Log("current user member objectid", u);
usermembers.Add(u.GetGuid());
}
}
else
{
Debugging.Log("no current user members");
}
if (this.ReadTarget.Resource[this.ComputerMembersAttributeName] != null)
{
foreach (UniqueIdentifier u in this.ReadTarget.Resource[this.ComputerMembersAttributeName] as List<UniqueIdentifier>)
{
Debugging.Log("current computer member objectid", u);
currentcomputermembers.Add(u.GetGuid());
}
}
else
{
Debugging.Log("no current computer members");
}
}
catch (Exception ex)
{
Debugging.Log(ex);
}
}
void EnumerateComputersClosed(object sender, ActivityExecutionStatusChangedEventArgs e)
{
Debugging.Log(string.Format("{0} {1} with result: {2}", e.ExecutionStatus, e.Activity.Name, e.ExecutionResult));
}
private void PrepareReadTarget_ExecuteCode(object sender, EventArgs e)
{
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
{
throw new InvalidOperationException("Could not get parent workflow!");
}
ReadTarget.ActorId = WellKnownGuids.FIMServiceAccount;
ReadTarget.ResourceId = containingWorkflow.TargetId;
ReadTarget.SelectionAttributes = new string[] { this.UserMembersAttributeName, this.ComputerMembersAttributeName };
ReadTarget.Closed += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(ReadTarget_Closed);
}
private void FindUsersComputers_ChildInitialized(object sender, ReplicatorChildEventArgs e)
{
Debugging.Log("child initialized");
Debugging.Log("activity", e.Activity.Name);
Debugging.Log("instancedata", e.InstanceData);
// get the correct instance of the child activity
FindResourcesActivity fc = e.Activity as FindResourcesActivity;
fc.ActorId = WellKnownGuids.FIMServiceAccount;
fc.XPathFilter = string.Format("/Computer[ComputerLocalAdministrator='{0}']", e.InstanceData as Guid?);
Debugging.Log("enumeration filter", fc.XPathFilter);
fc.Attributes = new string[] { "ObjectID" };
fc.PageSize = 100;
fc.StatusChanged += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(EnumerateComputersClosed);
fc.Faulting += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(EnumerateComputersClosed);
}
private void FindUsersComputers_ChildCompleted(object sender, ReplicatorChildEventArgs e)
{
Debugging.Log("child completed");
// get the correct instance of the child activity
FindResourcesActivity fc = e.Activity as FindResourcesActivity;
if (fc != null)
{
Debugging.Log("enumerate computers result count", fc.TotalResultsCount);
if (fc.EnumeratedResourceIDs != null)
{
foreach (Guid computer in fc.EnumeratedResourceIDs.ToList())
{
Debugging.Log("expected member", computer);
expectedcomputermembers.Add(computer);
}
}
}
}
private void FindUsersComputers_Completed(object sender, EventArgs e)
{
Debugging.Log("completed");
}
private void FindUsersComputers_Initialized(object sender, EventArgs e)
{
Debugging.Log("initialized");
}
private void UpdateTarget_Condition(object sender, ConditionalEventArgs e)
{
List<UpdateRequestParameter> updateparameters = new List<UpdateRequestParameter>();
e.Result = false;
foreach (Guid member in currentcomputermembers.Except(expectedcomputermembers))
{
Debugging.Log("remove currentmember", member);
e.Result = true;
updateparameters.Add(
new UpdateRequestParameter(this.ComputerMembersAttributeName, UpdateMode.Remove, member)
);
}
foreach (Guid member in expectedcomputermembers.Except(currentcomputermembers))
{
Debugging.Log("add expected member", member);
e.Result = true;
updateparameters.Add(
new UpdateRequestParameter(this.ComputerMembersAttributeName, UpdateMode.Insert, member)
);
}
UpdateExplicitComputerMembers.ActorId = WellKnownGuids.FIMServiceAccount;
UpdateExplicitComputerMembers.ResourceId = containingWorkflow.TargetId;
UpdateExplicitComputerMembers.UpdateParameters = updateparameters.ToArray();
UpdateExplicitComputerMembers.StatusChanged += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(EnumerateComputersClosed);
}
}
}

View File

@ -0,0 +1,164 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Reflection;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class UpdateReferenceOnRegExMatchActivity
{
#region Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
[System.Diagnostics.DebuggerNonUserCode]
[System.CodeDom.Compiler.GeneratedCode("", "")]
private void InitializeComponent()
{
this.CanModifyActivities = true;
System.Collections.Generic.List<Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType> list_11 = new System.Collections.Generic.List<Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType>();
System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition();
System.Workflow.ComponentModel.ActivityBind activitybind1 = new System.Workflow.ComponentModel.ActivityBind();
System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
this.PrepareClearingReference = new System.Workflow.Activities.CodeActivity();
this.PrepareUpdateReference = new System.Workflow.Activities.CodeActivity();
this.FindUser = new Granfeldt.FIM.ActivityLibrary.FindResourcesActivity();
this.NoClearReference = new System.Workflow.Activities.IfElseBranchActivity();
this.YesUpdateReference = new System.Workflow.Activities.IfElseBranchActivity();
this.UpdateUserReference = new Granfeldt.FIM.ActivityLibrary.UpdateSingleValueAttributeAsNeededActivity();
this.DoesComputerNameContainUsername = new System.Workflow.Activities.IfElseActivity();
this.ReadTarget = new Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity();
this.PrepareReadTarget = new System.Workflow.Activities.CodeActivity();
this.GetCurrentRequest = new Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity();
//
// PrepareClearingReference
//
this.PrepareClearingReference.Name = "PrepareClearingReference";
this.PrepareClearingReference.ExecuteCode += new System.EventHandler(this.PrepareClearingReferenceCode);
//
// PrepareUpdateReference
//
this.PrepareUpdateReference.Name = "PrepareUpdateReference";
this.PrepareUpdateReference.ExecuteCode += new System.EventHandler(this.PrepareUpdateReferenceCode);
//
// FindUser
//
this.FindUser.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.FindUser.Attributes = null;
this.FindUser.EnumeratedResourceIDs = null;
this.FindUser.EnumeratedResources = list_11;
this.FindUser.Name = "FindUser";
this.FindUser.PageSize = 0;
this.FindUser.SortingAttributes = null;
this.FindUser.TotalResultsCount = 0;
this.FindUser.XPathFilter = null;
//
// NoClearReference
//
this.NoClearReference.Activities.Add(this.PrepareClearingReference);
this.NoClearReference.Name = "NoClearReference";
//
// YesUpdateReference
//
this.YesUpdateReference.Activities.Add(this.FindUser);
this.YesUpdateReference.Activities.Add(this.PrepareUpdateReference);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.IfComputerNameContainsUsername);
this.YesUpdateReference.Condition = codecondition1;
this.YesUpdateReference.Name = "YesUpdateReference";
//
// UpdateUserReference
//
this.UpdateUserReference.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateUserReference.AttributeName = null;
this.UpdateUserReference.Name = "UpdateUserReference";
this.UpdateUserReference.NewValue = null;
this.UpdateUserReference.TargetId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateUserReference.TargetResource = null;
//
// DoesComputerNameContainUsername
//
this.DoesComputerNameContainUsername.Activities.Add(this.YesUpdateReference);
this.DoesComputerNameContainUsername.Activities.Add(this.NoClearReference);
this.DoesComputerNameContainUsername.Name = "DoesComputerNameContainUsername";
//
// ReadTarget
//
this.ReadTarget.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.Name = "ReadTarget";
activitybind1.Name = "UpdateReferenceOnRegExMatchActivity";
activitybind1.Path = "TargetResource";
this.ReadTarget.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.SelectionAttributes = null;
this.ReadTarget.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ResourceProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
//
// PrepareReadTarget
//
this.PrepareReadTarget.Name = "PrepareReadTarget";
this.PrepareReadTarget.ExecuteCode += new System.EventHandler(this.PrepareReadTargetCode);
//
// GetCurrentRequest
//
activitybind2.Name = "UpdateReferenceOnRegExMatchActivity";
activitybind2.Path = "CurrentRequest";
this.GetCurrentRequest.Name = "GetCurrentRequest";
this.GetCurrentRequest.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity.CurrentRequestProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
//
// UpdateReferenceOnRegExMatchActivity
//
this.Activities.Add(this.GetCurrentRequest);
this.Activities.Add(this.PrepareReadTarget);
this.Activities.Add(this.ReadTarget);
this.Activities.Add(this.DoesComputerNameContainUsername);
this.Activities.Add(this.UpdateUserReference);
this.Name = "UpdateReferenceOnRegExMatchActivity";
this.CanModifyActivities = false;
}
#endregion
private CodeActivity PrepareUpdateReference;
private CodeActivity PrepareClearingReference;
private UpdateSingleValueAttributeAsNeededActivity UpdateUserReference;
private FindResourcesActivity FindUser;
private IfElseBranchActivity NoClearReference;
private IfElseBranchActivity YesUpdateReference;
private IfElseActivity DoesComputerNameContainUsername;
private CodeActivity PrepareReadTarget;
private Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity ReadTarget;
private Microsoft.ResourceManagement.Workflow.Activities.CurrentRequestActivity GetCurrentRequest;
}
}

View File

@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.UI.WebControls;
using System.Workflow.ComponentModel;
using Microsoft.IdentityManagement.WebUI.Controls;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
class UpdateReferenceOnRegExMatchActivitySettingsPart : BaseActivitySettingsPart
{
const string RegExFilter = "RegExFilter";
const string PositiveRegExFilter = "PositiveRegExFilter";
const string ComputerNameAttributeName = "ComputerNameAttribute";
const string UserNameAttributeName = "UserNameAttributeName";
const string TargetReferenceAttributeName = "TargetReferenceAttributeName";
const string Actor = "Actor";
protected override void CreateChildControls()
{
Table layoutTable;
layoutTable = new Table();
// width is set to 100% of the control size
layoutTable.Width = Unit.Percentage(100.0);
layoutTable.BorderWidth = 0;
layoutTable.CellPadding = 2;
// add a TableRow for each textbox in the UI
layoutTable.Rows.Add(this.AddTableRowTextBox("Regex Filter:", "txt" + RegExFilter, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddTableRowTextBox("Positive Regex Filter:<br/><sup>if computername match filter, username is always updated</sup>", "txt" + PositiveRegExFilter, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddTableRowTextBox("ComputerName attribute:", "txt" + ComputerNameAttributeName, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddTableRowTextBox("UserName attribute:", "txt" + UserNameAttributeName, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddTableRowTextBox("User reference attribute:", "txt" + TargetReferenceAttributeName, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddActorDropDownList("Actor (run as):", "txt" + Actor, 400, WellKnownGuids.FIMServiceAccount.ToString()));
this.Controls.Add(layoutTable);
base.CreateChildControls();
}
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
{
Debugging.Log("GenerateActivityOnWorkflow");
if (!this.ValidateInputs())
{
return null;
}
UpdateReferenceOnRegExMatchActivity act = new UpdateReferenceOnRegExMatchActivity();
act.RegExFilter = this.GetText("txt" + RegExFilter);
act.PositiveRegExFilter = this.GetText("txt" + PositiveRegExFilter);
act.ComputerNameAttributeName = this.GetText("txt" + ComputerNameAttributeName);
act.UserNameAttributeName = this.GetText("txt" + UserNameAttributeName);
act.TargetReferenceAttributeName = this.GetText("txt" + TargetReferenceAttributeName);
act.Actor = this.GetActorDropDownList("txt" + Actor);
return act;
}
public override void LoadActivitySettings(Activity activity)
{
Debugging.Log("LoadActivitySettings");
UpdateReferenceOnRegExMatchActivity act = activity as UpdateReferenceOnRegExMatchActivity;
if (act != null)
{
this.SetText("txt" + RegExFilter, act.RegExFilter);
this.SetText("txt" + PositiveRegExFilter, act.PositiveRegExFilter);
this.SetText("txt" + ComputerNameAttributeName, act.ComputerNameAttributeName);
this.SetText("txt" + UserNameAttributeName, act.UserNameAttributeName);
this.SetText("txt" + TargetReferenceAttributeName, act.TargetReferenceAttributeName);
this.SetActorDropDownList("txt" + Actor, act.Actor);
}
}
public override ActivitySettingsPartData PersistSettings()
{
Debugging.Log("PersistSettings");
ActivitySettingsPartData data = new ActivitySettingsPartData();
data[RegExFilter] = this.GetText("txt" + RegExFilter);
data[PositiveRegExFilter] = this.GetText("txt" + PositiveRegExFilter);
data[UserNameAttributeName] = this.GetText("txt" + UserNameAttributeName);
data[ComputerNameAttributeName] = this.GetText("txt" + ComputerNameAttributeName);
data[TargetReferenceAttributeName] = this.GetText("txt" + TargetReferenceAttributeName);
data[Actor] = this.GetActorDropDownList("txt" + Actor);
return data;
}
public override void RestoreSettings(ActivitySettingsPartData data)
{
Debugging.Log("RestoreSettings");
if (null != data)
{
this.SetText("txt" + RegExFilter, (string)data[RegExFilter]);
this.SetText("txt" + PositiveRegExFilter, (string)data[PositiveRegExFilter]);
this.SetText("txt" + UserNameAttributeName, (string)data[UserNameAttributeName]);
this.SetText("txt" + ComputerNameAttributeName, (string)data[ComputerNameAttributeName]);
this.SetText("txt" + TargetReferenceAttributeName, (string)data[TargetReferenceAttributeName]);
this.SetActorDropDownList("txt" + Actor, (string)data[Actor]);
}
}
public override void SwitchMode(ActivitySettingsPartMode mode)
{
Debugging.Log("SwitchMode");
bool isDisabled = (mode != ActivitySettingsPartMode.Edit);
this.SetTextBoxReadOnlyOption("txt" + RegExFilter, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + PositiveRegExFilter, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + UserNameAttributeName, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + ComputerNameAttributeName, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + TargetReferenceAttributeName, isDisabled);
this.SetDropDownListDisabled("txt" + Actor, isDisabled);
}
public override string Title
{
get { return "Update Reference on regular expression match"; }
}
public override bool ValidateInputs()
{
Debugging.Log("ValidateInputs");
return true;
}
}
}

View File

@ -0,0 +1,259 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Linq;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using System.Text.RegularExpressions;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class UpdateReferenceOnRegExMatchActivity : SequenceActivity
{
#region Properties
public static DependencyProperty CurrentRequestProperty = DependencyProperty.Register("CurrentRequest", typeof(RequestType), typeof(UpdateReferenceOnRegExMatchActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public RequestType CurrentRequest
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.RequestType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.UpdateReferenceOnRegExMatchActivity.CurrentRequestProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.UpdateReferenceOnRegExMatchActivity.CurrentRequestProperty, value);
}
}
// ^w8(ab|fe)pc|[1|2|3]*[w|t]$
public static DependencyProperty RegExFilterProperty = DependencyProperty.Register("RegExFilter", typeof(string), typeof(UpdateReferenceOnRegExMatchActivity));
[Description("RegExFilter")]
[Category("RegExFilter Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string RegExFilter
{
get
{
return ((string)(base.GetValue(UpdateReferenceOnRegExMatchActivity.RegExFilterProperty)));
}
set
{
base.SetValue(UpdateReferenceOnRegExMatchActivity.RegExFilterProperty, value);
}
}
public static DependencyProperty PositiveRegExFilterProperty = DependencyProperty.Register("PositiveRegExFilter", typeof(string), typeof(UpdateReferenceOnRegExMatchActivity));
[Description("PositiveRegExFilter")]
[Category("PositiveRegExFilter Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string PositiveRegExFilter
{
get
{
return ((string)(base.GetValue(UpdateReferenceOnRegExMatchActivity.PositiveRegExFilterProperty)));
}
set
{
base.SetValue(UpdateReferenceOnRegExMatchActivity.PositiveRegExFilterProperty, value);
}
}
public static DependencyProperty ComputerNameAttributeNameProperty = DependencyProperty.Register("ComputerNameAttributeName", typeof(string), typeof(UpdateReferenceOnRegExMatchActivity));
[Description("ComputerNameAttributeName")]
[Category("ComputerNameAttributeName Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string ComputerNameAttributeName
{
get
{
return ((string)(base.GetValue(UpdateReferenceOnRegExMatchActivity.ComputerNameAttributeNameProperty)));
}
set
{
base.SetValue(UpdateReferenceOnRegExMatchActivity.ComputerNameAttributeNameProperty, value);
}
}
public static DependencyProperty UserNameAttributeNameProperty = DependencyProperty.Register("UserNameAttributeName", typeof(string), typeof(UpdateReferenceOnRegExMatchActivity));
[Description("UserNameAttributeName")]
[Category("UserNameAttribute Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string UserNameAttributeName
{
get
{
return ((string)(base.GetValue(UpdateReferenceOnRegExMatchActivity.UserNameAttributeNameProperty)));
}
set
{
base.SetValue(UpdateReferenceOnRegExMatchActivity.UserNameAttributeNameProperty, value);
}
}
public static DependencyProperty TargetReferenceAttributeNameProperty = DependencyProperty.Register("TargetReferenceAttributeName", typeof(string), typeof(UpdateReferenceOnRegExMatchActivity));
[Description("TargetReferenceAttributeName")]
[Category("TargetReferenceAttributeName Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string TargetReferenceAttributeName
{
get
{
return ((string)(base.GetValue(UpdateReferenceOnRegExMatchActivity.TargetReferenceAttributeNameProperty)));
}
set
{
base.SetValue(UpdateReferenceOnRegExMatchActivity.TargetReferenceAttributeNameProperty, value);
}
}
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(Granfeldt.FIM.ActivityLibrary.UpdateReferenceOnRegExMatchActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
public ResourceType TargetResource
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.UpdateReferenceOnRegExMatchActivity.TargetResourceProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.UpdateReferenceOnRegExMatchActivity.TargetResourceProperty, value);
}
}
public static DependencyProperty ActorProperty = DependencyProperty.Register("Actor", typeof(string), typeof(UpdateReferenceOnRegExMatchActivity));
[Description("Actor")]
[Category("Actor Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string Actor
{
get
{
return ((string)(base.GetValue(UpdateReferenceOnRegExMatchActivity.ActorProperty)));
}
set
{
base.SetValue(UpdateReferenceOnRegExMatchActivity.ActorProperty, value);
}
}
#endregion
public UpdateReferenceOnRegExMatchActivity()
{
InitializeComponent();
}
private void PrepareReadTargetCode(object sender, EventArgs e)
{
Debugging.Log("Enter PrepareReadTargetCode");
Debugging.Log("Actor", this.Actor);
Debugging.Log("Computername attribute", this.ComputerNameAttributeName);
Debugging.Log("Usernamename attribute", this.UserNameAttributeName);
Debugging.Log("Request targetid", CurrentRequest.Target.GetGuid());
ReadTarget.ActorId = new Guid(this.Actor);
ReadTarget.SelectionAttributes = new string[] { this.ComputerNameAttributeName, this.UserNameAttributeName };
ReadTarget.ResourceId = CurrentRequest.Target.GetGuid();
ReadTarget.StatusChanged += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(Activity_StatusChanged);
Debugging.Log("Exit PrepareReadTargetCode");
}
void Activity_StatusChanged(object sender, ActivityExecutionStatusChangedEventArgs e)
{
Debugging.Log(string.Format("{0} {1} with result: {2}", e.ExecutionStatus, e.Activity.Name, e.ExecutionResult));
}
private void IfComputerNameContainsUsername(object sender, ConditionalEventArgs e)
{
Debugging.Log("Enter IfComputerNameContainsUsername");
// always setup defaults for updating
UpdateUserReference.ActorId = new Guid(this.Actor);
UpdateUserReference.AttributeName = this.TargetReferenceAttributeName;
UpdateUserReference.TargetId = CurrentRequest.Target.GetGuid();
UpdateUserReference.NewValue = null;
UpdateUserReference.StatusChanged += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(Activity_StatusChanged);
if (ReadTarget.Resource == null)
{
Debugging.Log("Could not read request target");
e.Result = false;
return;
}
object computername = ReadTarget.Resource[this.ComputerNameAttributeName];
object username = ReadTarget.Resource[this.UserNameAttributeName];
Debugging.Log("Computername", computername);
Debugging.Log("Username", username);
e.Result = false;
if ((username == null) || (computername == null))
{
Debugging.Log(string.Format("{0} or {1} is null. No match", this.ComputerNameAttributeName, this.UserNameAttributeName));
return;
}
string computerusername = Regex.Replace(computername as string, this.RegExFilter, "", RegexOptions.IgnoreCase);
Debugging.Log("Regex trimmed computername", computerusername);
if ((computerusername.Equals(username as string, StringComparison.OrdinalIgnoreCase)) || (Regex.IsMatch(computername as string, this.PositiveRegExFilter, RegexOptions.IgnoreCase)))
{
Debugging.Log("We got a match; doing lookup for user", username);
e.Result = true;
// set up lookup code
FindUser.ActorId = WellKnownGuids.FIMServiceAccount;
FindUser.Attributes = new string[] { "ObjectID" };
FindUser.XPathFilter = string.Format("/Person[AccountName='{0}']", username);
FindUser.PageSize = 100;
FindUser.StatusChanged += new System.EventHandler<ActivityExecutionStatusChangedEventArgs>(Activity_StatusChanged);
return;
}
Debugging.Log("Exit IfComputerNameContainsUsername");
}
private void PrepareUpdateReferenceCode(object sender, EventArgs e)
{
Debugging.Log("Enter PrepareUpdateReferenceCode");
if (FindUser.TotalResultsCount == 1)
{
ResourceType r;
r = FindUser.EnumeratedResources[0];
UpdateUserReference.NewValue = r["ObjectID"];
}
Debugging.Log("Exit PrepareUpdateReferenceCode");
}
private void PrepareClearingReferenceCode(object sender, EventArgs e)
{
Debugging.Log("Enter PrepareClearingReferenceCode");
// all setup for clearing is done in IfComputerNameContainsUsername
Debugging.Log("Exit PrepareClearingReferenceCode");
}
}
}

View File

@ -36,23 +36,19 @@
<ItemGroup>
<Reference Include="Microsoft.IdentityManagement.Activities, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Microsoft.IdentityManagement.Activities.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityManagement.SettingsContract">
<HintPath>..\..\..\..\..\..\Program Files\Microsoft Forefront Identity Manager\2010\Service\Microsoft.IdentityManagement.SettingsContract.dll</HintPath>
<Private>False</Private>
<HintPath>FIMDLLs\Microsoft.IdentityManagement.Activities.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityManagement.WebUI.Controls, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Microsoft.IdentityManagement.WebUI.Controls.dll</HintPath>
<HintPath>FIMDLLs\Microsoft.IdentityManagement.WebUI.Controls.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityManagement.WFExtensionInterfaces, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>.\Microsoft.IdentityManagement.WFExtensionInterfaces.dll</HintPath>
<HintPath>FIMDLLs\Microsoft.IdentityManagement.WFExtensionInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ResourceManagement, Version=4.1.2273.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files\Microsoft Forefront Identity Manager\2010\Service\Microsoft.ResourceManagement.dll</HintPath>
<HintPath>FIMDLLs\Microsoft.ResourceManagement.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Workflow.Activities" />
@ -68,6 +64,20 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Activity.AddRemoveFromMultivalue\Activity.AddRemoveFromMultiValue.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Activity.AddRemoveFromMultivalue\Activity.AddRemoveFromMultiValue.Designer.cs">
<DependentUpon>Activity.AddRemoveFromMultiValue.cs</DependentUpon>
</Compile>
<Compile Include="Activity.AddRemoveFromMultivalue\Activity.AddRemoveFromMultiValue.SettingsPart.cs" />
<Compile Include="Activity.ClearSingleValueAttribute\Activity.ClearSingleValuedAttribute.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Activity.ClearSingleValueAttribute\Activity.ClearSingleValuedAttribute.Designer.cs">
<DependentUpon>Activity.ClearSingleValuedAttribute.cs</DependentUpon>
</Compile>
<Compile Include="Activity.ClearSingleValueAttribute\ClearSingleValuedAttributeActivitySettingsPart.cs" />
<Compile Include="Activity.CodeRun\Activity.CodeRun.cs">
<SubType>Component</SubType>
</Compile>
@ -108,6 +118,12 @@
<Compile Include="Base\Base.ActivitySettings\Base.ActivitySettings.cs" />
<Compile Include="Base\Base.Common\Base.Common.cs" />
<Compile Include="Activity.CodeRun\Activity.CodeRun.SettingsPart.cs" />
<Compile Include="Base\Helper.AddRemoveMultiValueAsNeededActivity.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Base\Helper.AddRemoveMultiValueAsNeededActivity.Designer.cs">
<DependentUpon>Helper.AddRemoveMultiValueAsNeededActivity.cs</DependentUpon>
</Compile>
<Compile Include="Base\Helper.FindResourcesActivity.cs">
<SubType>Component</SubType>
</Compile>
@ -126,6 +142,7 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Tracer.cs" />
<Content Include="readme.txt" />
<None Include="Add-AssemblyToGlobalAssemblyCache.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

View File

@ -1,5 +1,7 @@
# January 30, 2013 | Soren Granfeldt
# - changed LookupAttributeValue to LookupValueActivity
# december 16, 2015 | soren granfeldt
# - added ClearSingleValueActivity
PARAM
(
@ -8,6 +10,7 @@ PARAM
[switch] $CreateLookupValueActivity,
[switch] $CreateCopyValuesActivity,
[switch] $CreateCreateObjectActivity,
[switch] $CreateClearSingleValueActivity,
[switch] $CreateDeleteObjectActivity
)
@ -95,6 +98,19 @@ PROCESS
.\New-FIMActivityInformationConfigurationObject.ps1 @Params
}
if ($CreateClearSingleValueActivity)
{
$Params = @{ `
DisplayName = 'Clear Single Value'
Description = 'Clears a single value attribute'
ActivityName = "$ManifestModule.ClearSingleValuedAttributeActivity"
TypeName = "$ManifestModule.WebUIs.ClearSingleValuedAttributeActivitySettingsPart"
IsActionActivity = $true
AssemblyName = $LoadedAssembly.Fullname
}
$Params
.\New-FIMActivityInformationConfigurationObject.ps1 @Params
}
}
END

View File

@ -30,4 +30,4 @@ using System.Runtime.InteropServices;
//NOTE: When updating the namespaces in the project please add new or update existing the XmlnsDefinitionAttribute
//You can add additional attributes in order to map any additional namespaces you have in the project
//[assembly: System.Workflow.ComponentModel.Serialization.XmlnsDefinition("http://schemas.com/Granfeldt.FIM.ActivityLibrary", "Granfeldt.FIM.ActivityLibrary")]
[assembly: AssemblyFileVersionAttribute("1.5.0.0")]
[assembly: AssemblyFileVersion("1.6.0.1612")]

View File

@ -0,0 +1,75 @@
using System;
using System.Diagnostics;
using System.Text;
namespace Granfeldt.FIM.ActivityLibrary
{
public static class Tracer
{
//TODO: convert ident to stringbuilder
const string SwitchName = "WFL";
const string SourceName = "WFL";
public static TraceSource Trace = new TraceSource(SourceName, SourceLevels.All);
static string IndentText = "";
public static int IndentLevel
{
get
{
return IndentText.Length;
}
set
{
IndentText = "";
}
}
public static void Indent()
{
IndentText = IndentText + " ";
}
public static void Unindent()
{
IndentText = IndentText.EndsWith(" ") ? IndentText.Remove(IndentText.Length - 2) : IndentText;
}
public static void Enter(string entryPoint)
{
TraceInformation("enter {0}", entryPoint);
Indent();
//Process currentProc = Process.GetCurrentProcess();
//Tracer.TraceInformation("memory-usage {0:n0}Kb, private memomry {1:n0}Kb", GC.GetTotalMemory(true) / 1024, currentProc.PrivateMemorySize64 / 1024);
}
public static void Exit(string entryPoint)
{
//Process currentProc = Process.GetCurrentProcess();
//Tracer.TraceInformation("memory-usage {0:n0}Kb, private memory {1:n0}Kb", GC.GetTotalMemory(true) / 1024, currentProc.PrivateMemorySize64 / 1024);
Unindent();
TraceInformation("exit {0}", entryPoint);
}
public static void TraceInformation(string message, params object[] param)
{
Trace.TraceInformation(IndentText + message, param);
}
public static void TraceWarning(string message, params object[] param)
{
Trace.TraceEvent(TraceEventType.Warning, -1, IndentText + message, param);
}
public static void TraceError(string message, int id, params object[] param)
{
Trace.TraceEvent(TraceEventType.Error, id, IndentText + message, param);
}
public static void TraceError(string message, Exception ex)
{
Trace.TraceEvent(TraceEventType.Error, ex.GetHashCode(), IndentText + "{0}, {1}", message, ex.Message);
}
public static void TraceError(string message, params object[] param)
{
TraceError(message, -2, param);
}
static Tracer()
{
SourceSwitch sw = new SourceSwitch(SwitchName, SwitchName);
sw.Level = SourceLevels.All;
Trace.Switch = sw;
}
}
}