Added Lookup Value activity

Renamed Code activity to CodeRun activity to avoid name clashes
Cleaned up here and there
master
Granfeldt_cp 2013-01-17 13:38:27 -08:00
parent 689c436462
commit 34bc8a15de
18 changed files with 1233 additions and 96 deletions

Binary file not shown.

View File

@ -13,7 +13,7 @@ using System.Workflow.Activities.Rules;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class CodeActivity
public partial class CodeRunActivity
{
#region Designer generated code
@ -106,7 +106,7 @@ namespace Granfeldt.FIM.ActivityLibrary
//
this.ReadTarget.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.Name = "ReadTarget";
activitybind1.Name = "CodeActivity";
activitybind1.Name = "CodeRunActivity";
activitybind1.Path = "TargetResource";
this.ReadTarget.ResourceId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadTarget.SelectionAttributes = null;
@ -143,7 +143,7 @@ namespace Granfeldt.FIM.ActivityLibrary
//
this.ResolveParameterValue.GrammarExpression = null;
this.ResolveParameterValue.Name = "ResolveParameterValue";
activitybind2.Name = "CodeActivity";
activitybind2.Name = "CodeRunActivity";
activitybind2.Path = "ResolvedParameterExpression";
this.ResolveParameterValue.WorkflowDictionaryKey = null;
this.ResolveParameterValue.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.ResolvedExpressionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
@ -195,26 +195,26 @@ namespace Granfeldt.FIM.ActivityLibrary
this.ResolveAllParameters.Condition = codecondition3;
this.ResolveAllParameters.Name = "ResolveAllParameters";
//
// CodeActivity
// CodeRunActivity
//
this.Activities.Add(this.ResolveAllParameters);
this.Activities.Add(this.CompileCode);
this.Activities.Add(this.ExecuteCode);
this.Activities.Add(this.ShouldUpdateTarget);
this.Name = "CodeActivity";
this.Name = "CodeRunActivity";
this.CanModifyActivities = false;
}
#endregion
private System.Workflow.Activities.CodeActivity CatchAndArgumentException;
private CodeActivity CatchAndArgumentException;
private FaultHandlerActivity faultHandlerActivity1;
private FaultHandlersActivity faultHandlersActivity3;
private System.Workflow.Activities.CodeActivity ExitGracefully;
private CodeActivity ExitGracefully;
private Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity UpdateTargetResource;
@ -236,17 +236,17 @@ namespace Granfeldt.FIM.ActivityLibrary
private FaultHandlersActivity faultHandlersActivity2;
private System.Workflow.Activities.CodeActivity NullOrInvalidGrammar;
private CodeActivity NullOrInvalidGrammar;
private FaultHandlerActivity faultHandlerActivity2;
private System.Workflow.Activities.CodeActivity ExecuteCode;
private CodeActivity ExecuteCode;
private FaultHandlersActivity faultHandlersActivity1;
private System.Workflow.Activities.CodeActivity CompileCode;
private CodeActivity CompileCode;
private System.Workflow.Activities.CodeActivity SaveResolvedParameterValue;
private CodeActivity SaveResolvedParameterValue;
private Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity ResolveParameterValue;
@ -268,6 +268,8 @@ namespace Granfeldt.FIM.ActivityLibrary

View File

@ -8,7 +8,7 @@ using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
class CodeActivitySettingsPart : BaseActivitySettingsPart
class CodeRunActivitySettingsPart : BaseActivitySettingsPart
{
const string InstanceTitle = "Title";
@ -17,23 +17,16 @@ namespace Granfeldt.FIM.ActivityLibrary.WebUIs
const string Code = "Code";
const string Destination = "Destination";
/// <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
// 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
// add a TableRow for each textbox in the UI
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Title:", "txt" + InstanceTitle, 400, 100, false, ""));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("References (DLL's):<br/><i>(please note that System.dll is added by default)</i>", "txt" + References, 400, 4000, true, "System.dll"));
controlLayoutTable.Rows.Add(this.AddTableRowTextBox("Parameters:<br/><i>(parameters are passed to the FIMDynamicFunction method in the order shown. Therefore, you should make sure that the function FIMDynamicFunction accepts the correct number of parameters and possible types)</i>", "txt" + Parameters, 400, 4000, true, ""));
@ -49,7 +42,7 @@ namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
return null;
}
CodeActivity ThisActivity = new CodeActivity();
CodeRunActivity ThisActivity = new CodeRunActivity();
ThisActivity.Title = this.GetText("txt" + InstanceTitle);
ThisActivity.References = this.GetTextArray("txt" + References);
ThisActivity.Parameters = this.GetTextArray("txt" + Parameters);
@ -61,7 +54,7 @@ namespace Granfeldt.FIM.ActivityLibrary.WebUIs
public override void LoadActivitySettings(Activity activity)
{
CodeActivity ThisActivity = activity as CodeActivity;
CodeRunActivity ThisActivity = activity as CodeRunActivity;
if (ThisActivity != null)
{
this.SetText("txt" + InstanceTitle, ThisActivity.Title);
@ -109,7 +102,7 @@ namespace Granfeldt.FIM.ActivityLibrary.WebUIs
{
get
{
return string.Format("Code: {0}", this.GetText("txt" + InstanceTitle));
return string.Format("Code Run: {0}", this.GetText("txt" + InstanceTitle));
}
}

View File

@ -1,4 +1,10 @@
using System;
// January 15, 2013 | Soren Granfeldt
// - initial version
// January 17, 2013 | Soren Granfeldt
// - changed activity name from CodeActivity to CodeRunActivity
// due to clashes with built-in naming convention
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
@ -20,12 +26,12 @@ using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class CodeActivity : SequenceActivity
public partial class CodeRunActivity : SequenceActivity
{
#region Properties
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(Granfeldt.FIM.ActivityLibrary.CodeActivity));
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(Granfeldt.FIM.ActivityLibrary.CodeRunActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
@ -33,11 +39,11 @@ namespace Granfeldt.FIM.ActivityLibrary
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeActivity.TargetResourceProperty)));
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.TargetResourceProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeActivity.TargetResourceProperty, value);
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.TargetResourceProperty, value);
}
}
@ -45,7 +51,7 @@ namespace Granfeldt.FIM.ActivityLibrary
/// <summary>
/// The title of the current instance of the workflow
/// </summary>
public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(CodeActivity));
public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(CodeRunActivity));
[Description("Title")]
[Category("Title Category")]
[Browsable(true)]
@ -54,15 +60,15 @@ namespace Granfeldt.FIM.ActivityLibrary
{
get
{
return ((string)(base.GetValue(CodeActivity.TitleProperty)));
return ((string)(base.GetValue(CodeRunActivity.TitleProperty)));
}
set
{
base.SetValue(CodeActivity.TitleProperty, value);
base.SetValue(CodeRunActivity.TitleProperty, value);
}
}
public static DependencyProperty ReferencesProperty = DependencyProperty.Register("References", typeof(string[]), typeof(CodeActivity));
public static DependencyProperty ReferencesProperty = DependencyProperty.Register("References", typeof(string[]), typeof(CodeRunActivity));
[Description("References")]
[Category("References Category")]
[Browsable(true)]
@ -71,15 +77,15 @@ namespace Granfeldt.FIM.ActivityLibrary
{
get
{
return ((string[])(base.GetValue(CodeActivity.ReferencesProperty)));
return ((string[])(base.GetValue(CodeRunActivity.ReferencesProperty)));
}
set
{
base.SetValue(CodeActivity.ReferencesProperty, value);
base.SetValue(CodeRunActivity.ReferencesProperty, value);
}
}
public static DependencyProperty ParametersProperty = DependencyProperty.Register("Parameters", typeof(string[]), typeof(CodeActivity));
public static DependencyProperty ParametersProperty = DependencyProperty.Register("Parameters", typeof(string[]), typeof(CodeRunActivity));
[Description("Parameters")]
[Category("Parameters Category")]
[Browsable(true)]
@ -88,15 +94,15 @@ namespace Granfeldt.FIM.ActivityLibrary
{
get
{
return ((string[])(base.GetValue(CodeActivity.ParametersProperty)));
return ((string[])(base.GetValue(CodeRunActivity.ParametersProperty)));
}
set
{
base.SetValue(CodeActivity.ParametersProperty, value);
base.SetValue(CodeRunActivity.ParametersProperty, value);
}
}
public static DependencyProperty ResolvedParameterExpressionProperty = DependencyProperty.Register("ResolvedParameterExpression", typeof(System.String), typeof(Granfeldt.FIM.ActivityLibrary.CodeActivity));
public static DependencyProperty ResolvedParameterExpressionProperty = DependencyProperty.Register("ResolvedParameterExpression", typeof(System.String), typeof(Granfeldt.FIM.ActivityLibrary.CodeRunActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
@ -104,15 +110,15 @@ namespace Granfeldt.FIM.ActivityLibrary
{
get
{
return ((string)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeActivity.ResolvedParameterExpressionProperty)));
return ((string)(base.GetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.ResolvedParameterExpressionProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeActivity.ResolvedParameterExpressionProperty, value);
base.SetValue(Granfeldt.FIM.ActivityLibrary.CodeRunActivity.ResolvedParameterExpressionProperty, value);
}
}
public static DependencyProperty CodeProperty = DependencyProperty.Register("Code", typeof(string), typeof(CodeActivity));
public static DependencyProperty CodeProperty = DependencyProperty.Register("Code", typeof(string), typeof(CodeRunActivity));
[Description("Code")]
[Category("Code Category")]
[Browsable(true)]
@ -121,15 +127,15 @@ namespace Granfeldt.FIM.ActivityLibrary
{
get
{
return ((string)(base.GetValue(CodeActivity.CodeProperty)));
return ((string)(base.GetValue(CodeRunActivity.CodeProperty)));
}
set
{
base.SetValue(CodeActivity.CodeProperty, value);
base.SetValue(CodeRunActivity.CodeProperty, value);
}
}
public static DependencyProperty DestinationProperty = DependencyProperty.Register("Destination", typeof(string), typeof(CodeActivity));
public static DependencyProperty DestinationProperty = DependencyProperty.Register("Destination", typeof(string), typeof(CodeRunActivity));
[Description("Destination")]
[Category("Destination Category")]
[Browsable(true)]
@ -138,11 +144,11 @@ namespace Granfeldt.FIM.ActivityLibrary
{
get
{
return ((string)(base.GetValue(CodeActivity.DestinationProperty)));
return ((string)(base.GetValue(CodeRunActivity.DestinationProperty)));
}
set
{
base.SetValue(CodeActivity.DestinationProperty, value);
base.SetValue(CodeRunActivity.DestinationProperty, value);
}
}
@ -167,7 +173,7 @@ namespace Granfeldt.FIM.ActivityLibrary
string destinationObject = null;
string destinationAttribute = null;
public CodeActivity()
public CodeRunActivity()
{
Debugging.Log("Enter :: Initialize");
InitializeComponent();

View File

@ -0,0 +1,131 @@
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 LookupAttributeValueActivity
{
#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.UpdateTargetIfNeeded = new Granfeldt.FIM.ActivityLibrary.UpdateSingleValueAttributeAsNeededActivity();
this.UpdateWorkflowDataBranch = new System.Workflow.Activities.IfElseBranchActivity();
this.UpdateTargetBranch = new System.Workflow.Activities.IfElseBranchActivity();
this.UpdateTargetOrWorkflowData = new System.Workflow.Activities.IfElseActivity();
this.Enumerate = new Granfeldt.FIM.ActivityLibrary.FindResourcesActivity();
this.SetupVariablesActivity = new System.Workflow.Activities.CodeActivity();
this.ResolveGrammarForXPathFilter = new Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity();
//
// UpdateTargetIfNeeded
//
this.UpdateTargetIfNeeded.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateTargetIfNeeded.AttributeName = null;
this.UpdateTargetIfNeeded.Name = "UpdateTargetIfNeeded";
this.UpdateTargetIfNeeded.NewValue = null;
this.UpdateTargetIfNeeded.TargetId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.UpdateTargetIfNeeded.TargetResource = null;
//
// UpdateWorkflowDataBranch
//
this.UpdateWorkflowDataBranch.Name = "UpdateWorkflowDataBranch";
//
// UpdateTargetBranch
//
this.UpdateTargetBranch.Activities.Add(this.UpdateTargetIfNeeded);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.UpdateTargetOrWorkflowData_Condition);
this.UpdateTargetBranch.Condition = codecondition1;
this.UpdateTargetBranch.Name = "UpdateTargetBranch";
//
// UpdateTargetOrWorkflowData
//
this.UpdateTargetOrWorkflowData.Activities.Add(this.UpdateTargetBranch);
this.UpdateTargetOrWorkflowData.Activities.Add(this.UpdateWorkflowDataBranch);
this.UpdateTargetOrWorkflowData.Name = "UpdateTargetOrWorkflowData";
//
// 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);
//
// ResolveGrammarForXPathFilter
//
activitybind1.Name = "LookupAttributeValueActivity";
activitybind1.Path = "XPathFilter";
this.ResolveGrammarForXPathFilter.Name = "ResolveGrammarForXPathFilter";
activitybind2.Name = "LookupAttributeValueActivity";
activitybind2.Path = "ResolvedXPathFilter";
this.ResolveGrammarForXPathFilter.WorkflowDictionaryKey = null;
this.ResolveGrammarForXPathFilter.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.GrammarExpressionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
this.ResolveGrammarForXPathFilter.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity.ResolvedExpressionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
//
// LookupAttributeValueActivity
//
this.Activities.Add(this.ResolveGrammarForXPathFilter);
this.Activities.Add(this.SetupVariablesActivity);
this.Activities.Add(this.Enumerate);
this.Activities.Add(this.UpdateTargetOrWorkflowData);
this.Name = "LookupAttributeValueActivity";
this.CanModifyActivities = false;
}
#endregion
private Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity ReadResource;
private IfElseBranchActivity UpdateWorkflowDataBranch;
private IfElseBranchActivity UpdateTargetBranch;
private IfElseActivity UpdateTargetOrWorkflowData;
private UpdateSingleValueAttributeAsNeededActivity UpdateTargetIfNeeded;
private FindResourcesActivity Enumerate;
private CodeActivity SetupVariablesActivity;
private Microsoft.ResourceManagement.Workflow.Activities.ResolveGrammarActivity ResolveGrammarForXPathFilter;
#region "Special workflows"
// October 22, 2010 | Søren Granfeldt
// this.ReadEnumeratedResources = new System.Workflow.Activities.CodeActivity();
// this.ReadEnumeratedResources.Name = "ReadEnumeratedResources";
// this.ReadEnumeratedResources.ExecuteCode += new System.EventHandler(this.ReadEnumeratedResources_ExecuteCode);
// October 22, 2010 | Søren Granfeldt
// this.Enumerate.Activities.Add(this.ReadEnumeratedResources);
#endregion
}
}

View File

@ -0,0 +1,119 @@
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 LookupAttributeValueActivitySettingsPart : BaseActivitySettingsPart
{
const string XPathFilter = "XPathFilter";
const string AttributeToRetrieve = "AttributeToRetrieve";
const string Destination = "Destination";
const string LookupActor = "LookupActor";
const string NonUniqueResultAction = "NonUniqueResultAction";
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("XPath Filter:", "txt" + XPathFilter, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddTableRowTextBox("Attribute Name:", "txt" + AttributeToRetrieve, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddTableRowTextBox("Destination:", "txt" + Destination, 400, 100, false, ""));
layoutTable.Rows.Add(this.AddActorDropDownList("Actor (run as):", "txt" + LookupActor, 400, WellKnownGuids.FIMServiceAccount.ToString()));
layoutTable.Rows.Add(this.AddLookupActionDropDownList("Action on multiple lookup results:", "txt" + NonUniqueResultAction, 400, ""));
this.Controls.Add(layoutTable);
base.CreateChildControls();
}
public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow)
{
Debugging.Log("GenerateActivityOnWorkflow");
if (!this.ValidateInputs())
{
return null;
}
LookupAttributeValueActivity LookupActivity = new LookupAttributeValueActivity();
LookupActivity.AttributeName = this.GetText("txt" + AttributeToRetrieve);
LookupActivity.XPathFilter = this.GetText("txt" + XPathFilter);
LookupActivity.Destination = this.GetText("txt" + Destination);
LookupActivity.LookupActor = this.GetActorDropDownList("txt" + LookupActor);
LookupActivity.NonUniqueValueAction = this.GetLookupActionDropDownList("txt" + NonUniqueResultAction);
return LookupActivity;
}
public override void LoadActivitySettings(Activity activity)
{
Debugging.Log("LoadActivitySettings");
LookupAttributeValueActivity thisActivity = activity as LookupAttributeValueActivity;
if (thisActivity != null)
{
this.SetText("txt" + XPathFilter, thisActivity.XPathFilter);
this.SetText("txt" + AttributeToRetrieve, thisActivity.AttributeName);
this.SetText("txt" + Destination, thisActivity.Destination);
this.SetActorDropDownList("txt" + LookupActor, thisActivity.LookupActor);
this.SetLookupActionDropDownList("txt" + NonUniqueResultAction, thisActivity.NonUniqueValueAction);
}
}
public override ActivitySettingsPartData PersistSettings()
{
Debugging.Log("PersistSettings");
ActivitySettingsPartData data = new ActivitySettingsPartData();
data[XPathFilter] = this.GetText("txt" + XPathFilter);
data[Destination] = this.GetText("txt" + Destination);
data[AttributeToRetrieve] = this.GetText("txt" + AttributeToRetrieve);
data[LookupActor] = this.GetActorDropDownList("txt" + LookupActor);
data[NonUniqueResultAction] = this.GetLookupActionDropDownList("txt" + NonUniqueResultAction);
return data;
}
public override void RestoreSettings(ActivitySettingsPartData data)
{
Debugging.Log("RestoreSettings");
if (null != data)
{
this.SetText("txt" + XPathFilter, (string)data[XPathFilter]);
this.SetText("txt" + Destination, (string)data[Destination]);
this.SetText("txt" + AttributeToRetrieve, (string)data[AttributeToRetrieve]);
this.SetActorDropDownList("txt" + LookupActor, (string)data[LookupActor]);
this.SetLookupActionDropDownList("txt" + NonUniqueResultAction, (string)data[NonUniqueResultAction]);
}
}
public override void SwitchMode(ActivitySettingsPartMode mode)
{
Debugging.Log("SwitchMode");
bool isDisabled = (mode != ActivitySettingsPartMode.Edit);
this.SetTextBoxReadOnlyOption("txt" + XPathFilter, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + Destination, isDisabled);
this.SetTextBoxReadOnlyOption("txt" + AttributeToRetrieve, isDisabled);
this.SetDropDownListDisabled("txt" + LookupActor, isDisabled);
this.SetDropDownListDisabled("txt" + NonUniqueResultAction, isDisabled);
}
public override string Title
{
get { return "Lookup Attribute Value"; }
}
public override bool ValidateInputs()
{
Debugging.Log("ValidateInputs");
return true;
}
}
}

View File

@ -0,0 +1,208 @@
// January 17, 2013 | Soren Granfeldt
// - code revised and partially rewritten before CodePlex release
using System;
using System.ComponentModel;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using Microsoft.ResourceManagement.WebServices.WSResourceManagement;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
public partial class LookupAttributeValueActivity : SequenceActivity
{
#region Public Properties
public static DependencyProperty LookupActorProperty = DependencyProperty.Register("LookupActor", typeof(string), typeof(LookupAttributeValueActivity));
[Description("LookupActor")]
[Category("LookupActor Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string LookupActor
{
get
{
return ((string)(base.GetValue(LookupAttributeValueActivity.LookupActorProperty)));
}
set
{
base.SetValue(LookupAttributeValueActivity.LookupActorProperty, value);
}
}
public static DependencyProperty AttributeNameProperty = DependencyProperty.Register("AttributeName", typeof(System.String), typeof(LookupAttributeValueActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String AttributeName
{
get
{
return ((string)(base.GetValue(LookupAttributeValueActivity.AttributeNameProperty)));
}
set
{
base.SetValue(LookupAttributeValueActivity.AttributeNameProperty, value);
}
}
public static DependencyProperty XPathFilterProperty = DependencyProperty.Register("XPathFilter", typeof(System.String), typeof(LookupAttributeValueActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String XPathFilter
{
get
{
return ((string)(base.GetValue(LookupAttributeValueActivity.XPathFilterProperty)));
}
set
{
base.SetValue(LookupAttributeValueActivity.XPathFilterProperty, value);
}
}
public static DependencyProperty DestinationProperty = DependencyProperty.Register("Destination", typeof(System.String), typeof(LookupAttributeValueActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String Destination
{
get
{
return ((string)(base.GetValue(LookupAttributeValueActivity.DestinationProperty)));
}
set
{
base.SetValue(LookupAttributeValueActivity.DestinationProperty, value);
}
}
public static DependencyProperty ResolvedXPathFilterProperty = DependencyProperty.Register("ResolvedXPathFilter", typeof(System.String), typeof(LookupAttributeValueActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public String ResolvedXPathFilter
{
get
{
return ((string)(base.GetValue(LookupAttributeValueActivity.ResolvedXPathFilterProperty)));
}
set
{
base.SetValue(LookupAttributeValueActivity.ResolvedXPathFilterProperty, value);
}
}
public static DependencyProperty NonUniqueValueActionProperty = DependencyProperty.Register("NonUniqueValueAction", typeof(string), typeof(LookupAttributeValueActivity));
[Description("NonUniqueValueAction")]
[Category("NonUniqueValueAction Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string NonUniqueValueAction
{
get
{
return ((string)(base.GetValue(LookupAttributeValueActivity.NonUniqueValueActionProperty)));
}
set
{
base.SetValue(LookupAttributeValueActivity.NonUniqueValueActionProperty, value);
}
}
#endregion
#region Code
public LookupAttributeValueActivity()
{
InitializeComponent();
}
private void SetupVariablesActivity_ExecuteCode(object sender, EventArgs e)
{
Debugging.Log("Enter SetupVariablesActivity_ExecuteCode");
Enumerate.ActorId = new Guid(this.LookupActor);
Debugging.Log("XPath (resolved)", this.ResolvedXPathFilter);
Enumerate.XPathFilter = this.ResolvedXPathFilter;
Enumerate.Attributes = new string[] { this.AttributeName };
Enumerate.PageSize = 100;
Debugging.Log("Leave SetupVariablesActivity_ExecuteCode");
}
private void UpdateTargetOrWorkflowData_Condition(object sender, ConditionalEventArgs e)
{
Debugging.Log("Enter UpdateTargetOrWorkflowData_Condition");
e.Result = false; // go in workflowdata direction (we'll update workflowdata here, so actually nothing to do)
object newValue = null;
ResourceType r;
Debugging.Log("Results #", Enumerate.TotalResultsCount);
if (Enumerate.TotalResultsCount > 1)
{
switch (this.NonUniqueValueAction)
{
case "RETURNLAST":
// get the first object in the resultset and grab the
// value from the requested attribute
r = Enumerate.EnumeratedResources[Enumerate.TotalResultsCount - 1];
newValue = r[this.AttributeName];
break;
case "ERROR":
Debugging.Log(new System.ArgumentException("Too many results returned from lookup"));
break;
default:
// get the first object in the resultset and grab the
// value from the requested attribute
r = Enumerate.EnumeratedResources[0];
newValue = r[this.AttributeName];
break;
}
}
SequentialWorkflow containingWorkflow = null;
if (!SequentialWorkflow.TryGetContainingWorkflow(this, out containingWorkflow))
{
throw new InvalidOperationException("Could not get parent workflow!");
}
// separate destination object and destination attribute.
string destination = null;
string destinationAttribute = null;
StringUtilities.ExtractWorkflowExpression(this.Destination, out destination, out destinationAttribute);
if (!string.IsNullOrEmpty(destinationAttribute))
{
if (destination.Equals("workflowdata", StringComparison.OrdinalIgnoreCase))
{
// write output value to WorkflowDictionary.
if ((containingWorkflow != null) && (newValue != null))
{
containingWorkflow.WorkflowDictionary.Add(destinationAttribute, newValue);
}
}
else
{
if (destination.Equals("target", StringComparison.OrdinalIgnoreCase))
{
e.Result = true;
UpdateTargetIfNeeded.ActorId = new Guid(this.LookupActor);
UpdateTargetIfNeeded.AttributeName = destinationAttribute;
UpdateTargetIfNeeded.NewValue = newValue;
UpdateTargetIfNeeded.TargetId = containingWorkflow.TargetId;
}
}
}
Debugging.Log("Exit UpdateTargetOrWorkflowData_Condition");
}
#endregion
}
}

View File

@ -45,9 +45,75 @@ namespace Granfeldt.FIM.ActivityLibrary
return row;
}
protected TableRow AddDropDownList(String labelText, String controlID, int width, String defaultValue)
#region Lookup Action Dropdown
protected TableRow AddLookupActionDropDownList(String labelText, String controlID, int width, String defaultValue)
{
Debugging.Log("Enter AddDropDownList");
Debugging.Log("Enter AddLookupActionDropDownList");
TableRow row = new TableRow();
TableCell labelCell = new TableCell();
TableCell controlCell = new TableCell();
// Add label
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("Return first element", "")); // default is ''
ddl.Items.Add(new ListItem("Return last element", "RETURNLAST"));
ddl.Items.Add(new ListItem("Throw error and stop", "ERROR"));
ddl.SelectedValue = defaultValue;
controlCell.Controls.Add(ddl);
row.Cells.Add(labelCell);
row.Cells.Add(controlCell);
Debugging.Log("Leave AddLookupActionDropDownList");
return row;
}
protected string GetLookupActionDropDownList(string dropDownListID)
{
Debugging.Log("Enter GetLookupActionDropDownList");
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 + "'");
Debugging.Log("Leave GetLookupActionDropDownList");
return g;
}
protected void SetLookupActionDropDownList(string dropDownListID, string value)
{
Debugging.Log("Enter SetLookupActionDropDownList");
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 + "'");
Debugging.Log("Leave SetLookupActionDropDownList");
}
#endregion
#region Actor Dropdown
protected TableRow AddActorDropDownList(String labelText, String controlID, int width, String defaultValue)
{
Debugging.Log("Enter AddActorDropDownList");
TableRow row = new TableRow();
TableCell labelCell = new TableCell();
TableCell controlCell = new TableCell();
@ -75,10 +141,42 @@ namespace Granfeldt.FIM.ActivityLibrary
row.Cells.Add(labelCell);
row.Cells.Add(controlCell);
Debugging.Log("Leave AddDropDownList");
Debugging.Log("Leave AddActorDropDownList");
return row;
}
protected string GetActorDropDownList(string dropDownListID)
{
Debugging.Log("Enter GetActorDropDownList");
string g = WellKnownGuids.FIMServiceAccount.ToString();
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 + "'");
Debugging.Log("Leave GetActorDropDownList");
return g;
}
protected void SetActorDropDownList(string dropDownListID, object Guid)
{
Debugging.Log("Enter SetActorDropDownList");
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 + "'");
Debugging.Log("Leave SetActorDropDownList");
}
#endregion
protected TableRow AddCheckbox(String labelText, String controlID, bool defaultValue)
{
Debugging.Log("Enter AddCheckbox");
@ -171,46 +269,21 @@ namespace Granfeldt.FIM.ActivityLibrary
textBox.Enabled = !readOnly;
}
string GetDropDownList(string dropDownListID)
{
Debugging.Log("Enter GetDropDownList");
string g = WellKnownGuids.FIMServiceAccount.ToString();
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 + "'");
Debugging.Log("Leave GetDropDownList");
return g;
}
void SetDropDownList(string dropDownListID, object Guid)
{
Debugging.Log("Enter SetDropDownList");
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 + "'");
Debugging.Log("Leave SetDropDownList");
}
void SetDropDownListEnabled(string dropDownListID, bool enabled)
protected void SetDropDownListDisabled(string dropDownListID, bool disabled)
{
Debugging.Log("Enter SetDropDownListEnabled");
DropDownList ddl = (DropDownList)this.FindControl(dropDownListID);
if (ddl != null)
{
ddl.Enabled = enabled;
ddl.Enabled = !disabled;
}
else
Debugging.Log("Cannot find control with ID '" + dropDownListID + "'");
Debugging.Log("Leave SetDropDownListEnabled");
}
#endregion
/// <summary>

View File

@ -0,0 +1,87 @@
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 FindResourcesActivity
{
#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.ComponentModel.ActivityBind activitybind6 = new System.Workflow.ComponentModel.ActivityBind();
this.ReadEnumeratedResource = new System.Workflow.Activities.CodeActivity();
this.GenerateResourceIds = new System.Workflow.Activities.CodeActivity();
this.Enumerate = new Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity();
//
// readEnumeratedResource
//
this.ReadEnumeratedResource.Name = "ReadEnumeratedResource";
this.ReadEnumeratedResource.ExecuteCode += new System.EventHandler(this.ReadEnumeratedResource_ExecuteCode);
//
// GenerateResourceIds
//
this.GenerateResourceIds.Name = "GenerateResourceIds";
this.GenerateResourceIds.ExecuteCode += new System.EventHandler(this.GenerateResourceIds_ExecuteCode);
//
// Enumerate
//
this.Enumerate.Activities.Add(this.ReadEnumeratedResource);
activitybind1.Name = "FindResourcesActivity";
activitybind1.Path = "ActorId";
this.Enumerate.Name = "Enumerate";
activitybind2.Name = "FindResourcesActivity";
activitybind2.Path = "PageSize";
activitybind3.Name = "FindResourcesActivity";
activitybind3.Path = "Attributes";
activitybind4.Name = "FindResourcesActivity";
activitybind4.Path = "SortingAttributes";
activitybind5.Name = "FindResourcesActivity";
activitybind5.Path = "TotalResultsCount";
activitybind6.Name = "FindResourcesActivity";
activitybind6.Path = "XPathFilter";
this.Enumerate.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity.ActorIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
this.Enumerate.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity.PageSizeProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
this.Enumerate.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity.SelectionProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind3)));
this.Enumerate.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity.SortingAttributesProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind4)));
this.Enumerate.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity.TotalResultsCountProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind5)));
this.Enumerate.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity.XPathFilterProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind6)));
//
// FindResourcesActivity
//
this.Activities.Add(this.Enumerate);
this.Activities.Add(this.GenerateResourceIds);
this.Name = "FindResourcesActivity";
this.CanModifyActivities = false;
}
#endregion
private CodeActivity GenerateResourceIds;
private CodeActivity ReadEnumeratedResource;
private Microsoft.ResourceManagement.Workflow.Activities.EnumerateResourcesActivity Enumerate;
}
}

View File

@ -0,0 +1,192 @@
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;
using Microsoft.ResourceManagement.Workflow.Activities;
namespace Granfeldt.FIM.ActivityLibrary
{
[Designer(typeof(ActivityDesigner), typeof(IDesigner))]
public partial class FindResourcesActivity : SequenceActivity
{
public FindResourcesActivity()
{
EnumeratedResources = new List<ResourceType>();
InitializeComponent();
}
#region Public Fields
public static DependencyProperty EnumeratedResourcesProperty = DependencyProperty.Register("EnumeratedResources", typeof(List<ResourceType>), typeof(FindResourcesActivity));
public static DependencyProperty EnumeratedResourceIDsProperty = DependencyProperty.Register("EnumeratedResourceIDs", typeof(Guid[]), typeof(FindResourcesActivity));
public static DependencyProperty ActorIdProperty = DependencyProperty.Register("ActorId", typeof(System.Guid), typeof(FindResourcesActivity));
public static DependencyProperty PageSizeProperty = DependencyProperty.Register("PageSize", typeof(System.Int32), typeof(FindResourcesActivity));
public static DependencyProperty AttributesProperty = DependencyProperty.Register("Attributes", typeof(System.String[]), typeof(FindResourcesActivity));
public static DependencyProperty SortingAttributesProperty = DependencyProperty.Register("SortingAttributes", typeof(Microsoft.ResourceManagement.WebServices.WSEnumeration.SortingAttribute[]), typeof(FindResourcesActivity));
public static DependencyProperty TotalResultsCountProperty = DependencyProperty.Register("TotalResultsCount", typeof(System.Int32), typeof(FindResourcesActivity));
public static DependencyProperty XPathFilterProperty = DependencyProperty.Register("XPathFilter", typeof(System.String), typeof(FindResourcesActivity));
#endregion
#region Public Properties
[Description("EnumeratedResource")]
[Category("Result")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public List<ResourceType> EnumeratedResources
{
get { return (List<ResourceType>)base.GetValue(FindResourcesActivity.EnumeratedResourcesProperty); }
set { base.SetValue(FindResourcesActivity.EnumeratedResourcesProperty, value); }
}
[DescriptionAttribute("EnumeratedResourceIDs")]
[CategoryAttribute("Result")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public Guid[] EnumeratedResourceIDs
{
get
{
return ((Guid[])(base.GetValue(FindResourcesActivity.EnumeratedResourceIDsProperty)));
}
set
{
base.SetValue(FindResourcesActivity.EnumeratedResourceIDsProperty, value);
}
}
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Input")]
public Guid ActorId
{
get
{
return ((System.Guid)(base.GetValue(FindResourcesActivity.ActorIdProperty)));
}
set
{
base.SetValue(FindResourcesActivity.ActorIdProperty, value);
}
}
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Input")]
public Int32 PageSize
{
get
{
return ((int)(base.GetValue(FindResourcesActivity.PageSizeProperty)));
}
set
{
base.SetValue(FindResourcesActivity.PageSizeProperty, value);
}
}
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Input")]
public String[] Attributes
{
get
{
return ((string[])(base.GetValue(FindResourcesActivity.AttributesProperty)));
}
set
{
base.SetValue(FindResourcesActivity.AttributesProperty, value);
}
}
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Input")]
public Microsoft.ResourceManagement.WebServices.WSEnumeration.SortingAttribute[] SortingAttributes
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSEnumeration.SortingAttribute[])(base.GetValue(FindResourcesActivity.SortingAttributesProperty)));
}
set
{
base.SetValue(FindResourcesActivity.SortingAttributesProperty, value);
}
}
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Misc")]
public Int32 TotalResultsCount
{
get
{
return ((int)(base.GetValue(FindResourcesActivity.TotalResultsCountProperty)));
}
set
{
base.SetValue(FindResourcesActivity.TotalResultsCountProperty, value);
}
}
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Input")]
public String XPathFilter
{
get
{
return ((string)(base.GetValue(FindResourcesActivity.XPathFilterProperty)));
}
set
{
base.SetValue(FindResourcesActivity.XPathFilterProperty, value);
}
}
#endregion
#region Code
/// <summary>
/// This function is called by the enumerateactivity for each result returned.
/// We'll put each result into the EnumeratedResources list for later processing
/// and passing on to other activities
/// </summary>
private void ReadEnumeratedResource_ExecuteCode(object sender, EventArgs e)
{
// If the EnumeratedGuids list is not instantiated do so now
if (this.EnumeratedResources == null) this.EnumeratedResources = new List<ResourceType>();
// Instantiate the result and verify that it is not null
ResourceType result = EnumerateResourcesActivity.GetCurrentIterationItem((CodeActivity)sender) as ResourceType;
if (result != null)
{
EnumeratedResources.Add(result);
}
}
/// <summary>
/// This function populates the list of objectID's that maybe
/// passed on to other activities
/// </summary>
private void GenerateResourceIds_ExecuteCode(object sender, EventArgs e)
{
List<Guid> resourceGuids = new List<Guid>(this.EnumeratedResources.Count);
foreach (ResourceType resource in this.EnumeratedResources)
{
resourceGuids.Add(resource.ObjectID.GetGuid());
}
this.EnumeratedResourceIDs = resourceGuids.ToArray();
}
#endregion
}
}

View File

@ -0,0 +1,114 @@
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 UpdateSingleValueAttributeAsNeededActivity
{
#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();
System.Workflow.ComponentModel.ActivityBind activitybind2 = new System.Workflow.ComponentModel.ActivityBind();
this.UpdateResource = new Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity();
this.NoBranch = new System.Workflow.Activities.IfElseBranchActivity();
this.YesBranch = new System.Workflow.Activities.IfElseBranchActivity();
this.IsUpdateNeeded = new System.Workflow.Activities.IfElseActivity();
this.ReadResource = new Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity();
this.SetupReadTarget = new System.Workflow.Activities.CodeActivity();
//
// 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;
//
// NoBranch
//
this.NoBranch.Name = "NoBranch";
//
// YesBranch
//
this.YesBranch.Activities.Add(this.UpdateResource);
codecondition1.Condition += new System.EventHandler<System.Workflow.Activities.ConditionalEventArgs>(this.TargetUpdateNeeded_Condition);
this.YesBranch.Condition = codecondition1;
this.YesBranch.Name = "YesBranch";
//
// IsUpdateNeeded
//
this.IsUpdateNeeded.Activities.Add(this.YesBranch);
this.IsUpdateNeeded.Activities.Add(this.NoBranch);
this.IsUpdateNeeded.Name = "IsUpdateNeeded";
//
// ReadResource
//
this.ReadResource.ActorId = new System.Guid("00000000-0000-0000-0000-000000000000");
this.ReadResource.Description = "Reads the current target";
this.ReadResource.Name = "ReadResource";
activitybind1.Name = "UpdateSingleValueAttributeAsNeededActivity";
activitybind1.Path = "TargetResource";
activitybind2.Name = "UpdateSingleValueAttributeAsNeededActivity";
activitybind2.Path = "TargetId";
this.ReadResource.SelectionAttributes = null;
this.ReadResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ResourceProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind1)));
this.ReadResource.SetBinding(Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity.ResourceIdProperty, ((System.Workflow.ComponentModel.ActivityBind)(activitybind2)));
//
// SetupReadTarget
//
this.SetupReadTarget.Name = "SetupReadTarget";
this.SetupReadTarget.ExecuteCode += new System.EventHandler(this.SetupReadTarget_ExecuteCode);
//
// UpdateSingleValueAttributeAsNeededActivity
//
this.Activities.Add(this.SetupReadTarget);
this.Activities.Add(this.ReadResource);
this.Activities.Add(this.IsUpdateNeeded);
this.Name = "UpdateSingleValueAttributeAsNeededActivity";
this.CanModifyActivities = false;
}
#endregion
private CodeActivity SetupReadTarget;
private IfElseBranchActivity NoBranch;
private IfElseBranchActivity YesBranch;
private IfElseActivity IsUpdateNeeded;
private Microsoft.ResourceManagement.Workflow.Activities.UpdateResourceActivity UpdateResource;
private Microsoft.ResourceManagement.Workflow.Activities.ReadResourceActivity ReadResource;
}
}

View File

@ -0,0 +1,158 @@
// January 17, 2013 | Soren Granfeldt
// - initial version
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 UpdateSingleValueAttributeAsNeededActivity : SequenceActivity
{
#region Properties
public static DependencyProperty NewValueProperty = DependencyProperty.Register("NewValue", typeof(object), typeof(UpdateSingleValueAttributeAsNeededActivity));
[Description("New value to write (or null for delete)")]
[Category("NewValue Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public object NewValue
{
get
{
return ((object)(base.GetValue(UpdateSingleValueAttributeAsNeededActivity.NewValueProperty)));
}
set
{
base.SetValue(UpdateSingleValueAttributeAsNeededActivity.NewValueProperty, value);
}
}
public static DependencyProperty AttributeNameProperty = DependencyProperty.Register("AttributeName", typeof(string), typeof(UpdateSingleValueAttributeAsNeededActivity));
[Description("Name of attribute to update")]
[Category("AttributeName Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string AttributeName
{
get
{
return ((string)(base.GetValue(UpdateSingleValueAttributeAsNeededActivity.AttributeNameProperty)));
}
set
{
base.SetValue(UpdateSingleValueAttributeAsNeededActivity.AttributeNameProperty, value);
}
}
public static DependencyProperty TargetIdProperty = DependencyProperty.Register("TargetId", typeof(System.Guid), typeof(Granfeldt.FIM.ActivityLibrary.UpdateSingleValueAttributeAsNeededActivity));
[Description("The ID of the object to update")]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
public Guid TargetId
{
get
{
return ((System.Guid)(base.GetValue(Granfeldt.FIM.ActivityLibrary.UpdateSingleValueAttributeAsNeededActivity.TargetIdProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.UpdateSingleValueAttributeAsNeededActivity.TargetIdProperty, value);
}
}
public static DependencyProperty TargetResourceProperty = DependencyProperty.Register("TargetResource", typeof(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), typeof(Granfeldt.FIM.ActivityLibrary.UpdateSingleValueAttributeAsNeededActivity));
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
[BrowsableAttribute(true)]
[CategoryAttribute("Parameters")]
public ResourceType TargetResource
{
get
{
return ((Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)(base.GetValue(Granfeldt.FIM.ActivityLibrary.UpdateSingleValueAttributeAsNeededActivity.TargetResourceProperty)));
}
set
{
base.SetValue(Granfeldt.FIM.ActivityLibrary.UpdateSingleValueAttributeAsNeededActivity.TargetResourceProperty, value);
}
}
public static DependencyProperty ActorIdProperty = DependencyProperty.Register("ActorId", typeof(System.Guid), typeof(UpdateSingleValueAttributeAsNeededActivity));
[Description("ID of the actor updating the target object")]
[Category("ActorId Category")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public System.Guid ActorId
{
get
{
return ((System.Guid)(base.GetValue(UpdateSingleValueAttributeAsNeededActivity.ActorIdProperty)));
}
set
{
base.SetValue(UpdateSingleValueAttributeAsNeededActivity.ActorIdProperty, value);
}
}
#endregion
public UpdateSingleValueAttributeAsNeededActivity()
{
InitializeComponent();
}
private void TargetUpdateNeeded_Condition(object sender, ConditionalEventArgs e)
{
List<UpdateRequestParameter> updateParameters = new List<UpdateRequestParameter>();
e.Result = false;
object CurrentValue = TargetResource[this.AttributeName];
if (object.Equals(CurrentValue, this.NewValue))
{
Debugging.Log(string.Format("No need to update {0}. Value is already '{1}'", this.AttributeName, this.NewValue));
}
else
{
e.Result = true;
// if the new value is null then remove current value.
// otherwise, update attribute to new value
updateParameters.Add(new UpdateRequestParameter(this.AttributeName, this.NewValue == null ? UpdateMode.Remove : UpdateMode.Modify, this.NewValue == null ? CurrentValue : this.NewValue));
UpdateResource.ActorId = this.ActorId;
UpdateResource.ResourceId = this.TargetId;
UpdateResource.UpdateParameters = updateParameters.ToArray();
if (this.NewValue == null)
{
Debugging.Log(string.Format("Removing existing value '{0}' from {1}", CurrentValue, this.AttributeName));
}
else
{
Debugging.Log(string.Format("Updating {0} from '{1}' to '{2}'", this.AttributeName, CurrentValue == null ? "(null)" : CurrentValue, this.NewValue == null ? "(null)" : this.NewValue));
}
}
}
private void SetupReadTarget_ExecuteCode(object sender, EventArgs e)
{
ReadResource.ActorId = this.ActorId;
ReadResource.ResourceId = this.TargetId;
ReadResource.SelectionAttributes = new string[] { this.AttributeName };
}
}
}

View File

@ -54,6 +54,7 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files\Microsoft Forefront Identity Manager\2010\Service\Microsoft.ResourceManagement.dll</HintPath>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Workflow.Activities" />
<Reference Include="System.Workflow.ComponentModel" />
<Reference Include="System.Workflow.Runtime" />
@ -67,22 +68,42 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Activity.Code\Activity.Code.cs">
<Compile Include="Activity.Code\Activity.CodeRun.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Activity.Code\Activity.Code.Designer.cs">
<DependentUpon>Activity.Code.cs</DependentUpon>
<Compile Include="Activity.Code\Activity.CodeRun.Designer.cs">
<DependentUpon>Activity.CodeRun.cs</DependentUpon>
</Compile>
<Compile Include="Activity.LookupAttributeValue\Activity.LookupAttributeValue.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Activity.LookupAttributeValue\Activity.LookupAttributeValue.Designer.cs">
<DependentUpon>Activity.LookupAttributeValue.cs</DependentUpon>
</Compile>
<Compile Include="Activity.LookupAttributeValue\Activity.LookupAttributeValue.SettingsPart.cs" />
<Compile Include="Base.Classes\Base.ActivitySettings.cs" />
<Compile Include="Base.Classes\Base.HelperClasses.cs" />
<Compile Include="Activity.Code\Activity.Code.SettingsPart.cs" />
<Compile Include="Activity.Code\Activity.CodeRun.SettingsPart.cs" />
<Content Include="Activity.Code\CodeActivity.sample.regex.txt" />
<Compile Include="Base.Classes\Helper.FindResourcesActivity.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Base.Classes\Helper.FindResourcesActivity.Designer.cs">
<DependentUpon>Helper.FindResourcesActivity.cs</DependentUpon>
</Compile>
<Compile Include="Base.Classes\Helper.UpdateSingleValueAttributeAsNeededActivity.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Base.Classes\Helper.UpdateSingleValueAttributeAsNeededActivity.Designer.cs">
<DependentUpon>Helper.UpdateSingleValueAttributeAsNeededActivity.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Content Include="readme.txt" />
<None Include="Add-AssemblyToGlobalAssemblyCache.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@ -105,6 +126,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.Targets" />
<Import Project="$(MSBuildToolsPath)\Workflow.Targets" />
</Project>

View File

@ -1,7 +1,8 @@
PARAM
(
[string] $AssemblyName = "Granfeldt.FIM.ActivityLibrary.dll",
[switch] $CreateCodeActivity
[switch] $CreateCodeRunActivity,
[switch] $CreateLookupActivity
)
BEGIN
@ -18,13 +19,13 @@ PROCESS
$LoadedAssembly = [System.Reflection.Assembly]::LoadFile( (Resolve-Path $AssemblyName).Path )
$ManifestModule = $LoadedAssembly.ManifestModule -replace '\.dll$'
if ($CreateCodeActivity)
if ($CreateCodeRunActivity)
{
$Params = @{ `
DisplayName = 'Code Activity'
Description = 'Execute C# code as an activity'
ActivityName = "$ManifestModule.CodeActivity"
TypeName = "$ManifestModule.WebUIs.CodeActivitySettingsPart"
Description = 'Compile and execute C# code as an activity'
ActivityName = "$ManifestModule.CodeRunActivity"
TypeName = "$ManifestModule.WebUIs.CodeRunActivitySettingsPart"
IsActionActivity = $true
AssemblyName = $LoadedAssembly.Fullname
}
@ -32,6 +33,19 @@ PROCESS
.\New-FIMActivityInformationConfigurationObject.ps1 @Params
}
if ($CreateLookupActivity)
{
$Params = @{ `
DisplayName = 'Lookup Attribute Value'
Description = 'Using XPath query looks up value in FIM Service'
ActivityName = "$ManifestModule.LookupAttributeValueActivity"
TypeName = "$ManifestModule.WebUIs.LookupAttributeValueActivitySettingsPart"
IsActionActivity = $true
AssemblyName = $LoadedAssembly.Fullname
}
$Params
.\New-FIMActivityInformationConfigurationObject.ps1 @Params
}
}
END

View File

@ -8,7 +8,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Granfeldt.FIM.ActivityLibrary")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCompany("Goverco")]
[assembly: AssemblyProduct("Granfeldt.FIM.ActivityLibrary")]
[assembly: AssemblyCopyright("Copyright © Goverco 2013")]
[assembly: AssemblyTrademark("")]

View File

@ -1,7 +1,8 @@
PARAM
(
[string] $AssemblyName = "Granfeldt.FIM.ActivityLibrary.dll",
[switch] $CreateCodeActivity
[switch] $CreateCodeRunActivity,
[switch] $CreateLookupActivity
)
BEGIN
@ -18,13 +19,13 @@ PROCESS
$LoadedAssembly = [System.Reflection.Assembly]::LoadFile( (Resolve-Path $AssemblyName).Path )
$ManifestModule = $LoadedAssembly.ManifestModule -replace '\.dll$'
if ($CreateCodeActivity)
if ($CreateCodeRunActivity)
{
$Params = @{ `
DisplayName = 'Code Activity'
Description = 'Execute C# code as an activity'
ActivityName = "$ManifestModule.CodeActivity"
TypeName = "$ManifestModule.WebUIs.CodeActivitySettingsPart"
Description = 'Compile and execute C# code as an activity'
ActivityName = "$ManifestModule.CodeRunActivity"
TypeName = "$ManifestModule.WebUIs.CodeRunActivitySettingsPart"
IsActionActivity = $true
AssemblyName = $LoadedAssembly.Fullname
}
@ -32,6 +33,19 @@ PROCESS
.\New-FIMActivityInformationConfigurationObject.ps1 @Params
}
if ($CreateLookupActivity)
{
$Params = @{ `
DisplayName = 'Lookup Attribute Value'
Description = 'Using XPath query looks up value in FIM Service'
ActivityName = "$ManifestModule.LookupAttributeValueActivity"
TypeName = "$ManifestModule.WebUIs.LookupAttributeValueActivitySettingsPart"
IsActionActivity = $true
AssemblyName = $LoadedAssembly.Fullname
}
$Params
.\New-FIMActivityInformationConfigurationObject.ps1 @Params
}
}
END

View File

@ -0,0 +1,4 @@
If you add one of the Helper workflow to an existing workflow and you get
the error 'Cannot use custom activities - failed to load toolbox item', it may
be because you have the target assemble Granfeldt.FIM.ActivityLibrary.dll
in the GAC already. Try removing it from C:\Windows\Assembly