Windows 워크 플로 파운데이션 4.5에 간단한 휴가 요청 응용 프로그램을 만들려고합니다. 워크 플로가 approveRequest 작업을 기다리지 않고 완료하려고 할 때 다음 예외가 throw됩니다.Windows 워크 플로 기반의 인간 기반 작업
동일한 ServiceContractName 및 OperationName 'ApplyLeave'가있는 두 개의 SendParameters 개체는 서로 다른 매개 변수 이름을 갖습니다.
무엇이 누락 되었습니까?
using System;
using System.ServiceModel.Activities;
using System.Activities;
using System.ServiceModel;
using System.Activities.Statements;
namespace DemoWF
{
public class _25_LeaveRequest
{
public WorkflowService GetInstance()
{
WorkflowService service;
Variable<int> empID = new Variable<int> { Name = "empID" };
Variable<int> requestID = new Variable<int> { Name = "requestID" };
Receive receiveLeaveRequest = new Receive
{
ServiceContractName = "ILeaveRequestService",
OperationName = "ApplyLeave",
CanCreateInstance = true,
Content = new ReceiveParametersContent
{
Parameters ={
{"empID",new OutArgument<int>(empID)}
}
}
};
SendReply replyLeaveRequestID = new SendReply
{
Request = receiveLeaveRequest,
Content = new SendParametersContent
{
Parameters ={
{"requestID",new InArgument<int>(requestID)},
},
},
};
Receive approveRequest = new Receive
{
ServiceContractName = "ILeaveRequestService",
OperationName = "ApproveLeave",
CanCreateInstance = true,
Content = new ReceiveParametersContent
{
Parameters ={
{"requestID",new OutArgument<int>(requestID)}
}
}
};
SendReply sendApproval = new SendReply
{
Request = receiveLeaveRequest,
Content = new SendParametersContent
{
Parameters ={
{"approved",new InArgument<int>(0)},
},
},
};
Sequence workflow = new Sequence()
{
Variables = { empID, requestID },
Activities = {
new WriteLine{Text="WF service is starting..."},
receiveLeaveRequest,
new WriteLine{
Text=new InArgument<string>(aec=> "Emp ID="+empID.Get(aec).ToString())
},
new Assign<int>{
Value=new InArgument<int>(5),
To=new OutArgument<int>(requestID)
},
new WriteLine{
Text=new InArgument<string>(aec=> "Request ID="+requestID.Get(aec).ToString())
},
replyLeaveRequestID,
approveRequest,
new WriteLine{Text="Approved"},
sendApproval
},
};
service = new WorkflowService
{
Name = "AddService",
Body = workflow
};
return service;
}
}
}
그리고 당신은 아마 두 개의 매개 변수를받을 같은 이름을 가진 두 가지 방법이
namespace DemoWF
{
class Program
{
static void Main(string[] args)
{
LeaveRequest();
}
private static void LeaveRequest()
{
_25_LeaveRequest receiveAndReplyWorkflow = new _25_LeaveRequest();
WorkflowService wfService = receiveAndReplyWorkflow.GetInstance();
Uri address = new Uri("http://localhost:8000/WFServices");
WorkflowServiceHost host = new WorkflowServiceHost(wfService, address);
try
{
Console.WriteLine("Opening Service...");
host.Open();
Console.WriteLine("WF service is listening on " + address.ToString() + ", press any key to close");
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine("some thing bad happened" + e.StackTrace);
}
finally
{
host.Close();
}
}
}
}
귀중한 의견을 보내 주셔서 감사합니다. –
환영합니다. 도움이 되었기 때문에 기쁩니다. –