Workflow With Asp.net Sample

i need samples for reject and approval using asp.net:

such as page Default.aspx get the user ability to request vacation and Manager.aspx approval or reject the vacation.

can any one help me please.

thanks.

[251 byte] By [Omar_Jordan] at [2007-12-28]
# 1

Hi Omar,

check the links on this post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=981174&SiteID=1

Vignesh

VigneshKannappan-MSFT at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2

thanks mr.Vignesh Kannappan, but i dont need the same examples

my problem that when hosting the workflow from one page, in the middle of my workflow I need to get manager approval but when open the Manager.aspx page and fire the event will not get the manager approval.

Oka, will discuss it in more now:

In my project I have three project with one solution

The first one: WebSiteHost that contains Default.aspx page that gets the user ability to host the workflow, and the Manager.aspx page.

The Global.asax

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

Dim workflowRuntime As New System.Workflow.Runtime.WorkflowRuntime

Dim manualService As New System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService

workflowRuntime.AddService(manualService)

Dim dataService As System.Workflow.Activities.ExternalDataExchangeService = New System.Workflow.Activities.ExternalDataExchangeService()

workflowRuntime.AddService(dataService)

Dim Service As ServiceLibrary.ManagerServiceImpl = New ServiceLibrary.ManagerServiceImpl()

dataService.AddService(Service)

workflowRuntime.StartRuntime()

Application("WorkflowRuntime") = workflowRuntime

End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)

Dim workflowRuntime As System.Workflow.Runtime.WorkflowRuntime = CType(Application("WorkflowRuntime"), System.Workflow.Runtime.WorkflowRuntime)

workflowRuntime.StopRuntime()

End Sub

The second: Service library that contains

Imports System

Imports System.Workflow.Activities

Imports System.Workflow.ComponentModel

Imports System.Collections.Generic

<Serializable()> _

Public Class ManagerEventArgs

Inherits ExternalDataEventArgs

Private _Id_no As String

Private _Card_id As String

Private _F_Name As String

Private _M_Name As String

Private _L_Name As String

Private _Area_Size As String

Private _Area_Place As String

Public Sub New(ByVal instanceid As Guid, ByVal Id_No As String, _

ByVal Card_Id As String, ByVal F_Name As String, ByVal M_Name As String, _

ByVal L_Name As String, ByVal Area_Size As String, ByVal Area_Place As String)

MyBase.New(instanceid)

Me._Id_no = Id_No

Me._Card_id = Card_Id

Me._F_Name = F_Name

Me._M_Name = M_Name

Me._L_Name = L_Name

Me._Area_Size = Area_Size

Me._Area_Place = Area_Place

End Sub

Public Property ID_NO() As String

Get

Return Me._Id_no

End Get

Set(ByVal value As String)

Me._Id_no = value

End Set

End Property

Public Property CARD_ID() As String

Get

Return (Me._Card_id)

End Get

Set(ByVal value As String)

Me._Card_id = value

End Set

End Property

Public Property FIRST_NAME() As String

Get

Return Me._F_Name

End Get

Set(ByVal value As String)

Me._F_Name = value

End Set

End Property

Public Property MIDDLE_NAME() As String

Get

Return Me._M_Name

End Get

Set(ByVal value As String)

Me._M_Name = value

End Set

End Property

Public Property LAST_NAME() As String

Get

Return Me._L_Name

End Get

Set(ByVal value As String)

Me._L_Name = value

End Set

End Property

Public Property AREA_SIZE() As String

Get

Return Me._Area_Size

End Get

Set(ByVal value As String)

Me._Area_Size = value

End Set

End Property

Public Property AREA_PLACE() As String

Get

Return Me._Area_Place

End Get

Set(ByVal value As String)

Me._Area_Place = value

End Set

End Property

End Class

<ExternalDataExchange()> _

Public Interface IManagerService

Event ManagerApproval As EventHandler(Of ManagerEventArgs)

Event ManagerReject As EventHandler(Of ManagerEventArgs)

Sub RequestManagerApproval(ByVal id_no As String, ByVal card_id As String, ByVal f_name As String, ByVal m_name As String, ByVal l_name As String, ByVal area_size As String, ByVal area_place As String)

End Interface

And the

Public Class ManagerServiceImpl

Implements IManagerService

Public instanceid As Workflow.Runtime.WorkflowInstance

Private _id_no As String

Private _card_id As String

Private _f_name As String

Private _m_name As String

Private _l_name As String

Private _area_size As String

Private _area_place As String

Public Sub ShowDialog(ByVal _ManagerEventArgs As ManagerEventArgs)

Dim result As DialogResult

Dim id_no As String = _ManagerEventArgs.ID_NO

Dim _card_id As String = _ManagerEventArgs.CARD_ID

Dim _f_name As String = _ManagerEventArgs.FIRST_NAME

Dim _m_name As String = _ManagerEventArgs.MIDDLE_NAME

Dim _l_name As String = _ManagerEventArgs.LAST_NAME

Dim _area_size As String = _ManagerEventArgs.AREA_SIZE

Dim _area_place As String = _ManagerEventArgs.AREA_PLACE

result = MessageBox.Show(String.Format("Approve, {0}?", id_no), String.Format("{0} ", id_no), MessageBoxButtons.YesNo)

If result = DialogResult.Yes Then

RaiseEvent ManagerApproval(Nothing, _ManagerEventArgs)

Else

RaiseEvent ManagerReject(Nothing, _ManagerEventArgs)

End If

End Sub

Public Event ManagerApproval(ByVal sender As Object, ByVal e As ManagerEventArgs) Implements IManagerService.ManagerApproval

Public Event ManagerReject(ByVal sender As Object, ByVal e As ManagerEventArgs) Implements IManagerService.ManagerReject

Public Sub RequestManagerApproval(ByVal id_no As String, ByVal card_id As String, ByVal f_name As String, ByVal m_name As String, ByVal l_name As String, ByVal area_size As String, ByVal area_place As String) Implements IManagerService.RequestManagerApproval

MessageBox.Show("The Manager Requested")

Me._id_no = id_no

Me._card_id = card_id

Me._f_name = f_name

Me._m_name = m_name

Me._l_name = l_name

Me._area_size = area_size

Me._area_place = area_place

ShowgDialog(New ManagerEventArgs(WorkflowEnvironment.WorkflowInstanceId, Me._id_no, Me._card_id, Me._f_name, Me._m_name, Me._l_name, Me._area_size, Me._area_place))

End Sub

Public Sub Approve(ByVal args As ManagerEventArgs)

RaiseEvent ManagerApproval(Nothing, args)

End Sub

Public Sub Reject(ByVal args As ManagerEventArgs)

RaiseEvent ManagerReject(Nothing, args)

End Sub

End Class

Third: Workflow

In middle of my workflow will needs to the manager approval:

Please look at here in more details:

Public Sub ShowDialog(ByVal _ManagerEventArgs As ManagerEventArgs)

Dim result As DialogResult

Dim id_no As String = _ManagerEventArgs.ID_NO

Dim _card_id As String = _ManagerEventArgs.CARD_ID

Dim _f_name As String = _ManagerEventArgs.FIRST_NAME

Dim _m_name As String = _ManagerEventArgs.MIDDLE_NAME

Dim _l_name As String = _ManagerEventArgs.LAST_NAME

Dim _area_size As String = _ManagerEventArgs.AREA_SIZE

Dim _area_place As String = _ManagerEventArgs.AREA_PLACE

result = MessageBox.Show(String.Format("Approve, {0}?", id_no), String.Format("{0} ", id_no), MessageBoxButtons.YesNo)

If result = DialogResult.Yes Then

RaiseEvent ManagerApproval(Nothing, _ManagerEventArgs)

Else

RaiseEvent ManagerReject(Nothing, _ManagerEventArgs)

End If

End Sub

Here in ShowDialog() will get the Message box to approve or reject but this not I need, I need to get the manager from Manager.aspx page ability to reject or approve but I don’t know how.

Please any One can help me.

Omar_Jordan at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3

Hi Omar,

it seems to be a normal case of communication from a workflow to the host by using the CallExternalMethodActivity.

In this case, the workflow will ask the service a redirection to the Approval page (approval.aspx).

The approval informations can be passed as querystring parameters and read/displayed in the approval page.

The following code works, however I encourage you to take a look at jon flanders pageFlow sample;

Another important info is Windows Sharepoint services v3 provides a great out of the box workflow foundation integration , and in your case the Task Activity could help(the user will be notified that there is an approval task,will click on the appropriate url and will be redirected to the page).

Cheers,

Serge

Public Sub RequestManagerApproval(ByVal id_no As String, ByVal card_id As String, ByVal f_name As String, ByVal m_name As String, ByVal l_name As String, ByVal area_size As String, ByVal area_place As String) Implements IManagerService.RequestManagerApproval

Me._id_no = id_no
Me._card_id = card_id
Me._f_name = f_name
Me._m_name = m_name
Me._l_name = l_name
Me._area_size = area_size
Me._area_place = area_place

System.Web.HttpContext.Current.Response.Redirect("approval.aspx?id_no=<put the value in the querystring>&card_id=...", True)

End Sub

SergeLuca at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4

thanks you very much Mr.Serge luca, but will redirect the manager page to the end user

again i want to get this event to the manager who is responsible for approve or reject.

can you help me plz.

Omar_Jordan at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5

Omar,

as far as I know, this is provided by the Sharepoint CreateTask activity.

I you want to avoid sharepoint (wsss v3 or Moss 2007), you'll have to create your own custom task activity.

Serge

SergeLuca at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6

Mr.Serge Luca thanks.

i need examples or video for using sharepoint.

thanks

Omar_Jordan at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 8

Omar

For simple workflows in the sharepoint designer :

http://channel9.msdn.com/ShowPost.aspx?PostID=199256#199256

For more complex workflows (sharepoint activities + visual studio workflow designer) :

http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?EventID=1032307359&EventCategory=5&culture=en-US&CountryCode=US

Hope this helps

Serge

SergeLuca at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 9

thanks Mr.Serge luca.

plz tell me about the last release of wwf.

Omar_Jordan at 2007-9-4 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified