コード例 #1
0
ファイル: Main.xaml.cs プロジェクト: tian1ll1/WPF_Examples
        WorkflowServiceHost wsh; // Host for workflow -- receives responses to requests made by this client

        #endregion Fields

        #region Constructors

        public Main()
        {
            InitializeComponent();

            statusWriter = new WindowTextWriter(statusConsole);
            WriterParticipant.Writer = statusWriter;

            addrListenForApprovalResponses = "http://localhost:" + Convert.ToString(GenerateRandomPort()) + "/ClientService";
            addrListenForApprovalRequests = "http://localhost:" + Convert.ToString(GenerateRandomPort()) + "/ApprovalService";

            // Set static variable in another class so WCF service can find the user interface instance
            ExternalToMainComm.Context = this;

            // Service Host for approving requests from other clients
            sh = new ServiceHost(typeof(Microsoft.Samples.DocumentApprovalProcess.ApprovalClient.ApprovalRequestsService), new Uri(addrListenForApprovalRequests));

            // Create the workflow and service to be hosted by the Workflow ServiceHost
            Activity element = new ClientRequestApprovalWorkflow();
            WorkflowService wshservice = new WorkflowService
            {
                Name = "ApprovalMonitor",
                ConfigurationName = "Microsoft.Samples.DocumentApprovalProcess.ApprovalClient.ApprovalMonitor",
                Body = element
            };

            wsh = new WorkflowServiceHost(wshservice, new Uri(addrListenForApprovalResponses));

            subscriptionDC = new DiscoveryClient(new UdpDiscoveryEndpoint());
            approvalDC = new DiscoveryClient(new UdpDiscoveryEndpoint());

            sh.Open();
            wsh.Open();

            statusWriter.WriteLine(addrListenForApprovalResponses);
            statusWriter.WriteLine(addrListenForApprovalRequests);
        }
コード例 #2
0
        public Main()
        {
            InitializeComponent();

            statusWriter             = new WindowTextWriter(statusConsole);
            WriterParticipant.Writer = statusWriter;

            addrListenForApprovalResponses = "http://localhost:" + Convert.ToString(GenerateRandomPort()) + "/ClientService";
            addrListenForApprovalRequests  = "http://localhost:" + Convert.ToString(GenerateRandomPort()) + "/ApprovalService";

            // Set static variable in another class so WCF service can find the user interface instance
            ExternalToMainComm.Context = this;

            // Service Host for approving requests from other clients
            sh = new ServiceHost(typeof(Microsoft.Samples.DocumentApprovalProcess.ApprovalClient.ApprovalRequestsService), new Uri(addrListenForApprovalRequests));

            // Create the workflow and service to be hosted by the Workflow ServiceHost
            Activity        element    = new ClientRequestApprovalWorkflow();
            WorkflowService wshservice = new WorkflowService
            {
                Name = "ApprovalMonitor",
                ConfigurationName = "Microsoft.Samples.DocumentApprovalProcess.ApprovalClient.ApprovalMonitor",
                Body = element
            };

            wsh = new WorkflowServiceHost(wshservice, new Uri(addrListenForApprovalResponses));

            subscriptionDC = new DiscoveryClient(new UdpDiscoveryEndpoint());
            approvalDC     = new DiscoveryClient(new UdpDiscoveryEndpoint());

            sh.Open();
            wsh.Open();

            statusWriter.WriteLine(addrListenForApprovalResponses);
            statusWriter.WriteLine(addrListenForApprovalRequests);
        }