GenerateUniqueValue.vb

 

Imports Microsoft.ResourceManagement.WebServices.WSResourceManagement
Imports Microsoft.ResourceManagement.Workflow.Activities

Public Class GenerateUniqueValue
    Inherits SequenceActivity

    Const FIMADMIN_GUID As String = "7fb2b853-24f0-4498-9534-4e10589723c4"

    Dim GAResolvedOptions As String()
    Dim GAReturnValue As String = ""
    Dim loopCount As Integer
    Dim loopAgain As Boolean
    Dim TargetGUID As System.Guid
    Dim RequestorGUID As System.Guid

    Private Sub GetWorkflowData_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.ReadTarget_ActorId1 = New Guid(FIMADMIN_GUID)
        Dim containingWorkflow As SequentialWorkflow = Nothing
        If Not SequentialWorkflow.TryGetContainingWorkflow(Me, containingWorkflow) Then
            Throw New InvalidOperationException("Could not get parent workflow!")
        End If
        Me.ReadTarget_ResourceId1 = containingWorkflow.TargetId
        TargetGUID = containingWorkflow.TargetId
        RequestorGUID = containingWorkflow.ActorId

        Dim GAOptions As String() = {Me.GUOption1, Me.GUOption2, Me.GUOption3, Me.GUOption4}
        Dim wfDataString As String
        Dim wfDataName As String
        Dim i As Integer = 0
        For Each gaoption In GAOptions
            wfDataString = ""
            wfDataName = gaoption.Replace("[\\WorkflowData\", "").Replace("]", "")
            containingWorkflow.WorkflowDictionary.TryGetValue(wfDataName, wfDataString)
            If Not wfDataString = "" Then
                ReDim Preserve GAResolvedOptions(i)
                GAResolvedOptions(i) = wfDataString
                i = i + 1
            End If
        Next
        If GAResolvedOptions.Length = 0 Then
            Throw New WorkflowTerminatedException("Unable to resolve any options for the attribute.")
        End If
    End Sub

#Region "While Loop"
'' Declarative Rule Condition: this.loopAgain

    Private Sub InitializeWhile_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
        loopAgain = True
        loopCount = 0
    End Sub

    Private Sub InitializeEnumerateResourcesActivity_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.enumerateResourcesActivity1_ActorId1 = New Guid(FIMADMIN_GUID)
        Dim resourceType As String = Me.ReadTarget_Resource1("ObjectType")
        Me.enumerateResourcesActivity1_XPathFilter1 = "/" & resourceType & "[" & Me.GUAttribute & " = " & GAResolvedOptions(loopCount) & "]"
    End Sub

    Private Sub CheckUniqueness_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Me.enumerateResourcesActivity1_TotalResultsCount1 > 0 Then
            If loopCount < GAResolvedOptions.Length - 1 Then
                loopAgain = True
            Else
                loopAgain = False
            End If
        Else
            loopAgain = False
            GAReturnValue = GAResolvedOptions(loopCount)
        End If
        loopCount = loopCount + 1
    End Sub
#End Region

#Region "If UniqueValueFound"
'' Declarative Rule Condition: this.GAReturnValue != ""

    Private Sub InitializeUpdateResource_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.updateResourceActivity1.UpdateParameters = New UpdateRequestParameter() {New UpdateRequestParameter(Me.GUAttribute, UpdateMode.Modify, GAReturnValue)}
        Me.updateResourceActivity1_ActorId1 = RequestorGUID
        Me.updateResourceActivity1_ResourceId1 = TargetGUID
    End Sub

#End Region

#Region "If UniqueValueNotFound"
'' Declarative Rule Condition: this.GAReturnValue == ""

    Private Sub SetError_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.throwActivity1_Fault1 = New WorkflowTerminatedException("Unable to find unique value.")
    End Sub

#End Region

#Region "Workflow UI Properties"

    ''' <summary>
    '''  Identifies the target attribute
    ''' </summary>
    Public Shared GUAttributeProperty As DependencyProperty = DependencyProperty.Register("GUAttribute", GetType(System.String), GetType(GenerateUniqueValue))
    <Description("Please specify the target attribute")> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    <Browsable(True)> _
    Public Property GUAttribute() As String
        Get
            Return DirectCast(MyBase.GetValue(GenerateUniqueValue.GUAttributeProperty), [String])
        End Get
        Set(ByVal value As String)
            MyBase.SetValue(GenerateUniqueValue.GUAttributeProperty, value)
        End Set
    End Property
    ''' <summary>
    '''  Attribute value generation options
    ''' </summary>
    Public Shared GUOption1Property As DependencyProperty = DependencyProperty.Register("GUOption1", GetType(System.String), GetType(GenerateUniqueValue))
    <Description("Please specify the target attribute")> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    <Browsable(True)> _
    Public Property GUOption1() As String
        Get
            Return DirectCast(MyBase.GetValue(GenerateUniqueValue.GUOption1Property), [String])
        End Get
        Set(ByVal value As String)
            MyBase.SetValue(GenerateUniqueValue.GUOption1Property, value)
        End Set
    End Property
    Public Shared GUOption2Property As DependencyProperty = DependencyProperty.Register("GUOption2", GetType(System.String), GetType(GenerateUniqueValue))
    <Description("Please specify the target attribute")> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    <Browsable(True)> _
    Public Property GUOption2() As String
        Get
            Return DirectCast(MyBase.GetValue(GenerateUniqueValue.GUOption2Property), [String])
        End Get
        Set(ByVal value As String)
            MyBase.SetValue(GenerateUniqueValue.GUOption2Property, value)
        End Set
    End Property
    Public Shared GUOption3Property As DependencyProperty = DependencyProperty.Register("GUOption3", GetType(System.String), GetType(GenerateUniqueValue))
    <Description("Please specify the target attribute")> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    <Browsable(True)> _
    Public Property GUOption3() As String
        Get
            Return DirectCast(MyBase.GetValue(GenerateUniqueValue.GUOption3Property), [String])
        End Get
        Set(ByVal value As String)
            MyBase.SetValue(GenerateUniqueValue.GUOption3Property, value)
        End Set
    End Property
    Public Shared GUOption4Property As DependencyProperty = DependencyProperty.Register("GUOption4", GetType(System.String), GetType(GenerateUniqueValue))
    <Description("Please specify the target attribute")> _
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    <Browsable(True)> _
    Public Property GUOption4() As String
        Get
            Return DirectCast(MyBase.GetValue(GenerateUniqueValue.GUOption4Property), [String])
        End Get
        Set(ByVal value As String)
            MyBase.SetValue(GenerateUniqueValue.GUOption4Property, value)
        End Set
    End Property

#End Region

#Region "Read Target Properties"
    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Parameters")> _
                Public Property ReadTarget_Resource1() As Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.ReadTarget_Resource1Property), Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)

        End Get
        Set(ByVal value As Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.ReadTarget_Resource1Property, value)

        End Set
    End Property
    Public Shared ReadTarget_SelectionAttributes1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("ReadTarget_SelectionAttributes1", GetType(System.String()), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Parameters")> _
                Public Property ReadTarget_SelectionAttributes1() As System.String()
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.ReadTarget_SelectionAttributes1Property), String())

        End Get
        Set(ByVal value As System.String())
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.ReadTarget_SelectionAttributes1Property, value)

        End Set
    End Property
    Public Shared ReadTarget_ResourceId1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("ReadTarget_ResourceId1", GetType(System.Guid), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Parameters")> _
                Public Property ReadTarget_ResourceId1() As System.Guid
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.ReadTarget_ResourceId1Property), System.Guid)

        End Get
        Set(ByVal value As System.Guid)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.ReadTarget_ResourceId1Property, value)

        End Set
    End Property
    Public Shared ReadTarget_ActorId1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("ReadTarget_ActorId1", GetType(System.Guid), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Parameters")> _
                Public Property ReadTarget_ActorId1() As System.Guid
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.ReadTarget_ActorId1Property), System.Guid)

        End Get
        Set(ByVal value As System.Guid)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.ReadTarget_ActorId1Property, value)

        End Set
    End Property
#End Region

#Region "EnumerateResourcesActivity Properties"
    Public Shared enumerateResourcesActivity1_PageSize1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("enumerateResourcesActivity1_PageSize1", GetType(System.Int32), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Misc")> _
                Public Property enumerateResourcesActivity1_PageSize1() As System.Int32
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_PageSize1Property), Integer)

        End Get
        Set(ByVal value As System.Int32)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_PageSize1Property, value)

        End Set
    End Property
    Public Shared enumerateResourcesActivity1_SortingAttributes1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("enumerateResourcesActivity1_SortingAttributes1", GetType(Microsoft.ResourceManagement.WebServices.WSEnumeration.SortingAttribute()), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Misc")> _
                Public Property enumerateResourcesActivity1_SortingAttributes1() As Microsoft.ResourceManagement.WebServices.WSEnumeration.SortingAttribute()
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_SortingAttributes1Property), Microsoft.ResourceManagement.WebServices.WSEnumeration.SortingAttribute())

        End Get
        Set(ByVal value As Microsoft.ResourceManagement.WebServices.WSEnumeration.SortingAttribute())
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_SortingAttributes1Property, value)

        End Set
    End Property
    Public Shared enumerateResourcesActivity1_Selection1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("enumerateResourcesActivity1_Selection1", GetType(System.String()), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Misc")> _
                Public Property enumerateResourcesActivity1_Selection1() As System.String()
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_Selection1Property), String())

        End Get
        Set(ByVal value As System.String())
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_Selection1Property, value)

        End Set
    End Property
    Public Shared enumerateResourcesActivity1_TotalResultsCount1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("enumerateResourcesActivity1_TotalResultsCount1", GetType(System.Int32), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Misc")> _
                Public Property enumerateResourcesActivity1_TotalResultsCount1() As System.Int32
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_TotalResultsCount1Property), Integer)

        End Get
        Set(ByVal value As System.Int32)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_TotalResultsCount1Property, value)

        End Set
    End Property
    Public Shared enumerateResourcesActivity1_XPathFilter1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("enumerateResourcesActivity1_XPathFilter1", GetType(System.String), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Misc")> _
                Public Property enumerateResourcesActivity1_XPathFilter1() As System.String
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_XPathFilter1Property), String)

        End Get
        Set(ByVal value As System.String)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_XPathFilter1Property, value)

        End Set
    End Property
    Public Shared enumerateResourcesActivity1_ActorId1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("enumerateResourcesActivity1_ActorId1", GetType(System.Guid), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Misc")> _
                Public Property enumerateResourcesActivity1_ActorId1() As System.Guid
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_ActorId1Property), System.Guid)

        End Get
        Set(ByVal value As System.Guid)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.enumerateResourcesActivity1_ActorId1Property, value)

        End Set
    End Property
    Public Shared ReadTarget_Resource1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("ReadTarget_Resource1", GetType(Microsoft.ResourceManagement.WebServices.WSResourceManagement.ResourceType), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))
#End Region

#Region "UpdateResourceActivity Parameters"
    Public Shared updateResourceActivity1_ResourceId1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("updateResourceActivity1_ResourceId1", GetType(System.Guid), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Parameters")> _
                Public Property updateResourceActivity1_ResourceId1() As System.Guid
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.updateResourceActivity1_ResourceId1Property), System.Guid)

        End Get
        Set(ByVal value As System.Guid)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.updateResourceActivity1_ResourceId1Property, value)

        End Set
    End Property
    Public Shared updateResourceActivity1_UpdateParameters1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("updateResourceActivity1_UpdateParameters1", GetType(Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateRequestParameter()), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Parameters")> _
                Public Property updateResourceActivity1_UpdateParameters1() As Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateRequestParameter()
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.updateResourceActivity1_UpdateParameters1Property), Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateRequestParameter())

        End Get
        Set(ByVal value As Microsoft.ResourceManagement.WebServices.WSResourceManagement.UpdateRequestParameter())
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.updateResourceActivity1_UpdateParameters1Property, value)

        End Set
    End Property
    Public Shared updateResourceActivity1_ActorId1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("updateResourceActivity1_ActorId1", GetType(System.Guid), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Parameters")> _
                Public Property updateResourceActivity1_ActorId1() As System.Guid
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.updateResourceActivity1_ActorId1Property), System.Guid)

        End Get
        Set(ByVal value As System.Guid)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.updateResourceActivity1_ActorId1Property, value)

        End Set
    End Property
#End Region

#Region "Throw Parameters"
    Public Shared throwActivity1_FaultType1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("throwActivity1_FaultType1", GetType(System.Type), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Handlers")> _
                Public Property throwActivity1_FaultType1() As System.Type
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.throwActivity1_FaultType1Property), System.Type)

        End Get
        Set(ByVal value As System.Type)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.throwActivity1_FaultType1Property, value)

        End Set
    End Property
    Public Shared throwActivity1_Fault1Property As System.Workflow.ComponentModel.DependencyProperty = DependencyProperty.Register("throwActivity1_Fault1", GetType(System.Exception), GetType(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue))

    <System.ComponentModel.DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)> _
        <System.ComponentModel.BrowsableAttribute(True)> _
            <System.ComponentModel.CategoryAttribute("Handlers")> _
                Public Property throwActivity1_Fault1() As System.Exception
        Get
            Return CType(MyBase.GetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.throwActivity1_Fault1Property), System.Exception)

        End Get
        Set(ByVal value As System.Exception)
            MyBase.SetValue(FIM.CustomWorkflowActivitiesLibrary.Activities.GenerateUniqueValue.throwActivity1_Fault1Property, value)

        End Set
    End Property
#End Region

End Class