diff --git a/Granfeldt.FIM.ActivityLibrary.suo b/Granfeldt.FIM.ActivityLibrary.suo index 002a0db..938a678 100644 Binary files a/Granfeldt.FIM.ActivityLibrary.suo and b/Granfeldt.FIM.ActivityLibrary.suo differ diff --git a/Granfeldt.FIM.ActivityLibrary/..svnbridge/.svnbridge b/Granfeldt.FIM.ActivityLibrary/..svnbridge/.svnbridge index 990decf..dbf294a 100644 --- a/Granfeldt.FIM.ActivityLibrary/..svnbridge/.svnbridge +++ b/Granfeldt.FIM.ActivityLibrary/..svnbridge/.svnbridge @@ -1,3 +1,6 @@ svn:ignoreFIMDLLs obj +svn:ignoreFIMDLLs +bin +obj \ No newline at end of file diff --git a/Granfeldt.FIM.ActivityLibrary/Activity.CopyValues/Activity.CopyValues.cs b/Granfeldt.FIM.ActivityLibrary/Activity.CopyValues/Activity.CopyValues.cs index 1ea1d73..878e295 100644 --- a/Granfeldt.FIM.ActivityLibrary/Activity.CopyValues/Activity.CopyValues.cs +++ b/Granfeldt.FIM.ActivityLibrary/Activity.CopyValues/Activity.CopyValues.cs @@ -3,11 +3,13 @@ // January 22, 2013 | Soren Granfeldt // - added function to convert different types/values // before comparison. +// January 22, 2013 | Soren Granfeldt +// - rewrote update logic to allow updating more the one object // January 29, 2013 | Kristian Birk Thim -// - Extended the AttributeValue class to include more logic specific to it. -// - Created ConditionalAttributeValue. A AttributeValue class which includes conditional properties (Inherits from AttributeValue) -// - Created AttributeValueCollection which includes some of the processing logic specific to a collection of AttributeValues. -// - Re-Wrote parts of the main code to incorporate the new classes. +// - extended the AttributeValue class to include more logic specific to it. +// - created ConditionalAttributeValue. A AttributeValue class which includes conditional properties (Inherits from AttributeValue) +// - created AttributeValueCollection which includes some of the processing logic specific to a collection of AttributeValues. +// - re-wrote parts of the main code to incorporate the new classes. using System; using System.Collections; diff --git a/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.Designer.cs b/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.Designer.cs deleted file mode 100644 index 0e82819..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.Designer.cs +++ /dev/null @@ -1,131 +0,0 @@ -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 - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - [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 list_11 = new System.Collections.Generic.List(); - 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(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 - - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.SettingsPart.cs b/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.SettingsPart.cs deleted file mode 100644 index 68e27eb..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.SettingsPart.cs +++ /dev/null @@ -1,119 +0,0 @@ -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 Value"; } - } - - public override bool ValidateInputs() - { - Debugging.Log("ValidateInputs"); - return true; - } - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.cs b/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.cs deleted file mode 100644 index 043324a..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Activity.LookupAttributeValue/Activity.LookupAttributeValue.cs +++ /dev/null @@ -1,215 +0,0 @@ -// January 17, 2013 | Soren Granfeldt -// - code revised and partially rewritten before CodePlex release -// January 22, 2013 | Kristian Birk Thim -// - Added support to return results in Enumerate.TotalResultsCount where count is 1. - -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; - } - } - if (Enumerate.TotalResultsCount == 1) - { - r = Enumerate.EnumeratedResources[0]; - newValue = r[this.AttributeName]; - } - - 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 - - } - -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/AttributeValue.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/AttributeValue.cs deleted file mode 100644 index 53c270f..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/AttributeValue.cs +++ /dev/null @@ -1,186 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.ResourceManagement.WebServices.WSResourceManagement; - -namespace Granfeldt.FIM.ActivityLibrary -{ - public class AttributeValue - { - //Constructors - /// - /// Creates a new instance of the object type AttributeValue. - /// - public AttributeValue() - { - this.IsResolved = false; - } - /// - /// Creates a new instance of the object type AttributeValue, and sets source and target attribute name. - /// - /// Name of the source attribute. - /// Name of the target attribute. - 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; } - /// - /// Indicates if the SourceAttributeName have been resolved. - /// This is set when SourceAttributeValue is set. - /// - public bool IsResolved { get; private set; } - /// - /// Tells if the SourceAttributeValue should be resolved from SourceAttributeName. - /// It is decided by testing if the SourceAttributeName contains a resolveable string. - /// - public bool ShouldResolve - { - get - { - if (this.IsResolved) - { - return false; - } - else - { - if (this.SourceAttributeName != null) - return this.SourceAttributeName.Trim().Contains("[//"); - else - return false; - } - } - } - - #region Methods - /// - /// Returns this AttributeValue as an UpdateRequestParameter used for updating resources in FIM. - /// - /// ObjectID of the resource being updated. - /// Tells the method what type of update to return. - /// If isDelete is true a UpdateMode is set to: Remove. - /// - /// - 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); - } - } - /// - /// Returns this AttributeValue as an UpdateRequestParameter used for updating resources in FIM, without specifying which object to update. - /// - /// Tells the method what type of update to return. - /// If isDelete is true a UpdateMode is set to: Remove. - /// - 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); - } - - } - /// - /// Compares the source value with the supplied readValue parameter. - /// Also sets IsDelete to true or false - /// - /// A value to compare with the SourceValue. - /// - 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); - } - /// - /// 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. - /// - /// Result of compare - 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; - } - /// - /// Private method for comparing Source and Target attributes - /// - /// Taget value - /// Source value - /// Whether or not the target attribute should be updated. - 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; - } - } - /// - /// Sets the TargetAttributeValue on this AttributeValue based on the it's current TargetAttributeName. - /// - /// the ResourceType object to pull the attribute value from. - internal virtual void SetValues(ResourceType resource) - { - TargetAttributeValue = resource[this.TargetAttributeName] != null ? resource[this.TargetAttributeName] : null; - Debugging.Log(this.TargetAttributeName, this.TargetAttributeValue); - } - #endregion - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/AttributeValueCollection.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/AttributeValueCollection.cs deleted file mode 100644 index 77d07c9..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/AttributeValueCollection.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.ResourceManagement.WebServices.WSResourceManagement; - -namespace Granfeldt.FIM.ActivityLibrary -{ - public class AttributeValueCollection : ICollection - { - //Constructors - /// - /// Creates a new instance of AttributeValueCollection. - /// - public AttributeValueCollection() - { - this._attributeValues = new List(); - } - /// - /// Creates a new instance of AttributeValueCollection that takes the ObjectID of the target resource. - /// - /// ObjectID of the target resource - public AttributeValueCollection(Guid targetObjectID) - { - this.TargetObjectID = targetObjectID; - this._attributeValues = new List(); - } - - //Fields - /// - /// List of all the AttributeValue objects in the collection. - /// - private List _attributeValues; - /// - /// Target resource that needs to be updates. - /// - private ResourceType _targetResource; - //Properties - public Guid TargetObjectID { get; set; } - public ResourceType TargetResource - { - get { return _targetResource; } - set - { - _targetResource = value; - PopulateAttributeValues(); - } - } - /// - /// Gets all the AttributeValues in the collection, which contains differences between the source and the target value - /// - /// All changes in the collection to send to target. - public List Changes - { - get - { - List changes = new List(); - foreach (AttributeValue a in _attributeValues) - { - Debugging.Log(a.TargetAttributeName, a.TargetAttributeValue); - if (a.ShouldUpdate()) - { - changes.Add(a.ToUpdateRequestParameter(this.TargetObjectID, a.IsDelete)); - } - } - return changes; - } - } - - #region Methods - /// - /// Sets attribute values on all AttributeValue objects in the collection. - /// - private void PopulateAttributeValues() - { - foreach (AttributeValue val in _attributeValues) - { - val.SetValues(_targetResource); - } - } - - #region ICollection implementation - - public void Add(AttributeValue item) - { - this._attributeValues.Add(item); - } - - public void Clear() - { - this._attributeValues.Clear(); - } - - public bool Contains(AttributeValue item) - { - return this._attributeValues.Contains(item); - } - - public void CopyTo(AttributeValue[] array, int arrayIndex) - { - this._attributeValues.CopyTo(array, arrayIndex); - } - - public int Count - { - get { return this._attributeValues.Count; } - } - - public bool IsReadOnly - { - get { return false; } - } - - public bool Remove(AttributeValue item) - { - return this._attributeValues.Remove(item); - } - - public IEnumerator GetEnumerator() - { - return this._attributeValues.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } - #endregion - #endregion - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/ConditionalAttributeValue.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/ConditionalAttributeValue.cs deleted file mode 100644 index e6c0ad9..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/AttributeValue/ConditionalAttributeValue.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Microsoft.ResourceManagement.WebServices.WSResourceManagement; - -namespace Granfeldt.FIM.ActivityLibrary -{ - public class ConditionalAttributeValue : AttributeValue - { - //Constructors - public ConditionalAttributeValue(string conditionAttributeName) - { - this.ConditionAttributeName = conditionAttributeName; - } - public ConditionalAttributeValue(string sourceAttributeName, string targetAttributeName, string conditionAttributeName) - { - this.ConditionAttributeName = conditionAttributeName; - this.SourceAttributeName = sourceAttributeName; - this.TargetAttributeName = targetAttributeName; - } - public ConditionalAttributeValue(string sourceAttributeName, string targetAttributeName, string conditionAttributeName, bool updateOnConditionTrue) - { - this.ConditionAttributeName = conditionAttributeName; - this.UpdateOnTrue = updateOnConditionTrue; - this.SourceAttributeName = sourceAttributeName; - this.TargetAttributeName = targetAttributeName; - - } - - //Properties - public string ConditionAttributeName { get; set; } - public bool ConditionAttributeValue { get; private set; } - public bool UpdateOnTrue { get; set; } - - /// - /// 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. - /// - /// Result of the comparison. - public override bool ShouldUpdate() - { - if (conditionsSatisfied()) - { - return base.ShouldUpdate(); - } - else - { - Debugging.Log(String.Format("Conditions not met. Because {0} has the value: {1}.",this.ConditionAttributeName,this.ConditionAttributeValue)); - return false; - } - } - /// - /// Sets Source and Target values as well as conditional values. - /// - /// resource object of the target to be updated. - internal override void SetValues(ResourceType resource) - { - base.SetValues(resource); - this.SetConditionValue(resource); - } - /// - /// Private methods that determines if the conditions are met to allow the target to be updated. - /// - /// If conditions are met, it will return true, otherwise false. - private bool conditionsSatisfied() - { - if (UpdateOnTrue) - { - if (ConditionAttributeValue) - { - //True and True is True - return true; - } - else - { - return false; - } - } - else - { - if (!ConditionAttributeValue) - { - //False and False is true - return true; - } - else - { - return false; - } - } - } - /// - /// Sets the ConditionAttributeValue, based on ConditionAttributeName and . - /// - /// - private void SetConditionValue(ResourceType resource) - { - this.ConditionAttributeValue = resource[this.ConditionAttributeName] != null ? (bool)resource[this.ConditionAttributeName] : false; - Debugging.Log(String.Format("Condition set to: {0}", this.ConditionAttributeValue)); - } - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Base.ActivitySettings.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/Base.ActivitySettings.cs deleted file mode 100644 index 489367c..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Base.ActivitySettings.cs +++ /dev/null @@ -1,341 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -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 -{ - class BaseActivitySettingsPart : ActivitySettingsPart - { - - #region Utility Functions - - /// - /// Create a TableRow that contains a label and a textbox. - /// - protected 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; - } - - #region Lookup Action Dropdown - - protected TableRow AddLookupActionDropDownList(String labelText, String controlID, int width, String defaultValue) - { - 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); - - return row; - } - - protected string GetLookupActionDropDownList(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 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 + "'"); - } - - #endregion - - #region Actor Dropdown - - protected TableRow AddActorDropDownList(String labelText, String controlID, int width, String defaultValue) - { - 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.CssClass = base.???cssclass - ddl.Width = width; - ListItem BuiltInSynchronizationAccount = new ListItem("Built-in Synchronization Account", WellKnownGuids.BuiltInSynchronizationAccount.ToString()); - ListItem FIMServiceAccount = new ListItem("FIMServiceAccount", WellKnownGuids.FIMServiceAccount.ToString()); - ListItem Anonymous = new ListItem("Anonymous", WellKnownGuids.Anonymous.ToString()); - - ddl.Items.Add(BuiltInSynchronizationAccount); - ddl.Items.Add(FIMServiceAccount); - ddl.Items.Add(Anonymous); - ddl.SelectedValue = defaultValue; - controlCell.Controls.Add(ddl); - - row.Cells.Add(labelCell); - row.Cells.Add(controlCell); - - return row; - } - - protected string GetActorDropDownList(string dropDownListID) - { - 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 + "'"); - return g; - } - - protected void SetActorDropDownList(string dropDownListID, object Guid) - { - 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 + "'"); - } - - #endregion - - protected TableRow AddCheckbox(String labelText, String controlID, bool defaultValue) - { - 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); - - CheckBox cb = new CheckBox(); - cb.ID = controlID; - cb.Checked = defaultValue; - controlCell.Controls.Add(cb); - - row.Cells.Add(labelCell); - row.Cells.Add(controlCell); - - return row; - } - - protected bool GetCheckbox(string checkBoxID) - { - CheckBox checkBox = (CheckBox)this.FindControl(checkBoxID); - if (checkBox != null) - return checkBox.Checked; - else - return false; - } - - protected void SetCheckbox(string checkBoxID, bool isChecked) - { - CheckBox checkBox = (CheckBox)this.FindControl(checkBoxID); - if (checkBox != null) - { - checkBox.Checked = isChecked; - } - } - - protected string GetText(string textBoxID) - { - TextBox textBox = (TextBox)this.FindControl(textBoxID); - return textBox.Text ?? String.Empty; - } - - protected void SetText(string textBoxID, string text) - { - TextBox textBox = (TextBox)this.FindControl(textBoxID); - if (textBox != null) - textBox.Text = text; - else - textBox.Text = ""; - } - - protected string[] GetTextArray(string textBoxId) - { - TextBox textBox = (TextBox)this.FindControl(textBoxId); - string[] words = textBox.Text.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); - return words ?? null; - } - - protected void SetTextArray(string textBoxID, string[] text) - { - TextBox textBox = (TextBox)this.FindControl(textBoxID); - StringBuilder myBuilder = new StringBuilder(); - foreach (string s in text) - { - if (!String.IsNullOrEmpty(s)) - myBuilder.AppendLine(s); - } - string toInsert = myBuilder.ToString().TrimEnd('\r', '\n'); - textBox.Text = toInsert; - } - - //Set the text box to read mode or read/write mode - protected void SetCheckboxReadOnlyOption(string CheckBoxID, bool readOnly) - { - CheckBox checkBox = (CheckBox)this.FindControl(CheckBoxID); - checkBox.Enabled = !readOnly; - } - - //Set the check box to read mode or read/write mode - protected void SetTextBoxReadOnlyOption(string textBoxID, bool readOnly) - { - TextBox textBox = (TextBox)this.FindControl(textBoxID); - textBox.Enabled = !readOnly; - } - - protected void SetDropDownListDisabled(string dropDownListID, bool disabled) - { - DropDownList ddl = (DropDownList)this.FindControl(dropDownListID); - if (ddl != null) - { - ddl.Enabled = !disabled; - } - else - Debugging.Log("Cannot find control with ID '" + dropDownListID + "'"); - } - - #endregion - - /// - /// 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. - /// - public override Activity GenerateActivityOnWorkflow(SequentialWorkflow workflow) - { - throw new NotImplementedException(); - } - - /// - /// Called by FIM when the UI for the activity must be reloaded. - /// It passes us an instance of our workflow activity so that we can - /// extract the values of the properties to display in the UI. - /// - public override void LoadActivitySettings(Activity activity) - { - throw new NotImplementedException(); - } - - /// - /// Saves the activity settings. - /// - public override ActivitySettingsPartData PersistSettings() - { - throw new NotImplementedException(); - } - - /// - /// Restores the activity settings in the UI - /// - public override void RestoreSettings(ActivitySettingsPartData data) - { - throw new NotImplementedException(); - } - - /// - /// Switches the activity between read only and read/write mode - /// - public override void SwitchMode(ActivitySettingsPartMode mode) - { - throw new NotImplementedException(); - } - - /// - /// Returns the activity name. - /// - public override string Title - { - get { throw new NotImplementedException(); } - } - - /// - /// 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. - /// - public override bool ValidateInputs() - { - throw new NotImplementedException(); - } - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Base.HelperClasses.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/Base.HelperClasses.cs deleted file mode 100644 index c14e487..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Base.HelperClasses.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Diagnostics; -using System.Text.RegularExpressions; -using System.Reflection; -using System.Threading; -using System.Runtime.InteropServices; -using Microsoft.Win32; - -namespace Granfeldt.FIM.ActivityLibrary -{ - - public class WellKnownGuids - { - public static Guid BuiltInSynchronizationAccount = new Guid("fb89aefa-5ea1-47f1-8890-abe7797d6497"); - public static Guid FIMServiceAccount = new Guid("e05d1f1b-3d5e-4014-baa6-94dee7d68c89"); - public static Guid Anonymous = new Guid("b0b36673-d43b-4cfa-a7a2-aff14fd90522"); - } - - public static class Debugging - { - private static string DebugLogFilename = null; - private static Mutex loggingMutex = new Mutex(); - - static Debugging() - { - try - { - DebugLogFilename = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Granfeldt\FIM\Workflows", false).GetValue("DebugLogFilename", null).ToString(); - DebugLogFilename = string.Format(DebugLogFilename, DateTime.Now); - } - catch - { - // we get here if key og hive doesn't exist - } - } - - public static void Log(string s) - { - string message = string.Format("{0}: {1}", DateTime.Now, string.IsNullOrEmpty(s) ? "(null)" : s); - loggingMutex.WaitOne(); - if (!string.IsNullOrEmpty(DebugLogFilename)) - { - using (StreamWriter f = new StreamWriter(DebugLogFilename, true)) - { - f.WriteLine(message); - } - } - loggingMutex.ReleaseMutex(); - System.Diagnostics.Trace.WriteLine(string.Format("{0}: {1} - {2}", DateTime.Now, s, TraceRoutine(""))); - } - - public static void Log(string name, object value) - { - Log(string.Format("{0}: {1}", name, value != null ? value.ToString() : "(null)")); - } - - public static void Log(Exception ex) - { - Log(string.Format("Error: {0}", ex.Message)); - throw ex; - } - - public static string TraceRoutine(string action) - { - StackTrace CallStack = new StackTrace(); - int i = 0; - string StrOut = null; - for (i = CallStack.FrameCount - 1; i >= 1; i += -1) - { - if (StrOut != null) - { - StrOut += "->"; - } - StrOut += CallStack.GetFrame(i).GetMethod().Name; - } - CallStack = null; - return string.Format("{0}: {1}", action, StrOut); - } - - } - - public static class FIMAttributeUtilities - { - - /// - /// Returns a formatted value ready for committing to create/update resource built-in activity - /// - /// - /// - public static object FormatValue(object value) - { - if (value == null) - return null; - - if (value.GetType() == typeof(bool)) - return value; - - // if the source value is a date, we need to format the date for the update to take the value - DateTime outputDate; - if (DateTime.TryParse(value.ToString(), out outputDate)) - { - value = outputDate.ToString("yyyy-MM-ddTHH:mm:ss.000"); - return value; - } - - // if it's a reference value, we need to remove leading urn:uuid text before later comparison - value = Regex.Replace(value.ToString(), "^urn:uuid:", "", RegexOptions.IgnoreCase); - return value; - } - - /// - /// Returns true if the two values are different (FIM evaluation) - /// - /// - /// - /// - public static bool ValuesAreDifferent(object sourceValue, object targetValue) - { - if (targetValue == null || sourceValue == null) - { - if (targetValue != null || sourceValue != null) - { - return true; - } - else - { - return false; - } - } - else - { - if (!targetValue.ToString().Equals(sourceValue.ToString(), StringComparison.OrdinalIgnoreCase)) - { - return true; - } - else - { - return false; - } - } - } - } - - public class StringUtilities - { - /// - /// Parses and splits the expression passed - /// - /// Expression to parse, i.e. [//Target/DisplayName] or [//WorkflowData/Password] - /// Will hold the destination object type after parsing - /// Will hold the destination attribute after parsing - /// - public static void ExtractWorkflowExpression(string Expression, out string Destination, out string DestinationAttribute) - { - Regex regex = new Regex(@"^\[//(?\w+)/+?(?\w*[^]])", RegexOptions.IgnoreCase); - Destination = regex.Match(Expression).Result("${destination}"); - DestinationAttribute = regex.Match(Expression).Result("${destinationattribute}"); - } - - } - -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.FindResourcesActivity.Designer.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.FindResourcesActivity.Designer.cs deleted file mode 100644 index 90147dd..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.FindResourcesActivity.Designer.cs +++ /dev/null @@ -1,87 +0,0 @@ -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 - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - [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; - - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.FindResourcesActivity.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.FindResourcesActivity.cs deleted file mode 100644 index 7857d8d..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.FindResourcesActivity.cs +++ /dev/null @@ -1,192 +0,0 @@ -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(); - InitializeComponent(); - } - - #region Public Fields - - public static DependencyProperty EnumeratedResourcesProperty = DependencyProperty.Register("EnumeratedResources", typeof(List), 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 EnumeratedResources - { - get { return (List)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 - - /// - /// 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 - /// - 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(); - - // Instantiate the result and verify that it is not null - ResourceType result = EnumerateResourcesActivity.GetCurrentIterationItem((CodeActivity)sender) as ResourceType; - if (result != null) - { - EnumeratedResources.Add(result); - } - } - - /// - /// This function populates the list of objectID's that maybe - /// passed on to other activities - /// - private void GenerateResourceIds_ExecuteCode(object sender, EventArgs e) - { - List resourceGuids = new List(this.EnumeratedResources.Count); - foreach (ResourceType resource in this.EnumeratedResources) - { - resourceGuids.Add(resource.ObjectID.GetGuid()); - } - this.EnumeratedResourceIDs = resourceGuids.ToArray(); - } - - #endregion - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.UpdateSingleValueAttributeAsNeededActivity.Designer.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.UpdateSingleValueAttributeAsNeededActivity.Designer.cs deleted file mode 100644 index 1eb0963..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.UpdateSingleValueAttributeAsNeededActivity.Designer.cs +++ /dev/null @@ -1,114 +0,0 @@ -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 - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - [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(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; - - - - - - - - - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.UpdateSingleValueAttributeAsNeededActivity.cs b/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.UpdateSingleValueAttributeAsNeededActivity.cs deleted file mode 100644 index a3bb7ed..0000000 --- a/Granfeldt.FIM.ActivityLibrary/Base.Classes/Helper.UpdateSingleValueAttributeAsNeededActivity.cs +++ /dev/null @@ -1,166 +0,0 @@ -// January 17, 2013 | Soren Granfeldt -// - initial version -// January 22, 2013 | Soren Granfeldt -// - added additional code to handle comparison of date, booleans and reference types - -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; -using System.Text.RegularExpressions; - -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 updateParameters = new List(); - - e.Result = false; - object CurrentValue = TargetResource[this.AttributeName]; - - object convertedSourceValue = FIMAttributeUtilities.FormatValue(CurrentValue); - object convertedNewValue = FIMAttributeUtilities.FormatValue(this.NewValue); - - if (FIMAttributeUtilities.ValuesAreDifferent(convertedSourceValue, convertedNewValue)) - { - 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 : convertedNewValue)); - - 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)); - } - } - else - { - Debugging.Log(string.Format("No need to update {0}. Value is already '{1}'", this.AttributeName, convertedNewValue)); - } - - } - - private void SetupReadTarget_ExecuteCode(object sender, EventArgs e) - { - ReadResource.ActorId = this.ActorId; - ReadResource.ResourceId = this.TargetId; - ReadResource.SelectionAttributes = new string[] { this.AttributeName }; - } - - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/Granfeldt.FIM.ActivityLibrary.csproj b/Granfeldt.FIM.ActivityLibrary/Granfeldt.FIM.ActivityLibrary.csproj index effb731..911b566 100644 --- a/Granfeldt.FIM.ActivityLibrary/Granfeldt.FIM.ActivityLibrary.csproj +++ b/Granfeldt.FIM.ActivityLibrary/Granfeldt.FIM.ActivityLibrary.csproj @@ -95,29 +95,29 @@ Activity.DeleteObject.cs - + Component - - Activity.LookupAttributeValue.cs + + Activity.LookupValue.cs - - - - - - + + + + + + - + Component - + Helper.FindResourcesActivity.cs - + Component - + Helper.UpdateSingleValueAttributeAsNeededActivity.cs diff --git a/Granfeldt.FIM.ActivityLibrary/Install-Workflows.ps1 b/Granfeldt.FIM.ActivityLibrary/Install-Workflows.ps1 index a1c5bcb..5eecca2 100644 --- a/Granfeldt.FIM.ActivityLibrary/Install-Workflows.ps1 +++ b/Granfeldt.FIM.ActivityLibrary/Install-Workflows.ps1 @@ -1,4 +1,7 @@ -PARAM +# January 30, 2013 | Soren Granfeldt +# - changed LookupAttributeValue to LookupValueActivity + +PARAM ( [string] $AssemblyName = "Granfeldt.FIM.ActivityLibrary.dll", [switch] $CreateCodeRunActivity, @@ -41,8 +44,8 @@ PROCESS $Params = @{ ` DisplayName = 'Lookup Attribute Value' Description = 'Using XPath query looks up value in FIM Service' - ActivityName = "$ManifestModule.LookupAttributeValueActivity" - TypeName = "$ManifestModule.WebUIs.LookupAttributeValueActivitySettingsPart" + ActivityName = "$ManifestModule.LookupValueActivity" + TypeName = "$ManifestModule.WebUIs.LookupValueActivitySettingsPart" IsActionActivity = $true AssemblyName = $LoadedAssembly.Fullname } diff --git a/Granfeldt.FIM.ActivityLibrary/Properties/AssemblyInfo.cs b/Granfeldt.FIM.ActivityLibrary/Properties/AssemblyInfo.cs index 7f7c823..aec7822 100644 --- a/Granfeldt.FIM.ActivityLibrary/Properties/AssemblyInfo.cs +++ b/Granfeldt.FIM.ActivityLibrary/Properties/AssemblyInfo.cs @@ -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.4.0.0")] +[assembly: AssemblyFileVersionAttribute("1.5.0.0")] diff --git a/Granfeldt.FIM.ActivityLibrary/bin/..svnbridge/.svnbridge b/Granfeldt.FIM.ActivityLibrary/bin/..svnbridge/.svnbridge deleted file mode 100644 index 8385865..0000000 --- a/Granfeldt.FIM.ActivityLibrary/bin/..svnbridge/.svnbridge +++ /dev/null @@ -1,2 +0,0 @@ -svn:ignoreDebug - \ No newline at end of file diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/..svnbridge/Granfeldt.FIM.ActivityLibrary.dll b/Granfeldt.FIM.ActivityLibrary/bin/Release/..svnbridge/Granfeldt.FIM.ActivityLibrary.dll deleted file mode 100644 index 0814930..0000000 --- a/Granfeldt.FIM.ActivityLibrary/bin/Release/..svnbridge/Granfeldt.FIM.ActivityLibrary.dll +++ /dev/null @@ -1 +0,0 @@ -svn:mime-typeapplication/octet-stream \ No newline at end of file diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/..svnbridge/Microsoft.IdentityManagement.ExternalSettingsManager.dll b/Granfeldt.FIM.ActivityLibrary/bin/Release/..svnbridge/Microsoft.IdentityManagement.ExternalSettingsManager.dll deleted file mode 100644 index 0814930..0000000 --- a/Granfeldt.FIM.ActivityLibrary/bin/Release/..svnbridge/Microsoft.IdentityManagement.ExternalSettingsManager.dll +++ /dev/null @@ -1 +0,0 @@ -svn:mime-typeapplication/octet-stream \ No newline at end of file diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/Add-AssemblyToGlobalAssemblyCache.ps1 b/Granfeldt.FIM.ActivityLibrary/bin/Release/Add-AssemblyToGlobalAssemblyCache.ps1 deleted file mode 100644 index f3f5272..0000000 --- a/Granfeldt.FIM.ActivityLibrary/bin/Release/Add-AssemblyToGlobalAssemblyCache.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -<# -.SYNOPSIS - Installing Assemblies to Global Assembly Cache (GAC) -.DESCRIPTION - This script is an alternative to the GACUTIL available in - the .NET Framework SDK. It will put the specified assembly - in the GAC. -.EXAMPLE - .\Add-AssemblyToGlobalAssemblyCache.ps1 -AssemblyName C:\Temp\MyWorkflow.dll - - This command will install the file MyWorkflow.dll from the C:\Temp directory in the GAC. -.EXAMPLE - Dir C:\MyWorkflowAssemblies | % {$_.Fullname} | .\Add-AssemblyToGlobalAssemblyCache.ps1 - - You can also pass the assembly filenames through the pipeline making it easy - to install several assemblies in one run. The command abobe will install - all assemblies from the directory C:\MyWorkflowAssemblies, run this command - -.PARAMETER AssemblyName - Full path of the assembly file -.NOTES - April 18, 2012 | Soren Granfeldt (soren@granfeldt.dk) - - initial version -.LINK - http://blog.goverco.com -#> - -[CmdletBinding()] -PARAM -( - [Parameter(Mandatory=$true, ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)] - [ValidateNotNullOrEmpty()] - [string] $AssemblyName = "", - - [switch]$PassThru -) -BEGIN -{ - $me = $MyInvocation.MyCommand -Replace '\.ps1$', '' - Write-Debug "BEGIN: $Me" - if ( $null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq "System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" }) ) { - [System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null - } - $PublishObject = New-Object System.EnterpriseServices.Internal.Publish -} - -PROCESS { - Write-Debug "PROCESS: $me" - - foreach ($Assembly in $AssemblyName) - { - if ( -not (Test-Path $Assembly -type Leaf) ) - { - throw "The assembly '$Assembly' does not exist." - } - - $LoadedAssembly = [System.Reflection.Assembly]::LoadFile($Assembly) - - if ($LoadedAssembly.GetName().GetPublicKey().Length -eq 0) - { - throw "The assembly '$Assembly' must be strongly signed." - } - - Write-Verbose "Installing: $Assembly" - $PublishObject.GacInstall($Assembly) - - if ($PassThru) { $_ } - } -} - -END -{ - Write-Debug "END: $me" -} diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/FIM2010-Module.psm1 b/Granfeldt.FIM.ActivityLibrary/bin/Release/FIM2010-Module.psm1 deleted file mode 100644 index 625f29b..0000000 --- a/Granfeldt.FIM.ActivityLibrary/bin/Release/FIM2010-Module.psm1 +++ /dev/null @@ -1,73 +0,0 @@ -# April 17, 2012 | Soren Granfeldt (soren@granfeldt.dk) -# - initial version - -#---------------------------------------------------------------------------------------------------------- -function Get-FIMResource -{ - PARAM($Filter, $Uri = $DefaultUri) - END - { - $resources = Export-FIMConfig -CustomConfig $Filter -Uri $Uri - $resources - } -} -#---------------------------------------------------------------------------------------------------------- -function Get-FIMResourceObjectID -{ - PARAM($Filter, $Uri, $FilterObjectType) - END - { - $resources = Export-FIMConfig -CustomConfig $Filter -Uri $Uri - if ($FilterObjectType) - { - $resources = $resources | ? { $_.ResourceManagementObject.ObjectType -imatch $FilterObjectType} - } - [Microsoft.ResourceManagement.Automation.ObjectModel.ExportObject] $ObjectID = $resources | Select -First 1 - $ObjectID.ResourceManagementObject.ObjectIdentifier - } -} - -#---------------------------------------------------------------------------------------------------------- - Function Set-FIMAttribute - { - Param($object, $attributeName, $attributeValue) - End - { - $importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange - $importChange.Operation = 1 - $importChange.AttributeName = $attributeName - $importChange.AttributeValue = $attributeValue - $importChange.FullyResolved = 1 - $importChange.Locale = "Invariant" - If ($object.Changes -eq $null) {$object.Changes = (,$importChange)} - Else {$object.Changes += $importChange} - } -} -#---------------------------------------------------------------------------------------------------------- - Function New-FIMImportObject - { - Param($objectType) - End - { - $newObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject - $newObject.ObjectType = $objectType - $newObject.SourceObjectIdentifier = [System.Guid]::NewGuid().ToString() - $newObject - } - } -#---------------------------------------------------------------------------------------------------------- -Function Add-FIMMultiValue -{ - Param($object, $attributeName, $attributeValue) - End - { - $importChange = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportChange - $importChange.Operation = 0 - $importChange.AttributeName = $attributeName - $importChange.AttributeValue = $attributeValue - $importChange.FullyResolved = 1 - $importChange.Locale = "Invariant" - If ($object.Changes -eq $null) {$object.Changes = (,$importChange)} - Else {$object.Changes += $importChange} - } -} diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/Granfeldt.FIM.ActivityLibrary.dll b/Granfeldt.FIM.ActivityLibrary/bin/Release/Granfeldt.FIM.ActivityLibrary.dll deleted file mode 100644 index c7baae3..0000000 Binary files a/Granfeldt.FIM.ActivityLibrary/bin/Release/Granfeldt.FIM.ActivityLibrary.dll and /dev/null differ diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/Install-Workflows.ps1 b/Granfeldt.FIM.ActivityLibrary/bin/Release/Install-Workflows.ps1 deleted file mode 100644 index a1c5bcb..0000000 --- a/Granfeldt.FIM.ActivityLibrary/bin/Release/Install-Workflows.ps1 +++ /dev/null @@ -1,99 +0,0 @@ -PARAM -( - [string] $AssemblyName = "Granfeldt.FIM.ActivityLibrary.dll", - [switch] $CreateCodeRunActivity, - [switch] $CreateLookupValueActivity, - [switch] $CreateCopyValuesActivity, - [switch] $CreateCreateObjectActivity, - [switch] $CreateDeleteObjectActivity -) - -BEGIN -{ - if ( $null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq "System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" }) ) { - [System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null - } -} - -PROCESS -{ - (Join-Path $PWD $AssemblyName) | .\Add-AssemblyToGlobalAssemblyCache.ps1 - - $LoadedAssembly = [System.Reflection.Assembly]::LoadFile( (Resolve-Path $AssemblyName).Path ) - $ManifestModule = $LoadedAssembly.ManifestModule -replace '\.dll$' - - if ($CreateCodeRunActivity) - { - $Params = @{ ` - DisplayName = 'Code Activity' - Description = 'Compile and execute C# code as an activity' - ActivityName = "$ManifestModule.CodeRunActivity" - TypeName = "$ManifestModule.WebUIs.CodeRunActivitySettingsPart" - IsActionActivity = $true - AssemblyName = $LoadedAssembly.Fullname - } - $Params - .\New-FIMActivityInformationConfigurationObject.ps1 @Params - } - - if ($CreateLookupValueActivity) - { - $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 - } - - if ($CreateCopyValuesActivity) - { - $Params = @{ ` - DisplayName = 'Copy Values' - Description = 'Copies values to target or enumerated object' - ActivityName = "$ManifestModule.CopyValuesActivity" - TypeName = "$ManifestModule.WebUIs.CopyValuesActivitySettingsPart" - IsActionActivity = $true - AssemblyName = $LoadedAssembly.Fullname - } - $Params - .\New-FIMActivityInformationConfigurationObject.ps1 @Params - } - - if ($CreateCreateObjectActivity) - { - $Params = @{ ` - DisplayName = 'Create Object' - Description = 'Creates new object with initial values' - ActivityName = "$ManifestModule.CreateObjectActivity" - TypeName = "$ManifestModule.WebUIs.CreateObjectActivitySettingsPart" - IsActionActivity = $true - AssemblyName = $LoadedAssembly.Fullname - } - $Params - .\New-FIMActivityInformationConfigurationObject.ps1 @Params - } - - if ($CreateDeleteObjectActivity) - { - $Params = @{ ` - DisplayName = 'Delete Object' - Description = 'Deletes an object' - ActivityName = "$ManifestModule.DeleteObjectActivity" - TypeName = "$ManifestModule.WebUIs.DeleteObjectActivitySettingsPart" - IsActionActivity = $true - AssemblyName = $LoadedAssembly.Fullname - } - $Params - .\New-FIMActivityInformationConfigurationObject.ps1 @Params - } - -} - -END -{ -} \ No newline at end of file diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/Microsoft.IdentityManagement.ExternalSettingsManager.dll b/Granfeldt.FIM.ActivityLibrary/bin/Release/Microsoft.IdentityManagement.ExternalSettingsManager.dll deleted file mode 100644 index e00a7eb..0000000 Binary files a/Granfeldt.FIM.ActivityLibrary/bin/Release/Microsoft.IdentityManagement.ExternalSettingsManager.dll and /dev/null differ diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/New-FIMActivityInformationConfigurationObject.ps1 b/Granfeldt.FIM.ActivityLibrary/bin/Release/New-FIMActivityInformationConfigurationObject.ps1 deleted file mode 100644 index 02292e4..0000000 --- a/Granfeldt.FIM.ActivityLibrary/bin/Release/New-FIMActivityInformationConfigurationObject.ps1 +++ /dev/null @@ -1,104 +0,0 @@ -<# -.SYNOPSIS - Creates Activity Information Configuration (AIC) in FIM 2010 -.DESCRIPTION - TBD. -.PARAMETER Uri - The URI where the FIM 2010 Service can be reached. Default credentials are used for - access, so the user logged in must have permission to access the FIM Service Schema -.PARAMETER DisplayName - The display name of the AIC as it will appear in the FIM Portal -.PARAMETER Description - The description of the AIC -.PARAMETER ActivityName - TBD -.PARAMETER AssemblyName - TBD -.PARAMETER TypeName - TBD -.PARAMETER IsActionActivity - TBD -.PARAMETER IsAuthenticationActivity - TBD -.PARAMETER IsAuthorizationActivity - TBD -.PARAMETER IsConfigurationType - TBD -.NOTES - April 18, 2012 | Soren Granfeldt (soren@granfeldt.dk) - - initial version -.LINK - http://blog.goverco.com -#> - -[CmdletBinding()] -PARAM -( - [string] $Uri = "http://localhost:5725", - - [Parameter(Mandatory=$true)] - [ValidateNotNullOrEmpty()] - [string] $DisplayName = "", - - [string] $Description = "", - - [Parameter(Mandatory=$true)] - [ValidateNotNullOrEmpty()] - [string] $ActivityName = "", - - [Parameter(Mandatory=$true)] - [ValidateNotNullOrEmpty()] - [string] $AssemblyName = "", - - [Parameter(Mandatory=$true)] - [ValidateNotNullOrEmpty()] - [string] $TypeName = "", - - [bool] $IsActionActivity = $false, - [bool] $IsAuthenticationActivity = $false, - [bool] $IsAuthorizationActivity = $false, - [bool] $IsConfigurationType = $true -) - -BEGIN -{ - $me = $MyInvocation.MyCommand -replace '\.ps1$', '' - Write-Debug "BEGIN: $Me" - Import-Module (Join-Path $PWD "FIM2010-Module.psm1") -Force - If(@(Get-PSSnapin | Where-Object {$_.Name -eq "FIMAutomation"} ).Count -eq 0) {Add-PSSnapin FIMAutomation} -} - -PROCESS -{ - Write-Debug "PROCESS: $me" - $ExistObject = Export-FIMConfig -Uri $Uri –OnlyBaseResources -CustomConfig "/ActivityInformationConfiguration[ActivityName='$DisplayName']" - $NewObject = New-FIMImportObject -objectType "ActivityInformationConfiguration" - If(!$ExistObject) { - Set-FIMAttribute -object $NewObject -attributeName "DisplayName" -attributeValue $DisplayName - Set-FIMAttribute -object $NewObject -attributeName "Description" -attributeValue $Description - Set-FIMAttribute -object $NewObject -attributeName "ActivityName" -attributeValue $ActivityName - Set-FIMAttribute -object $NewObject -attributeName "AssemblyName" -attributeValue $AssemblyName - Set-FIMAttribute -object $NewObject -attributeName "TypeName" -attributeValue $TypeName - Set-FIMAttribute -object $NewObject -attributeName "IsActionActivity" -attributeValue $IsActionActivity - Set-FIMAttribute -object $NewObject -attributeName "IsAuthenticationActivity" -attributeValue $IsAuthenticationActivity - Set-FIMAttribute -object $NewObject -attributeName "IsAuthorizationActivity" -attributeValue $IsAuthorizationActivity - Set-FIMAttribute -object $NewObject -attributeName "IsConfigurationType" -attributeValue $IsConfigurationType - - $NewObject | Import-FIMConfig -uri $Uri - Write-Debug "$($NewObject.ObjectType.ToString()) '$DisplayName' created successfully" - - $CreatedObject = Export-FIMConfig -Uri $Uri –OnlyBaseResources -CustomConfig "/ActivityInformationConfiguration[ActivityName='$ActivityName']" - $CreatedObject - } - else - { - Write-Warning "$($NewObject.ObjectType) '$DisplayName' already exists" - $ExistObject - } -} - -END -{ - Write-Debug "END: $me" -} - diff --git a/Granfeldt.FIM.ActivityLibrary/bin/Release/Reinstall.ps1 b/Granfeldt.FIM.ActivityLibrary/bin/Release/Reinstall.ps1 deleted file mode 100644 index cc250d3..0000000 --- a/Granfeldt.FIM.ActivityLibrary/bin/Release/Reinstall.ps1 +++ /dev/null @@ -1,23 +0,0 @@ -param -( - [switch] $IISReset - -) - -function Get-WebpageWithAuthN([string]$Url, [System.Net.NetworkCredential] $cred=$null){ - Write-Verbose "Warming up $url" - $wc = New-Object Net.WebClient - $wc.Credentials = $cred - $html = $wc.DownloadString($url) -} - -if (Test-Path "C:\Temp\_FIM-WF-*.log") { Del "C:\Temp\_FIM-WF-*.log" } -(Join-Path $PWD Granfeldt.FIM.ActivityLibrary.dll) | .\Add-AssemblyToGlobalAssemblyCache.ps1 -Get-Service FIMService | Restart-Service -Verbose -if ($IISReset) { - IISRESET - - $website = "http://localhost/IdentityManagement" - $credentials = [System.Net.CredentialCache]::DefaultCredentials; - get-webpageWithAuthN -url $website -cred $credentials -}